示例#1
0
        protected override bool Run(SimDescription me, bool singleSelection)
        {
            List <Opportunity> allOpportunities = OpportunityEx.GetAllOpportunities(me.CreatedSim, OpportunityCategory.None);

            if (allOpportunities.Count == 0)
            {
                SimpleMessageDialog.Show(Name, Common.Localize("Opportunity:None"));
                return(false);
            }

            List <Item> allOptions = new List <Item>();

            foreach (Opportunity item in allOpportunities)
            {
                string name = item.Name;
                if (item.IsCareer)
                {
                    name = Common.LocalizeEAString("Ui/Caption/HUD/CareerPanel:Career") + ": " + name;
                }

                allOptions.Add(new Item(item, me.CreatedSim, name, allOpportunities));
            }

            Item selection = new CommonSelection <Item>(Name, allOptions, new CompletedColumn()).SelectSingle();

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

            return(OpportunityEx.Perform(me, selection.Value.Guid));
        }
示例#2
0
        protected override bool Run(SimDescription me, bool singleSelection)
        {
            List <Opportunity> allOpportunities = OpportunityEx.GetAllOpportunities(me.CreatedSim, OpportunityCategory.None);

            if (allOpportunities.Count == 0)
            {
                SimpleMessageDialog.Show(Name, Common.Localize("Opportunity:None"));
                return(false);
            }

            return(OpportunityEx.Perform(me, RandomUtil.GetRandomObjectFromList(allOpportunities).Guid));
        }
示例#3
0
            public bool Run(SimDescription me)
            {
                List <SelectOpportunity.Item> allOptions = new List <SelectOpportunity.Item>();

                foreach (Opportunity item in Value)
                {
                    allOptions.Add(new SelectOpportunity.Item(item, me.CreatedSim, item.Name, Value));
                }

                SelectOpportunity.Item selection = new CommonSelection <SelectOpportunity.Item>(mName, allOptions, new SelectOpportunity.CompletedColumn()).SelectSingle();
                if (selection == null)
                {
                    return(false);
                }

                return(OpportunityEx.Perform(me, selection.Value.Guid));
            }
示例#4
0
 public OpportunityEx(OpportunityEx obj)
     : base(obj.SharedData)
 { }
示例#5
0
        protected override bool Run(SimDescription me, bool singleSelection)
        {
            List <Opportunity> allOpportunities = OpportunityEx.GetAllOpportunities(me.CreatedSim, OpportunityCategory.None);

            if (allOpportunities.Count == 0)
            {
                SimpleMessageDialog.Show(Name, Common.Localize("Opportunity:None"));
                return(false);
            }

            Dictionary <string, Item> lookup = new Dictionary <string, Item>();

            string all = "(" + Common.LocalizeEAString("Ui/Caption/ObjectPicker:All") + ")";

            foreach (Opportunity opp in allOpportunities)
            {
                string name = null;
                switch (opp.OpportunityCategory)
                {
                case OpportunityCategory.Career:
                    name = Common.LocalizeEAString("Ui/Caption/HUD/CareerPanel:Career");
                    break;

                case OpportunityCategory.Special:
                    name = Common.Localize("Opportunity:Celebrity");
                    break;

                case OpportunityCategory.AdventureChina:
                case OpportunityCategory.AdventureEgypt:
                case OpportunityCategory.AdventureFrance:
                    name = Common.Localize("Opportunity:Adventure");
                    break;

                case OpportunityCategory.Dare:
                case OpportunityCategory.DayJob:
                case OpportunityCategory.SocialGroup:
                    name = Common.LocalizeEAString("Gameplay/Objects/PostBoxJobBoard:" + opp.OpportunityCategory);
                    break;

                case OpportunityCategory.Skill:
                    bool found = false;

                    foreach (Opportunity.OpportunitySharedData.RequirementInfo info in opp.SharedData.mRequirementList)
                    {
                        if (info.mType == RequirementType.Skill)
                        {
                            SkillNames guid = (SkillNames)info.mGuid;

                            Skill staticSkill = SkillManager.GetStaticSkill(guid);
                            if (staticSkill.NonPersistableData != null)
                            {
                                name  = Common.LocalizeEAString(staticSkill.NonPersistableData.Name);
                                found = true;
                            }

                            if (found)
                            {
                                break;
                            }
                        }
                    }

                    if (opp is GigOpportunity)
                    {
                        Common.DebugNotify(opp.Name);

                        Occupation band = CareerManager.GetStaticOccupation(OccupationNames.RockBand);
                        if (band != null)
                        {
                            name = band.CareerName;
                        }
                    }
                    break;
                }

                if (string.IsNullOrEmpty(name))
                {
                    name = Common.Localize("Opportunity:Generic");
                }

                Item item;
                if (!lookup.TryGetValue(name, out item))
                {
                    item = new Item(name);
                    lookup.Add(name, item);
                }

                item.Add(opp);

                if (!lookup.TryGetValue(all, out item))
                {
                    item = new Item(all);
                    lookup.Add(all, item);
                }

                item.Add(opp);
            }

            Item choice = new CommonSelection <Item>(Name, me.FullName, lookup.Values).SelectSingle();

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

            return(choice.Run(me));
        }
