Beispiel #1
0
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (animator.GetComponent <MobHealth>().isAlive == true)
        {
            if (_meleeRange >= TransformExtension.DistanceBetween(animator.transform.position, _target.transform.position))
            {
                RotateTowards(animator);
                if (_canAttack == true)
                {
                    animator.SetTrigger("Melee");
                    _canAttack = false;
                }

                if (animator.GetCurrentAnimatorStateInfo(0).IsName("Attack"))
                {
                }
                else
                {
                    _canAttack = true;
                }
            }
            else
            {
                animator.SetBool("IsFollow", true);
            }
        }
    }
Beispiel #2
0
 override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (animator.GetComponent <LivingCreature>().isAlive == true)
     {
         _agent.SetDestination(_target.position);
         if (meleeRange >= TransformExtension.DistanceBetween(animator.transform.position, _target.transform.position))
         {
             animator.SetBool(_combat, true);
         }
     }
 }
Beispiel #3
0
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (animator.GetComponent <LivingCreature>().isAlive)
        {
            if (_meleeRange >= TransformExtension.DistanceBetween(animator.transform.position, _target.transform.position))
            {
                RotateTowards(animator);
                if (_canAttack == true)
                {
                    while (_lastAttack == _randomAttack)
                    {
                        _randomAttack = UnityEngine.Random.Range(1, 4);
                        Debug.Log(_randomAttack);
                    }
                    _lastAttack = _randomAttack;
                    _canAttack  = false;
                    if (_randomAttack == 1)
                    {
                        animator.SetTrigger("SwingAttack");
                    }
                    if (_randomAttack == 2)
                    {
                        animator.SetTrigger("Punch1");
                    }
                    if (_randomAttack == 3)
                    {
                        animator.SetTrigger("Punch2");
                    }
                }

                if (animator.GetCurrentAnimatorStateInfo(0).IsName("OgreHorizontal") || animator.GetCurrentAnimatorStateInfo(0).IsName("OgrePunch") || animator.GetCurrentAnimatorStateInfo(0).IsName("OgreSwipe")) // check if "attack" is playing...
                {
                }
                else
                {
                    _canAttack = true;
                }
            }
            else
            {
                animator.SetBool("IsCombat", false);
                if (animator.GetComponent <OgreHealth>().phase == OgreHealth.HPState.Full)
                {
                    animator.SetBool("IsRun", false);
                    animator.SetBool("IsFollow", true);
                }
                else
                {
                    animator.SetBool("IsFollow", false);
                    animator.SetBool("IsRun", true);
                }
            }
        }
    }