コード例 #1
0
ファイル: ScoreManager.cs プロジェクト: lucasncs/match-3
    public void SubmitPoints(int pieces)
    {
        CurrentScore += _pointsPerPiece * pieces;
        OnScoreChange?.Invoke(CurrentScore);

        if (CurrentScore > HighScore)
        {
            isNewHigh        = true;
            _highScore.Value = CurrentScore;
            OnHighScoreChange?.Invoke(CurrentScore);
        }
    }
コード例 #2
0
    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);
        }
    }
コード例 #3
0
 private void SaveHighScore()
 {
     PlayerPrefs.SetInt(PrefHighScoreKey, _highScore);
     OnHighScoreChange?.Invoke(_highScore);
 }
コード例 #4
0
ファイル: ScoreManager.cs プロジェクト: lucasncs/match-3
 private void Start()
 {
     OnScoreChange?.Invoke(CurrentScore);
     OnHighScoreChange?.Invoke(HighScore);
 }