|
|
|
@ -16,22 +16,6 @@ namespace Fungus
|
|
|
|
|
return string.Format(SlotKeyFormat, slot); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected virtual bool LoadNewGame(string key) |
|
|
|
|
{ |
|
|
|
|
if (PlayerPrefs.HasKey(key) && |
|
|
|
|
PlayerPrefs.GetString(key) != "") |
|
|
|
|
{ |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Create a new save entry |
|
|
|
|
PlayerPrefs.SetString(key, ""); |
|
|
|
|
|
|
|
|
|
SavePointLoaded.NotifyEventHandlers("new_game"); |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected virtual void StoreJSONData(string key, string jsonData) |
|
|
|
|
{ |
|
|
|
|
if (key.Length > 0) |
|
|
|
@ -79,20 +63,42 @@ namespace Fungus
|
|
|
|
|
saveBuffer = ""; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public virtual bool SlotExists(int slot) |
|
|
|
|
{ |
|
|
|
|
var key = FormatSaveKey(slot); |
|
|
|
|
|
|
|
|
|
if (PlayerPrefs.HasKey(key) && |
|
|
|
|
PlayerPrefs.GetString(key) != "") |
|
|
|
|
{ |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public virtual void Load(int slot) |
|
|
|
|
{ |
|
|
|
|
ActiveSlot = slot; |
|
|
|
|
|
|
|
|
|
var key = FormatSaveKey(slot); |
|
|
|
|
|
|
|
|
|
if (LoadNewGame(key)) |
|
|
|
|
var saveDataJSON = LoadJSONData(key); |
|
|
|
|
if (saveDataJSON != "") |
|
|
|
|
{ |
|
|
|
|
return; |
|
|
|
|
SavePointData.Decode(saveDataJSON); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var saveDataJSON = LoadJSONData(key); |
|
|
|
|
public virtual void LoadNewGame(int slot, string saveDescription) |
|
|
|
|
{ |
|
|
|
|
var key = FormatSaveKey(slot); |
|
|
|
|
|
|
|
|
|
SavePointData.Decode(saveDataJSON); |
|
|
|
|
var saveDataJSON = SavePointData.EncodeNewGame(saveDescription, SceneManager.GetActiveScene().name); |
|
|
|
|
|
|
|
|
|
// Create a new save entry |
|
|
|
|
PlayerPrefs.SetString(key, saveDataJSON); |
|
|
|
|
|
|
|
|
|
SavePointLoaded.NotifyEventHandlers("new_game"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public virtual void Delete(int slot) |
|
|
|
|