Exemplo n.º 1
0
        private void RecordHighscore()
        {
            if (YourName.Text != String.Empty)
            {
                List <BestScore> highscores = Load.LoadHighScores();

                BestScore newScore = new BestScore();
                newScore.score           = gameScore;
                newScore.name            = YourName.Text;
                newScore.replay_filename = "replays/" + newScore.name + "-" + newScore.score + ".xml";
                newScore.map             = chooseMap.currentMap;
                GameManager.gi.SaveReplay(newScore.replay_filename);
                highscores.Add(newScore);
                highscores.Sort((b1, b2) => BestScore.Compare(b1, b2));

                while (highscores.Count > SizeHighscores)
                {
                    try { File.Delete(highscores.Last().replay_filename); } catch { }
                    highscores.Remove(highscores.Last());
                }

                Serializer <List <BestScore> > .Save(Load.PathHighScores, highscores);

                BackInitialMenu();
            }
        }
Exemplo n.º 2
0
 public static int Compare(BestScore b1, BestScore b2)
 {
     if (b1.score <= b2.score)
     {
         return(1);
     }
     else
     {
         return(-1);
     }
 }