Files
XMen/Assets/Scripts/Portal.cs
2025-07-10 14:49:53 +08:00

32 lines
939 B
C#

using System.Collections;
using System.Collections.Generic;
using Mirror;
using UnityEngine;
public class Portal : NetworkBehaviour
{
public void Init(int amount, float interval, bool isActive, EnemyType type)
{
StartCoroutine(CreateEnemy(amount, interval, type));
}
/// <summary>
/// 创建怪物
/// </summary>
/// <param name="amount">数量</param>
/// <param name="interval">间隔</param>
/// <param name="type">类型</param>
/// <returns></returns>
public IEnumerator CreateEnemy(int amount, float interval, EnemyType type)
{
for (int i = 0; i < amount; i++)
{
yield return new WaitForSeconds(interval);
GameObject enemy = GameManager.Ins.GenerateEnemy(type, transform.position, transform.eulerAngles, transform.localScale);
}
yield return new WaitForSeconds(1F);
NetworkServer.Destroy(gameObject);
}
}