float totalSeconds; // The total seconds the timer will run

    #endregion Fields

    #region Constructors

    /// <summary>
    /// Constructor
    /// </summary>
    /// <param name="seconds">the seconds for the timer</param>
    public Timer(float seconds)
    {
        // Sets the time and creates the finish event
        totalSeconds = seconds;
        elapsedSeconds = seconds;
        timerFinishedEvent = new TimerFinishedEvent();
    }
示例#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();
            }
        }
示例#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);
        }
    }
示例#4
0
        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();
            }
        }
        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();
 }
示例#7
0
 void Awake()
 {
     timerFinishedEvent = new TimerFinishedEvent();
     timerStartEvent    = new TimerStartEvent();
 }