using UnityEngine;
using System.Collections;
public class CreateEnemeies : MonoBehaviour {
float timer = 0;
//
float timer2 = 0;
//产生敌人的速率
public float rate;
//敌人的预制体
public GameObject enemeyPrefab;
//每一波的时间
public float timesofEachWave = 30;
//每一波的已经产生的数量
public int count;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
timer2 += Time.deltaTime;
if (timer2 < timesofEachWave && count!=10)
{
timer += Time.deltaTime;
if (timer > rate)
{
Instantiate(enemeyPrefab, Vector3.zero, Quaternion.identity);
count++;
timer -= rate;
}
}
if (timer2>timesofEachWave)
{
timer2 -= timesofEachWave;
count = 0;
}
}
}
控制敌人数量及波数
最新推荐文章于 2024-09-07 22:04:51 发布