using UnityEngine; // using UniTask; namespace BrewMonster.Scripts { public class CECSunMoon : MonoSingleton { private const float TIME_SCALE = 6f; private const float NIGHT_DAY_START = (3.0f / 24.0f); private const float NIGHT_SUN_RISE_MIN = (4.0f / 24.0f); private const float NIGHT_DAY_END = (7.0f / 24.0f); private const float DAY_NIGHT_START = (18.0f / 24.0f); private const float DAY_SUN_SET_MAX = (19.5f / 24.0f); private const float DAY_NIGHT_END = (21.0f / 24.0f); public double m_vTimeOfTheDay; // time of the day 0.0f means 00:00, 1.0f means 24:00 public float m_fDNFactor; // day or night factor public float m_fDNFactorDest; // day or night factor dest protected override void Initialize() { base.Initialize(); // keep this alive when scene is loaded DontDestroyOnLoad(gameObject); } public void Update() { m_vTimeOfTheDay += Time.deltaTime / 3600.0 / 24.0 * TIME_SCALE; while( m_vTimeOfTheDay > 1.0 ) m_vTimeOfTheDay -= 1.0; } } }