public void AddEntry(HighScoresEntryData highScoresEntryData) //Adds new entry to list { HighScoresSaveData savedScores = GetSavedScores(); bool scoreAdded = false; { for (int i = 0; i < savedScores.highscores.Count; i++) { if (highScoresEntryData.entryScore > savedScores.highscores[i].entryScore) { savedScores.highscores.Insert(i, highScoresEntryData); scoreAdded = true; break; } } if (!scoreAdded && savedScores.highscores.Count < maxHighScoresEntries) { savedScores.highscores.Add(highScoresEntryData); } if (savedScores.highscores.Count > maxHighScoresEntries) { savedScores.highscores.RemoveRange(maxHighScoresEntries, savedScores.highscores.Count - maxHighScoresEntries); } UpdateUI(savedScores); SaveScores(savedScores); } }
public void Initialise(HighScoresEntryData highScoresEntryData) { entryNameText.text = highScoresEntryData.entryName; entryScoreText.text = highScoresEntryData.entryScore.ToString(); }