From 1e820b823aba7c579a9ceb1514028f1da558112b Mon Sep 17 00:00:00 2001 From: keshaohong <740612340@qq.com> Date: Sun, 5 Jul 2026 03:14:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=A4=B1=E8=B4=A5=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E5=81=9C=E6=AD=A2=E6=95=8C=E4=BA=BA=E5=92=8C=E8=A7=92?= =?UTF-8?q?=E8=89=B2=E7=9A=84=E6=89=80=E6=9C=89=E8=A1=8C=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- unity/Assets/UI/GameManager.cs | 41 +++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) 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。 ///