Beispiel #1
0
 /// <summary>
 /// Ładuje dane najlepszych wyników z pliku
 /// </summary>
 /// <returns>Obiekt reprezentujący najlepsze wyniki</returns>
 public static HighScoresData LoadHighScores()
 {
     try
     {
         return HighScoresData.Deserialize(GetHighScoresFilePath());
     }
     catch (FileNotFoundException exception)
     {
         var emptyHighScores = new HighScoresData();
         emptyHighScores.Serialize(GetHighScoresFilePath());
         return emptyHighScores;
     }
 }
Beispiel #2
0
        /// <summary>
        /// Tworzy wymagane foldery i pliki
        /// </summary>
        private void CreateGameFilesAndDirectories()
        {
            var directories = new List<string>()
            {
                Path.Combine(AppDomain.CurrentDomain.BaseDirectory,ConfigurationManager.AppSettings["LevelsPath"]),
                Path.Combine(AppDomain.CurrentDomain.BaseDirectory,ConfigurationManager.AppSettings["UsersPath"])
            };

            foreach (var directory in directories)
            {
                if (!Directory.Exists(directory))
                {
                    Directory.CreateDirectory(directory);
                }
            }

            var highScoresFile = HighScoresManager.GetHighScoresFilePath();
            if (!File.Exists(highScoresFile))
            {
                var highScores = new HighScoresData();
                highScores.Serialize(highScoresFile);
            }
        }