You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

65 lines
1.6 KiB

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);
}
public void spottedBoat()
{
LeanTween.cancel(text.gameObject, false);
LeanTween.cancel(slider.gameObject, false);
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");
NotificationServer.notify("statechange Searchlight");
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;
}
}