2017-09-04 23:53:18 +00:00
|
|
|
|
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
|
2017-09-05 22:12:08 +00:00
|
|
|
|
void OnEnable ()
|
|
|
|
|
{
|
2017-09-04 23:53:18 +00:00
|
|
|
|
active = true;
|
2017-09-05 22:12:08 +00:00
|
|
|
|
double randomRotation = GetRandomNumber(-4.0, 4.0);
|
|
|
|
|
transform.Rotate(0.0f, 0.0f, (float)randomRotation);
|
|
|
|
|
Debug.Log("Rotation set to :" + randomRotation);
|
2017-09-04 23:53:18 +00:00
|
|
|
|
origin = this.transform.localPosition;
|
|
|
|
|
localNotify = GameObject.Find("EventSystem").GetComponent<GameManager>().GetNotify();
|
|
|
|
|
}
|
2017-09-05 22:12:08 +00:00
|
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
|
void FixedUpdate()
|
|
|
|
|
{
|
2017-09-04 23:53:18 +00:00
|
|
|
|
|
|
|
|
|
timer += 0.02f;
|
|
|
|
|
|
2017-09-05 22:12:08 +00:00
|
|
|
|
this.gameObject.transform.Translate(new Vector3(0, 50f * Time.deltaTime, 0));
|
2017-09-04 23:53:18 +00:00
|
|
|
|
this.gameObject.GetComponentInChildren<Text>().text = localNotify;
|
2017-09-05 22:12:08 +00:00
|
|
|
|
|
|
|
|
|
if (timer >= 3)
|
2017-09-04 23:53:18 +00:00
|
|
|
|
{
|
|
|
|
|
active = false;
|
|
|
|
|
timer = 0.0f;
|
2017-09-05 22:12:08 +00:00
|
|
|
|
Destroy(this.gameObject);
|
2017-09-04 23:53:18 +00:00
|
|
|
|
}
|
2017-09-05 22:12:08 +00:00
|
|
|
|
}
|
2017-09-04 23:53:18 +00:00
|
|
|
|
|
2017-09-05 22:12:08 +00:00
|
|
|
|
public double GetRandomNumber(double min, double max)
|
|
|
|
|
{
|
|
|
|
|
System.Random random = new System.Random();
|
|
|
|
|
return random.NextDouble() * (max - min) + min;
|
2017-09-04 23:53:18 +00:00
|
|
|
|
}
|
2017-09-05 22:12:08 +00:00
|
|
|
|
|
2017-09-04 23:53:18 +00:00
|
|
|
|
}
|
2017-09-05 22:12:08 +00:00
|
|
|
|
|