public void DisplayCurrentHearts() { foreach (GameObject i in heartContainers) { i.SetActive(false); } //first delete all arts, for (int i = 0; i < gameSession.GetCurrentLives(); i++) { heartContainers[i].SetActive(true); } // then display the correct number of hearts }
void Start() { CameraBounderies(); BowMovement = GetComponent <Animator>(); //to control the bow animation Spawner = FindObjectOfType <PH_EnemySpawner>(); //find all those elements in the scene PauseController = FindObjectOfType <PH_Pause>(); gameSession = FindObjectOfType <PH_GameSession>(); sceneLoader = FindObjectOfType <PH_SceneLoader>(); float healthBonus = ((gameSession.GetMaxLives() - gameSession.GetCurrentLives()) * 1f / gameSession.GetMaxLives()) / 2; health = startingHealth *= (1 + healthBonus);//calculate bonus health, +10% for each lost heart }
void Die() { Spawner.SetWaveLooping(false); // stop spawing enemies while player is dead Destroy(gameObject); //remove player BowBreak(); //player death animation gameSession.LoseALife(); //process for losing a life if (gameSession.GetCurrentLives() >= 1) { sceneLoader.ShowRetryScreen(); } //if some lives left, try again option, else, go to game over scene else { sceneLoader.LoadGameOverScene(); } }