Пример #1
0
        public override string MetricDescription(Career career)
        {
            ProSports sports = OmniCareer.Career <ProSports>(career);

            if (sports != null)
            {
                return(OmniCareer.LocalizeString(career.OwnerDescription, "DescriptionWinLossRecord", "Gameplay/Careers/Metrics:DescriptionWinLossRecord", new object[] { sports.GamesTillSeasonEnds, sports.GamesWon, sports.GamesLost, sports.GamesWonTotal, sports.GamesLostTotal }));
            }
            return("");
        }
Пример #2
0
        public override float FindMetricValue(Career career)
        {
            ProSports sports = OmniCareer.Career <ProSports>(career);

            if (sports != null)
            {
                return((float)(sports.mWinRecord - sports.mLossRecord));
            }
            return(0f);
        }
Пример #3
0
        // Methods
        public override void OnTimePassed(InteractionInstance interactionInstance, float totalTime, float deltaTime)
        {
            base.OnTimePassed(interactionInstance, totalTime, deltaTime);

            ProSports career = OmniCareer.Career <ProSports>(base.Career);

            if ((career != null) && (career.CurLevel != null))
            {
                career.mPreparationForGame = Math.Min((float)100f, (float)(career.mPreparationForGame + ((deltaTime * ProSports.PrepareForGame.kPrepareForGamePerSimHour) / 60f)));
                this.OnProgressChanged(this);
            }
        }
Пример #4
0
        // Methods
        public override bool BeforeEnteringRabbitHole()
        {
            ProSports job = OmniCareer.Career <ProSports>(Actor.Occupation);

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

            if (!job.IsAllowedToWork() && job.IsAllowedToWorkThisTime(ProSports.kGameStartTime, ProSports.kGameLength))
            {
                return(job.WaitForWork(Actor, Target));
            }
            return(true);
        }
Пример #5
0
            public override bool Test(Sim a, RabbitHole target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                GreyedOutTooltipCallback callback = null;

                if (!(a.Occupation is OmniCareer))
                {
                    return(false);
                }

                ProSports job = OmniCareer.Career <ProSports>(a.Occupation);

                RabbitHole hole = target;

                if (job != null)
                {
                    CareerLocation location;
                    if (!hole.CareerLocations.TryGetValue((ulong)job.Guid, out location) || (job.CareerLoc != location))
                    {
                        return(false);
                    }
                    bool flag = job.IsAllowedToWorkThisTime(ProSports.kGameStartTime, ProSports.kGameLength);
                    if (!job.SpecialWorkDay || !job.HasWinLossRecordMetric())
                    {
                        return(false);
                    }
                    if (flag && !job.IsDayOff)
                    {
                        return(true);
                    }
                    if (callback == null)
                    {
                        callback = delegate
                        {
                            int num = ProSports.DaysUntilNextGame();
                            if (num == 0)
                            {
                                return(PlayGame.LocalizeString(a.SimDescription, "GameGreyedTooltip", new object[] { SimClockUtils.GetText(ProSports.kGameStartTime) }));
                            }
                            return(PlayGame.LocalizeString(a.SimDescription, "GameGreyedTooltipFuture", new object[] { SimClockUtils.GetText(ProSports.kGameStartTime), num }));
                        };
                    }
                    greyedOutTooltipCallback = callback;
                }
                return(false);
            }
Пример #6
0
        public static Sim FamilyMemberOfSportsPlayer(Sim a, bool mustBeOmniCareer)
        {
            foreach (Sim sim in a.Household.Sims)
            {
                if (!(sim.Occupation is OmniCareer))
                {
                    if (mustBeOmniCareer)
                    {
                        continue;
                    }
                }

                ProSports job = OmniCareer.Career <ProSports>(sim.Occupation);

                if ((job != null) && (job.HasWinLossRecordMetric()))
                {
                    return(sim);
                }
            }
            return(null);
        }
