示例#1
0
    /*Private methods*/

    private IEnumerator UpdateGameTime()
    {
        while (true)
        {
            yield return(new WaitForSeconds(TIME_UPDATE_FREQUENCY));

            //Next days occurs when time specified by
            //TIME_UPDATE_FREQUENCY passes
            DateTime newTime = CurrentTime.AddDays(1);

            ++DaysSinceStart;
            DayChanged?.Invoke();

            if (newTime.Month != CurrentTime.Month)
            {
                MonthChanged?.Invoke();
            }

            if (newTime.Year != CurrentTime.Year)
            {
                YearChanged?.Invoke();
            }

            CurrentTime = newTime;
        }
    }
示例#2
0
        private DateTimeService()
        {
            lastNow     = Now;
            tPeriodical = new AsyncTimerAction(TimeSpan.FromSeconds(1), () =>
            {
                now = Now;
                if (now.Minute != lastNow.Minute)
                {
                    tPeriodical.Interval = TimeSpan.FromMinutes(1);

                    MinuteChanged?.Invoke(this, now);

                    if (now.Hour != lastNow.Hour)
                    {
                        HourChanged?.Invoke(this, now);
                    }
                    if (now.Day != lastNow.Day)
                    {
                        DayChanged?.Invoke(this, now);
                    }
                    if (now.Month != lastNow.Month)
                    {
                        MonthChanged?.Invoke(this, now);
                    }
                    if (now.Year != lastNow.Year)
                    {
                        YearChanged?.Invoke(this, now);
                    }
                }

                lastNow = now;
            });
            tPeriodical.Start();
        }
        private void GameDateComponent_TimeChanged(GameDateComponent sender)
        {
            if (prevMinute != Minute)
            {
                prevMinute = Minute;
                if (MinuteChanged != null)
                {
                    MinuteChanged.Invoke(this);
                }
            }

            if (prevHour != Hour)
            {
                prevHour = Hour;
                if (HourChanged != null)
                {
                    HourChanged.Invoke(this);
                }
            }

            if (prevDay != Day)
            {
                prevDay = Day;
                if (DayChanged != null)
                {
                    DayChanged.Invoke(this);
                }
            }

            if (prevMonth != Month)
            {
                prevMonth = Month;
                if (MonthChanged != null)
                {
                    MonthChanged.Invoke(this);
                }
            }

            if (prevYear != Year)
            {
                prevYear = Year;
                if (YearChanged != null)
                {
                    YearChanged.Invoke(this);
                }
            }
        }
示例#4
0
 void FilmFiltersSet_SelectedValueChanged(object sender, SelectedValueChangedEventArgs e)
 {
     if (e.Source == this[GENRES_FILTER_NAME])
     {
         GenreChanged?.Invoke(this, new GenreChangedEventArgs(e));
     }
     else if (e.Source == this[YEARS_FILTER_NAME])
     {
         YearChanged?.Invoke(this, new YearChangedEventArgs(e));
     }
     else if (e.Source == this[RATINGS_FILTER_NAME])
     {
         RatingChanged?.Invoke(this, new RatingChangedEventArgs(e));
     }
     else if (e.Source == this[SELFRATINGS_FILTER_NAME])
     {
         SelfRatingChanged?.Invoke(this, new SelfRatingChangedEventArgs(e));
     }
 }