From 48d872b4b9a1221590d4b08c773f15e608fee88c Mon Sep 17 00:00:00 2001 From: GanX <2423855310@qq.com> Date: Sat, 18 Oct 2025 09:25:06 +0800 Subject: [PATCH] =?UTF-8?q?feat(Time=20&=20Mode):=20=E7=BB=99=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E5=88=87=E6=8D=A2=E6=B7=BB=E5=8A=A0=E4=B8=8A=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E6=9A=82=E5=81=9C=E7=9B=B8=E5=85=B3=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Player/PlayerWatchModeController.cs | 31 ++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/Assets/Script/Gameplay/Player/PlayerWatchModeController.cs b/Assets/Script/Gameplay/Player/PlayerWatchModeController.cs index 39bde59..a4e2141 100644 --- a/Assets/Script/Gameplay/Player/PlayerWatchModeController.cs +++ b/Assets/Script/Gameplay/Player/PlayerWatchModeController.cs @@ -2,6 +2,7 @@ using System; using Script.Gameplay.Input; using UnityEngine; using Core; +using Script.Gameplay.Global; namespace Gameplay.Player { @@ -11,13 +12,16 @@ namespace Gameplay.Player Inside, Outside } + public class PlayerWatchModeController : MonoBehaviour { [SerializeField] private Camera cam; public event Action OnEnterInsideWatchMode; public event Action OnExitInsideWatchMode; private InputManager inputManager; + private TimePauseManager timePauseManager; private WatchMode currentMode = WatchMode.Normal; + public WatchMode CurrentWatchMode { get => currentMode; @@ -27,10 +31,12 @@ namespace Gameplay.Player { OnExitInsideWatchMode?.Invoke(); } + if (value == WatchMode.Inside) { OnEnterInsideWatchMode?.Invoke(); } + currentMode = value; SwitchWatchMode(currentMode); } @@ -39,17 +45,19 @@ namespace Gameplay.Player private void Start() { inputManager = InputManager.Instance; - + timePauseManager = TimePauseManager.Instance; + var input = inputManager.Input; input.Player.SwitchWatchMode.performed += ctx => { var modeTemp = (WatchMode)(((int)CurrentWatchMode + 1) % 3); CurrentWatchMode = modeTemp; - };; - + }; + ; + ControllerLocator.Instance.Register(this); } - + // 实现按Tap键实现在WatchMode 3个模式切换,并通过SwitchWatchMode设置正确的相机模式 private void SwitchWatchMode(WatchMode watchMode) { @@ -60,18 +68,33 @@ namespace Gameplay.Player inputManager.SetCursorState(false, CursorLockMode.Locked); inputManager.SetInputForLook(true); inputManager.SetInputForMove(true); + if (timePauseManager != null) + { + timePauseManager.SetPaused(false); + } + break; case WatchMode.Inside: SetSeeLines(false); inputManager.SetCursorState(true, CursorLockMode.Confined); inputManager.SetInputForLook(false); inputManager.SetInputForMove(false); + if (timePauseManager != null) + { + timePauseManager.SetPaused(true); + } + break; case WatchMode.Outside: SetSeeLines(true); inputManager.SetCursorState(false, CursorLockMode.Locked); inputManager.SetInputForLook(true); inputManager.SetInputForMove(true); + if (timePauseManager != null) + { + timePauseManager.SetPaused(false); + } + break; default: throw new ArgumentOutOfRangeException();