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:
38
Assets/Scripts/PopupNotification.cs
Normal file
38
Assets/Scripts/PopupNotification.cs
Normal file
@@ -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<GameManager>().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>().text = localNotify;
|
||||
|
||||
if(timer >= 3)
|
||||
{
|
||||
this.gameObject.SetActive(false);
|
||||
active = false;
|
||||
timer = 0.0f;
|
||||
this.gameObject.transform.localPosition = origin;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user