Added basic notification system

-Works with minimal calls to SendNotification(), infinite loop possible
on multiple calls
-Add to MoreExp()
--Add case for multiple notifications of same type combining value
--If notification timer > maxTime
---expRate = expNotifyValue / secondsPassed
---Display Exp/s instead of continuously growing value
This commit is contained in:
2017-09-04 19:53:18 -04:00
parent cc86eabeef
commit 33664d2735
5 changed files with 204 additions and 2 deletions

View File

@@ -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<ExperienceBar>().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<GameObject> popups = new List<GameObject>();
GameObject[] allPopups = GameObject.Find("Notification Panel").GetComponentsInChildren<GameObject>(true);
foreach (GameObject obj in allPopups)
{
popups.Add(obj.GetComponent<GameObject>());
}
*/
//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;
}
}