Exemple #1
0
        // Summary:
        // Subtracts time from the timer.
        //
        // Remarks:
        // Timer get arounded into minutes when seconds become less than 0.
        // Does not subtract milliseconds.
        public void SubTime(NanoTimers.Time time)
        {
            if (m_state == ETimerState.Expired)
            {
                return;
            }

            int minutes = m_minutes - time.minutes;
            int seconds = m_seconds - time.seconds;
            int millis  = m_millis - time.millis;

            while (millis < 0)
            {
                millis  += 1000;
                seconds -= 1;
            }

            while (seconds < 0)
            {
                seconds += 60;
                minutes -= 1;
            }

            m_minutes = minutes;
            m_seconds = seconds;
            m_millis  = millis;

            UpdateUI();
        }
Exemple #2
0
 public void Initialize(NanoTimers.Time time, Action callback)
 {
     m_minutes = time.minutes;
     m_seconds = time.seconds;
     m_millis  = time.millis;
     m_state   = ETimerState.New;
     m_originTimeState.minutes = time.minutes;
     m_originTimeState.seconds = time.seconds;
     m_originTimeState.millis  = time.millis;
     m_callback      = callback;
     m_isInitialized = true;
     UpdateUI();
 }
Exemple #3
0
        // Summary:
        // Sets the timer's time to this specific amount.
        //
        // Remarks:
        // Milliseconds roll over into seconds and seconds roll over into minutes.
        public void SetTime(NanoTimers.Time time)
        {
            int minutes = time.minutes;
            int seconds = time.seconds;
            int millis  = time.millis;

            while (millis >= 1000)
            {
                millis  -= 1000;
                seconds += 1;
            }

            while (seconds >= 60)
            {
                seconds -= 60;
                minutes += 1;
            }

            m_minutes = minutes;
            m_seconds = seconds;
            m_millis  = millis;

            UpdateUI();
        }
Exemple #4
0
 public static int ConvertToMillis(NanoTimers.Time time)
 {
     return((((time.minutes * 60) + time.seconds) * 1000) + time.millis);
 }