/// <summary> /// Start the timer from a specific time /// </summary> /// <param name="startTime">The time the timer will start at</param> public virtual void Start(System.TimeSpan startTime) { timerState = TimerState.Running; currentTime = startTime; if (timerCoroutine == null && !shuttingDown) { timerCoroutine = TimerCoroutineManager.Instance.StartCoroutine(CoroutineTime()); } }
/// <summary> /// Update the timer every frame if the timer is running /// This function should be called in an update function /// </summary> protected virtual void UpdateTime() { if (timerState != TimerState.Running) { return; } currentTime = currentTime.val.Add(System.TimeSpan.FromSeconds(Time.deltaTime)); timerUpdateEvent?.Invoke(); }
/// <summary> /// Create a new time split /// </summary> /// <param name="start">The time the split started</param> /// <param name="finish">The time the split finished</param> public TimerSplit(System.TimeSpan start, System.TimeSpan finish) { splitTime = finish - start; splitStart = start; splitFinish = finish; }
set => SetValue(TimeSpanProperty, value);
/// <summary> /// Reset the timer to the time that is was started at /// </summary> public virtual void Reset() { currentTime = new System.TimeSpan(0); timerUpdateEvent?.Invoke(); }
/// <summary> /// Time overloaded constructor /// </summary> public Timer(System.TimeSpan time) { currentTime = time; }
/// <summary> /// Manual overloaded constructor /// </summary> public Timer(int days = 0, int hours = 0, int minutes = 0, int seconds = 0, int milliseconds = 0) { currentTime = new System.TimeSpan(days, hours, minutes, seconds, milliseconds); }
/// <summary> /// Default constructor /// </summary> public Timer() { currentTime = new System.TimeSpan(0); }
/// <summary> /// Sets the <see cref="TimeSpanValue"/>. /// </summary> /// <param name="index">The index of the <see cref="TimeSpanProperty"/>.</param> public virtual void SetTimeSpanValue(int index) { TimeSpanValue = EnumExtensions.GetByIndex <TimeSpanProperty>(index); }