public ConditionalDialogueNode GetNextNode() { if (indexing >= Count || indexing == 1) { ReachedEnd = true; return(null); } ConditionalDialogueNode currentNode = Nodes[indexing]; ConditionalDialogueNode[] childrens = currentNode.GetChildren(); for (int i = 0; i < childrens.Length && !ReachedEnd; i++) { if (childrens[i].ConditionMet) { int nextIndex = SearchNodeIndex(childrens[i].NodeID); indexing = nextIndex; } } if (currentNode.Value == ConditionalDialogueNode.StartValue) { return(GetNextNode()); } return(currentNode); }
public void AddChildToStart(ConditionalDialogueNode child) { if (child.NodeID == null || child.NodeID.Trim() == "") { child.NodeID = AutoID(); } Nodes.Add(child); Nodes[0].Add(child); }
public void AddChildToStart(ConditionalDialogueNode child, string child_id) { if (child.ParentNode == null) { child.ParentNode = Nodes[0]; } child.NodeID = child_id; Nodes.Add(child); Nodes[0].Add(child); }
public void AddChild(ConditionalDialogueNode parent, ConditionalDialogueNode child, INodeOwner owner) { if (Nodes.Count == 2) { if (child.ParentNode == null) { child.ParentNode = Nodes[0]; } if (child.NodeID == null || child.NodeID.Trim() == "") { child.NodeID = AutoID(); } child.SetNodeOwner(owner); Nodes.Add(child); Nodes[0].Add(child); } else { int index = SearchNodeIndexByValue(parent.Value); if (index == -1) { throw new Exception("No such parent node!"); } if (child.ParentNode != null) { //Multiple Parents child.MultipleParents = true; child.SetNodeOwner(owner); child.AddParent(parent); if (child.NodeID == null || child.NodeID.Trim() == "") { child.NodeID = AutoID(); } Nodes[index].Add(child); } else { if (child.NodeID == null || child.NodeID.Trim() == "") { child.NodeID = AutoID(); } child.SetNodeOwner(owner); child.AddParent(parent); Nodes.Add(child); Nodes[index].Add(child); //SingleParent } } }
public bool DeleteNode(ConditionalDialogueNode node) { int index = SearchNodeIndexByValue(node.Value); if (index == -1) { return(false); } if (Nodes[index].HasChild) { throw new Exception("This dialogue has children!"); } Nodes.Remove(Nodes[index]); return(true); }
public void AddParent(ConditionalDialogueNode parent) { if (MultipleParents) { if (ParentCount > 0) { if (ParentNodes[0].NodeID != parent.NodeID) { ParentNodes.Add(parent); } } } else { ParentNode = parent; ParentNodes.Add(ParentNode); } }
public void AddChild(ConditionalDialogueNode parent, ConditionalDialogueNode child, string child_id) { if (Nodes.Count == 2) { if (child.ParentNode == null) { child.ParentNode = Nodes[0]; } child.NodeID = child_id; Nodes.Add(child); Nodes[0].Add(child); } else { int index = SearchNodeIndexByValue(parent.Value); if (index == -1) { throw new Exception("No such parent node!"); } if (child.ParentNode != null) { //Multiple Parents child.MultipleParents = true; child.AddParent(parent); child.NodeID = child_id; Nodes[index].Add(child); } else { child.NodeID = child_id; child.AddParent(parent); Nodes.Add(child); Nodes[index].Add(child); //SingleParent } } }
public void Add(ConditionalDialogueNode node) { ChildrenNodes.Add(node); }
public bool NotStartOrNotEnd(ConditionalDialogueNode node) => node.Value != ConditionalDialogueNode.EndValue && node.Value != ConditionalDialogueNode.StartValue;
public ConditionalDialogueNode[] GetChildren(ConditionalDialogueNode node) { return(node.GetChildren()); }
public void AddEnding(ConditionalDialogueNode parent) { int index = SearchNodeIndex(parent.NodeID); Nodes[index].Add(Nodes[1]); }