Beispiel #1
0
        public void SaveLocalStats(Vector3 position)
        {
            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Create(Application.persistentDataPath
                                               + pathToSaveFileAllStats);
            PlayerStateOnLevel stats = new PlayerStateOnLevel();

            stats.CountOfSheepEaten = CountOfSheepEaten;
            stats.IsLife            = IsLife;
            stats.LastPosition      = position;

            bf.Serialize(file, stats);
            file.Close();
        }
Beispiel #2
0
 public Vector3 LoadLocalStats()
 {
     if (File.Exists(Application.persistentDataPath
                     + pathToSaveFileAllStats))
     {
         BinaryFormatter bf   = new BinaryFormatter();
         FileStream      file =
             File.Open(Application.persistentDataPath
                       + pathToSaveFileAllStats, FileMode.Open);
         PlayerStateOnLevel stats = (PlayerStateOnLevel)bf.Deserialize(file);
         file.Close();
         CountOfSheepEaten = stats.CountOfSheepEaten;
         IsLife            = stats.IsLife;
         return(stats.LastPosition);
     }
     return(Vector3.zero);
 }