Ejemplo n.º 1
0
    public void ResetEventHandlers()
    {
        if (OnDayPassed != null)
        {
            foreach (System.Delegate del in OnDayPassed.GetInvocationList())
            {
                OnDayPassed -= (DayPassedEvent)del;
            }
        }

        if (OnWeekPassed != null)
        {
            foreach (System.Delegate del in OnWeekPassed.GetInvocationList())
            {
                OnWeekPassed -= (WeekPassedEvent)del;
            }
        }

        if (OnMonthPassed != null)
        {
            foreach (System.Delegate del in OnMonthPassed.GetInvocationList())
            {
                OnMonthPassed -= (MonthPassedEvent)del;
            }
        }

        if (OnYearPassed != null)
        {
            foreach (System.Delegate del in OnYearPassed.GetInvocationList())
            {
                OnYearPassed -= (YearPassedEvent)del;
            }
        }
    }
Ejemplo n.º 2
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);
     }
 }
Ejemplo n.º 3
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)));
                }
            }
        }