示例#1
0
        private static void CalculateDateTimeOfHoliday(HolidayManager ths, ref Season season)
        {
            DateAndTime startTime = SimClock.Subtract(SimClock.CurrentTime(), TimeUnit.Hours, SimClock.CurrentTime().Hour);

            startTime = SimClock.Subtract(startTime, TimeUnit.Days, Tempest.GetCurrentSeasonDay() - 1);

            List <Pair <Season, uint> > days = new List <Pair <Season, uint> >();

            HolidaySettings settings = Tempest.Settings.GetHolidays(season);

            Common.StringBuilder result = new Common.StringBuilder("Season: " + season);

            result += Common.NewLine + "CurrentTime: " + SimClock.CurrentTime();
            result += Common.NewLine + "StartTime: " + startTime;
            result += Common.NewLine + "ExpectedEndTime: " + SeasonsManager.ExpectedEndTime;
            result += Common.NewLine + "GetCurrentSeasonDay: " + Tempest.GetCurrentSeasonDay();
            result += Common.NewLine + SimClock.ElapsedTime(TimeUnit.Days, startTime);

            foreach (HolidaySettings.Holiday day in settings.Days)
            {
                uint actualDay = day.GetActualDay(season);
                if (actualDay == 0)
                {
                    continue;
                }

                days.Add(new Pair <Season, uint>(day.mSeason, actualDay - 1));
            }

            days.Sort(SortByDay);

            foreach (Pair <Season, uint> day in days)
            {
                ths.mStartDateTimeOfHoliday = SimClock.Add(startTime, TimeUnit.Days, day.Second);

                result += Common.NewLine + "Days: " + day.Second + " Time: " + ths.mStartDateTimeOfHoliday;

                if (ths.mStartDateTimeOfHoliday.Ticks < SimClock.CurrentTicks)
                {
                    ths.mStartDateTimeOfHoliday = DateAndTime.Invalid;
                }
                else
                {
                    result += Common.NewLine + " Success";

                    season = day.First;
                    break;
                }
            }

            Common.DebugNotify(result);
        }
示例#2
0
        public HolidaySettings GetHolidays(Season season)
        {
            HolidaySettings settings;
            if (!mHolidaySettings.TryGetValue(season, out settings))
            {
                settings = new HolidaySettings(season);
                mHolidaySettings.Add(season, settings);
            }

            return settings;
        }