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; }
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); }
public RootBehaviourNode(BehaviourNodeType type = BehaviourNodeType.Root) : base(type) { }
public SequenceBehaviourNode(BehaviourNodeType type = BehaviourNodeType.Sequence) : base(type) { _outputs = new string[0]; AddSequenceOutput(); }