using UnityEngine;
using System;
using System.Collections;
using UnityEngine.PlayerLoop;
[CreateAssetMenu(fileName = "NightSettings" , menuName = "Custom/NightMan")]
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 GameLose;
public event Action GameWin;
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);
}
GameWin();
}
}