Exemple #1
0
    public IEnumerator CastSpellAnimation()
    {
        if (!ai.attacking)
        {
            ai.anim.speed  = ai.startAnimSpeed;
            ai.attacking   = true;
            ai.rb.velocity = Vector2.zero;     //Stop moving to make the animation look better
            ai.anim.SetBool("Moving", false);
            ai.anim.SetBool("Attacking", true);
            while (!ai.anim.GetCurrentAnimatorStateInfo(0).IsTag("Attack")) //wait for first frame of attack anim before starting
            {
                yield return(null);
            }
            yield return(new WaitForSeconds(ai.anim.GetCurrentAnimatorStateInfo(0).length)); //wait while current anim is still playing

            {
                yield return(null);
            }

            ai.anim.SetBool("Attacking", false);
            yield return(new WaitForSeconds(0.5f));//to give space between attacks

            ai.attacking = false;
        }
        if (ai.currentState != EnemyState.dead)
        {
            if (ai.range.playerInRange == true)
            {
                ai.TooClose();
                if (!ai.tooClose)
                {
                    ai.currentState = EnemyState.attack;
                }
                else
                {
                    StartShockwave();

                    yield break;
                }
            }
            else
            {
                ai.currentState = EnemyState.idle;
            }
        }
        yield return(null);
    }
Exemple #2
0
 public void Attack()
 {
     if (ai.range.playerInRange == true)
     {
         ai.fleeWhenTooClose = false;
         StartCoroutine("Stab");
     }
     else
     {
         ai.TooClose();
         if (!ai.tooClose)
         {
             if (!throwing)
             {
                 StartCoroutine("Throw");
             }
         }
         else
         {
             ai.fleeWhenTooClose = true;
             ai.currentState     = EnemyState.flee;
         }
     }
 }