修复了游戏中暂停也会继续生成敌人的bug

This commit is contained in:
wulongxiao 2025-01-07 12:02:30 +08:00
parent 7bc80f89bc
commit bba6a6f9cc

View File

@ -101,7 +101,7 @@ public class SpawnMonster : Base
if (value.wave == index)
{
foreach (var enemy in value.enemies)
/*foreach (var enemy in value.enemies)
{
await Task.Delay(enemy.startTime * 3);
@ -112,19 +112,49 @@ public class SpawnMonster : Base
go.GetComponent<Role>().gold = enemy.Reward;
enemysList.Add(go);
}*/
for (int i = 0; i < value.enemies.Count;)
{
if(Time.timeScale == 0)
{
await Task.Delay(1000);
}
else
{
var enemy = value.enemies[i];
await Task.Delay(enemy.startTime * 3);
GameObject go = GameObject.Instantiate(
Monster_Infos.instance.GetMonster(enemy.id),
SpawnLocations[value.spawnPoint - 1].position,
Quaternion.identity
);
go.GetComponent<enemy>().index = value.spawnPoint - 1;
go.GetComponent<Role>().gold = enemy.Reward;
enemysList.Add(go);
i++;
}
}
}
}
}
// public void
private void OnDisable()
{
Base.GlobalObj.GetComponent<gameGlobal>().OnGamePlay -= this.StartSpawning;
}
}