using NodeCanvas.DialogueTrees; using System; using System.Collections; using System.Collections.Generic; using Unity.VisualScripting.Antlr3.Runtime.Tree; using UnityEngine; namespace Ether { public class DialogueSystem : Singleton { public void Init() { OnSubscribe(); } public void OnSubscribe() { DialogueTree.OnDialogueStarted += OnDialogueStarted; DialogueTree.OnDialoguePaused += OnDialoguePaused; DialogueTree.OnDialogueFinished += OnDialogueFinished; DialogueTree.OnSubtitlesRequest += OnSubtitlesRequest; DialogueTree.OnMultipleChoiceRequest += OnMultipleChoiceRequest; } public void OnUnSubscribe() { DialogueTree.OnDialogueStarted -= OnDialogueStarted; DialogueTree.OnDialoguePaused -= OnDialoguePaused; DialogueTree.OnDialogueFinished -= OnDialogueFinished; DialogueTree.OnSubtitlesRequest -= OnSubtitlesRequest; DialogueTree.OnMultipleChoiceRequest -= OnMultipleChoiceRequest; } private void OnDialogueStarted(DialogueTree tree) { //Debug.LogError("OnDialogueStarted"); UIManager.Inst.OpenFrame(); } private void OnDialoguePaused(DialogueTree tree) { //Debug.LogError("OnDialoguePaused"); UIManager.Inst.CloseFrame(); } private void OnDialogueFinished(DialogueTree tree) { //Debug.LogError("OnDialogueFinished"); UIManager.Inst.CloseFrame(); } private void OnSubtitlesRequest(SubtitlesRequestInfo info) { //Debug.LogError("OnSubtitlesRequest"); EventCenter.BroadCast("OnSubtitlesRequest", info); } private void OnMultipleChoiceRequest(MultipleChoiceRequestInfo info) { //Debug.LogError("OnMultipleChoiceRequest"); EventCenter.BroadCast("OnMultipleChoiceRequest", info); } public void Clear() { OnUnSubscribe(); } } }