Пример #7
0
        public override bool InRabbitHole()
        {
            try
            {
                bool succeeded = false;
                BeginCommodityUpdates();

                try
                {
                    ProSports career = OmniCareer.Career <ProSports>(Actor.OccupationAsCareer);

                    if (career.IsAllowedToWork())
                    {
                        career.StartWorking();
                        career.StartGame();
                        succeeded = DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached), new Interaction <Sim, RabbitHole> .InsideLoopFunction(GameLoop), null);
                        career.FinishWorking();
                        if (!succeeded)
                        {
                            career.mActorLeftGame = true;
                        }
                        if (!succeeded)
                        {
                            EventTracker.SendEvent(EventTypeId.kWorkCanceled, Actor);
                        }
                    }
                }
                finally
                {
                    EndCommodityUpdates(succeeded);
                }

                return(succeeded);
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
Пример #8
0
            public override bool Test(Sim a, Stadium target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                if (!(a.Occupation is OmniCareer))
                {
                    if (FamilyMemberOfSportsPlayer(a, true) == null)
                    {
                        return(false);
                    }
                }

                GreyedOutTooltipCallback callback = null;

                if ((!isAutonomous || !a.IsSelectable) || (AutonomyRestrictions.GetLevel() >= AutonomyLevel.Max))
                {
                    ProSports job = OmniCareer.Career <ProSports>(a.Occupation);
                    if (((job != null) && job.HasWinLossRecordMetric()) && !job.IsDayOff)
                    {
                        return(false);
                    }
                    bool hasMoney = FamilyMemberOfSportsPlayer(a, false) != null;
                    if (!hasMoney)
                    {
                        hasMoney = a.FamilyFunds >= Stadium.AttendGame.kCostToAttendGame;
                    }
                    if (target.mGameForced)
                    {
                        return(true);
                    }

                    Journalism journalism = OmniCareer.Career <Journalism>(a.Occupation);

                    if ((ProSports.IsTodayGameDay() && SimClock.IsTimeBetweenTimes(SimClock.HoursPassedOfDay, ProSports.GameStartTime - Stadium.AttendGame.kDoorsOpenTime, ProSports.GameStartTime + Stadium.AttendGame.kDoorsCloseTime)) && (hasMoney && ((journalism == null) || !journalism.BadReviewWrittenOnRabbitHole(target))))
                    {
                        return(true);
                    }
                    if (callback == null)
                    {
                        callback = delegate
                        {
                            if ((journalism != null) && journalism.BadReviewWrittenOnRabbitHole(target))
                            {
                                return(LocalizeString(a.SimDescription, "NotWelcomeFromBadReview", new object[0x0]));
                            }
                            if (!ProSports.IsTodayGameDay() || !SimClock.IsTimeBetweenTimes(SimClock.HoursPassedOfDay, ProSports.GameStartTime, ProSports.GameEndTime))
                            {
                                int num = ProSports.DaysUntilNextGame();
                                if (num == 0x0)
                                {
                                    return(LocalizeString(a.SimDescription, "DoorsOpenTodayTooltip", new object[] { SimClockUtils.GetText(ProSports.GameStartTime) }));
                                }
                                return(LocalizeString(a.SimDescription, "DoorsOpenLaterTooltip", new object[] { num, SimClockUtils.GetText(ProSports.GameStartTime) }));
                            }
                            if (!hasMoney)
                            {
                                return(LocalizeString(a.SimDescription, "NeedMoneyTooltip", new object[0x0]));
                            }
                            return(LocalizeString(a.SimDescription, "DoorsClosedTooltip", new object[0x0]));
                        };
                    }
                    greyedOutTooltipCallback = callback;
                }
                return(false);
            }
Пример #9
0
        public override void OnTimePassed(InteractionInstance interactionInstance, float totalTime, float deltaTime)
        {
            try
            {
                foreach (MetricRate rate in mMetrics)
                {
                    float hoursElapsed = SimClock.ElapsedTime(TimeUnit.Hours) - rate.mStartTime;

                    if (hoursElapsed < rate.mHoursUntilChange)
                    {
                        continue;
                    }

                    rate.mStartTime = SimClock.ElapsedTime(TimeUnit.Hours);

                    switch (rate.mMetric)
                    {
                    case MetricRate.MetricType.ConcertsPerformed:
                        Music music = OmniCareer.Career <Music>(Career);
                        if (music != null)
                        {
                            music.ConcertsPerformed += rate.mRate;
                        }
                        break;

                    case MetricRate.MetricType.Journals:
                        OmniCareer journals = Career as OmniCareer;
                        if (journals != null)
                        {
                            journals.FinishedJournal();
                        }
                        break;

                    case MetricRate.MetricType.Recruitment:
                        OmniCareer recruit = Career as OmniCareer;
                        if (recruit != null)
                        {
                            recruit.AddToRecruits();
                        }
                        break;

                    case MetricRate.MetricType.Reports:
                        LawEnforcement law = OmniCareer.Career <LawEnforcement>(Career);
                        if (law != null)
                        {
                            law.ReportsCompltetedToday += rate.mRate;
                        }
                        break;

                    case MetricRate.MetricType.StoriesAndReviews:
                        Journalism journalism = OmniCareer.Career <Journalism>(Career);
                        if (journalism != null)
                        {
                            journalism.StoriesWrittenToday += rate.mRate;
                        }
                        break;

                    case MetricRate.MetricType.WinLossRecord:
                        ProSports proSports = OmniCareer.Career <ProSports>(Career);
                        if (proSports != null)
                        {
                            if (rate.mRate > 0)
                            {
                                proSports.mWinRecord += rate.mRate;
                                proSports.mTotalWins += rate.mRate;
                            }
                            else
                            {
                                proSports.mLossRecord -= rate.mRate;
                                proSports.mTotalLoss  -= rate.mRate;
                            }
                        }
                        break;

                    case MetricRate.MetricType.MeetingsHeld:
                        Business business = OmniCareer.Career <Business>(Career);
                        if (business != null)
                        {
                            business.MeetingsHeldToday += rate.mRate;
                        }
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                Common.Exception(Career.OwnerDescription, e);
            }
        }