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 SetLifeSpawn(float location) { GameObject lifeManager = GameObject.Find("LifeManager"); KeepLives script = lifeManager.GetComponent <KeepLives> (); script.LifeSpawnLocation = location; }
void ResetLives() { // Reset The lives GameObject lifeManager = GameObject.Find("LifeManager"); KeepLives lifeScript = lifeManager.GetComponent <KeepLives>(); lifeScript.ResetLives(); }
void Update() { // if val is enough then add a life if (AddVal >= increaseLifeValue) { AddVal = AddVal - increaseLifeValue; KeepLives lifeScript = lifeManager.GetComponent <KeepLives>(); lifeScript.AddLife(); } }