Esempio n. 1
0
        public void AddNewHighscore(HighscoreModel highscore)
        {
            highscores.Add(highscore);

            var temp = highscores.OrderByDescending(a => a.PlayedDifficulty).ThenBy(n => n.TryCount);

            highscores = new ObservableCollection <HighscoreModel>(temp);

            SaveToFile(highscore);
        }
Esempio n. 2
0
        public static void SaveToFile(HighscoreModel highscore)
        {
            FileStream fs = new FileStream("highscores.txt",
                                           FileMode.Append, FileAccess.Write);

            try
            {
                StreamWriter sw = new StreamWriter(fs);
                sw.WriteLine(highscore.PlayedDifficulty + " " + highscore.TryCount);

                sw.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }