55 lines
1.6 KiB
C#
55 lines
1.6 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using BITKit;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Net.Project.B.Dialogue;
|
|
using NodeCanvas.DialogueTrees;
|
|
using NodeCanvas.Framework;
|
|
using ParadoxNotion;
|
|
using ParadoxNotion.Design;
|
|
using UnityEngine;
|
|
|
|
namespace Net.Project.B.DialogueTrees
|
|
{
|
|
[Name("Comic")]
|
|
[Description(
|
|
"Make the selected Dialogue Actor talk. You can make the text more dynamic by using variable names in square brackets\ne.g. [myVarName] or [Global/myVarName]")]
|
|
public class ComicNode : DTNode
|
|
{
|
|
[SerializeField] public Sprite sprite;
|
|
[SerializeField] public string text;
|
|
|
|
protected override Status OnExecute(Component agent, IBlackboard blackboard)
|
|
{
|
|
var dialogueService = BITApp.ServiceProvider.GetRequiredService<IDialogueService>();
|
|
|
|
var dialogue = new DialogueData()
|
|
{
|
|
MetaObject = sprite,
|
|
Text=text,
|
|
CancellationTokenSource = new()
|
|
};
|
|
|
|
dialogueService.CreateDialogue(dialogue);
|
|
|
|
dialogue.CancellationTokenSource.Token.Register(Success);
|
|
|
|
return Status.Running;
|
|
}
|
|
|
|
private void Success()
|
|
{
|
|
status = Status.Success;
|
|
DLGTree.Continue();
|
|
}
|
|
|
|
#if UNITY_EDITOR
|
|
protected override void OnNodeGUI() {
|
|
GUILayout.BeginVertical(Styles.roundedBox);
|
|
GUILayout.Label("\"<i> " + text.CapLength(30) + "</i> \"");
|
|
GUILayout.EndVertical();
|
|
}
|
|
#endif
|
|
}
|
|
}
|