feat():完成3种模式的基本运行框架

This commit is contained in:
2025-10-18 08:55:38 +08:00
parent 3d03c59dc3
commit 345930843d
39 changed files with 909 additions and 427 deletions

View File

@@ -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;

View File

@@ -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()

View File

@@ -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)