diff --git a/unity/Assets/UI/GameManager.cs b/unity/Assets/UI/GameManager.cs index 288cd97..de39a66 100644 --- a/unity/Assets/UI/GameManager.cs +++ b/unity/Assets/UI/GameManager.cs @@ -71,17 +71,34 @@ namespace GameFramework // 等待一帧,让 HUD 先更新血量显示 yield return null; - // 1. 查找玩家并禁用控制 + // 1. 禁用所有敌人 AI 和控制 + DisableAllEnemyAI(); + + // 2. 查找玩家并禁用一切控制 var player = GameObject.FindGameObjectWithTag("Player"); if (player != null) { + // 移动/翻滚/输入 var playerController = player.GetComponent(); if (playerController != null) playerController.enabled = false; + // 近战攻击(点击) + var swordAttack = player.GetComponent(); + if (swordAttack != null) swordAttack.enabled = false; + + // 远程攻击(点击) + var projectileShooter = player.GetComponent(); + if (projectileShooter != null) projectileShooter.enabled = false; + + // 技能:唤魂灯笼 + var lanternSystem = player.GetComponent(); + if (lanternSystem != null) lanternSystem.enabled = false; + + // 相机跟随 var camFollow = Camera.main != null ? Camera.main.GetComponent() : null; if (camFollow != null) camFollow.enabled = false; - // 2. 光源缩小至完全不可见 + // 3. 光源缩小至完全不可见 var lightSource = player.GetComponent(); if (lightSource != null) { @@ -112,10 +129,28 @@ namespace GameFramework yield return new WaitForSecondsRealtime(lightShrinkDuration); } - // 3. 淡出黑色 + 显示失败叠加层(不切场景) + // 4. 淡出黑色 + 显示失败叠加层(不切场景) yield return StartCoroutine(ShowLostOverlay()); } + /// + /// 禁用场景中所有敌人相关的 AI 和控制组件。 + /// + private void DisableAllEnemyAI() + { + // 禁用所有 EnemyAI + var enemyAIs = FindObjectsOfType(); + foreach (var ai in enemyAIs) + ai.enabled = false; + + // 禁用 EnemyManager(停止生成/管理逻辑) + var enemyManager = FindObjectOfType(); + if (enemyManager != null) + enemyManager.enabled = false; + + Debug.Log($"[GameManager] 已禁用 {enemyAIs.Length} 个 EnemyAI + EnemyManager"); + } + /// /// 胜利过场协程:光源扩大 → 淡出 → 跳转 Scoring。 ///