コード例 #1
0
ファイル: GameManager.cs プロジェクト: Zenith26/CodeSamples
    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);
    }
コード例 #2
0
ファイル: GameManager.cs プロジェクト: Zenith26/CodeSamples
    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;
    }
コード例 #3
0
ファイル: GameManager.cs プロジェクト: Zenith26/CodeSamples
 public void ResetSubscribe()
 {
     OnTowerPulling  = null;
     OnTowerChecking = null;
     OnCoinsCollided = null;
     OnWallsCollided = null;
 }
コード例 #4
0
ファイル: GameManager.cs プロジェクト: Zenith26/CodeSamples
 public void Retry()
 {
     OnEnemyKilled  = null; // RESET delegate when press retry
     Time.timeScale = 1f;   // Make sure it doesn't stop
     SceneManager.LoadScene(SceneManager.GetActiveScene().name);
 }