2020-04-18 14:09:37 +00:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public abstract class MicrogameController : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
[BeforeStart]
|
|
|
|
|
public float startingTime = 4f;
|
|
|
|
|
public delegate void OnTimeLeftChangeHandler(float previous, float current);
|
|
|
|
|
public event OnTimeLeftChangeHandler OnTimeLeftChange;
|
|
|
|
|
private float timeLeft;
|
|
|
|
|
public float TimeLeft {
|
|
|
|
|
get {
|
|
|
|
|
return timeLeft;
|
|
|
|
|
}
|
|
|
|
|
set {
|
|
|
|
|
OnTimeLeftChange?.Invoke(TimeLeft, value);
|
|
|
|
|
timeLeft = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-18 17:02:22 +00:00
|
|
|
|
public float TimeFraction {
|
|
|
|
|
get {
|
|
|
|
|
return startingTime / timeLeft;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-18 14:09:37 +00:00
|
|
|
|
public abstract bool MicrogameResults();
|
|
|
|
|
|
|
|
|
|
private void Update() {
|
2020-04-18 17:02:22 +00:00
|
|
|
|
TimeLeft = Mathf.Clamp(TimeLeft - Time.deltaTime, 0, Mathf.Infinity);
|
2020-04-18 14:09:37 +00:00
|
|
|
|
}
|
|
|
|
|
}
|