mirror of
https://github.com/Steffo99/keep-everything-alive.git
synced 2024-11-26 03:04:18 +00:00
33 lines
830 B
C#
33 lines
830 B
C#
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;
|
|
}
|
|
}
|
|
|
|
public float TimeFraction {
|
|
get {
|
|
return startingTime / timeLeft;
|
|
}
|
|
}
|
|
|
|
public abstract bool MicrogameResults();
|
|
|
|
private void Update() {
|
|
TimeLeft = Mathf.Clamp(TimeLeft - Time.deltaTime, 0, Mathf.Infinity);
|
|
}
|
|
}
|