Beispiel #1
0
 private void Tick(DateTime curTick, DateTime lTick)
 {
     try {
         OnSecondPassed?.Invoke(curTick, lTick);
         if (MinutePassed(curTick, lTick))
         {
             OnMinutePassed?.Invoke(curTick, lTick);
         }
         if (HourPassed(curTick, lTick))
         {
             OnHourPassed?.Invoke(curTick, lTick);
         }
         if (DayPassed(curTick, lTick))
         {
             OnDayPassed?.Invoke(curTick, lTick);
         }
         if (MonthPassed(curTick, lTick))
         {
             OnMonthPassed?.Invoke(curTick, lTick);
         }
         if (YearPassed(curTick, lTick))
         {
             OnYearPassed?.Invoke(curTick, lTick);
         }
     } catch (Exception exc) {
         ExceptionCaught?.Invoke(exc);
     }
 }
Beispiel #2
0
        private IEnumerator ManageWeeklyTimer()
        {
            while (weeklyTimer)
            {
                while (currentSeconds < secondsBetweenWeeks)
                {
                    timeSlider.maxValue = secondsBetweenWeeks;
                    currentSeconds     += Time.fixedDeltaTime;

                    float percentage = currentSeconds / timeSlider.maxValue;
                    timeSlider.value = Mathf.Lerp(0, secondsBetweenWeeks, percentage);
                    yield return(new WaitForSeconds(1f / (float)Math.Pow(10, 10)));
                }

                if (currentSeconds >= secondsBetweenWeeks)
                {
                    currentWeek++;
                    OnWeekPassed?.Invoke();

                    if (currentWeek > 4)
                    {
                        currentMonthIndex++;
                        currentWeek = 1;

                        OnMonthPassed?.Invoke();
                    }

                    if (currentMonthIndex > 11)
                    {
                        currentYear++;
                        currentMonthIndex = 0;
                        currentWeek       = 1;

                        OnYearPassed?.Invoke();
                    }

                    timePassedText.text = string.Format("Week 0{0}, {1} {2}", currentWeek, arrayOfMonths[currentMonthIndex], currentYear);
                    currentSeconds      = 0f;
                    yield return(new WaitForSeconds(1f / (float)Math.Pow(10, 10)));
                }
            }
        }