using UnityEngine;
using System;
using System.Collections;
using UnityEngine.PlayerLoop;
[CreateAssetMenu(fileName = "NightManager", menuName = "Custom/NightManager")]
public class NightManager : ScriptableObject {
public int TotalHours;
public int Hour;
public bool HasPower;
public float Power;
public float TotalPower;
public float BasePowerDrainModifier;
public float AddedPowerDrainModifier;
public float RealTimeSecondsPerHour;
public float RealTimeSecondsPerPowerTick;
public event Action GameOver;
public event Action<int> HourChange;
public event Action<float> PowerChange;
// Starts the Night timer
public IEnumerator RunGame() {
Power = 100;
while (Power < TotalPower) {
HasPower = true;
yield return null;
PowerChange(Power);
}
Hour = 0;
while (Hour < TotalHours) {
yield return new WaitForSeconds(RealTimeSecondsPerHour);
++Hour;
HourChange(Hour);
}
GameOver();
}
}