diff --git a/Assets/Scenes/Main.unity b/Assets/Scenes/Main.unity index ff1af1c..82fce2a 100644 Binary files a/Assets/Scenes/Main.unity and b/Assets/Scenes/Main.unity differ diff --git a/Assets/Scripts/ExperienceBar.cs b/Assets/Scripts/ExperienceBar.cs index ee9b807..0a5bab1 100644 --- a/Assets/Scripts/ExperienceBar.cs +++ b/Assets/Scripts/ExperienceBar.cs @@ -60,7 +60,7 @@ public class ExperienceBar : MonoBehaviour { ++clicks; currentExp = currentExp + Increment; fillAmount = currentExp / currentRequirement; - Debug.Log("fillAmount = " + fillAmount); + //Debug.Log("fillAmount = " + fillAmount); } public void LevelUp() diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index c4bd64d..5b4e0b6 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -1,6 +1,7 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; +using UnityEngine.UI; using System; using System.IO; using System.Runtime.Serialization.Formatters.Binary; @@ -23,6 +24,19 @@ public class GameManager : MonoBehaviour { } + public string notify; + public bool wait; + public bool activeOne; + public bool activeTwo; + public bool activeThree; + public bool activeFour; + public float idleExp; + public GameObject popupOne; + public GameObject popupTwo; + public GameObject popupThree; + public GameObject popupFour; + public float timer; + // Update is called once per frame void Update () { @@ -59,6 +73,28 @@ public class GameManager : MonoBehaviour { Save(); } + public void Start() + { + popupOne.SetActive(false); + popupTwo.SetActive(false); + popupThree.SetActive(false); + popupFour.SetActive(false); + + + } + + void FixedUpdate() + { + UpdatePopups(); + timer += 0.02f; + if(timer > 9999.0f) + { + timer = 0.0f; + } + + + } + public void Save() { BinaryFormatter bf = new BinaryFormatter(); @@ -103,9 +139,15 @@ public class GameManager : MonoBehaviour { DateTime loadTime = System.DateTime.Now; int secondsPassed = GetIdleTime(data.currentTime, loadTime); - float idleExp = (data.rotationsPerSec * secondsPassed) * data.increment; + idleExp = (data.rotationsPerSec * secondsPassed) * data.increment; GameObject.FindGameObjectWithTag("ExpGained").GetComponent().currentExp += idleExp; + if (idleExp >= 0.0f) + { + string notification = ("+" + idleExp + "EXP"); + SendNotification(notification); + } + Debug.Log("Loaded"); Debug.Log("idleExp: " + idleExp); } @@ -137,4 +179,114 @@ public class GameManager : MonoBehaviour { return secondsPassed; } + public void UpdatePopups() + { + + if (GameObject.Find("Pop-up Panel 1") == null) + { + activeOne = false; + } + else + { + activeOne = true; + } + + if (GameObject.Find("Pop-up Panel 2") == null) + { + activeTwo = false; + } + else + { + activeTwo = true; + } + + if (GameObject.Find("Pop-up Panel 3") == null) + { + activeThree = false; + } + else + { + activeThree = true; + } + + if (GameObject.Find("Pop-up Panel 4") == null) + { + activeFour = false; + }else + { + activeFour = true; + } + + } + + public void SendNotification(string notification) + { + + /* + List popups = new List(); + GameObject[] allPopups = GameObject.Find("Notification Panel").GetComponentsInChildren(true); + foreach (GameObject obj in allPopups) + { + popups.Add(obj.GetComponent()); + } + */ + + + + //Debug.Log("Number of Popups: " + popups.Count); + + + for (;;) + { + Debug.Log("For1"); + if (wait == true) + { + Debug.Log("For1.1"); + continue; + }else + { + Debug.Log("For1.1"); + notify = notification; + break; + } + } + + + for (;;) + { + Debug.Log("For2"); + if (activeOne == false) + { + popupOne.SetActive(true); + wait = false; + break; + } else if (activeTwo == false) + { + popupTwo.SetActive(true); + wait = false; + break; + } else if (activeThree == false) + { + popupThree.SetActive(true); + wait = false; + break; + } else if (activeFour == false) + { + popupFour.SetActive(true); + wait = false; + break; + } else + { + wait = true; + continue; + } + } + + } + + public string GetNotify() + { + return notify; + } + } diff --git a/Assets/Scripts/PopupNotification.cs b/Assets/Scripts/PopupNotification.cs new file mode 100644 index 0000000..e68f075 --- /dev/null +++ b/Assets/Scripts/PopupNotification.cs @@ -0,0 +1,38 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; + + +public class PopupNotification : MonoBehaviour { + + public bool active = false; + public Vector3 origin; + public float timer = 0.0f; + public string localNotify; + + // Use this for initialization + void OnEnable () { + active = true; + origin = this.transform.localPosition; + localNotify = GameObject.Find("EventSystem").GetComponent().GetNotify(); + } + + // Update is called once per frame + void FixedUpdate () { + + timer += 0.02f; + + this.gameObject.transform.Translate(new Vector3(0, 10f * Time.deltaTime, 0)); + this.gameObject.GetComponentInChildren().text = localNotify; + + if(timer >= 3) + { + this.gameObject.SetActive(false); + active = false; + timer = 0.0f; + this.gameObject.transform.localPosition = origin; + } + + } +} diff --git a/Assets/Scripts/PopupNotification.cs.meta b/Assets/Scripts/PopupNotification.cs.meta new file mode 100644 index 0000000..2f767b1 --- /dev/null +++ b/Assets/Scripts/PopupNotification.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f65f56ebba8d5fd49ac926af557e92d7 +timeCreated: 1504554538 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: