using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class AlertController : MonoBehaviour { public Text text; public Slider slider; public float hideTime = 5f; // private Vector3 originalPos; // private float lastSpotted; void Start () { NotificationServer.register("spotted boat", spottedBoat); NotificationServer.register("lost boat", lostBoat); NotificationServer.register("restart scene", restartScene); // originalPos = text.rectTransform.anchoredPosition3D; } public void spottedBoat() { LeanTween.cancel(text.gameObject, false); LeanTween.cancel(slider.gameObject, false); // lastSpotted = Time.timeSinceLevelLoad; NotificationServer.notify("show AlertText"); text.text = "hide!"; setTimer(0f); } public void lostBoat() { LeanTween.cancel(text.gameObject, false); LeanTween.cancel(slider.gameObject, false); NotificationServer.notify("show AlertText"); NotificationServer.notify("show AlertTimer"); text.text = "stay hidden"; LeanTween.value(slider.gameObject, 0f, 1f, hideTime).setOnUpdate((float val)=>{ setTimer(val); }).setOnComplete(()=>{ NotificationServer.notify("hide AlertTimer"); NotificationServer.notify("statechange Searchlight returning"); text.text = "hidden..."; LeanTween.delayedCall(text.gameObject, 2f, ()=>{ NotificationServer.notify("hide AlertText"); }); }); } public void restartScene() { LeanTween.cancel(text.gameObject, false); LeanTween.cancel(slider.gameObject, false); NotificationServer.notify("hide AlertText"); NotificationServer.notify("hide AlertTimer"); } public void setTimer(float val) { slider.value = val; } }