diff --git a/Roguelike2d/Assets/Prefabs/Persistence.meta b/Roguelike2d/Assets/Prefabs/Persistence.meta new file mode 100644 index 00000000..41d44783 --- /dev/null +++ b/Roguelike2d/Assets/Prefabs/Persistence.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 93e0a7c4cec3ae84c91cca78b2a94704 +folderAsset: yes +timeCreated: 1450149989 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Roguelike2d/Assets/Prefabs/Persistence/Persistent Counter.prefab b/Roguelike2d/Assets/Prefabs/Persistence/Persistent Counter.prefab new file mode 100644 index 00000000..f14bf5bb Binary files /dev/null and b/Roguelike2d/Assets/Prefabs/Persistence/Persistent Counter.prefab differ diff --git a/Roguelike2d/Assets/Prefabs/Persistence/Persistent Counter.prefab.meta b/Roguelike2d/Assets/Prefabs/Persistence/Persistent Counter.prefab.meta new file mode 100644 index 00000000..b096689d --- /dev/null +++ b/Roguelike2d/Assets/Prefabs/Persistence/Persistent Counter.prefab.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: be6e5d8c2cd3d174b92cc623e90b0d69 +timeCreated: 1450149992 +licenseType: Free +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Roguelike2d/Assets/Prefabs/Persistence/UIElementController.prefab b/Roguelike2d/Assets/Prefabs/Persistence/UIElementController.prefab new file mode 100644 index 00000000..c573c5c1 Binary files /dev/null and b/Roguelike2d/Assets/Prefabs/Persistence/UIElementController.prefab differ diff --git a/Roguelike2d/Assets/Prefabs/Persistence/UIElementController.prefab.meta b/Roguelike2d/Assets/Prefabs/Persistence/UIElementController.prefab.meta new file mode 100644 index 00000000..e8ce6aa3 --- /dev/null +++ b/Roguelike2d/Assets/Prefabs/Persistence/UIElementController.prefab.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 99083b943232edd4da95911391c983d2 +timeCreated: 1450151321 +licenseType: Free +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Roguelike2d/Assets/Scenes/ProcGenTest.unity b/Roguelike2d/Assets/Scenes/ProcGenTest.unity index 3752c959..fb039f12 100644 Binary files a/Roguelike2d/Assets/Scenes/ProcGenTest.unity and b/Roguelike2d/Assets/Scenes/ProcGenTest.unity differ diff --git a/Roguelike2d/Assets/Script/NextLevel.cs b/Roguelike2d/Assets/Script/NextLevel.cs index 83b2b1b3..bafa5828 100644 --- a/Roguelike2d/Assets/Script/NextLevel.cs +++ b/Roguelike2d/Assets/Script/NextLevel.cs @@ -3,11 +3,13 @@ using System.Collections; public class NextLevel : MonoBehaviour { public GameObject player; + public int checker = 0; void OnCollisionEnter2D(Collision2D col) { if (col.gameObject.tag == "Player") { + checker = checker + 1; Debug.Log("HitExit"); Application.LoadLevel(0); } diff --git a/Roguelike2d/Assets/Script/Persistence.cs b/Roguelike2d/Assets/Script/Persistence.cs index 08758b39..3e59d535 100644 --- a/Roguelike2d/Assets/Script/Persistence.cs +++ b/Roguelike2d/Assets/Script/Persistence.cs @@ -1,38 +1,68 @@ using UnityEngine; using System.Collections; +using UnityEngine.UI; public class Persistence : MonoBehaviour { + public static Persistence Instance; - public int health = 100; - public int score = 0; - public int cores = 0; - public int power = 0; + TextCore textCore; + public GameObject uiController = GameObject.Find("UIElementController"); + //public Canvas theUI; + + public int health; + public int score; + public int cores; + public int power; //Awake void Awake() { - //DontDestroyOnLoad(health); - //DontDestroyOnLoad(score); - //DontDestroyOnLoad(power); - DontDestroyOnLoad(gameObject); - } - //Collisoin Detection - void OnCollisionEnter2D(Collision2D col) - { - if (col.gameObject.tag == "EscapeCharge") + if (Instance == null) + { + DontDestroyOnLoad(gameObject); + Instance = this; + } + else if (Instance != this) { - Debug.Log("Charge Counted"); - power = power + 1; + Destroy(gameObject); } + } + // Use this for initialization - void Start () { - - } + void Start () + { + textCore = GameObject.Find("UIElementController").GetComponent(); + + health = Persistence.Instance.health; + power = Persistence.Instance.power; + cores = Persistence.Instance.cores; + score = Persistence.Instance.score; + uiController = Persistence.Instance.uiController; + textCore = Persistence.Instance.textCore; + // theUI = Persistence.Instance.theUI; + } // Update is called once per frame - void Update () { - - } + void Update () + { + + health = textCore.health; + score = textCore.score; + power = textCore.power; + // cores = textCore.cores; + + } + + //Scene Transitions + public void SavePlayer() + { + Persistence.Instance.health = health; + Persistence.Instance.score = score; + Persistence.Instance.cores = cores; + Persistence.Instance.power = power; + Persistence.Instance.uiController = uiController; + Persistence.Instance.textCore = textCore; + } } diff --git a/Roguelike2d/Assets/Script/Pickups.cs b/Roguelike2d/Assets/Script/Pickups.cs index 05904ae0..17e5ef39 100644 --- a/Roguelike2d/Assets/Script/Pickups.cs +++ b/Roguelike2d/Assets/Script/Pickups.cs @@ -6,6 +6,7 @@ public class Pickups : MonoBehaviour { public int charge = 0; public GameObject exit; + void OnCollisionEnter2D(Collision2D col) { if (col.gameObject.tag == "EscapeCharge") diff --git a/Roguelike2d/Assets/Script/TextCore.cs b/Roguelike2d/Assets/Script/TextCore.cs index a6310125..e8ba5f1a 100644 --- a/Roguelike2d/Assets/Script/TextCore.cs +++ b/Roguelike2d/Assets/Script/TextCore.cs @@ -4,15 +4,86 @@ using UnityEngine.UI; public class TextCore : MonoBehaviour { - public Text text; + public GameObject persistentStats = GameObject.Find("Persistent Counter"); + + // public GameObject reference; + + // public GameObject exit = GameObject.Find("Exit"); + public GameObject player = GameObject.Find("Player"); + public int health = 100; + public int score = 0; + public int cores = 0; + public int power = 0; + + public Text powerText; + public Text coreText; + public Text scoreText; + public Text healthText; + + public static string healthString; + public static string scoreString; + public static string coreString; + public static string powerString; + + //Awake + void Awake() + { + DontDestroyOnLoad(gameObject); + + Persistence persistence = persistentStats.GetComponent(); + + health = persistence.health; + score = persistence.score; + power = persistence.power; + } // Use this for initialization - void Start () { - - } - - // Update is called once per frame - void Update () { - - } + void Start() + { + persistentStats = GameObject.Find("Persistent Counter"); + Persistence persistence = persistentStats.GetComponent(); + + if (persistence.health != health) + { + health = persistence.health; + score = persistence.score; + cores = persistence.cores; + power = persistence.power; + } + // persistence.health = health; + } + + // Update is called once per frame + void Update() + { + // NextLevel nextLevel = exit.GetComponent(); + Pickups pickups = player.GetComponent(); + cores = pickups.charge; + if (pickups.charge > 4) + { + cores = 4; + } + + // cores = nextlevel.checker; + + healthString = health.ToString(); + scoreString = score.ToString(); + coreString = cores.ToString(); + powerString = power.ToString(); + + healthText.text = healthString; + scoreText.text = scoreString; + coreText.text = coreString; + powerText.text = powerString; + + } + + void OnCollisionEnter2D(Collision2D col) + { + if (col.gameObject.tag == "Player") + { + Debug.Log("HitExit"); + Application.LoadLevel(0); + } + } } diff --git a/Roguelike2d/Library/CurrentLayout.dwlt b/Roguelike2d/Library/CurrentLayout.dwlt index eac99872..ba230c74 100644 Binary files a/Roguelike2d/Library/CurrentLayout.dwlt and b/Roguelike2d/Library/CurrentLayout.dwlt differ diff --git a/Roguelike2d/Library/ScriptAssemblies/Assembly-CSharp.dll.mdb b/Roguelike2d/Library/ScriptAssemblies/Assembly-CSharp.dll.mdb index d7bf9b4b..31880609 100644 Binary files a/Roguelike2d/Library/ScriptAssemblies/Assembly-CSharp.dll.mdb and b/Roguelike2d/Library/ScriptAssemblies/Assembly-CSharp.dll.mdb differ diff --git a/Roguelike2d/Library/assetDatabase3 b/Roguelike2d/Library/assetDatabase3 index 447e68d1..c84b54f1 100644 Binary files a/Roguelike2d/Library/assetDatabase3 and b/Roguelike2d/Library/assetDatabase3 differ diff --git a/Roguelike2d/Library/expandedItems b/Roguelike2d/Library/expandedItems index 161cc677..a4b83f7c 100644 Binary files a/Roguelike2d/Library/expandedItems and b/Roguelike2d/Library/expandedItems differ diff --git a/Roguelike2d/Library/metadata/00/00000000000000004000000000000000 b/Roguelike2d/Library/metadata/00/00000000000000004000000000000000 index db9ea10b..d401cc97 100644 Binary files a/Roguelike2d/Library/metadata/00/00000000000000004000000000000000 and b/Roguelike2d/Library/metadata/00/00000000000000004000000000000000 differ