Beispiel #1
0
    public void SubmitPoints(int pieces)
    {
        CurrentScore += _pointsPerPiece * pieces;
        OnScoreChange?.Invoke(CurrentScore);

        if (CurrentScore > HighScore)
        {
            isNewHigh        = true;
            _highScore.Value = CurrentScore;
            OnHighScoreChange?.Invoke(CurrentScore);
        }
    }
    private void SetScore(int score)
    {
        _score = score;
        OnScoreChange?.Invoke(score);

        // TODO: Move this to when the player completes a level, or a game over is reached
        // TODO: High Score only should change when the player is done playing
        // TODO: (and then set it in Player Prefs)
        if (_score > _highScore)
        {
            _highScore = _score;
            SaveHighScore();
            OnHighScoreChange?.Invoke(_highScore);
        }
    }
 private void SaveHighScore()
 {
     PlayerPrefs.SetInt(PrefHighScoreKey, _highScore);
     OnHighScoreChange?.Invoke(_highScore);
 }
Beispiel #4
0
 private void Start()
 {
     OnScoreChange?.Invoke(CurrentScore);
     OnHighScoreChange?.Invoke(HighScore);
 }