refactor(UI):完善对于各个界面的管理逻辑,esc可以直接关闭所有的顶层UI
This commit is contained in:
@@ -20,14 +20,15 @@ namespace Script.Gameplay.Player
|
||||
public event Action OnPlayerEndDialogue;
|
||||
public event Action<GameObject> OnGazeEnterDialogue;
|
||||
public event Action<GameObject> OnGazeExitDialogue;
|
||||
|
||||
|
||||
private InputManager inputManager;
|
||||
|
||||
|
||||
private Queue<string> dialogueQueue = new Queue<string>();
|
||||
private PlayerDialogueViewer playerDialogueViewer;
|
||||
|
||||
private IDialogue previousDialogue;
|
||||
private IDialogue currentDialogueTarget;
|
||||
|
||||
public IDialogue CurrentDialogueTarget
|
||||
{
|
||||
get => currentDialogueTarget;
|
||||
@@ -41,6 +42,7 @@ namespace Script.Gameplay.Player
|
||||
{
|
||||
OnGazeEnterDialogue?.Invoke((currentDialogueTarget as MonoBehaviour)?.gameObject);
|
||||
}
|
||||
|
||||
if (previousDialogue != null)
|
||||
{
|
||||
OnGazeExitDialogue?.Invoke((previousDialogue as MonoBehaviour)?.gameObject);
|
||||
@@ -63,10 +65,16 @@ namespace Script.Gameplay.Player
|
||||
var input = inputManager.Input;
|
||||
input.Player.Read.performed += OnReadOnperformed;
|
||||
input.Player.ShowNextDialogue.performed += OnShowNextDialogueOnperformed;
|
||||
input.Player.Escape.performed += OnEscapeOnperformed;
|
||||
|
||||
ControllerLocator.Instance.Register(this);
|
||||
}
|
||||
|
||||
private void OnEscapeOnperformed(InputAction.CallbackContext ctx)
|
||||
{
|
||||
EndDialogue();
|
||||
}
|
||||
|
||||
private void OnShowNextDialogueOnperformed(InputAction.CallbackContext ctx)
|
||||
{
|
||||
if (!isEnablePlayerDialogue) return;
|
||||
@@ -104,8 +112,6 @@ namespace Script.Gameplay.Player
|
||||
OnPlayerBeginDialogue?.Invoke();
|
||||
CurrentDialogueTarget.OnBeginDialogue?.Invoke(true);
|
||||
dialogueQueue = SplitDialogue(CurrentDialogueTarget.DialogueContent);
|
||||
inputManager.SetInputForLook(false);
|
||||
inputManager.SetInputForMove(false);
|
||||
PassNextDialogue();
|
||||
}
|
||||
}
|
||||
@@ -135,13 +141,7 @@ namespace Script.Gameplay.Player
|
||||
isReadingDialogue = false;
|
||||
OnPlayerEndDialogue?.Invoke();
|
||||
CurrentDialogueTarget.OnEndDialogue?.Invoke(true);
|
||||
inputManager.SetInputForLook(true);
|
||||
inputManager.SetInputForMove(true);
|
||||
if (playerDialogueViewer != null)
|
||||
{
|
||||
playerDialogueViewer.ClosePanel();
|
||||
}
|
||||
// 可扩展:隐藏UI、恢复输入等
|
||||
UIManager.Instance.CloseUI<PlayerDialogueViewer>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,6 +174,7 @@ namespace Script.Gameplay.Player
|
||||
var input = inputManager.Input;
|
||||
input.Player.Read.performed -= OnReadOnperformed;
|
||||
input.Player.ShowNextDialogue.performed -= OnShowNextDialogueOnperformed;
|
||||
input.Player.Escape.performed -= OnEscapeOnperformed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user