Exemple #1
0
    void Take_Life()
    {
        //find player and lives script
        GameObject lifeManager = GameObject.Find("LifeManager");
        KeepLives  lifeScript  = lifeManager.GetComponent <KeepLives>();

        //if lives left then remove a life
        if (lifeScript.LifeVal != 0)
        {
            lifeScript.RemoveLife();
            // then respawn
            GameObject player      = GameObject.Find("Player");
            SpawnShip  spawnScript = player.GetComponent <SpawnShip> ();
            // reset to not first spawn
            spawnScript.firstSpawn = false;
            spawnScript.Spawn();
        }
        //if no more lives then enable the restart canvas
        else if (lifeScript.LifeVal == 0)
        {
            Enable_Canvas();
            // reset the wave count and disable the script
            GameObject waveManager = GameObject.Find("WaveManager");
            KeepWave   script      = waveManager.GetComponent <KeepWave>();
            script.ResetWave();
            script.enabled = false;
            // remove boss bar if exists
            GameObject boss = GameObject.FindWithTag("Boss");
            if (boss != null)
            {
                BossCollide bossScript = boss.GetComponent <BossCollide>();
                bossScript.ToggleHealthBar();
            }
        }
    }
Exemple #2
0
    void ResetBoss()
    {
        GameObject boss = GameObject.FindWithTag("Boss");

        if (boss != null)
        {
            // reset boss health
            BossHealth healthScript = boss.GetComponent <BossHealth>();
            healthScript.currentHealth = healthScript.maxHealth;
            healthScript.HandleHealth();
            BossCollide script = boss.GetComponent <BossCollide>();
            script.RemoveBoss();
            script.SwitchStatus();
        }
    }