Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
        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);
            };
        }
Beispiel #3
0
 public static int Compare(TimeStruct time1, TimeStruct time2)
 {
     if (time1 == time2)
     {
         return(0);
     }
     else if (time1 > time2)
     {
         return(1);
     }
     else
     {
         return(-1);
     }
 }
Beispiel #4
0
        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);
        }
Beispiel #5
0
 public TimeClock(TimeStruct initialTime)
 {
     BaseConstructor(initialTime);
 }
Beispiel #6
0
 public void Update(float realSecondsRatio, float deltaTime)
 {
     previousTimeValue = timeObserver.Value;
     minuteTimer.Update(realSecondsRatio * deltaTime);
 }
Beispiel #7
0
 public bool HasClockAlreadyPassed(TimeStruct time)
 {
     return(timeValue >= time);
 }
Beispiel #8
0
 public bool HasClockJustPassed(TimeStruct time)
 {
     return(timeValue >= time && previousTimeValue < time);
 }