Пример #1
0
        public void AddEntry(ScoreboardEntryData scoreboardEntryData)
        {
            ScoreboardSaveData savedScores = GetSavedScores();

            bool scoreAdded = false;


            //Vergleich der Highscores und ersetzen, falls der highscore höher ist als der alte.
            for (int i = 0; i < savedScores.highscores.Count; i++)
            {
                if (scoreboardEntryData.entryScore > savedScores.highscores[i].entryScore)
                {
                    savedScores.highscores.Insert(i, scoreboardEntryData);
                    scoreAdded = true;
                    break;
                }
            }

            if (!scoreAdded && savedScores.highscores.Count < maxScoreboardEntries)
            {
                savedScores.highscores.Add(scoreboardEntryData);
            }

            if (savedScores.highscores.Count > maxScoreboardEntries)
            {
                savedScores.highscores.RemoveRange(maxScoreboardEntries, savedScores.highscores.Count - maxScoreboardEntries);
            }


            UpdateUI(savedScores);
            SaveScores(savedScores);
        }
Пример #2
0
 public void Initialise(ScoreboardEntryData scoreboardEntryData)
 {
     entryNameText.text  = scoreboardEntryData.entryName;
     entryScoreText.text = scoreboardEntryData.entryScore.ToString();
 }