73 lines
2.1 KiB
C#
73 lines
2.1 KiB
C#
|
|
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<DialogueSystem>
|
|
{
|
|
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<DialogueFrame>();
|
|
}
|
|
|
|
private void OnDialoguePaused(DialogueTree tree)
|
|
{
|
|
//Debug.LogError("OnDialoguePaused");
|
|
UIManager.Inst.CloseFrame<DialogueFrame>();
|
|
}
|
|
|
|
private void OnDialogueFinished(DialogueTree tree)
|
|
{
|
|
//Debug.LogError("OnDialogueFinished");
|
|
UIManager.Inst.CloseFrame<DialogueFrame>();
|
|
}
|
|
|
|
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();
|
|
}
|
|
}
|
|
|
|
}
|