feat():完成3种模式的基本运行框架
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using Core;
|
||||
using UnityEngine;
|
||||
using Interface;
|
||||
using Script.Gameplay.Input;
|
||||
@@ -21,11 +22,8 @@ namespace Gameplay.Player
|
||||
inputManager = InputManager.Instance;
|
||||
if (playerCamera == null)
|
||||
playerCamera = GameObject.FindWithTag("MainCamera").GetComponent<Camera>();
|
||||
|
||||
inputManager.Input.Player.SwitchWatchMode.performed += ctx =>
|
||||
{
|
||||
if (currentTarget != null) currentTarget.BeginEdit();
|
||||
};
|
||||
|
||||
ControllerLocator.Instance.Register(this);
|
||||
}
|
||||
|
||||
void Update()
|
||||
@@ -73,6 +71,11 @@ namespace Gameplay.Player
|
||||
}
|
||||
}
|
||||
|
||||
public IEditable GetCurrentTarget()
|
||||
{
|
||||
return currentTarget;
|
||||
}
|
||||
|
||||
void OnDrawGizmos()
|
||||
{
|
||||
if(!isDrawGizmos) return;
|
||||
|
||||
@@ -21,7 +21,13 @@ namespace Gameplay.Player
|
||||
playerCamera = GameObject.FindWithTag("MainCamera").GetComponent<Camera>();
|
||||
|
||||
var input = InputManager.Instance.Input;
|
||||
input.Player.SwitchWatchMode.performed += ctx => currentTarget.Interact(this.gameObject);;
|
||||
input.Player.Interact.performed += ctx =>
|
||||
{
|
||||
if (currentTarget != null)
|
||||
{
|
||||
currentTarget.Interact(this.gameObject);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void Update()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using Script.Gameplay.Input;
|
||||
using UnityEngine;
|
||||
using Core;
|
||||
|
||||
namespace Gameplay.Player
|
||||
{
|
||||
@@ -10,34 +11,46 @@ namespace Gameplay.Player
|
||||
Inside,
|
||||
Outside
|
||||
}
|
||||
public class PlayerWatchModeSwitcher : MonoBehaviour
|
||||
public class PlayerWatchModeController : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Camera cam;
|
||||
public event Action OnEnterInsideWatchMode;
|
||||
public event Action OnExitInsideWatchMode;
|
||||
private InputManager inputManager;
|
||||
private WatchMode currentMode = WatchMode.Normal;
|
||||
public WatchMode CurrentWatchMode
|
||||
{
|
||||
get => currentMode;
|
||||
set
|
||||
{
|
||||
if (value != WatchMode.Inside)
|
||||
{
|
||||
OnExitInsideWatchMode?.Invoke();
|
||||
}
|
||||
if (value == WatchMode.Inside)
|
||||
{
|
||||
OnEnterInsideWatchMode?.Invoke();
|
||||
}
|
||||
currentMode = value;
|
||||
SwitchWatchMode(currentMode);
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
inputManager = InputManager.Instance;
|
||||
SetWatchMode(currentMode);
|
||||
|
||||
var input = inputManager.Input;
|
||||
input.Player.SwitchWatchMode.performed += ctx =>
|
||||
{
|
||||
currentMode = (WatchMode)(((int)currentMode + 1) % 3);
|
||||
SetWatchMode(currentMode);
|
||||
var modeTemp = (WatchMode)(((int)CurrentWatchMode + 1) % 3);
|
||||
CurrentWatchMode = modeTemp;
|
||||
};;
|
||||
|
||||
ControllerLocator.Instance.Register(this);
|
||||
}
|
||||
|
||||
public void SetWatchMode(WatchMode mode)
|
||||
{
|
||||
currentMode = mode;
|
||||
SwitchWatchMode(mode);
|
||||
}
|
||||
|
||||
|
||||
// 实现按Tap键实现在WatchMode 3个模式切换,并通过SwitchWatchMode设置正确的相机模式
|
||||
|
||||
private void SwitchWatchMode(WatchMode watchMode)
|
||||
{
|
||||
switch (watchMode)
|
||||
Reference in New Issue
Block a user