コード例 #1
0
        void ICountdownService.Next()
        {
            if (-1 == infoPtr)
            {
                return;
            }

            switch (currentInfo.Status)
            {
            case CountdownInfoStatus.NotStart:
                infoPtr     = (infoPtr + countdownInfos.Count + 1) % countdownInfos.Count;
                CurrentInfo = countdownInfos[infoPtr];

                TickEvent?.Invoke(CurrentInfo);
                return;

            case CountdownInfoStatus.Running:
                base.Stop();
                currentInfo.Minute     = 0;
                currentInfo.Second     = 0;
                currentInfo.FinishTime = DateTime.Now;
                currentInfo.Status     = CountdownInfoStatus.Completed;

                TickEvent?.Invoke(CurrentInfo);
                ReachEndEvent?.Invoke(CurrentInfo);
                return;

            case CountdownInfoStatus.Paused:
                base.Stop();
                currentInfo.Minute     = 0;
                currentInfo.Second     = 0;
                currentInfo.FinishTime = DateTime.Now;
                currentInfo.InterruptionInfos.Last().FinishTime = DateTime.Now;
                currentInfo.Status = CountdownInfoStatus.Completed;

                TickEvent?.Invoke(CurrentInfo);
                ReachEndEvent?.Invoke(CurrentInfo);
                return;

            case CountdownInfoStatus.Completed:
                infoPtr     = (infoPtr + countdownInfos.Count + 1) % countdownInfos.Count;
                CurrentInfo = countdownInfos[infoPtr];

                TickEvent?.Invoke(CurrentInfo);
                return;

            default:
                return;
            }
        }
コード例 #2
0
 public override void OnDisable()
 {
     OnReachBeginning = null;
     OnReachEnd       = null;
     base.OnDisable();
 }