void LoadHighscoreTable(int id)
        {
            var score = PlayerPrefs.GetInt(GetScoreKey(id));
            var combo = PlayerPrefs.GetInt(GetComboKey(id));

            _highscores.AddHighscore(HighscoreData.Create(score, combo));
        }
Exemple #2
0
 private void CreateDefaultHighscoreTables()
 {
     for (int i = 0; i < maxHighscoreTables; i++)
     {
         highscoreDatas.Add(HighscoreData.Create());
     }
 }
        // Add new score to Highscores class.
        // then going to save the scores to player prefs
        public bool AddHighscore(HighscoreData newScore)
        {
            if (_highscores.AddHighscore(newScore))
            {
                SaveHighscoresToPlayerPrefs();
                return(true);
            }

            return(false);
        }
Exemple #4
0
        public int CompareTo(object obj)
        {
            if (obj == null)
            {
                return(1);
            }

            HighscoreData other = obj as HighscoreData;

            if (other != null)
            {
                return(-this.score.CompareTo(other.score));
            }
            else
            {
                throw new ArgumentException("Object is not a Highscore Data");
            }
        }
Exemple #5
0
        public bool AddHighscore(HighscoreData newScore)
        {
            // never add a score already be added
            if (highscoreDatas.Contains(newScore))
            {
                return(false);
            }

            // add the new score first
            highscoreDatas.Add(newScore);

            // Sort it by Highscores(its decendant)
            highscoreDatas.Sort();

            // Remove smallest Highscore from the Highscores
            highscoreDatas.RemoveAt(highscoreDatas.Count - 1);

            return(highscoreDatas.Contains(newScore));
        }