public void initBehaviourTree() { root = new CompositeNode(this, null); root.setRoot(); root.initSequence(); DecoratorNode idle = new DecoratorNode(this, root.returnToMe); idle.setIdle(); root.AddChild(idle); CompositeNode idleChild = new CompositeNode(this, idle.returnToMe); idleChild.initSequence(); idle.setChild(idleChild); LeafNode setRandom = new LeafNode(this, idleChild.returnToMe, this.setRandom); idleChild.AddChild(setRandom); LeafNode randomMove = new LeafNode(this, idleChild.returnToMe, this.beginJourney); idleChild.AddChild(randomMove); //now move on to the second child of root CompositeNode getProfLocation = new CompositeNode(this, root.returnToMe); getProfLocation.initSelector(); root.AddChild(getProfLocation); LeafNode profKnown = new LeafNode(this, getProfLocation.returnToMe, this.profSaved); getProfLocation.AddChild(profKnown); CompositeNode explorePlaques = new CompositeNode(this, getProfLocation.returnToMe); explorePlaques.initSelector(); getProfLocation.AddChild(explorePlaques); for (int i = 0; i < 6; i++) { CompositeNode PlaqueFinder = new CompositeNode(this, explorePlaques.returnToMe); PlaqueFinder.initSequence(); explorePlaques.AddChild(PlaqueFinder); LeafNode setPlaque = new LeafNode(this, PlaqueFinder.returnToMe, this.setTargetPlaque); PlaqueFinder.AddChild(setPlaque); LeafNode plaqueMove = new LeafNode(this, PlaqueFinder.returnToMe, this.beginJourney); PlaqueFinder.AddChild(plaqueMove); LeafNode isProf = new LeafNode(this, PlaqueFinder.returnToMe, this.isAdvisor); PlaqueFinder.AddChild(isProf); } LeafNode finalMove = new LeafNode(this, root.returnToMe, this.beginJourney); root.AddChild(finalMove); }
public void Composite_Node_Properly_Returns_Childrens() { BTNode mock = Substitute.For <BTNode>(); CompositeNode composite = Substitute.ForPartsOf <CompositeNode>(); composite.AddChild(mock); Assert.IsTrue(composite.GetChildren().Contains(mock)); }
public void Composite_Properly_Sets_Node_As_Its_Child() { BTNode mock = Substitute.For <BTNode>(); CompositeNode composite = Substitute.ForPartsOf <CompositeNode>(); composite.AddChild(mock); Assert.IsTrue(mock.Parent == composite); }
protected override void AcceptNode(BehaviourTreeNode <TBlackboard> node) { _group.AddChild(node); }