예제 #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
파일: Tempest.cs 프로젝트: yakoder/NRaas
        public static int GetCurrentSeasonDay()
        {
            if (!SeasonsManager.Enabled)
            {
                return(0);
            }

            DateAndTime currentTime = SimClock.Subtract(SimClock.CurrentTime(), TimeUnit.Hours, SimClock.CurrentTime().Hour);

            // Number of remaining days
            int num = ((int)SimClock.ElapsedTime(TimeUnit.Days, currentTime, SeasonsManager.ExpectedEndTime));

            return((int)SeasonsManager.GetSeasonLength(SeasonsManager.CurrentSeason) - num);
        }
예제 #3
0
        protected static bool BumpUp(SimDescription a, SimDescription b, bool prompt, bool romantic)
        {
            Relationship relation = Relationship.Get(a, b, true);

            if (relation == null)
            {
                return(false);
            }

            LongTermRelationshipTypes currentState = relation.LTR.CurrentLTR;

            LongTermRelationshipTypes nextState = LongTermRelationshipTypes.Undefined;

            if (romantic)
            {
                nextState = NextPositiveRomanceState(currentState);
            }
            else
            {
                nextState = NextPositiveFriendState(currentState);
            }

            if (nextState == LongTermRelationshipTypes.Undefined)
            {
                if (prompt)
                {
                    SimpleMessageDialog.Show(Common.Localize("Romance:BumpUpTitle"), Common.Localize("Romance:TooHigh"));
                }
                return(false);
            }

            /*
             * if (relation.LTR.RelationshipIsInappropriate(LTRData.Get(nextState)))
             * {
             *  if (prompt)
             *  {
             *      SimpleMessageDialog.Show(Common.Localize("Romance:BumpUpTitle"), Common.Localize ("Romance:Improper", new object[] { Common.LocalizeStatus (a, b, nextState) }));
             *  }
             *  return false;
             * }
             */

            if ((romantic) && (a.Genealogy.IsBloodRelated(b.Genealogy)))
            {
                if ((prompt) && (!AcceptCancelDialog.Show(Common.Localize("Romance:BloodPrompt", a.IsFemale, new object [] { a, b }))))
                {
                    return(false);
                }
            }

            if ((currentState == LongTermRelationshipTypes.RomanticInterest) && (romantic))
            {
                if ((a.Partner != null) && (a.Partner != b))
                {
                    if ((b.Partner != null) && (b.Partner != a))
                    {
                        if ((prompt) && (!AcceptCancelDialog.Show(Common.Localize("Romance:DualPartnerPrompt", a.IsFemale, new object[] { a, b }))))
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        if ((prompt) && (!AcceptCancelDialog.Show(Common.Localize("Romance:PartnerPrompt", a.IsFemale, new object[] { a }))))
                        {
                            return(false);
                        }
                    }
                }
                else if ((b.Partner != null) && (b.Partner != a))
                {
                    if ((prompt) && (!AcceptCancelDialog.Show(Common.Localize("Romance:PartnerPrompt", b.IsFemale, new object[] { b }))))
                    {
                        return(false);
                    }
                }

                if (a.Partner != null)
                {
                    BumpDown(a, a.Partner, false, true);
                }

                if (b.Partner != null)
                {
                    BumpDown(b, b.Partner, false, true);
                }

                if (a.TraitManager == null)
                {
                    a.Fixup();
                }

                if (b.TraitManager == null)
                {
                    b.Fixup();
                }

                Relationships.SetPartner(a, b);
            }

            ForceChangeState(relation, nextState);

            if (romantic)
            {
                if (prompt && relation.RomanceVisibilityState != null)
                {
                    long time = 0;
                    relation.TryGetActiveRomanceStartTime(out time);

                    int days = 0;
                    if (time != 0)
                    {
                        days = (int)SimClock.ElapsedTime(TimeUnit.Days, new DateAndTime(time));
                    }

                    string text = StringInputDialog.Show(Common.Localize("Romance:StartTime"), Common.Localize("Romance:StartPrompt", a.IsFemale, new object[] { a, b, SimClock.ElapsedCalendarDays() }), days.ToString());
                    if (string.IsNullOrEmpty(text))
                    {
                        return(false);
                    }

                    int mValue = 0;
                    if (!int.TryParse(text, out mValue) || mValue > SimClock.ElapsedCalendarDays())
                    {
                        SimpleMessageDialog.Show(Common.Localize("Romance:StartTime"), Common.Localize("Numeric:ErrorInputIgnored"));
                    }
                    else
                    {
                        relation.RomanceVisibilityState.mStartTime = SimClock.Subtract(SimClock.CurrentTime(), TimeUnit.Days, (float)mValue);
                    }
                }
            }

            if (relation.LTR.CurrentLTR == LongTermRelationshipTypes.BestFriendsForever)
            {
                bool isPetBFF = ((!a.IsHuman) || (!b.IsHuman));

                a.HasBFF = true;
                b.HasBFF = true;
                FindAndRemoveBFF(a, b, isPetBFF);
                FindAndRemoveBFF(b, a, isPetBFF);
            }

            if (currentState == relation.LTR.CurrentLTR)
            {
                return(false);
            }

            StyledNotification.Format format = new StyledNotification.Format(Common.Localize("Romance:Success", a.IsFemale, new object[] { a, b, LocalizeStatus(a, b, relation.LTR.CurrentLTR) }), StyledNotification.NotificationStyle.kGameMessagePositive);
            format.mTNSCategory = NotificationManager.TNSCategory.Lessons;
            StyledNotification.Show(format);
            return(true);
        }
예제 #4
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            List <CareerLocation> schools = GetPotentials();

            if (schools.Count == 0)
            {
                IncStat("No Choice");
                return(false);
            }
            else
            {
                if ((Sim.CareerManager.School != null) &&
                    (schools.Contains(Sim.CareerManager.School.CareerLoc)))
                {
                    IncStat("Already Has");
                    return(false);
                }

                CareerLocation location = RandomUtil.GetRandomObjectFromList(schools);

                if ((Sim.CareerManager.School != null) &&
                    (location == Sim.CareerManager.School.CareerLoc))
                {
                    IncStat("Same");
                    return(false);
                }
                else
                {
                    Occupation job        = Sim.Occupation;
                    Occupation retiredJob = Sim.CareerManager.mRetiredCareer;

                    Sim.CareerManager.mJob           = null;
                    Sim.CareerManager.mRetiredCareer = null;

                    try
                    {
                        if (Sim.AcquireOccupation(new AcquireOccupationParameters(location, false, false)))
                        {
                            School school = Sim.CareerManager.School;
                            if (school != null)
                            {
                                school.mWhenCurLevelStarted = SimClock.Subtract(school.mWhenCurLevelStarted, TimeUnit.Days, 1);
                            }

                            return(true);
                        }
                        else
                        {
                            IncStat("Core Failure");
                            return(false);
                        }
                    }
                    catch (Exception e)
                    {
                        Common.DebugException(Sim, e);

                        IncStat("Exception Failure");
                        return(false);
                    }
                    finally
                    {
                        Sim.CareerManager.mJob           = job;
                        Sim.CareerManager.mRetiredCareer = retiredJob;
                    }
                }
            }
        }