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.
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using UnityEngine.Events;
|
|
|
|
|
|
|
|
|
|
|
|
namespace uc
|
|
|
|
|
|
{
|
|
|
|
|
|
public class TimerActivity : Activity
|
|
|
|
|
|
{
|
|
|
|
|
|
[AutoUI]
|
|
|
|
|
|
public float timerDuration = 5.0f;
|
|
|
|
|
|
|
|
|
|
|
|
public float setstamp { set { timer_stamp = value; } }
|
|
|
|
|
|
|
|
|
|
|
|
public float timer_stamp = 0.0f;
|
|
|
|
|
|
|
|
|
|
|
|
public UnityEvent onTimesUp = new UnityEvent();
|
|
|
|
|
|
|
|
|
|
|
|
public float remainingTime { get { return Mathf.Clamp(timerDuration - (Time.time - timer_stamp), 0, timerDuration); } }
|
|
|
|
|
|
|
|
|
|
|
|
private void Start()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnEnter()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.OnEnter();
|
|
|
|
|
|
|
|
|
|
|
|
timer_stamp = Time.time;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnUpdate()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.OnUpdate();
|
|
|
|
|
|
|
|
|
|
|
|
if (IsEntering == false)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (IsFinished)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (Time.time - timer_stamp > timerDuration)
|
|
|
|
|
|
{
|
|
|
|
|
|
onTimesUp.Invoke();
|
|
|
|
|
|
IsFinished = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnLeave()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.OnLeave();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnKilled()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.OnKilled();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|