private void Start()
 {
     globalBlackboard = (GlobalBlackboard)blackboard.GetValue("globalBlackboard");
     maxAttackDamage  = (float)globalBlackboard.GetValue("maxAttackDamage");
     minAttackDamage  = (float)globalBlackboard.GetValue("minAttackDamage");
     maxFood          = (int)globalBlackboard.GetValue("maxFood");
 }
    public override NodeState Evaluate()
    {
        int nAnts          = (int)globalBlackboard.GetValue("totalNumberOfCharacters");
        int nAntsDefending = (int)globalBlackboard.GetValue("antsDefending");

        if (nAntsDefending < nAnts / 2)
        {
            return(NodeState.SUCCESS);
        }
        else
        {
            return(NodeState.FAIL);
        }
    }
 protected override void Awake()
 {
     base.Awake();
     agent            = (NavMeshAgent)blackboard.GetValue("navMeshAgent");
     globalBlackboard = (GlobalBlackboard)blackboard.GetValue("globalBlackboard");
     baseLocation     = (Vector3)globalBlackboard.GetValue("baseLocation");
 }
Beispiel #4
0
 public override NodeState Evaluate()
 {
     if ((Vector3)blackboard.GetValue("currentFoodLocation") == Vector3.zero)
     {
         return(NodeState.SUCCESS);
     }
     if (isEating)
     {
         if (timer >= eatAnimationLength)
         {
             ObjectDestroyer.DestroyObjectAtGivenPosition((Vector3)blackboard.GetValue("currentFoodLocation"), LayerMask.GetMask("Food"));
             int foodEaten = (int)globalBlackboard.GetValue("foodEaten") + 1;
             globalBlackboard.UpdateValue("foodEaten", foodEaten);
             return(NodeState.SUCCESS);
         }
         else
         {
             timer += Time.deltaTime;
         }
     }
     else
     {
         anim.SetTrigger("Attack");
         agent.isStopped = true;
         isEating        = true;
     }
     return(NodeState.RUNNING);
 }
Beispiel #5
0
 public override NodeState Evaluate()
 {
     if (((int)globalBlackboard.GetValue("foodEaten") >= foodRequiredToBeStrong) == desiredBool)
     {
         return(NodeState.SUCCESS);
     }
     return(NodeState.FAIL);
 }
Beispiel #6
0
    public override bool EvaluateCondition()
    {
        nAllies    = (int)globalBlackboard.GetValue("totalNumberOfCharacters");
        minEnemies = nAllies + (int)(nAllies * fewEnemiesMultiplier);
        int nTotalCharacters = (int)gameGlobalBlackboard.GetValue("totalNumberOfCharacters");

        return((nTotalCharacters <= minEnemies) == desiredBool);
    }
Beispiel #7
0
    public override void OnStateEnter()
    {
        base.OnStateEnter();
        Vector3 currentEnemyBase = (Vector3)globalBlackboard.GetValue("currentEnemyBase");
        Vector3 positionToGo     = NavMeshUtilities.SamplePositionNearMe(transform.position, currentEnemyBase);

        agent.SetDestination(positionToGo);
    }
 protected void Start()
 {
     anim  = (Animator)blackboard.GetValue("animator");
     agent = (NavMeshAgent)blackboard.GetValue("navMeshAgent");
     attackAnimationLength = AnimatorUtilities.GetClipLength(anim, "Attack");
     globalBlackboard      = (GlobalBlackboard)blackboard.GetValue("globalBlackboard");
     attackDamage          = (float)globalBlackboard.GetValue("attackDamage");
 }
    public override NodeState Evaluate()
    {
        int   foodEaten    = (int)globalBlackboard.GetValue("foodEaten");
        float t            = Mathf.InverseLerp(0, maxFood, foodEaten);
        float attackDamage = Mathf.Lerp(minAttackDamage, maxAttackDamage, t);

        globalBlackboard.UpdateValue("attackDamage", attackDamage);
        return(NodeState.SUCCESS);
    }
Beispiel #10
0
 public override bool EvaluateCondition()
 {
     if (baseManager.isBaseAlive((Vector3)globalBlackboard.GetValue("currentEnemyBase")))
     {
         return(false);
     }
     globalBlackboard.UpdateValue("enemyBaseFound", false);
     return(true);
 }
    public override void OnStateEnter()
    {
        agent.isStopped = false;
        anim.SetBool("isMoving", true);
        Vector3 homeLocation = (Vector3)globalBlackboard.GetValue("baseLocation");
        Vector3 positionToGo = NavMeshUtilities.SamplePositionNearMe(transform.position, homeLocation);

        agent.SetDestination(positionToGo);
        base.OnStateEnter();
    }
 public override NodeState Evaluate()
 {
     nAllies    = (int)globalBlackboard.GetValue("totalNumberOfCharacters");
     minEnemies = nAllies * 2;
     if (((int)gameGlobalBlackboard.GetValue("totalNumberOfCharacters") <= minEnemies) == desiredBool)
     {
         return(NodeState.SUCCESS);
     }
     return(NodeState.FAIL);
 }
