|
|
|
|
|
|
using UnityEngine; |
|
|
|
using UnityEngine.InputSystem; |
|
|
|
using UnityEngine.Playables; |
|
|
|
|
|
|
|
public class CutsceneManager : MonoBehaviour |
|
|
|
|
|
|
|
|
|
|
private void OnEnable() |
|
|
|
{ |
|
|
|
_inputReader.gameInput.Dialogues.AdvanceDialogue.performed += ctx => OnAdvance(); |
|
|
|
_inputReader.advanceDialogueEvent += OnAdvance; |
|
|
|
_inputReader.gameInput.Dialogues.AdvanceDialogue.performed -= ctx => OnAdvance(); |
|
|
|
_inputReader.advanceDialogueEvent -= OnAdvance; |
|
|
|
_inputReader.EnableDialogueInput(); |
|
|
|
|
|
|
|
_activePlayableDirector.stopped += ctx => CutsceneEnded(); |
|
|
|
|
|
|
|
EnableDialogueInput(); |
|
|
|
_activePlayableDirector.stopped += HandleDirectorStopped; |
|
|
|
UIManager.Instance.CloseUIDialogue(); |
|
|
|
EnableGameplayInput(); |
|
|
|
if (_activePlayableDirector != null) |
|
|
|
_activePlayableDirector.stopped -= HandleDirectorStopped; |
|
|
|
|
|
|
|
_inputReader.EnableGameplayInput(); |
|
|
|
private void HandleDirectorStopped(PlayableDirector director) => CutsceneEnded(); |
|
|
|
|
|
|
|
public void PlayDialogueFromClip(DialogueLineSO dialogueLine) |
|
|
|
{ |
|
|
|
_dialogueManager.DisplayDialogueLine(dialogueLine); |
|
|
|
|
|
|
_isPaused = false; |
|
|
|
_activePlayableDirector.playableGraph.GetRootPlayable(0).SetSpeed(1); |
|
|
|
} |
|
|
|
|
|
|
|
private void EnableDialogueInput() |
|
|
|
{ |
|
|
|
_inputReader.gameInput.Dialogues.Enable(); |
|
|
|
_inputReader.gameInput.Gameplay.Disable(); |
|
|
|
} |
|
|
|
|
|
|
|
private void EnableGameplayInput() |
|
|
|
{ |
|
|
|
_inputReader.gameInput.Gameplay.Enable(); |
|
|
|
_inputReader.gameInput.Dialogues.Disable(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |