public override bool Equals(object obj) { // See the full list of guidelines at // http://go.microsoft.com/fwlink/?LinkID=85237 // and also the guidance for operator== at // http://go.microsoft.com/fwlink/?LinkId=85238 if (obj == null || GetType() != obj.GetType()) { var exc = new System.SystemException("Warning, don't compare a struct to 'null' !!!"); UnityEngine.Debug.LogException(exc); throw exc; //return !isInitialized; } else { TimeStruct castedObj = (TimeStruct)obj; if (!isInitialized || !castedObj.isInitialized) { var exc = new System.SystemException("One of the TimeStructs is not initialized"); UnityEngine.Debug.LogException(exc); throw exc; } return(day == castedObj.day && hour == castedObj.hour && minute == castedObj.minute); } }
private void BaseConstructor(TimeStruct initialTime) { minuteTimer = new Clock(); timeObserver = new ObservedValue <TimeStruct>(initialTime); minuteTimer.Reset(60f); minuteTimer.OnClockExpired += () => { timeObserver.Value += TimeStruct.OneMinute; minuteTimer.Reset(60f); }; }
public static int Compare(TimeStruct time1, TimeStruct time2) { if (time1 == time2) { return(0); } else if (time1 > time2) { return(1); } else { return(-1); } }
public static TimeStruct operator +(TimeStruct time1, TimeStruct time2) { if (!time1.isInitialized || !time2.isInitialized) { var exc = new System.SystemException("One of the TimeStructs is not initialized"); UnityEngine.Debug.LogException(exc); throw exc; } TimeStruct res = new TimeStruct( time1.day + time2.day, time1.hour + time2.hour, time1.minute + time2.minute); return(res); }
public TimeClock(TimeStruct initialTime) { BaseConstructor(initialTime); }
public void Update(float realSecondsRatio, float deltaTime) { previousTimeValue = timeObserver.Value; minuteTimer.Update(realSecondsRatio * deltaTime); }
public bool HasClockAlreadyPassed(TimeStruct time) { return(timeValue >= time); }
public bool HasClockJustPassed(TimeStruct time) { return(timeValue >= time && previousTimeValue < time); }