C# Class SunsetHigh.SaveManager

Static class for managing save states. Saves games by serializing SaveGameData as XML and then encrypting it. The encryption prevents players from easily accessing and "hacking" the XML files.
Mostrar archivo Open project: ErraticUnicorn/MOSH

Public Methods

Method Description
generateNewFileName ( ) : string
getSaveData ( string fileName, bool encrypt = true ) : SaveGameData

Loads a game with a given file name in the "SaveData" folder. By default the method will attempt to decrypt the file.

loadAllGames ( bool encrypt = true ) : List

Loads all save files in the "SaveData" folder. Can be used for previewing save files in the title screen

loadGame ( string fileName, bool encrypt = true ) : void
packData ( ) : SaveGameData
saveGame ( string fileName, SaveGameData saveGame, bool encrypt = true ) : bool

Saves a game to an external file in the "SaveData" folder. By default the save file is encrypted.

saveGame ( string fileName, bool encrypt = true ) : void
unpackData ( SaveGameData data ) : void
unpackDefaultData ( ) : void

Private Methods

Method Description
decryptFile ( string fileNameIn, bool debug = false ) : Stream
encryptFile ( Stream streamIn, string fileNameOut ) : bool

Method Details

generateNewFileName() public static method

public static generateNewFileName ( ) : string
return string

getSaveData() public static method

Loads a game with a given file name in the "SaveData" folder. By default the method will attempt to decrypt the file.
public static getSaveData ( string fileName, bool encrypt = true ) : SaveGameData
fileName string Name of the file to load
encrypt bool Optional, specifies whether to decrypt the file
return SaveGameData

loadAllGames() public static method

Loads all save files in the "SaveData" folder. Can be used for previewing save files in the title screen
public static loadAllGames ( bool encrypt = true ) : List
encrypt bool
return List

loadGame() public static method

public static loadGame ( string fileName, bool encrypt = true ) : void
fileName string
encrypt bool
return void

packData() public static method

public static packData ( ) : SaveGameData
return SaveGameData

saveGame() public static method

Saves a game to an external file in the "SaveData" folder. By default the save file is encrypted.
public static saveGame ( string fileName, SaveGameData saveGame, bool encrypt = true ) : bool
fileName string Name to give saved data file
saveGame SaveGameData Data to be saved
encrypt bool Optional, specifies whether output file should be encrypted (True by default)
return bool

saveGame() public static method

public static saveGame ( string fileName, bool encrypt = true ) : void
fileName string
encrypt bool
return void

unpackData() public static method

public static unpackData ( SaveGameData data ) : void
data SaveGameData
return void

unpackDefaultData() public static method

public static unpackDefaultData ( ) : void
return void