Example #1
0
 private static void SaveHighScores(HighScoreData data)
 {
     FileStream stream = File.Open(HIGH_SCORES_FILENAME, FileMode.OpenOrCreate);
     try
     {
         var serializer = new XmlSerializer(typeof (HighScoreData));
         serializer.Serialize(stream, data);
     }
     finally
     {
         stream.Close();
     }
 }
Example #2
0
 public void Initialize()
 {
     if (!File.Exists(HIGH_SCORES_FILENAME))
     {
         var data = new HighScoreData {Score = 50};
         SaveHighScores(data);
     }
     else
     {
         HighScoreData data = LoadHighScores();
         Score = data.Score;
     }
 }