IndieGame/client/Assets/ParadoxNotion/NodeCanvas/Modules/DialogueTrees/Nodes/StatementNode.cs

41 lines
1.4 KiB
C#
Raw Normal View History

2024-10-11 10:12:15 +08:00
using NodeCanvas.Framework;
using ParadoxNotion;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.DialogueTrees
{
[Name("Say")]
[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 StatementNode : DTNode
{
[SerializeField]
public Statement statement = new Statement("This is a dialogue text");
public override bool requireActorSelection { get { return true; } }
protected override Status OnExecute(Component agent, IBlackboard bb) {
var tempStatement = statement.BlackboardReplace(bb);
DialogueTree.RequestSubtitles(new SubtitlesRequestInfo(finalActor, tempStatement, OnStatementFinish));
return Status.Running;
}
void OnStatementFinish() {
status = Status.Success;
DLGTree.Continue();
}
///----------------------------------------------------------------------------------------------
///---------------------------------------UNITY EDITOR-------------------------------------------
#if UNITY_EDITOR
protected override void OnNodeGUI() {
GUILayout.BeginVertical(Styles.roundedBox);
GUILayout.Label("\"<i> " + statement.text.CapLength(30) + "</i> \"");
GUILayout.EndVertical();
}
#endif
}
}