diff --git a/Assets/Scripts/States/GlobalStateManager.cs b/Assets/Scripts/States/GlobalStateManager.cs new file mode 100644 index 0000000000000000000000000000000000000000..a0d815dc9d068c978584e8aead6d70d30d1c391e --- /dev/null +++ b/Assets/Scripts/States/GlobalStateManager.cs @@ -0,0 +1,40 @@ +using Nightmare; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class GlobalStateManager : MonoBehaviour +{ + // Create Singleton + public static GlobalStateManager Instance { get; private set; } + + private CheatManager cheatManager; + + private void Awake() + { + if (Instance != null) + { + if (Instance != this) + { + Destroy(this); + } + } + else + { + Instance = this; + Refresh(); + } + } + + private void Refresh() + { + cheatManager = FindObjectOfType<CheatManager>(); + } + + public void SetState(SaveState state) + { + Refresh(); + + cheatManager.LoadCheat(state.globalSaveState.cheats); + } +} diff --git a/Assets/Scripts/States/GlobalStateManager.cs.meta b/Assets/Scripts/States/GlobalStateManager.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..5b855cc07dfe04bb16508c18a0bec865c021258f --- /dev/null +++ b/Assets/Scripts/States/GlobalStateManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 40f7e905f1aa63741b02b9146e251f76 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/States/SaveState.cs b/Assets/Scripts/States/SaveState.cs new file mode 100644 index 0000000000000000000000000000000000000000..da0b873c5755471c4b62b090a78d431c76926084 --- /dev/null +++ b/Assets/Scripts/States/SaveState.cs @@ -0,0 +1,37 @@ +using System; +using Newtonsoft.Json; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +[Serializable] +public class GlobalSaveState +{ + public bool[] cheats; + + public GlobalSaveState(bool[] cheats) + { + this.cheats = cheats; + } + + public override string ToString() + { + return JsonConvert.SerializeObject(this); + } +} + +[Serializable] +public class SaveState +{ + public GlobalSaveState globalSaveState; + + public SaveState(GlobalSaveState globalSaveState) + { + this.globalSaveState = globalSaveState; + } + + public override string ToString() + { + return JsonConvert.SerializeObject(this); + } +} diff --git a/Assets/Scripts/States/SaveState.cs.meta b/Assets/Scripts/States/SaveState.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..a0c00a35f05aaf0458ec3906981de547b54f4e62 --- /dev/null +++ b/Assets/Scripts/States/SaveState.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e0c4e2ce428b7c044baefcfca6687111 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: