public BehaviourTreeNode(
     Game1 game,
     GameObject parent, 
     BehaviourNodeType type)
 {
     this._type = type;
     this._state = BehaviourNodeState.Ready;
     this._children = new List<BehaviourTreeNode>();
     this._behaviourComponent = (BehaviourComponent)parent.GetComponent(ComponentType.Behaviour);
     this._parent = parent;
     this._game = game;
 }
示例#2
0
        public int addChild(BehaviourNodeType type, int parent)
        {
            if (nodeDepth == null)
            {
                nodeDepth = new List <int>();
                nodeList  = new List <BehaviourNodeType>();
                nodeName  = new List <string>();
            }

            if (parent >= 0 && (parent >= nodeList.Count || nodeList[parent] == BehaviourNodeType.action))
            {
                Debug.LogError("Attempting to add child to action node. " + parent.ToString());
                return(parent);
            }

            int childIndex = -1;

            for (int i = parent + 1; i < nodeList.Count; ++i)
            {
                if (nodeDepth[i] <= nodeDepth[parent])
                {
                    childIndex = i;
                    nodeDepth.Insert(childIndex, nodeDepth[parent] + 1);
                    nodeList.Insert(childIndex, type);
                    nodeName.Insert(childIndex, "");
                    break;
                }
            }

            if (childIndex < 0)
            {
                childIndex = nodeDepth.Count;
                nodeDepth.Add(parent >= 0 ? nodeDepth[parent] + 1 : 0);
                nodeList.Add(type);
                nodeName.Add("");
            }

            return(childIndex);
        }
示例#3
0
 public RootBehaviourNode(BehaviourNodeType type = BehaviourNodeType.Root) : base(type)
 {
 }
示例#4
0
 public SequenceBehaviourNode(BehaviourNodeType type = BehaviourNodeType.Sequence) : base(type)
 {
     _outputs = new string[0];
     AddSequenceOutput();
 }