Esempio n. 1
0
 /// <summary>
 /// Saves the current game.
 /// </summary>
 public static void SaveCurrentGame()
 {
     if (CurrentGameUID != string.Empty)
     {
         GameSaveInfo gameSaveInfo = GetGameSaveInfoFromCurrent();
         SaveGameInfo(CurrentGameUID, gameSaveInfo);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Saves a given save game info with the given save UID.
        /// </summary>
        /// <param name="saveUID">The save UID to save the save as.</param>
        /// <param name="gameSaveInfo">The game save info.</param>
        public static void SaveGameInfo(string saveUID, GameSaveInfo gameSaveInfo)
        {
            ;
            Directory.CreateDirectory(SaveFolderPath);
            BinaryFormatter binFormatter = new BinaryFormatter();

            using (FileStream saveFs = new FileStream(SaveFolderPath + "/" + saveUID + ".sda", FileMode.Create))
            {
                binFormatter.Serialize(saveFs, gameSaveInfo);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Loads a saved game info with the given saveUID.
        /// </summary>
        /// <param name="saveUID">The save UID to load the save of.</param>
        /// <returns>The game save.</returns>
        public static GameSaveInfo LoadGameInfo(string saveUID)
        {
            string savePath = SaveFolderPath + "/" + saveUID + ".sda";

            if (!File.Exists(savePath))
            {
                Debug.LogError("Error while loading '" + savePath + "': File does not exist.");
                return(null);
            }
            BinaryFormatter binFormatter = new BinaryFormatter();
            GameSaveInfo    gameSaveInfo = null;

            using (FileStream loadFs = new FileStream(savePath, FileMode.Open))
            {
                gameSaveInfo = binFormatter.Deserialize(loadFs) as GameSaveInfo;
            }
            return(gameSaveInfo);
        }