/// <summary>
    /// Update is called once per frame
    /// </summary>
    void Update()
    {
        // Update timer and check for finished
        if (running)
        {
            elapsedSeconds += Time.deltaTime;

            if (isUsingTick) // unused in RoGC
            {
                // check for new countdown value
                int newCountdownValue = GetCurrentCountdownValue();
                if (newCountdownValue != previousCountdownValue)
                {
                    previousCountdownValue = newCountdownValue;
                    tickEvent.Invoke(previousCountdownValue);
                }
            }

            // check for timer finished
            if (elapsedSeconds >= totalSeconds)
            {
                running = false;
                finishEvent.Invoke();
            }
        }

        // if this was a retry attempt, disable a retry on the next frame.
        if (retry)
        {
            finishEvent.Invoke(); retry = false;
        }
    }
Beispiel #2
0
        private void OnFinished()
        {
            PomodoroState complatedState = PomodoroStatus.PomodoroState;

            TimerFinishedEvent?.Invoke(this, new PomodoroChangedEventArgs(complatedState));

            if (complatedState == PomodoroState.Pomodoro)
            {
                FinishedWitoutSessionBreak++;
                if (FinishedWitoutSessionBreak == PomodoroSettings.SessionPomodoroCount)
                {
                    StartSessionBreak();
                }
                else
                {
                    StartBreak();
                }
            }
            else if (complatedState == PomodoroState.PomodoroBreak || complatedState == PomodoroState.SessionBreak)
            {
                if (PomodoroSettings.AutoContinue)
                {
                    StartPomodoro();
                }
            }
            else
            {
                WaitForStart();
            }
        }
Beispiel #3
0
    public static void UpdateTimer(Timer timer, TimerFinishedEvent timerEvents)
    {
        var previousTime = timer.time;

        timer.time += Time.deltaTime;
        if (previousTime < timer.duration && timer.time >= timer.duration)
        {
            timerEvents.Invoke(timer);
        }
    }
    void Update()
    {
        if (running)
        {
            elapsedSeconds += Time.deltaTime;

            if (elapsedSeconds >= totalSeconds)
            {
                running = false;
                timerFinishedEvent.Invoke();
            }
        }
    }
Beispiel #5
0
 /// <summary>
 /// Update is called once per frame
 /// </summary>
 void Update()
 {
     // update timer and check for finished
     if (running)
     {
         elapsedSeconds += Time.deltaTime;
         if (elapsedSeconds >= totalSeconds)
         {
             running = false;
             _timerFinishedEvent.Invoke();
         }
     }
 }
Beispiel #6
0
 /// <summary>
 /// Update is called once per frame
 /// </summary>
 void Update()
 {
     // update timer and check for finished
     if (running)
     {
         elapsedSeconds += Time.deltaTime;
         if (elapsedSeconds >= totalSeconds)
         {
             running = false;
             timerFinishedEvent.Invoke(0);                 //0 is a useless parameter that allow us to call all listeners as UnityEvents<int>
         }
     }
 }
Beispiel #7
0
 /// <summary>
 /// Update is called once per frame
 /// </summary>
 void Update()
 {
     // update timer and check for finished
     if (running)
     {
         leftTime        = (int)Mathf.Ceil(totalSeconds - elapsedSeconds);
         elapsedSeconds += Time.deltaTime;
         if (elapsedSeconds >= totalSeconds)
         {
             running  = false;
             leftTime = 0;
             timerFinishedEvent.Invoke();
         }
     }
 }
        private void OnTimerFinished(object sender, PomodoroChangedEventArgs eventArgs)
        {
            TimerFinishedEvent?.Invoke(
                this,
                eventArgs
                );
            if (IsNotificationEnable)
            {
                NotificationService.SetFinisedInfo(eventArgs.ComplatedState);
            }

            if (eventArgs.ComplatedState == PomodoroState.Pomodoro)
            {
                OnPomodoroFinished();
            }
            else
            {
                OnBreakFinished();
            }
        }
Beispiel #9
0
    /// <summary>
    /// Update is called once per frame
    /// </summary>
    void Update()
    {
        // update timer
        if (running)
        {
            elapsedSeconds += Time.deltaTime;

            // check for new countdown value
            int newCountdownValue = GetCurrentCountdownValue();
            if (newCountdownValue != previousCountdownValue)
            {
                previousCountdownValue = newCountdownValue;
            }

            // check for timer finished
            if (elapsedSeconds >= totalSeconds)
            {
                running = false;
                timerFinishedEvent.Invoke();
            }
        }
    }
        private void OnFinished()
        {
            Logger.Log("Finished\n\n");
            PomodoroState complatedState = PomodoroStatus.PomodoroState;

            TimerFinishedEvent?.Invoke(this, new PomodoroChangedEventArgs(complatedState));

            switch (complatedState)
            {
            case PomodoroState.Pomodoro:
                FinishedWitoutSessionBreak++;
                if (FinishedWitoutSessionBreak == PomodoroSettings.SessionPomodoroCount)
                {
                    StartSessionBreak();
                }
                else
                {
                    StartBreak();
                }
                break;

            case PomodoroState.PomodoroBreak:
            case PomodoroState.SessionBreak:
                if (PomodoroSettings.AutoContinue)
                {
                    StartPomodoro();
                }
                else
                {
                    WaitForStart();
                }
                break;

            default:
                WaitForStart();
                break;
            }
        }
 private void TimerFinished()
 {
     timerActive = false;
     TimerFinishedEvent?.Invoke();
 }