示例#1
0
        protected static void LoadCareerEvents(Career career, BooterHelper.BootFile eventsFile, XmlDbTable eventDataTable)
        {
            if (eventDataTable == null)
            {
                return;
            }

            BooterLogger.AddTrace(eventsFile + ": Found " + career.Name + " Events = " + eventDataTable.Rows.Count);

            foreach (XmlDbRow row in eventDataTable.Rows)
            {
                ProductVersion version;
                row.TryGetEnum <ProductVersion>("ProductVersion", out version, ProductVersion.BaseGame);

                if (GameUtils.IsInstalled(version))
                {
                    string str3 = row.GetString("EventName");
                    string str4 = row.GetString("OpportunityName");
                    bool   flag = row.GetInt("SureShotEvent") == 1;

                    Type classType;
                    if ((str4 != string.Empty) && (str3 == string.Empty))
                    {
                        classType = typeof(Career.EventOpportunity);
                    }
                    else
                    {
                        classType = row.GetClassType("EventName");
                    }

                    Type[] types = new Type[] { typeof(XmlDbRow), typeof(Dictionary <string, Dictionary <int, CareerLevel> >), typeof(string) };
                    object obj   = null;

                    try
                    {
                        obj = classType.GetConstructor(types).Invoke(new object[] { row, career.SharedData.CareerLevels, eventDataTable.Name });
                    }
                    catch (Exception e)
                    {
                        BooterLogger.AddError(eventsFile + ": Constructor Fail " + row.GetString("EventName"));

                        Common.Exception(eventsFile + ": Constructor Fail " + row.GetString("EventName"), e);
                    }

                    if (obj == null)
                    {
                        BooterLogger.AddError(eventsFile + ": Bad Class " + row.GetString("EventName"));
                    }
                    else
                    {
                        Career.EventOpportunity opportunityEvent = obj as Career.EventOpportunity;

                        // new Code
                        if ((opportunityEvent != null) && (opportunityEvent.mOpportunity == OpportunityNames.Undefined))
                        {
                            opportunityEvent.mOpportunity = unchecked ((OpportunityNames)ResourceUtils.HashString64(str4));
                        }

                        Career.EventDaily dailyEvent = obj as Career.EventDaily;
                        if (dailyEvent != null)
                        {
                            if (dailyEvent.AvailableLevels(career).Count == 0)
                            {
                                BooterLogger.AddError(eventsFile + ": No AvailableLevels " + row.GetString("EventType"));
                            }
                            else
                            {
                                // new Code
                                if (dailyEvent.mEventType == Career.CareerEventType.None)
                                {
                                    dailyEvent.mEventType = unchecked ((Career.CareerEventType)ResourceUtils.HashString64(row.GetString("EventType")));
                                }

                                if (career.SharedData == null)
                                {
                                    BooterLogger.AddError(eventsFile + ": Career SharedData missing " + career.mCareerGuid);
                                }
                                else
                                {
                                    if (flag)
                                    {
                                        career.SharedData.SureShotEvent = dailyEvent;
                                    }
                                    else
                                    {
                                        career.SharedData.CareerEventList.Add(dailyEvent);

                                        try
                                        {
                                            CareerEventManager.sAllEvents.Add(dailyEvent.EventType, dailyEvent);
                                        }
                                        catch
                                        {
                                            BooterLogger.AddError(eventsFile + ": Duplicate Event " + row.GetString("EventType"));
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            BooterLogger.AddError(eventsFile + ": Not EventDaily " + row.GetString("EventType"));
                        }
                    }
                }
            }
        }
示例#2
0
        protected static List <Opportunity> GetAllOpportunities(Sim sim)
        {
            List <Opportunity> allOpportunities = new List <Opportunity>();

            Dictionary <OpportunityNames, Opportunity> opportunityList = null;

            if (GameUtils.GetCurrentWorld() == WorldName.Egypt)
            {
                opportunityList = OpportunityManager.sAdventureEgyptOpportunityList;
            }
            else if (GameUtils.GetCurrentWorld() == WorldName.China)
            {
                opportunityList = OpportunityManager.sAdventureChinaOpportunityList;
            }
            else if (GameUtils.GetCurrentWorld() == WorldName.France)
            {
                opportunityList = OpportunityManager.sAdventureFranceOpportunityList;
            }
            else
            {
                opportunityList = OpportunityManager.sSkillOpportunityList;
            }

            if (opportunityList == null)
            {
                opportunityList = new Dictionary <OpportunityNames, Opportunity>();
            }

            foreach (Opportunity opp in OpportunityManager.sCareerPhoneCallOpportunityList.Values)
            {
                if (opportunityList.ContainsKey(opp.Guid))
                {
                    continue;
                }

                opportunityList.Add(opp.Guid, opp);
            }

            if (opportunityList != null)
            {
                foreach (Opportunity opportunity in opportunityList.Values)
                {
                    if (opportunity.IsAvailable(sim))
                    {
                        allOpportunities.Add(opportunity);
                    }
                }
            }

            CareerManager manager = sim.CareerManager;

            if (manager != null)
            {
                for (int i = 0; i < 2; i++)
                {
                    Career career = manager.Occupation as Career;
                    if (i == 1)
                    {
                        career = manager.School;
                    }

                    if (career != null)
                    {
                        foreach (Career.EventDaily daily in career.CareerEventList)
                        {
                            Career.EventOpportunity oppEvent = daily as Career.EventOpportunity;
                            if (oppEvent == null)
                            {
                                continue;
                            }

                            if (oppEvent.IsAvailable(career))
                            {
                                Opportunity opportunity = null;
                                GenericManager <OpportunityNames, Opportunity, Opportunity> .sDictionary.TryGetValue((ulong)oppEvent.mOpportunity, out opportunity);

                                if (opportunity != null)
                                {
                                    allOpportunities.Add(opportunity);
                                }
                            }
                        }
                    }
                }
            }

            List <Opportunity> allPotentials = new List <Opportunity>();

            foreach (Opportunity opportunity in allOpportunities)
            {
                try
                {
                    if (opportunity.IsCareer)
                    {
                        if (sim.OpportunityManager.HasOpportunity(OpportunityCategory.Career))
                        {
                            continue;
                        }
                    }
                    else if (opportunity.IsSkill)
                    {
                        if (sim.OpportunityManager.HasOpportunity(OpportunityCategory.Skill))
                        {
                            continue;
                        }
                    }

                    Opportunity toAdd = opportunity.Clone();
                    toAdd.Actor = sim;

                    if (!sim.OpportunityManager.SetupTargets(toAdd))
                    {
                        continue;
                    }
                    toAdd.SetLocalizationIndex();

                    string name = toAdd.Name;

                    allPotentials.Add(toAdd);
                }
                catch (Exception e)
                {
                    Exception(e);
                }
            }

            return(allPotentials);
        }