feat(Time & Mode): 给模式切换添加上时间暂停相关逻辑
This commit is contained in:
@@ -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,13 +45,15 @@ 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);
|
||||
}
|
||||
@@ -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();
|
||||
|
Reference in New Issue
Block a user