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:
@@ -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<GameManager>().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>().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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user