public Clock() { this._maxTime = 0; this._elapsedTime = 0.0f; this._state = TimerStates.Stopped; }
IEnumerator HandleTimer() { while (isGameRunning) { switch (timerStates) { case TimerStates.Play: //Reduce the time and fire once at or below 0 then reset time -= Time.deltaTime; if (time <= 0.0f) { EventManager.CallTimerAction(Vector3.zero); time = timer; } break; case TimerStates.Pause: //Timer is paused nothing happens break; case TimerStates.Reset: //Reset the time to timer then Play the timer; time = timer; timerStates = TimerStates.Play; break; } yield return(null); } }
// Methods public Clock(float maxTime) { this._maxTime = maxTime; this._elapsedTime = 0.0f; this._state = TimerStates.Stopped; }
public void Resume() { if (_timerState == TimerStates.Off) { return; } _timerState = TimerStates.On; }
private void MoveToNextTimer() { _currentSubTimerIndex--; if (_currentSubTimerIndex >= 0) { _currentSubTimer = _subTimerBackgrounds[_currentSubTimerIndex].GetComponent <Image>(); _remainingTime = _timerSeconds; _currentSubTimerState = TimerStates.Normal; } }
public void ON() { if (_timerState == TimerStates.On) { return; } _timerState = TimerStates.On; CurrentTime = 0; }
////////////////////////////////////////// /// Update() ////////////////////////////////////////// protected virtual void Update() { if (!ShouldUpdate()) return; m_fTime -= Time.deltaTime; if (m_fTime <= 0) { m_eState = TimerStates.Done; Messenger.Broadcast("TimerDone"); } }
public void StartTimer(float secondsPerPuddle) { _currentSubTimerIndex = _subTimerBackgrounds.Length - 1; _currentSubTimer = _subTimerBackgrounds[_currentSubTimerIndex].GetComponent <Image>(); _timerSeconds = secondsPerPuddle; _remainingTime = _timerSeconds; _currentSubTimerState = TimerStates.Normal; SetSubTimersColor(Color.green); _completedMilestones = 0; _started = true; }
// Update is called once per frame void Update() { if (timerState != TimerStates.Active) { return; } CallTime -= Time.deltaTime; if (CallTime < 0) { onElapsed.BeginInvoke(null, null); timerState = TimerStates.Ended; } }
public void CompleteMilestone() { _completedMilestones++; SetSubTimersColor(Color.green); _currentSubTimerState = TimerStates.Normal; if (_completedMilestones == _targetWaterCount) { LevelManager.Instance.SetUpLevelCompletion(); } else { _timerBars[_timerBars.Length - _completedMilestones].SetActive(false); } }
////////////////////////////////////////// /// Update() ////////////////////////////////////////// protected virtual void Update() { if (!ShouldUpdate()) { return; } m_fTime -= Time.deltaTime; if (m_fTime <= 0) { m_eState = TimerStates.Done; Messenger.Broadcast("TimerDone"); } }
void Update() { if (_started) { _remainingTime -= Time.deltaTime; if (_remainingTime < 0) { _remainingTime = 0; } _currentSubTimer.fillAmount = _remainingTime / _timerSeconds; if (_remainingTime > 0 && (!IsCurrentMilestoneAchieved() || _currentSubTimerIndex == 0)) { const float remainingSecondsWarning = 0.4f; const float remainingSecondsDanger = 0.2f; if (_currentSubTimerState == TimerStates.Normal && _currentSubTimer.fillAmount <= remainingSecondsWarning) { _currentSubTimerState = TimerStates.Warning; SetSubTimersColor(Color.yellow); } else if (_currentSubTimerState == TimerStates.Warning && _currentSubTimer.fillAmount <= remainingSecondsDanger) { _currentSubTimerState = TimerStates.Danger; SetSubTimersColor(Color.red); } } else if (_remainingTime <= 0) { if (IsCurrentMilestoneAchieved() && _currentSubTimerIndex != 0) { MoveToNextTimer(); } else { StopTimer(); LevelManager.Instance.FailLevel(); } } } }
public void StopTimer() { timerState = TimerStates.Stopped; }
public void StartTimer() { timerState = TimerStates.Active; }
public void Stop() { this._state = TimerStates.Stopped; this._elapsedTime = 0.0f; }
public void Start() { this._state = TimerStates.Started; }
public void Pause() { _timerState = TimerStates.Paused; }
public void OFF() { _timerState = TimerStates.Off; }
public void Update(float deltaTime) { if (_state == TimerStates.Started) { if (_elapsedTime < _maxTime) { _elapsedTime += deltaTime; } if (_elapsedTime > _maxTime) { _elapsedTime = _maxTime; this._state = TimerStates.Expired; } } }
////////////////////////////////////////// /// Init() ////////////////////////////////////////// public virtual void Init(float i_fTime) { m_fTime = i_fTime; m_eState = TimerStates.Ticking; }
public void Pause() { this._state = TimerStates.Paused; }
////////////////////////////////////////// /// Init() ////////////////////////////////////////// public virtual void Init( float i_fTime ) { m_fTime = i_fTime; m_eState = TimerStates.Ticking; }