Exemplo n.º 1
0
    // Update is called once per frame
    public IEnumerator Resurrect()
    {
        Debug.Log("resurrect");
        if (ai.currentState == EnemyState.dead && !resurrecting && !finalDeath)
        {
            resurrecting = true;
            //health
            var halfHealth = eh.startingHealth / 2;
            eh.EnemyHeal(halfHealth);
            eh.circleCollider.isTrigger = false;
            eh.isDead = false;
            //play animation
            ai.currentState          = EnemyState.special;
            ai.anim.speed            = ai.startAnimSpeed;
            circleCollider.isTrigger = false;
            ai.anim.SetBool("Moving", false);
            ai.anim.SetTrigger("Resurrect");
            while (!ai.anim.GetCurrentAnimatorStateInfo(0).IsTag("Resurrect")) //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);
            }
            resurrecting    = false;
            ai.currentState = EnemyState.idle;
            yield return(null);
        }
    }