From bba6a6f9cc77b9c3c6850695f7eec7d47c093d9e Mon Sep 17 00:00:00 2001 From: wulongxiao <2545507770@qq.com> Date: Tue, 7 Jan 2025 12:02:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E6=B8=B8=E6=88=8F?= =?UTF-8?q?=E4=B8=AD=E6=9A=82=E5=81=9C=E4=B9=9F=E4=BC=9A=E7=BB=A7=E7=BB=AD?= =?UTF-8?q?=E7=94=9F=E6=88=90=E6=95=8C=E4=BA=BA=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Assets/script/A_Fight/SpawnMonster.cs | 36 +++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/meng_yao/Assets/script/A_Fight/SpawnMonster.cs b/meng_yao/Assets/script/A_Fight/SpawnMonster.cs index 0481b6e6..2283f282 100644 --- a/meng_yao/Assets/script/A_Fight/SpawnMonster.cs +++ b/meng_yao/Assets/script/A_Fight/SpawnMonster.cs @@ -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().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().index = value.spawnPoint - 1; + go.GetComponent().gold = enemy.Reward; + + enemysList.Add(go); + + i++; + } + } + } } } - // public void - + private void OnDisable() { Base.GlobalObj.GetComponent().OnGamePlay -= this.StartSpawning; } + }