我试图阻止玩家死亡时产生的波浪,但我似乎无法阻止协程。我真的不知道如何再攻击它,因为添加 if 语句和 break 不起作用。如何调用 StopCoroutine 并停止例程?我需要介绍新方法吗?
void Start () {
gameOver = false;
StartCoroutine (SpawnWaves());
}
void Update()
{
if (gameOver)
{
StopCoroutine(SpawnWaves());
}
}
IEnumerator SpawnWaves()
{
yield return new WaitForSeconds(startWait);
while (true)
{
for (int i = 0; i < hazardCount; i++)
{
GameObject enemy = enemies[Random.Range(0, enemies.Length)];
Instantiate(enemy, spawnPosition1, spawnRotation1);
Instantiate(enemy, spawnPosition2, spawnRotation2);
Instantiate(enemy, spawnPosition3, spawnRotation3);
Instantiate(enemy, spawnPosition4, spawnRotation4);
Instantiate(enemy, spawnPosition5, spawnRotation5);
Instantiate(enemy, spawnPosition6, spawnRotation6);
yield return new WaitForSeconds(spawnWait);
}
yield return new WaitForSeconds(waveWait);
enemies[0].GetComponent<EnemyBehviour>().currentHealth *= enemyHealthMultiplier;
}
}
繁华开满天机
MM们
芜湖不芜
慕的地10843
相关分类