Ejemplo n.º 1
0
    private void Awake()
    {
        enemyHealth  = GetComponent <EnemyHealth>();
        enemyAttacks = GetComponent <EnemyAttacks>();
        anim         = GetComponent <Animator>();

        isFearead   = false;
        canMove     = true;
        targetFound = false;
        following   = false;

        DecisionTreeDecision playersInThreatRangeDecision = new DecisionTreeDecision(PlayersInThreatRange);

        DecisionTreeAction targetMoreThreatening = new DecisionTreeAction(TargetMoreThreatening);
        DecisionTreeAction targetMoreNear        = new DecisionTreeAction(TargetMoreNear);

        playersInThreatRangeDecision.AddLink(true, targetMoreThreatening);
        playersInThreatRangeDecision.AddLink(false, targetMoreNear);
        chasingDT = new DecisionTree(playersInThreatRangeDecision);

        BehaviourTreeCondition abilityAvaible = new BehaviourTreeCondition(AbilityAvaible);

        BehaviourTreeAction useAbility     = new BehaviourTreeAction(UseAbility);
        BehaviourTreeAction useBasicAttack = new BehaviourTreeAction(UseBasicAttack);

        BehaviourTreeSequence abilitySequence = new BehaviourTreeSequence(new BehaviourTreeTask[] { abilityAvaible, useAbility });

        BehaviourTreeDecoratorUntilFail abilityDecorator     = new BehaviourTreeDecoratorUntilFail(abilitySequence);
        BehaviourTreeDecoratorUntilFail basicAttackDecorator = new BehaviourTreeDecoratorUntilFail(useBasicAttack);

        BehaviourTreeSequence           attackSequence          = new BehaviourTreeSequence(new BehaviourTreeTask[] { abilityDecorator, basicAttackDecorator });
        BehaviourTreeDecoratorUntilFail attackSequenceDecorator = new BehaviourTreeDecoratorUntilFail(attackSequence);

        attackingBT = new BehaviourTree(attackSequenceDecorator);
    }
Ejemplo n.º 2
0
 /// <summary>
 /// Initialize new instance BehaviourTree class with custom store logic.
 /// If logic instance  will be null - new store logic instance will be created.
 /// </summary>
 /// <param name="store">Store logic instance.</param>
 public BehaviourTree(T store = null)
 {
     _root = new BehaviourTreeSequence();
     if (store == null)
     {
         store = new T();
     }
     _store = store;
 }
Ejemplo n.º 3
0
    public BehaviourTreeConstructor Sequence(string name)
    {
        BehaviourTreeSequence node = new BehaviourTreeSequence(name);

        if (Nodes.Count > 0)
        {
            Nodes.Peek().AddChild(node);
        }

        Nodes.Push(node);

        return(this);
    }