Example #1
0
    void dropHealth()
    {
        lives--;

        if (lives <= 0)
        {
            if (gameObject.name == "Leader(Clone)")
            {
                MovementComands.isLeaderDead = true;
            }
            if (gameObject.tag != "Missle" && gameObject.tag != "EnemyMissle" && gameObject.tag != "Player")
            {
                FindObjectOfType <AudioManager>().Play("ExplosionSound");
                FindObjectOfType <Explosion>().Explode(transform.position, gameObject.name);
            }
            switch (gameObject.tag)
            {
            case "Enemy":
                if (transform.name.Contains("Boss"))
                {
                    SpawnScript.KillBoss(SpawnScript.stage);
                }
                Destroy(gameObject);
                killed++;
                break;

            case "Player":
                if (lives + Upgrades.getLifesBonus() <= 0)
                {
                    ShowDeathScreen.isDead = true;
                    FindObjectOfType <ShowDeathScreen>().EndGame();
                    Debug.Log("Killed");
                    FindObjectOfType <AudioManager>().Play("ExplosionSound");
                    FindObjectOfType <Explosion>().Explode(transform.position, "Player");
                    Destroy(gameObject);
                }
                break;

            case "Missle":
                if (lives + Upgrades.getProjectileLifeBonus() <= 0)
                {
                    Destroy(gameObject);
                }
                break;

            default:
                Destroy(gameObject);
                break;
            }
        }
    }