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(); } } }
void SpawnShip() { // spawn ship GameObject player = GameObject.Find("Player"); SpawnShip spawnScript = player.GetComponent <SpawnShip>(); spawnScript.firstSpawn = true; spawnScript.Spawn(); }