Example #1
0
    //builds the characters behaviour tree
    private void constructBehaviourTree()
    {
        //health node checks if health is below threshold
        HealthNode healthNode = new HealthNode(this, m_lowHealthThreshold);

        //inverted health checks if health is above threshhold
        Inverter invertHealth = new Inverter(healthNode);

        //Cover

        GetCoverNode getCoverNode = new GetCoverNode(target.transform, this);

        GoToCoverNode goToCoverNode = new GoToCoverNode(this, m_speed);

        HealNode Heal = new HealNode(20, this, m_healthRegenRate);

        Sequence CoverSequence = new Sequence(new List <BNode> {
            healthNode, getCoverNode, goToCoverNode, Heal
        });

        //chase
        Range = new RangeNode(m_detectionRange, target.transform, gameObject.transform, this);

        Chase = new ChaseNode(target.transform, this, m_speed);

        Sequence ChaseSequence = new Sequence(new List <BNode> {
            invertHealth, Range, Chase
        });

        //wander
        RangeNode wanderRange = new RangeNode(m_detectionRange, target.transform, gameObject.transform, this);

        Inverter invertWanderRange = new Inverter(wanderRange);

        WanderNode wander = new WanderNode(this, m_speed);

        Sequence WanderSequence = new Sequence(new List <BNode> {
            invertWanderRange, wander
        });

        //attack
        attackRange = new RangeNode(m_attackRange, target.transform, gameObject.transform, this);

        attack = new AttackNode(target.transform, this);

        Sequence AttackSequence = new Sequence(new List <BNode> {
            attackRange, attack
        });


        //root node
        topNode = new Selector(new List <BNode> {
            CoverSequence, AttackSequence, ChaseSequence, WanderSequence
        });
    }
    //builds the characters behaviour tree
    private void constructBehaviourTree()
    {
        ////Cover

        GetCoverNode getCoverNode = new GetCoverNode(m_target.transform, this);

        GoToCoverNode goToCoverNode = new GoToCoverNode(this, m_speed);

        HealNode Heal = new HealNode(20, this, m_healthRegenRate);

        Sequence CoverSequence = new Sequence(new List <BNode> {
            getCoverNode, goToCoverNode, Heal
        });

        coverTopNode = new Selector(new List <BNode> {
            CoverSequence
        });

        ////chase
        m_chase = new ChaseNode(m_target.transform, this, m_speed);

        Sequence ChaseSequence = new Sequence(new List <BNode> {
            m_chase
        });

        chaseTopNode = new Selector(new List <BNode> {
            ChaseSequence
        });

        ////wander
        WanderNode wander = new WanderNode(this, m_speed);

        Sequence WanderSequence = new Sequence(new List <BNode> {
            wander
        });

        WanderTopNode = new Selector(new List <BNode> {
            WanderSequence
        });

        ////attack
        m_attack = new AttackNode(m_target.transform, this);

        Sequence AttackSequence = new Sequence(new List <BNode> {
            m_attack
        });

        attackTopNode = new Selector(new List <BNode> {
            AttackSequence
        });
    }
