Reworked (bad)notification system
- Reduced huge amount of fluff logic, loops, conditionals - Fixed infinite loop within 4+ calls to SendNotification() -- Replaced with new function MakePopup(string contents) -- Spawns a prefab, can call as much as you want (overlapping issue) -Add combining of colliding Popups with similar contents (exp) -- Add a tag passed into MakePopup() as argument used to combine similar values ( and increase time left to Destroy(), raise speed of transform to move away from other popups) - Popups rotate within a range of -4 to 4 for trendy not-perfect look *shrug*
This commit is contained in:
parent
33664d2735
commit
1bcca0e925
Binary file not shown.
|
@ -0,0 +1,9 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 28a82baf8aadfa844a76fc5dd71094f8
|
||||||
|
timeCreated: 1504643709
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
mainObjectFileID: 100100000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,9 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 10e2d344b53a4c64b854b8b3904b369e
|
||||||
|
folderAsset: yes
|
||||||
|
timeCreated: 1504644496
|
||||||
|
licenseType: Free
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Binary file not shown.
|
@ -0,0 +1,9 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e37a904fb373d0244a3345167006b83d
|
||||||
|
timeCreated: 1504644537
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
mainObjectFileID: 100100000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Binary file not shown.
|
@ -0,0 +1,9 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4cf0708b040fc2c4aa29a200bec6056f
|
||||||
|
timeCreated: 1504644516
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
mainObjectFileID: 100100000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Binary file not shown.
|
@ -0,0 +1,9 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: acc04bbf04d68f24fa01177bb3ed86b8
|
||||||
|
timeCreated: 1504644530
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
mainObjectFileID: 100100000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Binary file not shown.
|
@ -0,0 +1,9 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3296a1925269b9c4699c0f4de17d0366
|
||||||
|
timeCreated: 1504644532
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
mainObjectFileID: 100100000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Binary file not shown.
|
@ -20,15 +20,21 @@ public class ExperienceBar : MonoBehaviour {
|
||||||
private float lerpSpeed;
|
private float lerpSpeed;
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private int clicks;
|
private int clicks;
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
private GameObject eventSystem;
|
||||||
|
|
||||||
|
|
||||||
private float clicksNeeded = 10;
|
private float clicksNeeded = 10;
|
||||||
private float previousExpRequired;
|
private float previousExpRequired;
|
||||||
private float barMovement;
|
private float barMovement;
|
||||||
private float barPosition;
|
private float barPosition;
|
||||||
private float Increment = 10;
|
private float Increment = 10;
|
||||||
|
private string notify;
|
||||||
|
|
||||||
// Use this for initialization
|
// Use this for initialization
|
||||||
void Start () {
|
void Start () {
|
||||||
|
eventSystem = GameObject.Find("EventSystem");
|
||||||
fillAmount = currentExp / currentRequirement;
|
fillAmount = currentExp / currentRequirement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,6 +66,9 @@ public class ExperienceBar : MonoBehaviour {
|
||||||
++clicks;
|
++clicks;
|
||||||
currentExp = currentExp + Increment;
|
currentExp = currentExp + Increment;
|
||||||
fillAmount = currentExp / currentRequirement;
|
fillAmount = currentExp / currentRequirement;
|
||||||
|
notify = "+" + Increment + "EXP";
|
||||||
|
eventSystem.GetComponent<GameManager>().MakePopup(notify);
|
||||||
|
|
||||||
//Debug.Log("fillAmount = " + fillAmount);
|
//Debug.Log("fillAmount = " + fillAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 float idleExp;
|
||||||
public GameObject popupOne;
|
|
||||||
public GameObject popupTwo;
|
|
||||||
public GameObject popupThree;
|
|
||||||
public GameObject popupFour;
|
|
||||||
public float timer;
|
|
||||||
|
|
||||||
// Update is called once per frame
|
public GameObject popup;
|
||||||
void Update () {
|
public GameObject popupSpawn;
|
||||||
|
public string notify;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void OnEnable()
|
|
||||||
{
|
|
||||||
Load();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnApplicationPause()
|
|
||||||
{
|
|
||||||
Save();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnApplicationFocus(bool pauseStatus)
|
void OnApplicationFocus(bool pauseStatus)
|
||||||
{
|
{
|
||||||
|
Debug.Log("OnApplicationFocused");
|
||||||
if (pauseStatus)
|
if (pauseStatus)
|
||||||
{
|
{
|
||||||
//your app is NO LONGER in the background
|
//your app is NO LONGER in the background
|
||||||
|
@ -73,28 +50,6 @@ public class GameManager : MonoBehaviour {
|
||||||
Save();
|
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()
|
public void Save()
|
||||||
{
|
{
|
||||||
BinaryFormatter bf = new BinaryFormatter();
|
BinaryFormatter bf = new BinaryFormatter();
|
||||||
|
@ -145,7 +100,7 @@ public class GameManager : MonoBehaviour {
|
||||||
if (idleExp >= 0.0f)
|
if (idleExp >= 0.0f)
|
||||||
{
|
{
|
||||||
string notification = ("+" + idleExp + "EXP");
|
string notification = ("+" + idleExp + "EXP");
|
||||||
SendNotification(notification);
|
MakePopup(notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Log("Loaded");
|
Debug.Log("Loaded");
|
||||||
|
@ -179,109 +134,11 @@ public class GameManager : MonoBehaviour {
|
||||||
return secondsPassed;
|
return secondsPassed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdatePopups()
|
public void MakePopup(string content)
|
||||||
{
|
{
|
||||||
|
notify = content;
|
||||||
if (GameObject.Find("Pop-up Panel 1") == null)
|
Instantiate(popup, popupSpawn.transform.position, popupSpawn.transform.rotation, GameObject.Find("Notification Panel").gameObject.transform );
|
||||||
{
|
Debug.Log("Popup Created");
|
||||||
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()
|
public string GetNotify()
|
||||||
|
|
|
@ -12,27 +12,38 @@ public class PopupNotification : MonoBehaviour {
|
||||||
public string localNotify;
|
public string localNotify;
|
||||||
|
|
||||||
// Use this for initialization
|
// Use this for initialization
|
||||||
void OnEnable () {
|
void OnEnable ()
|
||||||
|
{
|
||||||
active = true;
|
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;
|
origin = this.transform.localPosition;
|
||||||
localNotify = GameObject.Find("EventSystem").GetComponent<GameManager>().GetNotify();
|
localNotify = GameObject.Find("EventSystem").GetComponent<GameManager>().GetNotify();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void FixedUpdate () {
|
void FixedUpdate()
|
||||||
|
{
|
||||||
|
|
||||||
timer += 0.02f;
|
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>().text = localNotify;
|
this.gameObject.GetComponentInChildren<Text>().text = localNotify;
|
||||||
|
|
||||||
if(timer >= 3)
|
if (timer >= 3)
|
||||||
{
|
{
|
||||||
this.gameObject.SetActive(false);
|
|
||||||
active = false;
|
active = false;
|
||||||
timer = 0.0f;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue