Пример #1
0
 private void OnTimerFinish()
 {
     if (TimerFinished != null)
     {
         TimerFinished.Invoke(_groupMember, new EventArgs());
     }
 }
Пример #2
0
 /*
  * Desc: Updates the timer
  * Keeps track of how many seconds have passed
  * Updates the LevelTimerUI display by calling its UpdateDisplay() method
  * Triggers the TimerFinished event if the timer has run out of time -- Stops the timer
  */
 private void UpdateTimer()
 {
     _secondsSinceStart++;                                                                                            // Update the display every second
     _levelTimerUI.UpdateDisplay(_secondsSinceStart);
     if (_secondsSinceStart != LevelTimeInSeconds)
     {
         return;
     }
     TimerFinished?.Invoke();
     StopTimer();
 }
        private void OnTimerElapsed(object sender, ElapsedEventArgs e)
        {
            _timeSinceStart += TimerInterval;

            if (_timeSinceStart >= Period)
            {
                _timeSinceStart = 0;
                TimerFinished?.Invoke(this, e);
            }

            DrawProgress();
        }
Пример #4
0
 // Update is called once per frame
 void Update()
 {
     if (running)
     {
         time -= Time.deltaTime;
         if (time <= 0)
         {
             time = 0;
             TimerFinished?.Invoke();
         }
         Display();
     }
 }
Пример #5
0
        public void Update()
        {
            if (!isActive)
            {
                return;
            }

            if (Time.time >= startTime + duration)
            {
                TimerFinished?.Invoke();
                if (!isRepeatitive)
                {
                    Stop();
                }
                Reset();
            }
        }
Пример #6
0
        /// <summary>
        ///     Start the <see langword="timer" />
        /// </summary>
        public void Start()
        {
            if (IsBusy)
            {
                throw new InvalidOperationException("Unable to start timer: it is already running");
            }
            IsBusy           = true;
            RemainingSeconds = Seconds;
            TimerStarted?.Invoke(this);
            for (var i = 0; i < Seconds; i++)
            {
                RemainingSeconds = Seconds - i - 1;
                Thread.Sleep(1000);
                TimerTick?.Invoke(this);
            }

            TimerFinished?.Invoke(this);
            IsBusy = false;
        }
Пример #7
0
        /// <inheritdoc />
        public void Update(GameTime gameTime)
        {
            if (!_enabled)
            {
                return;
            }

            _elapsedTime += gameTime.DeltaTimeMS;
            if (_elapsedTime >= TimerTick)
            {
                _elapsedTime -= TimerTick;
                TimerTicked?.Invoke(this);

                if (_maxIterations > 0 && ++CurrentIteration >= _maxIterations)
                {
                    _enabled = false;
                    TimerFinished?.Invoke(this);
                }
            }
        }
Пример #8
0
    void Update()
    {
        if (_running)
        {
            _elapsedSeconds += Time.deltaTime;

            if (EventTickSeconds > 0f)
            {
                _eventTickAcc += Time.deltaTime;
                if (_eventTickAcc >= EventTickSeconds)
                {
                    _eventTickAcc -= EventTickSeconds;
                    TimerTick?.Invoke(TimedModifier);
                }
            }

            if (_elapsedSeconds >= _totalSeconds)
            {
                _running = false;
                TimerFinished?.Invoke(TimedModifier, this);
            }
        }
    }
Пример #9
0
    //the coroutine thats actually run
    private IEnumerator StartCountdownCoroutine(float startValue, float waitForDelay, float countDownBy, TimerElapsedCallback t, TimerFinished tf)
    {
        Debug.Log("StartCountdownCoroutine");

        //stopwatch to track time elapsed
        System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

        while (startValue > 0)
        {
            sw.Start();

            yield return(new WaitForSeconds(waitForDelay));

            //update 'time-remaining'
            startValue -= countDownBy;

            sw.Stop();

            //callback for interval
            t?.Invoke(sw.ElapsedMilliseconds);
        }

        //callback for end of timer
        tf?.Invoke();

        Debug.Log("Timer finished " + sw.ElapsedMilliseconds);
    }
Пример #10
0
 //start timer with full customisable
 public void StartTimer(float startValue, float waitForDelay, float countDownBy, TimerElapsedCallback t, TimerFinished tf)
 {
     Debug.Log("StartTimer2");
     coroutine = StartCoroutine(StartCountdownCoroutine(startValue, waitForDelay, countDownBy, t, tf));
 }
Пример #11
0
 //start timer for seconds with default parameters
 public void StartTimer(float delayInSeconds, TimerElapsedCallback t, TimerFinished tf)
 {
     Debug.Log("StartTimer");
     coroutine = StartCoroutine(StartCountdownCoroutine(delayInSeconds, delayInSeconds, delayInSeconds, t, tf));
 }
Пример #12
0
 /// <summary>
 /// Establece la funcion que sera llamada al acabarse el tiempo
 /// </summary>
 /// <param name="method">Funcion a llamar</param>
 public void SetMethod(TimerFinished method)
 {
     timerFinished_ = method;
 }
Пример #13
0
 public void AddTimerFinishedListener(TimerFinished timerFinished)
 {
     timerFinishedListeners += timerFinished;
 }
 protected virtual void OnTimerFinished(object sender, TimerFinishedEventArgs e)
 {
     TimerFinished?.Invoke(sender, e);
 }
Пример #15
0
 private void Start()
 {
     this.timerFinished = new TimerFinished();
     AddTimerFinishedListener(Hello);
 }
Пример #16
0
 // restablece la variable que indica la funcion a llamar
 private void OnDestroy()
 {
     timerFinished_ = null;
 }
Пример #17
0
 private void MyTimerOnTimerFinished()
 {
     TimerFinished?.Invoke(this, InitialNumberSeconds);
 }