diff --git a/meng_yao/Assets/script/A_Fight/SpawnPool.cs b/meng_yao/Assets/script/A_Fight/SpawnPool.cs index fce21318d..d9c1259f2 100644 --- a/meng_yao/Assets/script/A_Fight/SpawnPool.cs +++ b/meng_yao/Assets/script/A_Fight/SpawnPool.cs @@ -27,6 +27,7 @@ public class ObJPool { if (SurvivalPool.Contains(obj)) { + SurvivalPool.Remove(obj); DeathPool.Add(obj); } @@ -38,7 +39,7 @@ public class SpawnPool : Base public static SpawnPool intance; public ObJPool EnemyPool = new ObJPool(); - + public List Enemys = new List(); [Header("生成预制体")] public GameObject Prefab; @@ -91,11 +92,11 @@ public class SpawnPool : Base // 获取所有带有 SortingGroup 组件的物体 List gameObjectsList = new List(); - foreach (GameObject go in EnemyPool.SurvivalPool) + foreach (GameObject go in Enemys) { // 获取该物体上的 SortingGroup 组件 SortingGroup sortingGroup = go.GetComponent(); - if (sortingGroup != null) + if (sortingGroup != null&&go.activeSelf) { // 添加到列表中 gameObjectsList.Add(go); @@ -112,7 +113,7 @@ public class SpawnPool : Base if (sortingGroup != null) { // 设置 sortingOrder 来决定显示的层级 - sortingGroup.sortingOrder = gameObjectsList.Count - i; + sortingGroup.sortingOrder = gameObjectsList.Count - i+2; } } } @@ -194,8 +195,8 @@ public class SpawnPool : Base } enemy = Instantiate(Prefab); - EnemyPool.SurvivalPool.Add(enemy); - + //EnemyPool.SurvivalPool.Add(enemy); + Enemys.Add(enemy); } // 设置敌人的位置和其他属性 @@ -212,7 +213,7 @@ public class SpawnPool : Base { enemy.SetActive(false); // 禁用敌人对象 EnemyPool.Return(enemy); // 将敌人回收到池中 - + Enemys.Remove(enemy); deadNumber++; if (deadNumber>= GenerateQuantityMax) {