Beispiel #13
0
    public override NodeState Evaluate()
    {
        Vector3 baseLocation = (Vector3)globalBlackboard.GetValue("baseLocation");

        if (Vector3.Distance(transform.position, baseLocation) <= distance)
        {
            return(NodeState.SUCCESS);
        }
        return(NodeState.FAIL);
    }
Beispiel #14
0
 public override NodeState Evaluate()
 {
     if ((bool)globalBlackboard.GetValue("baseIsInDanger") == desiredBool)
     {
         return(NodeState.SUCCESS);
     }
     else
     {
         return(NodeState.FAIL);
     }
 }
Beispiel #15
0
    public override NodeState Evaluate()
    {
        Vector3 baseLocation = (Vector3)globalBlackboard.GetValue("baseLocation");

        if (baseLocation != agent.destination)
        {
            agent.SetDestination(NavMeshUtilities.SamplePositionNearMe(transform.position, baseLocation));
            agent.isStopped = false;
            anim.SetBool("isMoving", true);
        }
        if (agent.remainingDistance <= distanceHome && !agent.pathPending)
        {
            agent.isStopped = true;
            anim.SetBool("isMoving", false);
            return(NodeState.SUCCESS);
        }
        return(NodeState.RUNNING);
    }
Beispiel #16
0
    void setDestinationToBase()
    {
        Vector3    baseLocation = (Vector3)globalBlackboard.GetValue("baseLocation");
        Vector3    dirToBase    = (baseLocation - transform.position).normalized;
        NavMeshHit hit;
        Vector3    posToMove = (dirToBase * deltaMovement) + transform.position;

        if (NavMesh.SamplePosition(posToMove, out hit, 3f, NavMesh.AllAreas))
        {
            agent.SetDestination(hit.position);
            agent.isStopped = false;
            anim.SetBool("isMoving", true);
        }
        else
        {
            print("I could not flee");
        }
    }
Beispiel #17
0
    void setDestination()
    {
        Vector3    basePos         = (Vector3)globalBlackboard.GetValue("baseLocation");
        Vector3    dirToMe         = (transform.position - basePos).normalized * baseOffset;
        Vector3    directionToMove = Quaternion.Euler(0, deltaAngle, 0) * dirToMe;
        Vector3    posToMove       = basePos + directionToMove;
        NavMeshHit hit;

        if (NavMesh.SamplePosition(posToMove, out hit, 3f, NavMesh.AllAreas))
        {
            agent.SetDestination(hit.position);
        }
        else
        {
            posToMove = basePos - directionToMove;
            if (NavMesh.SamplePosition(posToMove, out hit, 3f, NavMesh.AllAreas))
            {
                agent.SetDestination(hit.position);
            }
        }
    }
Beispiel #18
0
 private void Start()
 {
     baseManager      = (BaseManager)GameGlobalBlackboard.Instance.GetValue("baseManager");
     globalBlackboard = (GlobalBlackboard)blackboard.GetValue("globalBlackboard");
     baseLocation     = (Vector3)globalBlackboard.GetValue("baseLocation");
 }
Beispiel #19
0
 private void Awake()
 {
     blackboard       = GetComponent <Blackboard>();
     globalBlackboard = (GlobalBlackboard)blackboard.GetValue("globalBlackboard");
     maxHealth        = (float)globalBlackboard.GetValue("maxHealth");
 }
Beispiel #20
0
 private void Start()
 {
     globalBlackboard = (GlobalBlackboard)blackboard.GetValue("globalBlackboard");
     maxHealth        = (float)globalBlackboard.GetValue("maxHealth");
 }
 public override NodeState Evaluate()
 {
     globalBlackboard.UpdateValue("antsDefending", (int)globalBlackboard.GetValue("antsDefending") - 1);
     return(NodeState.SUCCESS);
 }
 public override bool EvaluateCondition()
 {
     return(Vector3.Distance((Vector3)globalBlackboard.GetValue("baseLocation"), transform.position) <= distanceNear);
 }
 public override bool EvaluateCondition()
 {
     return((bool)globalBlackboard.GetValue("enemyBaseFound"));
 }
Beispiel #24
0
 public override void OnStateEnter()
 {
     base.OnStateEnter();
     globalBlackboard.UpdateValue("antsDefending", (int)globalBlackboard.GetValue("antsDefending") + 1);
 }
Beispiel #25
0
 private void Start()
 {
     globalBlackboard       = (GlobalBlackboard)blackboard.GetValue("globalBlackboard");
     foodRequiredToBeStrong = (int)globalBlackboard.GetValue("maxFood");
 }
Beispiel #26
0
    private void RemoveCharacterFromBase()
    {
        BaseManager baseManager = (BaseManager)GameGlobalBlackboard.Instance.GetValue("baseManager");

        baseManager.RemoveCharacterFromBase(GetComponentInParent <IDamageable>(), (Vector3)globalBlackboard.GetValue("baseLocation"));
    }