示例#6
0
        public override bool Run()
        {
            try
            {
                if (!Target.RouteToCone(Actor))
                {
                    return(false);
                }

                StandardEntry();

                try
                {
                    BeginCommodityUpdates();
                    if (((Target.mJobSelectionDay.Ticks == 0x0L) || (SimClock.CurrentDayOfWeek != Target.mJobSelectionDay.DayOfWeek)) || (SimClock.ElapsedTime(TimeUnit.Days, Target.mJobSelectionDay) >= 1f))
                    {
                        Target.mAvailableJobs.Clear();
                        Target.mTakenJobs.Clear();
                        Target.mJobSelectionDay = SimClock.CurrentTime();
                        Target.StartTimer();
                    }

                    if (GameUtils.IsUniversityWorld())
                    {
                        EnterStateMachine("JobBoard", "Enter", "x");
                        SetActor("jobBoard", Target);
                        AnimateSim("Exit");
                    }
                    else
                    {
                        Actor.PlaySoloAnimation("a2o_postBoxJobBoard_checkBoard_x", true);
                    }

                    EndCommodityUpdates(true);

                    Definition definition = InteractionDefinition as Definition;

                    Tutorialette.TriggerLesson(Lessons.QuestTracker, Actor);
                    if (Autonomous || !UIUtils.IsOkayToStartModalDialog())
                    {
                        Actor.Wander(kMinWanderDistance, kMaxWanderDistance, false, RouteDistancePreference.NoPreference, false);
                    }
                    else
                    {
                        OpportunityNames choice = OpportunityNames.Undefined;
                        if (Target.mTakenJobs.Count >= kOpportunitiesPerDay)
                        {
                            string msg = "JobBoardEmptyTNS";
                            if (GameUtils.IsUniversityWorld())
                            {
                                msg = "JobBoardEmptyTNSEP9";
                            }

                            Actor.ShowTNSIfSelectable(LocalizeString(Actor.IsFemale, msg, new object[0x0]), StyledNotification.NotificationStyle.kSimTalking);
                        }
                        else
                        {
                            if ((Target.mAvailableJobs.Count + Target.mTakenJobs.Count) < kOpportunitiesPerDay)
                            {
                                List <Opportunity> opportunities = OpportunityEx.GetAllOpportunities(Actor, definition.mOppName);

                                List <float> weights = new List <float>();
                                foreach (Opportunity opp in opportunities)
                                {
                                    float num = Actor.SimDescription.OpportunityHistory.HasRejectedOpportunity(opp.Guid) ? OpportunityHistory.kUserRejectedOpportunityWeightMultiplier : 1f;
                                    weights.Add(opp.ChanceToGetOnPhone * num);
                                }

                                Opportunity opportunity = null;
                                while (opportunities.Count > 0)
                                {
                                    int index = RandomUtil.GetWeightedIndex(weights.ToArray());

                                    opportunity = opportunities[index];

                                    weights.RemoveAt(index);
                                    opportunities.RemoveAt(index);

                                    if (!Target.mAvailableJobs.Contains(opportunity.Guid))
                                    {
                                        Target.mAvailableJobs.Add(opportunity.Guid);
                                        Target.mIndexOfLastChosen = Target.mAvailableJobs.Count - 0x1;

                                        if (!OpportunityEx.Perform(Actor.SimDescription, opportunity.Guid))
                                        {
                                            return(false);
                                        }

                                        choice = opportunity.Guid;
                                        break;
                                    }
                                }

                                if (choice == OpportunityNames.Undefined)
                                {
                                    Actor.ShowTNSIfSelectable(LocalizeString(Actor.IsFemale, "NoValidOppsTNS", new object[] { Actor }), StyledNotification.NotificationStyle.kGameMessagePositive, Target.ObjectId, Actor.ObjectId);
                                    return(false);
                                }
                            }
                            else
                            {
                                choice = OpportunityNames.Undefined;
                                int count = Target.mAvailableJobs.Count;
                                if (count > 0x0)
                                {
                                    int num2 = (Target.mIndexOfLastChosen + 0x1) % count;
                                    for (int i = 0x0; i < Target.mAvailableJobs.Count; i++)
                                    {
                                        int num4 = (i + num2) % count;
                                        OpportunityNames names3 = Target.mAvailableJobs[num4];
                                        if ((Actor.OpportunityManager.IsOpportunityAvailable(names3)) && (Actor.OpportunityManager.IsOpportunityCategory(names3, definition.mOppName)))
                                        {
                                            choice = names3;
                                            Target.mIndexOfLastChosen = num4;
                                            break;
                                        }
                                    }
                                }

                                if (choice != OpportunityNames.Undefined)
                                {
                                    if (!OpportunityEx.Perform(Actor.SimDescription, choice))
                                    {
                                        return(false);
                                    }
                                }
                                else
                                {
                                    Actor.ShowTNSIfSelectable(LocalizeString(Actor.IsFemale, "NoValidOppsTNS", new object[] { Actor }), StyledNotification.NotificationStyle.kGameMessagePositive, Target.ObjectId, Actor.ObjectId);
                                }
                            }

                            if (choice != OpportunityNames.Undefined)
                            {
                                Target.mIndexOfLastChosen = 0x0;
                                Target.mAvailableJobs.Remove(choice);
                                Target.mTakenJobs.Add(choice);
                                if (Target.mTakenJobs.Count >= kOpportunitiesPerDay)
                                {
                                    Target.StopHelperEffect();
                                }
                            }
                        }
                    }
                }
                finally
                {
                    StandardExit();
                }

                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }