Adventure Creator  1.56g
An adventure game toolkit for Unity, by Chris Burton, ICEBOX Studios 2013-2017
AC.SaveSystem Class Reference
Inheritance diagram for AC.SaveSystem:

Public Member Functions

void OnStart ()
 
void SetGameplayReturnTime (float _gameplayInvokeTime)
 Sets the delay after loading a saved game before gameplay is resumed. This is useful in games with custom systems, e.g. weapons, where we want to prevent firing being possible immediately after loading. More...
 
void GatherSaveFiles ()
 
string GetDefaultSaveLabel (int saveID)
 Returns the default label of a save file. More...
 
void GatherImportFiles (string projectName, string saveFilename, int boolID)
 Searches the filesystem for all available import files, and stores them in foundImportFiles. More...
 
void SetSelectiveLoadOptions (SelectiveLoad selectiveLoad)
 Sets the local instance of SelectiveLoad, which determines which save data is restored the next time (and only the next time) LoadGame is called. More...
 
void ClearAllData ()
 
void ImportSaveGame (int saveID)
 Imports a save file from another Adventure Creator game, once found to exist. More...
 
void LoadSaveGame (int saveID)
 Loads a save game, once found to exist. More...
 
bool SaveNewSaveGame (bool overwriteLabel=true, string newLabel="")
 Create a new save game file. More...
 
bool SaveSaveGame (int saveID, bool overwriteLabel=true, string newLabel="")
 Saves the game, once found to exist. More...
 
void SaveCurrentPlayerData ()
 
string GetSlotLabel (int elementSlot, int saveID, bool useSaveID, SaveFile[] saveFiles)
 Gets the label of a save file. More...
 
Texture2D GetScreenshot (int elementSlot, int saveID, bool useSaveID, SaveFile[] saveFiles)
 Gets the screenshot of a save file. More...
 
bool DoesPlayerDataExist (int ID, bool doSceneCheck=false)
 Checks if PlayerData for a given Player has been generated. More...
 
int GetPlayerScene (int ID)
 Gets the current scene number that a Player is in. More...
 
string GetPlayerSceneName (int ID)
 Gets the current scene nsmr that a Player is in. More...
 
void AssignPlayerAnimData (Player player)
 Updates a Player object with its associated saved animation data, if it exists. More...
 
void AssignPlayerAllData (Player player)
 Updates a Player object with its associated saved data, if it exists. More...
 
int AssignPlayerData (int ID, bool doInventory)
 Unloads stored PlayerData back onto the Player object. More...
 
List< InvItemGetItemsFromPlayer (int _playerID)
 Returns a list of inventory items currently carried by a particular Player. More...
 
void AssignItemsToPlayer (List< InvItem > invItems, int _playerID)
 Re-assigns the inventory items currently carried by a particular Player. More...
 
void RenameSave (string newLabel, int saveIndex)
 Renames the label of a save game file. More...
 
void DeleteProfile (int profileIndex=-2, bool includeActive=true)
 Deletes a player profile by referencing its entry in a MenuProfilesList element. More...
 
void DeleteProfileID (int profileID)
 Deletes a player profile ID. More...
 
void DeleteSave (int elementSlot, int saveID, bool useSaveID)
 Deletes a save game file. More...
 
int GetNumSaves (bool includeAutoSaves=true)
 Gets the number of save game files found. More...
 

Static Public Member Functions

static SaveMethod GetSaveMethod ()
 Gets the SaveMethod for the current platform. This is XML for iPhone, Windows Phone and Wii platforms, and Binary for all others More...
 
static bool DoesImportExist (int saveID)
 Checks if an import file with a particular ID number exists. More...
 
static bool DoesSaveExist (int elementSlot, int saveID, bool useSaveID)
 Checks if a save file with a particular ID number exists More...
 
static bool DoesSaveExist (int saveID)
 Checks if a save file with a particular ID number exists More...
 
static void LoadAutoSave ()
 
static bool ImportGame (int elementSlot, int saveID, bool useSaveID)
 Imports a save file from another Adventure Creator game. More...
 
static void ContinueGame ()
 
static bool LoadGame (int saveID)
 Loads a save game file. More...
 
static bool LoadGame (int elementSlot, int saveID, bool useSaveID)
 Loads a save game file. More...
 
static bool SaveNewGame (bool overwriteLabel=true, string newLabel="")
 Create a new save game file. More...
 
static bool SaveAutoSave ()
 Overwrites the AutoSave file. More...
 
static bool SaveGame (int saveID, bool overwriteLabel=true, string newLabel="")
 Saves the game. More...
 
static bool SaveGame (int elementSlot, int saveID, bool useSaveID, bool overwriteLabel=true, string newLabel="")
 Saves the game. More...
 
static int GetNumImportSlots ()
 Gets the number of found import files. More...
 
static int GetNumSlots ()
 Gets the number of found save files. More...
 
static string SetProjectName ()
 Generates a default name for the project, based on the project's folder name. More...
 
static string GetImportSlotLabel (int elementSlot, int saveID, bool useSaveID)
 Gets the label of an import file. More...
 
static string GetSaveSlotLabel (int elementSlot, int saveID, bool useSaveID)
 Gets the label of a save file. More...
 
static Texture2D GetImportSlotScreenshot (int elementSlot, int saveID, bool useSaveID)
 Gets the screenshot of an import file. More...
 
static Texture2D GetSaveSlotScreenshot (int elementSlot, int saveID, bool useSaveID)
 Gets the screenshot of a save file. More...
 
static void AssignVariables (string runtimeVariablesData, bool fromOptions=false)
 Unloads stored global variable data back into the RuntimeVariables script. More...
 
static string CreateVariablesData (List< GVar > vars, bool isOptionsData, VariableLocation location)
 Condenses the values of a List of variables into a single string. More...
 

Public Attributes

LoadingGame loadingGame
 
List< SaveFilefoundSaveFiles = new List<SaveFile>()
 
List< SaveFilefoundImportFiles = new List<SaveFile>()
 
const string pipe = "|"
 
const string colon = ":"
 

Detailed Description

Processes save game data to and from scene objects.

Member Function Documentation

void AC.SaveSystem.AssignItemsToPlayer ( List< InvItem invItems,
int  _playerID 
)

Re-assigns the inventory items currently carried by a particular Player.

Parameters
invItemsA List of InvItem instances representing the inventory items
_playerIDThe ID number of the Player to assign the inventory of
void AC.SaveSystem.AssignPlayerAllData ( Player  player)

Updates a Player object with its associated saved data, if it exists.

Parameters
playerThe Player to load animation data for
void AC.SaveSystem.AssignPlayerAnimData ( Player  player)

Updates a Player object with its associated saved animation data, if it exists.

Parameters
playerThe Player to load animation data for
int AC.SaveSystem.AssignPlayerData ( int  ID,
bool  doInventory 
)

Unloads stored PlayerData back onto the Player object.

Parameters
IDThe ID of the Player to affect
doInventoryIf True, updates the Player's inventory
Returns
The Player's new scene number
static void AC.SaveSystem.AssignVariables ( string  runtimeVariablesData,
bool  fromOptions = false 
)
static

Unloads stored global variable data back into the RuntimeVariables script.

Parameters
runtimeVariablesDataThe values of all global variables, combined into a stingle string
fromOptionsIf true, only global variables that are linked to OptionsData will be affected
void AC.SaveSystem.ClearAllData ( )

Clears all save data stored in the SaveData class.

static void AC.SaveSystem.ContinueGame ( )
static

Loads the last-recorded save game file.

static string AC.SaveSystem.CreateVariablesData ( List< GVar vars,
bool  isOptionsData,
VariableLocation  location 
)
static

Condenses the values of a List of variables into a single string.

Parameters
varsA List of variables (see GVar) to condense
isOptionsDataIf True, only global variables that are linked to OptionsData will be included
locationThe variables' location (Local, Variable)
Returns
The variable's values, condensed into a single string
void AC.SaveSystem.DeleteProfile ( int  profileIndex = -2,
bool  includeActive = true 
)

Deletes a player profile by referencing its entry in a MenuProfilesList element.

Parameters
profileIndexThe index in the MenuProfilesList element that represents the profile to delete. If it is set to its default, -2, the active profile will be deleted
includeActiveIf True, then the MenuProfilesList element that the profile was selected from also displays the active profile
void AC.SaveSystem.DeleteProfileID ( int  profileID)

Deletes a player profile ID.

Parameters
profileIDThe profile ID to delete
void AC.SaveSystem.DeleteSave ( int  elementSlot,
int  saveID,
bool  useSaveID 
)

Deletes a save game file.

Parameters
elementSlotThe slot index of the MenuProfilesList element that was clicked on
saveIDThe save ID to import
useSaveIDIf True, the saveID overrides the elementSlot to determine which file to import
static bool AC.SaveSystem.DoesImportExist ( int  saveID)
static

Checks if an import file with a particular ID number exists.

Parameters
saveIDThe import ID to check for
Returns
True if an import file with a matching ID number exists
bool AC.SaveSystem.DoesPlayerDataExist ( int  ID,
bool  doSceneCheck = false 
)

Checks if PlayerData for a given Player has been generated.

Parameters
IDThe ID number of the Player to check
doSceneCheckIf True, the check will only be successful if the Player is currently within a scene
Returns
True if PlayerData for the given Player exists
static bool AC.SaveSystem.DoesSaveExist ( int  elementSlot,
int  saveID,
bool  useSaveID 
)
static

Checks if a save file with a particular ID number exists

Parameters
elementSlotThe slot index of the MenuSavesList element
saveIDThe save ID to check for
useSaveIDIf True, the saveID overrides the elementSlot to determine which file to check for
Returns
True if a save file with a matching ID number exists
static bool AC.SaveSystem.DoesSaveExist ( int  saveID)
static

Checks if a save file with a particular ID number exists

Parameters
saveIDThe save ID to check for
Returns
True if a save file with a matching ID number exists
void AC.SaveSystem.GatherImportFiles ( string  projectName,
string  saveFilename,
int  boolID 
)

Searches the filesystem for all available import files, and stores them in foundImportFiles.

Parameters
projectNameThe project name of the game whose save files we're looking to import
saveFilenameThe "save filename" of the game whose save files we're looking to import
boolIDIf >= 0, the ID of the boolean Global Variable that must be True for the file to be considered valid for import
void AC.SaveSystem.GatherSaveFiles ( )

Searches the filesystem for all available save files, and stores them in foundSaveFiles.

string AC.SaveSystem.GetDefaultSaveLabel ( int  saveID)

Returns the default label of a save file.

Parameters
saveIDThe ID number of the save game
Returns
The save file's default label
static string AC.SaveSystem.GetImportSlotLabel ( int  elementSlot,
int  saveID,
bool  useSaveID 
)
static

Gets the label of an import file.

Parameters
elementSlotThe slot index of the MenuProfilesList element that was clicked on
saveIDThe save ID to import
useSaveIDIf True, the saveID overrides the elementSlot to determine which file to import
Returns
The label of the import file.
static Texture2D AC.SaveSystem.GetImportSlotScreenshot ( int  elementSlot,
int  saveID,
bool  useSaveID 
)
static

Gets the screenshot of an import file.

Parameters
elementSlotThe slot index of the MenuSavesList element that was clicked on
saveIDThe save ID to get the screenshot of
useSaveIDIf True, the saveID overrides the elementSlot to determine which file to look for
Returns
The import files's screenshots as a Texture2D. If the save file is not found, null is returned.
List<InvItem> AC.SaveSystem.GetItemsFromPlayer ( int  _playerID)

Returns a list of inventory items currently carried by a particular Player.

Parameters
_playerIDThe ID number of the Player to check the inventory of
Returns
A List of InvItem instances representing the inventory items
static int AC.SaveSystem.GetNumImportSlots ( )
static

Gets the number of found import files.

Returns
The number of found import files
int AC.SaveSystem.GetNumSaves ( bool  includeAutoSaves = true)

Gets the number of save game files found.

Parameters
includeAutoSavesIf True, then autosave files will be included in the result
Returns
The number of save games found
static int AC.SaveSystem.GetNumSlots ( )
static

Gets the number of found save files.

Returns
The number of found save files
int AC.SaveSystem.GetPlayerScene ( int  ID)

Gets the current scene number that a Player is in.

Parameters
IDThe ID number of the Player to check
Returns
The current scene number that the Player is in. If the Player is not found, the currently-open scene number will be returned.
string AC.SaveSystem.GetPlayerSceneName ( int  ID)

Gets the current scene nsmr that a Player is in.

Parameters
IDThe ID number of the Player to check
Returns
The current scene name that the Player is in. If the Player is not found, the currently-open scene name will be returned.
static SaveMethod AC.SaveSystem.GetSaveMethod ( )
static

Gets the SaveMethod for the current platform. This is XML for iPhone, Windows Phone and Wii platforms, and Binary for all others

Returns
The SaveMethod (XML, Binary) for the current platform
static string AC.SaveSystem.GetSaveSlotLabel ( int  elementSlot,
int  saveID,
bool  useSaveID 
)
static

Gets the label of a save file.

Parameters
elementSlotThe slot index of the MenuSavesList element that was clicked on
saveIDThe save ID to save
useSaveIDIf True, the saveID overrides the elementSlot to determine which file to save
Returns
The label of the save file. If the save file is not found, an empty string is returned.
static Texture2D AC.SaveSystem.GetSaveSlotScreenshot ( int  elementSlot,
int  saveID,
bool  useSaveID 
)
static

Gets the screenshot of a save file.

Parameters
elementSlotThe slot index of the MenuSavesList element that was clicked on
saveIDThe save ID to get the screenshot of
useSaveIDIf True, the saveID overrides the elementSlot to determine which file to look for

<return>The save files's screenshots as a Texture2D. If the save file is not found, null is returned.

Texture2D AC.SaveSystem.GetScreenshot ( int  elementSlot,
int  saveID,
bool  useSaveID,
SaveFile[]  saveFiles 
)

Gets the screenshot of a save file.

Parameters
elementSlotThe slot index of the MenuSavesList element that was clicked on
saveIDThe save ID to get the screenshot of
useSaveIDIf True, the saveID overrides the elementSlot to determine which file to look for
saveFilesAn array of SaveFile instances that the save file to retrieve is assumed to be in
Returns
The save files's screenshots as a Texture2D. If the save file is not found, null is returned.
string AC.SaveSystem.GetSlotLabel ( int  elementSlot,
int  saveID,
bool  useSaveID,
SaveFile[]  saveFiles 
)

Gets the label of a save file.

Parameters
elementSlotThe slot index of the MenuSavesList element that was clicked on
saveIDThe save ID to save
useSaveIDIf True, the saveID overrides the elementSlot to determine which file to save
saveFilesAn array of SaveFile instances that the save file to retrieve is assumed to be in
Returns
The label of the save file. If the save file is not found, an empty string is returned.
static bool AC.SaveSystem.ImportGame ( int  elementSlot,
int  saveID,
bool  useSaveID 
)
static

Imports a save file from another Adventure Creator game.

Parameters
elementSlotThe slot index of the MenuProfilesList element that was clicked on
saveIDThe save ID to import
useSaveIDIf True, the saveID overrides the elementSlot to determine which file to import
Returns
True if the import was successful
void AC.SaveSystem.ImportSaveGame ( int  saveID)

Imports a save file from another Adventure Creator game, once found to exist.

Parameters
saveIDThe ID number of the save file to import
static void AC.SaveSystem.LoadAutoSave ( )
static

Loads the AutoSave save file. If multiple save profiles are used, the current profiles AutoSave will be loaded.

static bool AC.SaveSystem.LoadGame ( int  saveID)
static

Loads a save game file.

Parameters
saveIDThe save ID of the file to load
Returns
True if the load was successful
static bool AC.SaveSystem.LoadGame ( int  elementSlot,
int  saveID,
bool  useSaveID 
)
static

Loads a save game file.

Parameters
elementSlotThe slot index of the MenuSavesList element that was clicked on
saveIDThe save ID to load
useSaveIDIf True, the saveID overrides the elementSlot to determine which file to load
Returns
True if the load was successful
void AC.SaveSystem.LoadSaveGame ( int  saveID)

Loads a save game, once found to exist.

Parameters
saveIDThe save ID of the file to load
void AC.SaveSystem.RenameSave ( string  newLabel,
int  saveIndex 
)

Renames the label of a save game file.

Parameters
newLabelThe new label to give the save game file
saveIndexThe index of the foundSaveFiles List that represents the save file to affect
static bool AC.SaveSystem.SaveAutoSave ( )
static

Overwrites the AutoSave file.

Returns
True if the save is successful
void AC.SaveSystem.SaveCurrentPlayerData ( )

Stores the PlayerData of the active Player.

static bool AC.SaveSystem.SaveGame ( int  saveID,
bool  overwriteLabel = true,
string  newLabel = "" 
)
static

Saves the game.

Parameters
saveIDThe save ID to save
overwriteLabelTrue if the label should be updated
newLabelThe new label, if it can be set. If blank, a default label will be generated.
Returns
True if the save was successful
static bool AC.SaveSystem.SaveGame ( int  elementSlot,
int  saveID,
bool  useSaveID,
bool  overwriteLabel = true,
string  newLabel = "" 
)
static

Saves the game.

Parameters
elementSlotThe slot index of the MenuSavesList element that was clicked on
saveIDThe save ID to save
useSaveIDIf True, the saveID overrides the elementSlot to determine which file to save
overwriteLabelTrue if the label should be updated
newLabelThe new label, if it can be set. If blank, a default label will be generated.
Returns
True if the save was successful
static bool AC.SaveSystem.SaveNewGame ( bool  overwriteLabel = true,
string  newLabel = "" 
)
static

Create a new save game file.

Parameters
overwriteLabelTrue if the label should be updated
newLabelThe new label, if it can be set
Returns
True if the save is successful
bool AC.SaveSystem.SaveNewSaveGame ( bool  overwriteLabel = true,
string  newLabel = "" 
)

Create a new save game file.

Parameters
overwriteLabelTrue if the label should be updated
newLabelThe new label, if it can be set
Returns
True if the save is successful
bool AC.SaveSystem.SaveSaveGame ( int  saveID,
bool  overwriteLabel = true,
string  newLabel = "" 
)

Saves the game, once found to exist.

Parameters
saveIDThe save ID to save
overwriteLabelTrue if the label should be updated
newLabelThe new label, if it can be set. If blank, a default label will be generated.
Returns
True if the save was successful
void AC.SaveSystem.SetGameplayReturnTime ( float  _gameplayInvokeTime)

Sets the delay after loading a saved game before gameplay is resumed. This is useful in games with custom systems, e.g. weapons, where we want to prevent firing being possible immediately after loading.

<param name = "The new delay time, in seconds

static string AC.SaveSystem.SetProjectName ( )
static

Generates a default name for the project, based on the project's folder name.

Returns
The name of the project's folder
void AC.SaveSystem.SetSelectiveLoadOptions ( SelectiveLoad  selectiveLoad)

Sets the local instance of SelectiveLoad, which determines which save data is restored the next time (and only the next time) LoadGame is called.

Parameters
selectiveLoadAn instance of SelectiveLoad the defines what elements to load

Member Data Documentation

List<SaveFile> AC.SaveSystem.foundImportFiles = new List<SaveFile>()

A List of SaveFile variables, storing all available import files.

List<SaveFile> AC.SaveSystem.foundSaveFiles = new List<SaveFile>()

A List of SaveFile variables, storing all available save files.

LoadingGame AC.SaveSystem.loadingGame

What type of load is being performed (No, InNewScene, InSameScene, JustSwitchingPlayer)