diff --git a/Assets/Prefabs/Pop-up Panel.prefab b/Assets/Prefabs/Pop-up Panel.prefab new file mode 100644 index 0000000..1788ead Binary files /dev/null and b/Assets/Prefabs/Pop-up Panel.prefab differ diff --git a/Assets/Prefabs/Pop-up Panel.prefab.meta b/Assets/Prefabs/Pop-up Panel.prefab.meta new file mode 100644 index 0000000..43299ab --- /dev/null +++ b/Assets/Prefabs/Pop-up Panel.prefab.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 28a82baf8aadfa844a76fc5dd71094f8 +timeCreated: 1504643709 +licenseType: Free +NativeFormatImporter: + mainObjectFileID: 100100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/Pop-up Panels.meta b/Assets/Prefabs/Pop-up Panels.meta new file mode 100644 index 0000000..b6f2937 --- /dev/null +++ b/Assets/Prefabs/Pop-up Panels.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 10e2d344b53a4c64b854b8b3904b369e +folderAsset: yes +timeCreated: 1504644496 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/Pop-up Panels/Pop-up Panel 1.prefab b/Assets/Prefabs/Pop-up Panels/Pop-up Panel 1.prefab new file mode 100644 index 0000000..a7c6d87 Binary files /dev/null and b/Assets/Prefabs/Pop-up Panels/Pop-up Panel 1.prefab differ diff --git a/Assets/Prefabs/Pop-up Panels/Pop-up Panel 1.prefab.meta b/Assets/Prefabs/Pop-up Panels/Pop-up Panel 1.prefab.meta new file mode 100644 index 0000000..6aef980 --- /dev/null +++ b/Assets/Prefabs/Pop-up Panels/Pop-up Panel 1.prefab.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: e37a904fb373d0244a3345167006b83d +timeCreated: 1504644537 +licenseType: Free +NativeFormatImporter: + mainObjectFileID: 100100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/Pop-up Panels/Pop-up Panel 2.prefab b/Assets/Prefabs/Pop-up Panels/Pop-up Panel 2.prefab new file mode 100644 index 0000000..371d483 Binary files /dev/null and b/Assets/Prefabs/Pop-up Panels/Pop-up Panel 2.prefab differ diff --git a/Assets/Prefabs/Pop-up Panels/Pop-up Panel 2.prefab.meta b/Assets/Prefabs/Pop-up Panels/Pop-up Panel 2.prefab.meta new file mode 100644 index 0000000..3e9bb83 --- /dev/null +++ b/Assets/Prefabs/Pop-up Panels/Pop-up Panel 2.prefab.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 4cf0708b040fc2c4aa29a200bec6056f +timeCreated: 1504644516 +licenseType: Free +NativeFormatImporter: + mainObjectFileID: 100100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/Pop-up Panels/Pop-up Panel 3.prefab b/Assets/Prefabs/Pop-up Panels/Pop-up Panel 3.prefab new file mode 100644 index 0000000..5d5f55c Binary files /dev/null and b/Assets/Prefabs/Pop-up Panels/Pop-up Panel 3.prefab differ diff --git a/Assets/Prefabs/Pop-up Panels/Pop-up Panel 3.prefab.meta b/Assets/Prefabs/Pop-up Panels/Pop-up Panel 3.prefab.meta new file mode 100644 index 0000000..c016641 --- /dev/null +++ b/Assets/Prefabs/Pop-up Panels/Pop-up Panel 3.prefab.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: acc04bbf04d68f24fa01177bb3ed86b8 +timeCreated: 1504644530 +licenseType: Free +NativeFormatImporter: + mainObjectFileID: 100100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/Pop-up Panels/Pop-up Panel 4.prefab b/Assets/Prefabs/Pop-up Panels/Pop-up Panel 4.prefab new file mode 100644 index 0000000..875cf58 Binary files /dev/null and b/Assets/Prefabs/Pop-up Panels/Pop-up Panel 4.prefab differ diff --git a/Assets/Prefabs/Pop-up Panels/Pop-up Panel 4.prefab.meta b/Assets/Prefabs/Pop-up Panels/Pop-up Panel 4.prefab.meta new file mode 100644 index 0000000..cad248d --- /dev/null +++ b/Assets/Prefabs/Pop-up Panels/Pop-up Panel 4.prefab.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 3296a1925269b9c4699c0f4de17d0366 +timeCreated: 1504644532 +licenseType: Free +NativeFormatImporter: + mainObjectFileID: 100100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/Main.unity b/Assets/Scenes/Main.unity index 82fce2a..c490b9a 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 0a5bab1..6200c9c 100644 --- a/Assets/Scripts/ExperienceBar.cs +++ b/Assets/Scripts/ExperienceBar.cs @@ -20,15 +20,21 @@ public class ExperienceBar : MonoBehaviour { private float lerpSpeed; [SerializeField] private int clicks; + + [SerializeField] + private GameObject eventSystem; + private float clicksNeeded = 10; private float previousExpRequired; private float barMovement; private float barPosition; private float Increment = 10; + private string notify; // Use this for initialization void Start () { + eventSystem = GameObject.Find("EventSystem"); fillAmount = currentExp / currentRequirement; } @@ -60,6 +66,9 @@ public class ExperienceBar : MonoBehaviour { ++clicks; currentExp = currentExp + Increment; fillAmount = currentExp / currentRequirement; + notify = "+" + Increment + "EXP"; + eventSystem.GetComponent().MakePopup(notify); + //Debug.Log("fillAmount = " + fillAmount); } diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index 5b4e0b6..d2a5cbd 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -24,38 +24,15 @@ 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 () { - - } - - - - void OnEnable() - { - Load(); - } - - void OnApplicationPause() - { - Save(); - } + public GameObject popup; + public GameObject popupSpawn; + public string notify; void OnApplicationFocus(bool pauseStatus) { + Debug.Log("OnApplicationFocused"); if (pauseStatus) { //your app is NO LONGER in the background @@ -73,28 +50,6 @@ 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(); @@ -145,7 +100,7 @@ public class GameManager : MonoBehaviour { if (idleExp >= 0.0f) { string notification = ("+" + idleExp + "EXP"); - SendNotification(notification); + MakePopup(notification); } Debug.Log("Loaded"); @@ -179,109 +134,11 @@ public class GameManager : MonoBehaviour { return secondsPassed; } - public void UpdatePopups() + public void MakePopup(string content) { - - 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; - } - } - + notify = content; + Instantiate(popup, popupSpawn.transform.position, popupSpawn.transform.rotation, GameObject.Find("Notification Panel").gameObject.transform ); + Debug.Log("Popup Created"); } public string GetNotify() diff --git a/Assets/Scripts/PopupNotification.cs b/Assets/Scripts/PopupNotification.cs index e68f075..4ec8742 100644 --- a/Assets/Scripts/PopupNotification.cs +++ b/Assets/Scripts/PopupNotification.cs @@ -12,27 +12,38 @@ public class PopupNotification : MonoBehaviour { public string localNotify; // Use this for initialization - void OnEnable () { + void OnEnable () + { active = true; + double randomRotation = GetRandomNumber(-4.0, 4.0); + transform.Rotate(0.0f, 0.0f, (float)randomRotation); + Debug.Log("Rotation set to :" + randomRotation); origin = this.transform.localPosition; localNotify = GameObject.Find("EventSystem").GetComponent().GetNotify(); } - - // Update is called once per frame - void FixedUpdate () { + + // Update is called once per frame + void FixedUpdate() + { timer += 0.02f; - this.gameObject.transform.Translate(new Vector3(0, 10f * Time.deltaTime, 0)); + this.gameObject.transform.Translate(new Vector3(0, 50f * Time.deltaTime, 0)); this.gameObject.GetComponentInChildren().text = localNotify; - - if(timer >= 3) + + if (timer >= 3) { - this.gameObject.SetActive(false); active = false; timer = 0.0f; - this.gameObject.transform.localPosition = origin; + Destroy(this.gameObject); } - } + + public double GetRandomNumber(double min, double max) + { + System.Random random = new System.Random(); + return random.NextDouble() * (max - min) + min; + } + } + diff --git a/ProjectSettings/TagManager.asset b/ProjectSettings/TagManager.asset index 8d1360a..23c99fe 100644 Binary files a/ProjectSettings/TagManager.asset and b/ProjectSettings/TagManager.asset differ