using System.Collections; using System.Collections.Generic; using UnityEngine; using SiegeSong; namespace SiegeSong { public class Calendar : MonoBehaviour { public int Minute; public int Hour; public int Day; public int WeekDay; public int Month; public int Year; private int daysInWeek = 7; private int daysInMonth = 28; public void SetDateTime(Calendar newDateTime) { EnviroSky.instance.SetTime(newDateTime.Year, newDateTime.Day, newDateTime.Hour, newDateTime.Minute, 0); } public void SetDateTime(int minute, int hour, int day, int year) { EnviroSky.instance.SetTime(year, day, hour, minute, 0); } // Logic to be executed at the start of every hour public void HourlyUpdate() { if (EnviroSky.instance.GameTime.Hours < Hour) DailyUpdate(); Hour = EnviroSky.instance.GameTime.Hours; } // Logic to be executed at the start of every day public void DailyUpdate() { Day = EnviroSky.instance.GameTime.Days; if (WeekDay < daysInWeek) WeekDay++; else WeekDay = 0; if (Day % daysInMonth == 0) Month++; if (Year != EnviroSky.instance.GameTime.Years) YearlyUpdate(); } // Logic to be executed at the start of every year public void YearlyUpdate() { Month = 0; Year = EnviroSky.instance.GameTime.Years; } void Start() { } void Update() { Minute = EnviroSky.instance.GameTime.Minutes; if (EnviroSky.instance.GameTime.Hours != Hour) HourlyUpdate(); } } }