/// <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
        });
    }
コード例 #2
0
    /// <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
        });
    }