From cb204813574b83cc0c6ec38eeeb3b3192bc41971 Mon Sep 17 00:00:00 2001 From: shurongsen <1799096798@qq.com> Date: Mon, 9 Dec 2024 23:48:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=80=AA=E7=89=A9=E6=AD=A3=E5=B8=B8=E6=AD=BB?= =?UTF-8?q?=E4=BA=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- meng_yao/Assets/script/A_Fight/SpawnPool.cs | 9 +++- meng_yao/Assets/script/A_Fight/enemy.cs | 51 ++++++++++++++++++++- 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/meng_yao/Assets/script/A_Fight/SpawnPool.cs b/meng_yao/Assets/script/A_Fight/SpawnPool.cs index ebc72c87..a4191ef4 100644 --- a/meng_yao/Assets/script/A_Fight/SpawnPool.cs +++ b/meng_yao/Assets/script/A_Fight/SpawnPool.cs @@ -27,13 +27,15 @@ public class ObJPool if (SurvivalPool.Contains(obj)) { SurvivalPool.Remove(obj); - DeathPool.Add(obj); + DeathPool.Add(obj); } } } public class SpawnPool : Base { + public static SpawnPool intance; + public ObJPool EnemyPool = new ObJPool(); [Header("生成预制体")] @@ -65,6 +67,11 @@ public class SpawnPool : Base private bool isWaveComplete = false; // 标记当前波是否完成 // Start is called before the first frame update + + private void Awake() + { + intance = this; + } void Start() { Base.GlobalObj.GetComponent().OnGamePlay += this.StartSpawning; diff --git a/meng_yao/Assets/script/A_Fight/enemy.cs b/meng_yao/Assets/script/A_Fight/enemy.cs index 31113fff..b4dd442d 100644 --- a/meng_yao/Assets/script/A_Fight/enemy.cs +++ b/meng_yao/Assets/script/A_Fight/enemy.cs @@ -27,13 +27,60 @@ public class enemy : Role public override void die() { if (Application.isPlaying) - { + { // 将当前敌人对象放入死亡池 - SpawnPool spawnPool = Base.GlobalObj.GetComponent(); // 获取 SpawnPool 组件 + SpawnPool spawnPool = SpawnPool.intance; // 获取 SpawnPool 组件 if (spawnPool != null) { + Debug.LogError(this.name+"die"); spawnPool.ReturnEnemyToPool(this.gameObject); // 回收当前敌人到池中 + ResetAllStatus(); } } } + + /// + /// 重置角色所有状态 + /// + public void ResetAllStatus() + { + // 重置血量 + Hp = 100f; + + // 重置攻击力 + Attack = 10f; + + // 重置护甲 + physicalArmor = 10; + magicArmor = 5; + + // 重置等级 + Level = 1; + + // 重置金币 + Gold = 10f; + + // 清空 Buff 列表 + buffList.Clear(); + + // 如果有导航组件,停止当前的导航行为 + if (Navigation != null) + { + //Navigation.Stop(); // 假设你有 Stop 方法来停止导航 + } + + // 重置角色动画 + animationHighlight = 0; + isAnimationPlay = false; + + // 重置碰撞体(根据需求是否需要调整) + if (mycollider != null) + { + mycollider.enabled = true; // 启用碰撞体 + } + + + + // 如果有其他需要重置的状态,可以在这里添加 + } }