Example #3
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 #4
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
        });
    }
    /// <summary>
    /// Método CreateBehaviourTree, que crea el árbol de comportamiento
    /// </summary>
    public override void CreateBehaviourTree()
    {
        // Quinta rama
        MoveToDestinationNode moveToDestinationNode = new MoveToDestinationNode(this);

        WanderNode      wanderNode      = new WanderNode(this, this.stillTime);
        EnoughSpaceNode enoughSpaceNode = new EnoughSpaceNode(this);
        Sequence        sequence6       = new Sequence(new List <Node>()
        {
            enoughSpaceNode, wanderNode
        });

        VillagerChooseDestinationNode chooseDestinationNode = new VillagerChooseDestinationNode(this);
        Selector selector3 = new Selector(new List <Node>()
        {
            sequence6, chooseDestinationNode
        });

        InDestinationNode inDestinationNode = new InDestinationNode(this, MINIMUM_DESTINY_DISTANCE);
        Sequence          sequence5         = new Sequence(new List <Node>()
        {
            inDestinationNode, selector3
        });

        Selector moveSelector = new Selector(new List <Node>()
        {
            sequence5, moveToDestinationNode
        });

        // Cuarta rama
        HasDestinationNode hasDestinationNode        = new HasDestinationNode(this);
        Inverter           destinationInvertedNode   = new Inverter(hasDestinationNode);
        Sequence           chooseDestinationSequence = new Sequence(new List <Node>()
        {
            destinationInvertedNode, chooseDestinationNode
        });

        // Tercera rama
        ZoneTimerNode zoneTimerNode      = new ZoneTimerNode(this);
        InZoneNode    inZoneNode         = new InZoneNode(this);
        Sequence      wanderZoneSequence = new Sequence(new List <Node>()
        {
            inZoneNode, zoneTimerNode, wanderNode
        });

        // Segunda rama
        StayStillNode       stayStillNode       = new StayStillNode(thisAgent, thisAnimator);
        GiveInformationNode giveInformationNode = new GiveInformationNode(this);
        RangeNode           marshallInRange     = new RangeNode(marshallInfoRange, playerTransform, this.transform);
        Sequence            sequence3           = new Sequence(new List <Node>()
        {
            marshallInRange, giveInformationNode, stayStillNode
        });

        HideInformationNode    hideInformationNode       = new HideInformationNode(this);
        Inverter               marshallRangeInvertedNode = new Inverter(marshallInRange);
        HasGivenInformatioNode hasGivenInformatioNode    = new HasGivenInformatioNode(this);
        Sequence               sequence2 = new Sequence(new List <Node>()
        {
            hasGivenInformatioNode, marshallRangeInvertedNode, hideInformationNode
        });

        Selector selector2 = new Selector(new List <Node>()
        {
            sequence2, sequence3
        });

        WitnessNode witnessNode = new WitnessNode(this);
        Sequence    sequence4   = new Sequence(new List <Node>()
        {
            witnessNode, selector2
        });

        Selector selector1 = new Selector(new List <Node>()
        {
            sequence2, sequence3, stayStillNode
        });

        VictimNode victimNode = new VictimNode(this);
        Sequence   sequence1  = new Sequence(new List <Node>()
        {
            victimNode, selector1
        });

        Selector staySelector = new Selector(new List <Node>()
        {
            sequence1, sequence4
        });

        // Primera rama
        MarshallCalledMeNode marshallCalledMeNode = new MarshallCalledMeNode(this);
        Sequence             detentionSequence    = new Sequence(new List <Node>()
        {
            marshallCalledMeNode, stayStillNode
        });

        // Nodo padre del árbol
        topNode = new Selector(new List <Node>()
        {
            detentionSequence, staySelector, wanderZoneSequence, chooseDestinationSequence, moveSelector
        });
    }
    /// <summary>
    /// Método CreateBehaviourTree, que crea el árbol de comportamiento
    /// </summary>
    public override void CreateBehaviourTree()
    {
        // Sexta rama
        MoveToDestinationNode moveToDestinationNode = new MoveToDestinationNode(this);

        WanderNode      wanderNode      = new WanderNode(this, this.stillTime);
        EnoughSpaceNode enoughSpaceNode = new EnoughSpaceNode(this);
        Sequence        sequence4       = new Sequence(new List <Node>()
        {
            enoughSpaceNode, wanderNode
        });

        ThiefChooseDestinationNoe chooseDestinationNode = new ThiefChooseDestinationNoe(this);
        Selector selector2 = new Selector(new List <Node>()
        {
            sequence4, chooseDestinationNode
        });

        InDestinationNode inDestinationNode = new InDestinationNode(this, MINIMUM_DESTINY_DISTANCE);
        Sequence          sequence3         = new Sequence(new List <Node>()
        {
            inDestinationNode, selector2
        });

        Selector moveSelector = new Selector(new List <Node>()
        {
            sequence3, moveToDestinationNode
        });

        // Quinta rama
        HasDestinationNode hasDestinationNode        = new HasDestinationNode(this);
        Inverter           destinationInvertedNode   = new Inverter(hasDestinationNode);
        Sequence           chooseDestinationSequence = new Sequence(new List <Node>()
        {
            destinationInvertedNode, chooseDestinationNode
        });

        // Cuarta rama
        ZoneTimerNode zoneTimerNode      = new ZoneTimerNode(this);
        InZoneNode    inZoneNode         = new InZoneNode(this);
        Sequence      wanderZoneSequence = new Sequence(new List <Node>()
        {
            inZoneNode, zoneTimerNode, wanderNode
        });

        // Tercera rama
        ChooseVictimNode   chooseVictimNode     = new ChooseVictimNode(this);
        VillagersCloseNode villagersCloseNode   = new VillagersCloseNode(this);
        Sequence           chooseVictimSequence = new Sequence(new List <Node>()
        {
            inZoneNode, villagersCloseNode, chooseVictimNode
        });

        MoveToVictimNode moveToVictimNode    = new MoveToVictimNode(this);
        HasVictimNode    hasVictimNode       = new HasVictimNode(this);
        Sequence         chaseVictimSequence = new Sequence(new List <Node>()
        {
            hasVictimNode, moveToVictimNode
        });

        ChooseIfWitnessNode chooseIfWitnessNode = new ChooseIfWitnessNode(this);
        StealNode           stealNode           = new StealNode(this);
        VictimCloseNode     victimCloseNode     = new VictimCloseNode(this);
        Sequence            stealSequence       = new Sequence(new List <Node>()
        {
            hasVictimNode, victimCloseNode, stealNode, chooseIfWitnessNode, chooseDestinationNode
        });

        Selector stealActionsSelector = new Selector(new List <Node>()
        {
            stealSequence, chaseVictimSequence, chooseVictimSequence
        });
        RangeNode    marshallInDetectRange           = new RangeNode(marshallDetectRange, playerTransform, this.transform);
        Inverter     marshallDetectRangeInvertedNode = new Inverter(marshallInDetectRange);
        CanStealNode canStealNode    = new CanStealNode(this);
        Sequence     robberySequence = new Sequence(new List <Node>()
        {
            canStealNode, marshallDetectRangeInvertedNode, stealActionsSelector
        });

        // Segunda rama
        StayStillNode       stayStillNode       = new StayStillNode(thisAgent, thisAnimator);
        GiveInformationNode giveInformationNode = new GiveInformationNode(this);
        RangeNode           marshallInInfoRange = new RangeNode(marshallInfoRange, playerTransform, this.transform);
        Sequence            sequence2           = new Sequence(new List <Node>()
        {
            marshallInInfoRange, giveInformationNode, stayStillNode
        });

        HideInformationNode    hideInformationNode       = new HideInformationNode(this);
        Inverter               marshallInvertedInfoRange = new Inverter(marshallInInfoRange);
        HasGivenInformatioNode hasGivenInformatioNode    = new HasGivenInformatioNode(this);
        Sequence               sequence1 = new Sequence(new List <Node>()
        {
            hasGivenInformatioNode, marshallInvertedInfoRange, hideInformationNode
        });

        Selector selector1 = new Selector(new List <Node>()
        {
            sequence1, sequence2
        });

        WitnessNode witnessNode         = new WitnessNode(this);
        Sequence    fakeWitnessSequence = new Sequence(new List <Node>()
        {
            witnessNode, selector1
        });

        // Primera rama
        MarshallCalledMeNode marshallCalledMeNode = new MarshallCalledMeNode(this);
        Sequence             detentionSequence    = new Sequence(new List <Node>()
        {
            marshallCalledMeNode, stayStillNode
        });

        // Nodo padre del árbol
        topNode = new Selector(new List <Node>()
        {
            detentionSequence, fakeWitnessSequence, robberySequence, wanderZoneSequence, chooseDestinationSequence, moveSelector
        });
    }