public void AddEntry(ScoreboardEntryData scoreboardEntryData) { ScoreboardSaveData savedScores = GetSavedScores(); bool scoreAdded = false; 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); }
public void Initalise(ScoreboardEntryData scoreboardEntryData) { entryNameText.text = scoreboardEntryData.entryName; entryScoreText.text = scoreboardEntryData.entryScore.ToString(); }