// I pass in the AI Behaviour to get access to the functions I // need for the tree public GoulBehaviourTree(BaseAIBehaviour goul) { // First I build the nodes for the tree main = new Selector(); moveToPlayer = new MoveAction(goul.Move, goul.FindPlayer); moveToPoint = new MoveAction(goul.Move, goul.GetNextPatrolPoint); huntKill.OpenBranch( //new SetVector(goul.FindPlayer, moveToPlayer.SetTarget), moveToPlayer, new ConditionalAction(goul.PlayerInRange), new ActionNode(goul.Attack)); patrol.OpenBranch( //new SetVector(goul.GetNextPatrolPoint, moveToPoint.SetTarget), moveToPoint, new WaitNode(goul.WaitForSeconds, 7f) // new ConditionalAction(goul.HasReachedPoint) ); canSeePlayer = new ThisOrThat(huntKill, patrol, goul.PlayerInView); main.OpenBranch(canSeePlayer); TreeRoot = new Root(); TreeRoot.OpenBranch(main); }
public static void test() { IThis <IThat> ThisOrThat1 = new ThisOrThat(); IThat <IThis> ThisOrThat2 = new ThisOrThat(); IThis <IOther> ThisOrOther1 = new ThisOrOther(); IOther <IThat> OtherOrThat1 = new ThatOrOther(); IThis <IThat <IOther> > ThisThatOrOther1 = new ThisThatOrOther(); IOther <IThat <IThis> > ThisThatOrOther2a = new ThisThatOrOther(); var ThisThatOrOther2b = (IOther <IThis <IThat> >)ThisThatOrOther1; TestThisOrThat(ThisOrThat1); TestThisOrThat((IThis <IThat>)ThisOrThat2); TestThisOrThat((IThis <IThat>)ThisThatOrOther1); TestThisOrOther(ThisOrOther1); TestThisOrOther((IThis <IOther>)ThisThatOrOther1); TestThatOrOther((IThat <IOther>)OtherOrThat1); TestThatOrOther((IThat <IOther>)ThisThatOrOther1); }
public BanditBossBehaviourTree(BanditBossBehaviour boss) { moveToPlayer = new MoveAction(boss.Move, boss.FindPlayer); moveToThrowingPosition = new MoveAction(boss.Move, boss.PositionForHealthEvent); moveToHidingPlace = new MoveAction(boss.Move, boss.HidingPlace); fireShotgun.OpenBranch(new ActionNode(boss.ShotgunAttack)); throwMolotov.OpenBranch(new ActionNode(boss.Attack)); ThisOrThat selectAttack = new ThisOrThat(throwMolotov, fireShotgun, boss.PlayerOnLowerLevel); healthEvent = new ActionNode(boss.HealthEvent); //TODO Define both weapon sequences and whistle sequence whistleAndRetreat.OpenBranch( whistle = new ActionNode(boss.WhistleToAllies), moveToHidingPlace, hide = new ActionNode(boss.Hide) ); healthEventSeq.OpenBranch( new ConditionalAction(boss.HealthEventDue), moveToThrowingPosition, healthEvent, whistleAndRetreat ); attack.OpenBranch( moveToPlayer, selectAttack ); findBestAction.OpenBranch( healthEventSeq, attack ); treeRoot = new Root(); treeRoot.OpenBranch(findBestAction); }