// 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(); }
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(); }
// 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(); }
public static int ConvertToMillis(NanoTimers.Time time) { return((((time.minutes * 60) + time.seconds) * 1000) + time.millis); }