feat(Time & Mode): 给模式切换添加上时间暂停相关逻辑
This commit is contained in:
@@ -2,6 +2,7 @@ using System;
|
|||||||
using Script.Gameplay.Input;
|
using Script.Gameplay.Input;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Core;
|
using Core;
|
||||||
|
using Script.Gameplay.Global;
|
||||||
|
|
||||||
namespace Gameplay.Player
|
namespace Gameplay.Player
|
||||||
{
|
{
|
||||||
@@ -11,13 +12,16 @@ namespace Gameplay.Player
|
|||||||
Inside,
|
Inside,
|
||||||
Outside
|
Outside
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PlayerWatchModeController : MonoBehaviour
|
public class PlayerWatchModeController : MonoBehaviour
|
||||||
{
|
{
|
||||||
[SerializeField] private Camera cam;
|
[SerializeField] private Camera cam;
|
||||||
public event Action OnEnterInsideWatchMode;
|
public event Action OnEnterInsideWatchMode;
|
||||||
public event Action OnExitInsideWatchMode;
|
public event Action OnExitInsideWatchMode;
|
||||||
private InputManager inputManager;
|
private InputManager inputManager;
|
||||||
|
private TimePauseManager timePauseManager;
|
||||||
private WatchMode currentMode = WatchMode.Normal;
|
private WatchMode currentMode = WatchMode.Normal;
|
||||||
|
|
||||||
public WatchMode CurrentWatchMode
|
public WatchMode CurrentWatchMode
|
||||||
{
|
{
|
||||||
get => currentMode;
|
get => currentMode;
|
||||||
@@ -27,10 +31,12 @@ namespace Gameplay.Player
|
|||||||
{
|
{
|
||||||
OnExitInsideWatchMode?.Invoke();
|
OnExitInsideWatchMode?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value == WatchMode.Inside)
|
if (value == WatchMode.Inside)
|
||||||
{
|
{
|
||||||
OnEnterInsideWatchMode?.Invoke();
|
OnEnterInsideWatchMode?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
currentMode = value;
|
currentMode = value;
|
||||||
SwitchWatchMode(currentMode);
|
SwitchWatchMode(currentMode);
|
||||||
}
|
}
|
||||||
@@ -39,17 +45,19 @@ namespace Gameplay.Player
|
|||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
inputManager = InputManager.Instance;
|
inputManager = InputManager.Instance;
|
||||||
|
timePauseManager = TimePauseManager.Instance;
|
||||||
|
|
||||||
var input = inputManager.Input;
|
var input = inputManager.Input;
|
||||||
input.Player.SwitchWatchMode.performed += ctx =>
|
input.Player.SwitchWatchMode.performed += ctx =>
|
||||||
{
|
{
|
||||||
var modeTemp = (WatchMode)(((int)CurrentWatchMode + 1) % 3);
|
var modeTemp = (WatchMode)(((int)CurrentWatchMode + 1) % 3);
|
||||||
CurrentWatchMode = modeTemp;
|
CurrentWatchMode = modeTemp;
|
||||||
};;
|
};
|
||||||
|
;
|
||||||
|
|
||||||
ControllerLocator.Instance.Register(this);
|
ControllerLocator.Instance.Register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 实现按Tap键实现在WatchMode 3个模式切换,并通过SwitchWatchMode设置正确的相机模式
|
// 实现按Tap键实现在WatchMode 3个模式切换,并通过SwitchWatchMode设置正确的相机模式
|
||||||
private void SwitchWatchMode(WatchMode watchMode)
|
private void SwitchWatchMode(WatchMode watchMode)
|
||||||
{
|
{
|
||||||
@@ -60,18 +68,33 @@ namespace Gameplay.Player
|
|||||||
inputManager.SetCursorState(false, CursorLockMode.Locked);
|
inputManager.SetCursorState(false, CursorLockMode.Locked);
|
||||||
inputManager.SetInputForLook(true);
|
inputManager.SetInputForLook(true);
|
||||||
inputManager.SetInputForMove(true);
|
inputManager.SetInputForMove(true);
|
||||||
|
if (timePauseManager != null)
|
||||||
|
{
|
||||||
|
timePauseManager.SetPaused(false);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case WatchMode.Inside:
|
case WatchMode.Inside:
|
||||||
SetSeeLines(false);
|
SetSeeLines(false);
|
||||||
inputManager.SetCursorState(true, CursorLockMode.Confined);
|
inputManager.SetCursorState(true, CursorLockMode.Confined);
|
||||||
inputManager.SetInputForLook(false);
|
inputManager.SetInputForLook(false);
|
||||||
inputManager.SetInputForMove(false);
|
inputManager.SetInputForMove(false);
|
||||||
|
if (timePauseManager != null)
|
||||||
|
{
|
||||||
|
timePauseManager.SetPaused(true);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case WatchMode.Outside:
|
case WatchMode.Outside:
|
||||||
SetSeeLines(true);
|
SetSeeLines(true);
|
||||||
inputManager.SetCursorState(false, CursorLockMode.Locked);
|
inputManager.SetCursorState(false, CursorLockMode.Locked);
|
||||||
inputManager.SetInputForLook(true);
|
inputManager.SetInputForLook(true);
|
||||||
inputManager.SetInputForMove(true);
|
inputManager.SetInputForMove(true);
|
||||||
|
if (timePauseManager != null)
|
||||||
|
{
|
||||||
|
timePauseManager.SetPaused(false);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new ArgumentOutOfRangeException();
|
throw new ArgumentOutOfRangeException();
|
||||||
|
Reference in New Issue
Block a user