public void AddHighScore(string name, int score, float time) { HighScoreRowData row = new HighScoreRowData(name, score, time); rows.Add(row); if (rows.Count > numberHighScores) { rows.Remove(rows.Max); } }
public bool isHighScore(int score, float time) { if (rows.Count < numberHighScores) { return(true); } //When considering a new high score we do not take into account the name of the player HighScoreRowData row = new HighScoreRowData("ZZZZZ", score, time); // Since the list is sorted in ascending order, // but we want the highest score first, then // the last row is the Max value from the set HighScoreRowData lastRow = rows.Max; if (new HighScoreComparator().Compare(row, lastRow) < 0) { return(true); } return(false); }
public void SaveHighScores() { HighScoreRowData[] arr = new HighScoreRowData[rows.Count]; rows.CopyTo(arr); SaveSystem.SaveHighScores(arr); }