19 changed files with 2713 additions and 225 deletions
@ -1,36 +0,0 @@ |
|||||||
// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus). |
|
||||||
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE) |
|
||||||
|
|
||||||
using UnityEngine; |
|
||||||
|
|
||||||
namespace Fungus |
|
||||||
{ |
|
||||||
[CommandInfo("Variable", |
|
||||||
"Load Game", |
|
||||||
"Loads a previously saved game. The original scene is loaded and the resume block is executed.")] |
|
||||||
public class LoadGame : Command |
|
||||||
{ |
|
||||||
[SerializeField] protected IntegerData saveSlot = new IntegerData(0); |
|
||||||
|
|
||||||
#region Public members |
|
||||||
|
|
||||||
public override void OnEnter() |
|
||||||
{ |
|
||||||
var saveManager = FungusManager.Instance.SaveManager; |
|
||||||
|
|
||||||
saveManager.Load(saveSlot.Value); |
|
||||||
} |
|
||||||
|
|
||||||
public override string GetSummary() |
|
||||||
{ |
|
||||||
return saveSlot.Value.ToString(); |
|
||||||
} |
|
||||||
|
|
||||||
public override Color GetButtonColor() |
|
||||||
{ |
|
||||||
return new Color32(235, 191, 217, 255); |
|
||||||
} |
|
||||||
|
|
||||||
#endregion |
|
||||||
} |
|
||||||
} |
|
@ -1,31 +0,0 @@ |
|||||||
using UnityEngine; |
|
||||||
using System.Collections; |
|
||||||
using System.Collections.Generic; |
|
||||||
using UnityEngine.SceneManagement; |
|
||||||
|
|
||||||
namespace Fungus |
|
||||||
{ |
|
||||||
public class GameSaver : MonoBehaviour |
|
||||||
{ |
|
||||||
[SerializeField] protected string startScene = ""; |
|
||||||
|
|
||||||
[SerializeField] protected List<Flowchart> flowcharts = new List<Flowchart>(); |
|
||||||
|
|
||||||
#region Public methods |
|
||||||
|
|
||||||
public List<Flowchart> Flowcharts { get { return flowcharts; } } |
|
||||||
|
|
||||||
public virtual void Save() |
|
||||||
{ |
|
||||||
var saveManager = FungusManager.Instance.SaveManager; |
|
||||||
saveManager.Save(); |
|
||||||
} |
|
||||||
|
|
||||||
public virtual void LoadScene(string sceneName) |
|
||||||
{ |
|
||||||
SceneManager.LoadScene(sceneName); |
|
||||||
} |
|
||||||
|
|
||||||
#endregion |
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,61 @@ |
|||||||
|
using UnityEngine; |
||||||
|
using UnityEngine.UI; |
||||||
|
using System.Collections; |
||||||
|
using System.Collections.Generic; |
||||||
|
using UnityEngine.SceneManagement; |
||||||
|
|
||||||
|
namespace Fungus |
||||||
|
{ |
||||||
|
public class SaveGameHelper : MonoBehaviour |
||||||
|
{ |
||||||
|
[SerializeField] protected string startScene = ""; |
||||||
|
|
||||||
|
[SerializeField] protected SaveGameObjects saveGameObjects = new SaveGameObjects(); |
||||||
|
|
||||||
|
protected virtual void OnEnable() |
||||||
|
{ |
||||||
|
SaveSignals.OnGameSave += OnGameSave; |
||||||
|
} |
||||||
|
|
||||||
|
protected virtual void OnDisable() |
||||||
|
{ |
||||||
|
SaveSignals.OnGameSave -= OnGameSave; |
||||||
|
} |
||||||
|
|
||||||
|
protected virtual void OnGameSave(string saveKey, string saveDescription) |
||||||
|
{ |
||||||
|
// TODO: Play sound effect |
||||||
|
} |
||||||
|
|
||||||
|
#region Public methods |
||||||
|
|
||||||
|
public SaveGameObjects SaveGameObjects { get { return saveGameObjects; } } |
||||||
|
|
||||||
|
public virtual void Save() |
||||||
|
{ |
||||||
|
var saveManager = FungusManager.Instance.SaveManager; |
||||||
|
saveManager.Save(); |
||||||
|
} |
||||||
|
|
||||||
|
public virtual void Load() |
||||||
|
{ |
||||||
|
var saveManager = FungusManager.Instance.SaveManager; |
||||||
|
saveManager.Load(); |
||||||
|
} |
||||||
|
|
||||||
|
public virtual void Rewind() |
||||||
|
{ |
||||||
|
var saveManager = FungusManager.Instance.SaveManager; |
||||||
|
saveManager.Rewind(); |
||||||
|
} |
||||||
|
|
||||||
|
public virtual void Restart() |
||||||
|
{ |
||||||
|
var saveManager = FungusManager.Instance.SaveManager; |
||||||
|
saveManager.Clear(); |
||||||
|
SceneManager.LoadScene(startScene); |
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,17 @@ |
|||||||
|
using UnityEngine; |
||||||
|
using System.Collections.Generic; |
||||||
|
|
||||||
|
namespace Fungus |
||||||
|
{ |
||||||
|
[System.Serializable] |
||||||
|
public class SaveGameObjects |
||||||
|
{ |
||||||
|
[SerializeField] protected List<Flowchart> flowcharts = new List<Flowchart>(); |
||||||
|
|
||||||
|
#region Public methods |
||||||
|
|
||||||
|
public List<Flowchart> Flowcharts { get { return flowcharts; } } |
||||||
|
|
||||||
|
#endregion |
||||||
|
} |
||||||
|
} |
@ -1,6 +1,6 @@ |
|||||||
fileFormatVersion: 2 |
fileFormatVersion: 2 |
||||||
guid: 60a19f3f0e9b84b14b2b310a296de1b1 |
guid: f9c00b58b03474e37b54a4b39ed6c8ee |
||||||
timeCreated: 1479485750 |
timeCreated: 1480503989 |
||||||
licenseType: Free |
licenseType: Free |
||||||
MonoImporter: |
MonoImporter: |
||||||
serializedVersion: 2 |
serializedVersion: 2 |
@ -0,0 +1,58 @@ |
|||||||
|
using UnityEngine; |
||||||
|
using System.Collections.Generic; |
||||||
|
using Fungus; |
||||||
|
using UnityEngine.SceneManagement; |
||||||
|
|
||||||
|
namespace Fungus |
||||||
|
{ |
||||||
|
[System.Serializable] |
||||||
|
public class SaveHistory |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// Version number of current save data format. |
||||||
|
/// </summary> |
||||||
|
protected const int SaveDataVersion = 1; |
||||||
|
|
||||||
|
[SerializeField] protected int version = SaveDataVersion; |
||||||
|
|
||||||
|
[SerializeField] protected List<string> savePoints = new List<string>(); |
||||||
|
|
||||||
|
#region Public methods |
||||||
|
|
||||||
|
public int NumSavePoints { get { return savePoints.Count; } } |
||||||
|
|
||||||
|
public void AddSavePoint(string saveKey, string saveDescription) |
||||||
|
{ |
||||||
|
string sceneName = SceneManager.GetActiveScene().name; |
||||||
|
var savePointData = SavePointData.Encode(saveKey, saveDescription, sceneName); |
||||||
|
savePoints.Add(savePointData); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// Removes the latest save point. |
||||||
|
/// </summary> |
||||||
|
public void RemoveSavePoint() |
||||||
|
{ |
||||||
|
if (savePoints.Count > 0) |
||||||
|
{ |
||||||
|
savePoints.RemoveAt(savePoints.Count - 1); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void LoadLatestSavePoint() |
||||||
|
{ |
||||||
|
if (savePoints.Count > 0) |
||||||
|
{ |
||||||
|
var savePointData = savePoints[savePoints.Count - 1]; |
||||||
|
SavePointData.Decode(savePointData); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void Clear() |
||||||
|
{ |
||||||
|
savePoints.Clear(); |
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
} |
||||||
|
} |
@ -1,6 +1,6 @@ |
|||||||
fileFormatVersion: 2 |
fileFormatVersion: 2 |
||||||
guid: 4bd5b7f5cc3944217aa05a6fa8552baf |
guid: fd859426b9f7445b5a1d7281f4943bb8 |
||||||
timeCreated: 1478530280 |
timeCreated: 1480422606 |
||||||
licenseType: Free |
licenseType: Free |
||||||
MonoImporter: |
MonoImporter: |
||||||
serializedVersion: 2 |
serializedVersion: 2 |
@ -0,0 +1,23 @@ |
|||||||
|
// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus). |
||||||
|
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE) |
||||||
|
|
||||||
|
namespace Fungus |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// Save manager signalling system. |
||||||
|
/// You can use this to be notified about various events in the save game system. |
||||||
|
/// </summary> |
||||||
|
public static class SaveSignals |
||||||
|
{ |
||||||
|
#region Public members |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// GameSave signal. Sent when the game is saved. |
||||||
|
/// </summary> |
||||||
|
public static event GameSaveHandler OnGameSave; |
||||||
|
public delegate void GameSaveHandler(string saveKey, string saveDescription); |
||||||
|
public static void DoGameSave(string saveKey, string saveDescription) { if (OnGameSave != null) OnGameSave(saveKey, saveDescription); } |
||||||
|
|
||||||
|
#endregion |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,12 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: a47447a63010d4230884d0978a26f097 |
||||||
|
timeCreated: 1474988491 |
||||||
|
licenseType: Free |
||||||
|
MonoImporter: |
||||||
|
serializedVersion: 2 |
||||||
|
defaultReferences: [] |
||||||
|
executionOrder: 0 |
||||||
|
icon: {instanceID: 0} |
||||||
|
userData: |
||||||
|
assetBundleName: |
||||||
|
assetBundleVariant: |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,8 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: a440424aaf73a4ff3bf88e9d1eb3a43c |
||||||
|
timeCreated: 1480421523 |
||||||
|
licenseType: Free |
||||||
|
DefaultImporter: |
||||||
|
userData: |
||||||
|
assetBundleName: |
||||||
|
assetBundleVariant: |
@ -1,34 +0,0 @@ |
|||||||
using UnityEngine; |
|
||||||
using System.Collections; |
|
||||||
|
|
||||||
namespace Fungus |
|
||||||
{ |
|
||||||
public class SavePicker : MonoBehaviour |
|
||||||
{ |
|
||||||
[SerializeField] protected string newGameDescription = "Playing"; |
|
||||||
|
|
||||||
#region Public methods |
|
||||||
|
|
||||||
public virtual void Select(int slot) |
|
||||||
{ |
|
||||||
var saveManager = FungusManager.Instance.SaveManager; |
|
||||||
|
|
||||||
if (saveManager.SlotExists(slot)) |
|
||||||
{ |
|
||||||
saveManager.Load(slot); |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
saveManager.LoadNewGame(slot, newGameDescription); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public virtual void Delete(int slot) |
|
||||||
{ |
|
||||||
var saveManager = FungusManager.Instance.SaveManager; |
|
||||||
saveManager.Delete(slot); |
|
||||||
} |
|
||||||
|
|
||||||
#endregion |
|
||||||
} |
|
||||||
} |
|
Loading…
Reference in new issue