Example #1
0
    //The initialisation of the boss' behaviour tree.
    protected void InitialiseBehaviourTree()
    {
        MoveToPlayerNode moveToPlayerNode = new MoveToPlayerNode(Player, this);
        MeleeAttackNode  meleeAttackNode  = new MeleeAttackNode(Player, this);
        SequenceNode     meleeSequence    = new SequenceNode(new BehaviourNode[2] {
            moveToPlayerNode, meleeAttackNode
        });

        AOEAttackNode aoeAttackNode = new AOEAttackNode(Player, this);
        PlayerInRangeDecoratorNode playerInRangeDecoratorNode = new PlayerInRangeDecoratorNode(aoeAttackNode, this);
        SelectorNode attackTypeSelector = new SelectorNode(new BehaviourNode[2] {
            meleeSequence, playerInRangeDecoratorNode
        });

        WanderNode wanderNode = new WanderNode(Player, this);

        RootNode = new SelectorNode(new BehaviourNode[2] {
            attackTypeSelector, wanderNode
        });

        //currentNode = null;
    }
Example #2
0
    /// <summary>
    /// Author: Daniel Holker
    /// Constructs nodes and puts them together into a behaviour tree that determines its actions
    /// </summary>
    private void ConstructBehaviourTree()
    {
        WalkToPlayerNode  WalkToPlayerNode  = new WalkToPlayerNode(GetTarget, NearnessToPlayer, NavMeshAgent);
        WanderNode        WanderNode        = new WanderNode(WanderTarget, NavMeshAgent, WanderRange);
        TargetInRangeNode TargetInRangeNode = new TargetInRangeNode(ChasingRange, PlayerList, this.transform, SetTarget);
        MeleeAttackNode   MeleeAttackNode   = new MeleeAttackNode(AttackCooldown, this, AnimManager, AttackDelay);

        Inverter TargetNotInRange = new Inverter(TargetInRangeNode);


        Sequence AttackSequence = new Sequence(new List <Node> {
            WalkToPlayerNode, MeleeAttackNode
        });
        Sequence ChaseSequence = new Sequence(new List <Node> {
            TargetInRangeNode, AttackSequence
        });
        Sequence ReturnToWander = new Sequence(new List <Node> {
            TargetNotInRange, WanderNode
        });

        RootNode = new Selector(new List <Node> {
            ChaseSequence, ReturnToWander
        });
    }