Beispiel #1
0
        private void IncrementClock()
        {
            CurrentTime.RealSeconds += Time.deltaTime;
            CurrentTime.Seconds      = (int)(CurrentTime.RealSeconds * SpeedFactor);
            if (CurrentTime.Seconds >= 60)
            {
                OnSecondTick?.Invoke();

                CurrentTime.RealSeconds = 0;
                CurrentTime.Minutes    += 1;
            }

            if (CurrentTime.Minutes >= 60)
            {
                CurrentTime.Minutes = 0;
                CurrentTime.Hours  += 1;
            }

            if (CurrentTime.Hours >= 24)
            {
                CurrentTime.Hours = 0;
            }

            CheckAlarms();
        }
Beispiel #2
0
        public void Tick()
        {
            OnTick?.Invoke();

            _secondTimer += Time.deltaTime;
            if (_secondTimer >= 1)
            {
                _secondTimer = 0;
                OnSecondTick?.Invoke();
            }

            _halfSecondTimer += Time.deltaTime;
            if (_halfSecondTimer >= 0.5f)
            {
                _halfSecondTimer = 0;
                OnHalfSecondTick?.Invoke();
            }
        }