Ejemplo n.º 1
0
 public static void LoadGame()
 {
     if (File.Exists(Application.persistentDataPath
                     + "/MySaveData.dat"))
     {
         BinaryFormatter bf   = new BinaryFormatter();
         FileStream      file =
             File.Open(Application.persistentDataPath
                       + "/MySaveData.dat", FileMode.Open);
         EndingData data = (EndingData)bf.Deserialize(file);
         file.Close();
         endingsToSave      = data.endingSeen;
         endingTitlesToSave = data.endingTitles;
         lastSeenEnding     = data.lastSeen;
         Debug.Log("Game data loaded!");
     }
     else
     {
         //endingsToSave = Enumerable.Repeat(false, 21).ToArray();
         //Debug.LogError("no data to load!");
         endingsToSave      = Enumerable.Repeat(false, 24).ToArray();
         endingTitlesToSave = Enumerable.Repeat("?", 24).ToArray();
         lastSeenEnding     = 0;
     }
 }
Ejemplo n.º 2
0
        public static void SaveGame()
        {
            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Create(Application.persistentDataPath
                                               + "/MySaveData.dat");
            EndingData data = new EndingData();

            data.endingSeen   = endingsToSave;
            data.endingTitles = endingTitlesToSave;
            data.lastSeen     = lastSeenEnding;

            bf.Serialize(file, data);
            file.Close();
            Debug.Log("Game data saved!");
        }