feat(Cycle):实现循环提前检测,修复交互提示消失,按键绑定的事件在重启的时候没能正确,触发循环的提前检测有错误

This commit is contained in:
2025-10-27 10:31:01 +08:00
parent e8b9f47067
commit 9646483fa6
36 changed files with 6743 additions and 5221 deletions

View File

@@ -7,6 +7,7 @@ using UnityEngine.Events;
using Script.Gameplay.Interface;
using Script.Gameplay.Input;
using UI;
using UnityEngine.InputSystem;
namespace Script.Gameplay.Player
{
@@ -60,24 +61,28 @@ namespace Script.Gameplay.Player
inputManager = InputManager.Instance;
var input = inputManager.Input;
input.Player.Read.performed += ctx =>
{
if (!isEnablePlayerDialogue) return;
if (CurrentDialogueTarget == null) return;
if (isReadingDialogue) return;
BeginDialogue();
};
input.Player.ShowNextDialogue.performed += ctx =>
{
if (!isEnablePlayerDialogue) return;
if (CurrentDialogueTarget == null) return;
if (!isReadingDialogue) return;
PassNextDialogue();
};
input.Player.Read.performed += OnReadOnperformed;
input.Player.ShowNextDialogue.performed += OnShowNextDialogueOnperformed;
ControllerLocator.Instance.Register(this);
}
private void OnShowNextDialogueOnperformed(InputAction.CallbackContext ctx)
{
if (!isEnablePlayerDialogue) return;
if (CurrentDialogueTarget == null) return;
if (!isReadingDialogue) return;
PassNextDialogue();
}
private void OnReadOnperformed(InputAction.CallbackContext ctx)
{
if (!isEnablePlayerDialogue) return;
if (CurrentDialogueTarget == null) return;
if (isReadingDialogue) return;
BeginDialogue();
}
void Update()
{
DetectDialogue();
@@ -159,5 +164,17 @@ namespace Script.Gameplay.Player
CurrentDialogueTarget = null;
}
}
private void OnDestroy()
{
ControllerLocator.Instance.Unregister<PlayerDialogueController>(this);
if (inputManager != null)
{
var input = inputManager.Input;
input.Player.Read.performed -= OnReadOnperformed;
input.Player.ShowNextDialogue.performed -= OnShowNextDialogueOnperformed;
}
}
}
}