Exemplo n.º 1
0
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (npcCtrl.CanSeeTarget())
        {
            npcCtrl.SetDestinationWithDelay();
            if (npcCtrl.DistanceToTarget() <= combatManager.meleeAttackDistance)
            {
                // ATTACK
                if (randInt > 0)
                {
                    // Handles a timer that upon reaching 0, flips canRecieveAttackInput to true!
                    combatManager.HandleAttackTimer();

                    if (combatManager.canRecieveAttackInput)
                    {
                        animator.SetBool("meleeAttackHold", true);
                    }
                }

                // STRAFE
                if (randInt == 0)
                {
                    int dirInt = Random.Range(0, 2);
                    animator.SetInteger("dirInt", dirInt);
                    animator.SetBool("strafeTarget", true);
                }
            }
        }
        else
        {
            combatManager.HandleCombatTimer();
        }
    }