예제 #1
0
        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
                }
            }
        }
예제 #2
0
 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
         }
     }
 }