/// <summary> /// If the player is not alive, respawns them, or ends the game. /// </summary> void FixedUpdate() { if (!Manager.Instance.playerIsAlive) { if (Manager.Instance.playerLives >= 1 && playerSpawnBox.spawnAreaClear) { playerLivesText.text = "Lives : " + Manager.Instance.playerLives; // update playerLivesUI Instantiate(playerPrefab, new Vector3(0.0F, 0.0F, 0.0F), Quaternion.identity); // spawn a player Manager.Instance.playerIsAlive = true; // set the playerIsAlive boolean to true Manager.Instance.ResetPlayerReference(); // have the manager update its reference to the player transform to the new player object } else if (Manager.Instance.playerLives <= 0 && SceneManager.GetActiveScene().buildIndex == 1) { playerLivesText.text = "Lives : " + Manager.Instance.playerLives; // update the playerLivesUI if (!gameOverCalled) { gameOverCalled = true; // set game over called to true (otherwise it will call game over every update) DungeonMaster dm = GetComponent <DungeonMaster>(); // turn off all the coroutines dm.StopAllCoroutines(); StartCoroutine(LoadGameOver()); // load game over } } } // put this in here for during demos // if anything in the game goes wrong, you can just press escape to get back to the main menu if (escape.triggered) { gameOverCalled = true; DungeonMaster dm = GetComponent <DungeonMaster>(); dm.StopAllCoroutines(); SceneManager.LoadScene(0); } }