Ejemplo n.º 1
0
        /// <summary>
        /// Loads up single game specific data.
        /// </summary>
        /// <param name="metadata">Metadata that is associated with the game data.</param>
        /// <param name="callback">Callback which is called when the loading is done.</param>
        public static void LoadSavedGame(SavedGameMetadata metadata, Action <SavedGame> callback)
        {
            if (callback == null)
            {
                throw new ArgumentNullException("callback", "Callback can't be null.");
            }

            if (metadata == null)
            {
                throw new ArgumentNullException("metadata", "Metadata can't be null.");
            }

            var gameDataPath = SavedGameRootPath + metadata.savedGameFileName + savedGameFileSuffix;

            if (Async)
            {
                ReadFileAsync <object>(gameDataPath, (object gameSpecificData) =>
                {
                    var savedGame = new SavedGame(metadata, gameSpecificData);
                    callback(savedGame);
                });
            }
            else
            {
                var gameSpecificData = ReadAndDeserialize <object>(gameDataPath);
                callback(new SavedGame(metadata, gameSpecificData));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Deletes a single saved game permanently.
        /// </summary>
        /// <param name="metadata">Metadata that is associated with the game data.</param>
        /// <param name="callback">Callback which is called when the deleting is done.</param>
        public static void DeleteSave(SavedGameMetadata metadata, Action callback)
        {
            var paths = new string[] {
                SavedGameRootPath + metadata.savedGameFileName + savedGameFileSuffix,
                SavedGameRootPath + metadata.savedGameFileName + metadataFileSuffix
            };

            if (Async)
            {
                DeleteFilesAsync(paths, callback);
            }
            else
            {
                DeleteFiles(paths);

                if (callback != null)
                {
                    callback();
                }
            }
        }
Ejemplo n.º 3
0
 public SavedGame(SavedGameMetadata metadata, object gameSpecificData)
 {
     this.metadata         = metadata;
     this.gameSpecificData = gameSpecificData;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Saves the game on persistent storage.
 /// </summary>
 /// <param name="metadata">Metadata for the saved game.</param>
 /// <param name="gameData">Game specific data that is to be saved.</param>
 /// <param name="callback">Callback which is called when the saving has finished.</param>
 public static void SaveGame(SavedGameMetadata metadata, object gameData, Action callback)
 {
     SaveGame(new SavedGame(metadata, gameData), callback);
 }