Пример #1
0
    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);
        }
    }
Пример #2
0
    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);
    }
Пример #3
0
 public void SaveHighScores()
 {
     HighScoreRowData[] arr = new HighScoreRowData[rows.Count];
     rows.CopyTo(arr);
     SaveSystem.SaveHighScores(arr);
 }