void DecreaseHealth(int i)
 {
     health -= i;
     if (health <= 0)
     {
         swordUI.ReplenishHealth(5);
         InvokeDeath();
     }
 }
Exemple #2
0
    IEnumerator TriggerDeath()
    {
        swordUI.ReplenishHealth(5);
        if (explosion != null)
        {
            Instantiate(explosion, transform.position, Quaternion.identity);
        }
        if (aiStates.enemyAudio.isPlaying)
        {
            aiStates.enemyAudio.Stop();
        }
        aiStates.PlaySound(aiStates.enemyAudio, aiStates.dieSound);
        if (autoRespawn)
        {
            gm.StartRespawnTimer(this.gameObject);
        }
        if (isBossEnemy)
        {
            Destroy(this.gameObject);
        }

        yield return(null);
    }