DialogueNodeGraph.cs 773 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. namespace XNode.Examples.StateGraph {
  6. public class StateNode : Node {
  7. [Input] public Empty enter;
  8. [Output] public Empty exit;
  9. public void MoveNext() {
  10. StateGraph fmGraph = graph as StateGraph;
  11. if (fmGraph.current != this) {
  12. Debug.LogWarning("Node isn't active");
  13. return;
  14. }
  15. NodePort exitPort = GetOutputPort("exit");
  16. if (!exitPort.IsConnected) {
  17. Debug.LogWarning("Node isn't connected");
  18. return;
  19. }
  20. StateNode node = exitPort.Connection.node as StateNode;
  21. node.OnEnter();
  22. }
  23. public void OnEnter() {
  24. StateGraph fmGraph = graph as StateGraph;
  25. fmGraph.current = this;
  26. }
  27. [Serializable]
  28. public class Empty { }
  29. }
  30. }