Ejemplo n.º 1
0
        public void createExternalNode(BehaviourTreeTask newNode, BehaviourTreeTask parent, Vector2 createAt)
        {
            newNode.name = System.Guid.NewGuid().ToString();
            Rect oldRect = newNode.NodeRect;

            newNode.NodeRect = new Rect(createAt.x, createAt.y, oldRect.width, oldRect.height);
            if (parent != null)
            {
                parent.addNewChild(newNode);
            }
            Undo.RegisterCreatedObjectUndo(newNode, "Undo Create Node");
            Undo.RecordObject(this, "Add new node");
            AddNode(newNode);
        }
Ejemplo n.º 2
0
 //Change parent of parentFor for a newParent, clear all old connections
 public static bool Reparent(BehaviourTreeTask newParent, BehaviourTreeTask parentFor)
 {
     if (newParent.taskType == TaskType.DECORATOR)
     {
         if (((DecoratorTreeTask)newParent).OnlySingleChildAllowed == true && newParent.children.Count > 0)
         {
             //cant add another child when flag only one children is enabled
             return(false);
         }
     }
     parentFor.parent.removeChildConnection(parentFor);
     parentFor.parent = newParent;
     newParent.addNewChild(parentFor);
     return(true);
 }
Ejemplo n.º 3
0
        private static BehaviourTreeTask MakeNodeOfType(Type t, BehaviourTreeTask parent, Vector2 createAt)
        {
            BehaviourTreeTask newNode = CreateInstance(t.Name) as BehaviourTreeTask;

            newNode.name = System.Guid.NewGuid().ToString();
            Rect oldRect = newNode.NodeRect;

            newNode.NodeRect = new Rect(createAt.x, createAt.y, oldRect.width, oldRect.height);
            if (parent != null)
            {
                parent.addNewChild(newNode);
            }

            return(newNode);
        }