Пример #1
0
        public void SaveGlobalStats()
        {
            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Create(Application.persistentDataPath
                                               + pathToSaveFileAllStats);
            PlayerStatistics stats = new PlayerStatistics();

            stats.CurrentLevel = currentLevel;
            stats.OpenedLevels = openedLevel;
            bf.Serialize(file, stats);
            file.Close();
        }
Пример #2
0
 public void LoadGlobalStats()
 {
     if (File.Exists(Application.persistentDataPath
                     + pathToSaveFileAllStats))
     {
         BinaryFormatter bf   = new BinaryFormatter();
         FileStream      file =
             File.Open(Application.persistentDataPath
                       + pathToSaveFileAllStats, FileMode.Open);
         PlayerStatistics stats = (PlayerStatistics)bf.Deserialize(file);
         file.Close();
         currentLevel = stats.CurrentLevel;
         openedLevel  = stats.OpenedLevels;
     }
 }