Esempio n. 1
0
 public void StartTimer()
 {
     _timer.Stop();
     Elapsed = TimeSpan.Zero;
     OnTimerChanged?.Invoke();
     _timer.Start();
 }
Esempio n. 2
0
 public void Tick(float deltaTime)
 {
     if (_counter > 0)
     {
         _counter -= deltaTime;
         OnTimerChanged?.Invoke(_counter);
     }
 }
Esempio n. 3
0
    public virtual void UpdateTimer(float timer)
    {
        OnTimerChangedEventArgs args = new OnTimerChangedEventArgs()
        {
            NewTime = timer
        };

        OnTimerChanged.Invoke(this, args);
    }
Esempio n. 4
0
        private void OnTimerOnElapsed(object o, ElapsedEventArgs e)
        {
            if (_isPaused)
            {
                return;
            }

            Elapsed += TimeSpan.FromSeconds(1);
            OnTimerChanged?.Invoke();
        }
Esempio n. 5
0
        /// <returns>Is attempt of fire successfull</returns>
        public bool TryFire()
        {
            if (!IsReloaded)
            {
                return(false);
            }

            _rocketsFactory.CreateRocket(RocketType, _transform.position, _transform.forward);
            _counter = _reloadingTime;
            OnTimerChanged?.Invoke(_counter);
            return(true);
        }
        void IOnUpdate.Do(float deltaTime)
        {
            if (!isGameStarted || isTimeStoped)
            {
                return;
            }

            DayTimeLeft -= deltaTime;

            foreach (var it in OnTimerChanged.Enumerate())
            {
                it.Do();
            }

            if (DayTimeLeft <= 0)
            {
                EndDay();
            }
        }
Esempio n. 7
0
 public static void TimerUpdated(object sender, ChangeEventArgs e)
 {
     OnTimerChanged?.Invoke(sender, e);
 }
Esempio n. 8
0
 public void SetTimer(float seconds)
 {
     OnTimerChanged?.Invoke(seconds);
 }