public void Play() { OnEnemyKilled = null; // RESET delegate when press play / also back to menu and play Time.timeScale = 1f; // Make sure it doesn't stop deathUI.SetActive(true); }
public void Death() { Cursor.visible = true; // enable mouse cursor crosshair.SetActive(false); // crosshair off gameUI.SetActive(false); // set Death UI On deathUI.SetActive(true); // disable other UI (remember to enable it later) finalScore.text = "Score: " + barUI.playerScore; if (barUI.playerScore > PlayerPrefs.GetInt("HighScore", 0)) { PlayerPrefs.SetInt("HighScore", barUI.playerScore); highScore.text = "CONGRATULATIONS, NEW RECORD"; } else { highScore.text = "HighScore: " + PlayerPrefs.GetInt("HighScore", 0).ToString(); } //THE IMPORTANT OF ALL, This thing took my stress to a whole new level //NEED TO SET IT TO NULL // 1. Since this is from Gamemanager delegate, it will not destroy, so it still get subscribed from a function // that is already destroyed once we change / reset scene. // 2. Once we reset, we get subscribe AGAIN, they will check the first one which is empty // since the first subscriber has been destroyed // Set it to null, that way it will get subscribe again from the script (ComboKill & BarUI) Start() OnEnemyKilled = null; }
public void ResetSubscribe() { OnTowerPulling = null; OnTowerChecking = null; OnCoinsCollided = null; OnWallsCollided = null; }
public void Retry() { OnEnemyKilled = null; // RESET delegate when press retry Time.timeScale = 1f; // Make sure it doesn't stop SceneManager.LoadScene(SceneManager.GetActiveScene().name); }