Exemplo n.º 1
0
        /// <summary>
        /// 以行业计算对政党的兴趣度
        /// </summary>
        /// <param name="workplaceId"></param>
        /// <returns></returns>
        private ushort GetFromSubService(ushort workplaceId)
        {
            //默认市民是没有工作的
            int choiceIndex = 0;

            //自定义行业:在政府工作
            if (RealCityResidentAI.IsGoverment(workplaceId))
            {
                choiceIndex = 1;
            }
            else
            {
                ItemClass workplaceItemClass = Singleton <BuildingManager> .instance
                                               .m_buildings.m_buffer[workplaceId].Info.m_class;
                //其他游戏内置行业
                switch (workplaceItemClass.m_subService)
                {
                case ItemClass.SubService.CommercialLow:
                case ItemClass.SubService.CommercialHigh:
                    if (workplaceItemClass.m_level == ItemClass.Level.Level1)
                    {
                        choiceIndex = 2;
                    }
                    else if (workplaceItemClass.m_level == ItemClass.Level.Level2)
                    {
                        choiceIndex = 3;
                    }
                    else if (workplaceItemClass.m_level == ItemClass.Level.Level3)
                    {
                        choiceIndex = 4;
                    }
                    break;

                case ItemClass.SubService.CommercialTourist:
                case ItemClass.SubService.CommercialLeisure:
                    choiceIndex = 5; break;

                case ItemClass.SubService.CommercialEco:
                    choiceIndex = 6; break;

                case ItemClass.SubService.IndustrialGeneric:
                    if (workplaceItemClass.m_level == ItemClass.Level.Level1)
                    {
                        choiceIndex = 7;
                    }
                    else if (workplaceItemClass.m_level == ItemClass.Level.Level2)
                    {
                        choiceIndex = 8;
                    }
                    else if (workplaceItemClass.m_level == ItemClass.Level.Level3)
                    {
                        choiceIndex = 9;
                    }
                    break;

                case ItemClass.SubService.IndustrialFarming:
                case ItemClass.SubService.IndustrialForestry:
                case ItemClass.SubService.IndustrialOil:
                case ItemClass.SubService.IndustrialOre:
                    choiceIndex = 10; break;

                case ItemClass.SubService.OfficeGeneric:
                    if (workplaceItemClass.m_level == ItemClass.Level.Level1)
                    {
                        choiceIndex = 11;
                    }
                    else if (workplaceItemClass.m_level == ItemClass.Level.Level2)
                    {
                        choiceIndex = 12;
                    }
                    else if (workplaceItemClass.m_level == ItemClass.Level.Level3)
                    {
                        choiceIndex = 13;
                    }
                    break;

                case ItemClass.SubService.OfficeHightech:
                    choiceIndex = 14; break;
                }
            }
            return(this.partyInterestData.SubService[choiceIndex]);
        }
        public static void GetVoteChance(uint citizenID, Citizen citizen, uint homeID)
        {
            if ((int)Citizen.GetAgeGroup(citizen.m_age) >= 2)
            {
                if (Politics.parliamentCount == 1)
                {
                    Politics.cPartyChance = 0;
                    Politics.gPartyChance = 0;
                    Politics.sPartyChance = 0;
                    Politics.lPartyChance = 0;
                    Politics.nPartyChance = 0;

                    Politics.cPartyChance += (ushort)(Politics.education[(int)citizen.EducationLevel, 0] << 1);
                    Politics.gPartyChance += (ushort)(Politics.education[(int)citizen.EducationLevel, 1] << 1);
                    Politics.sPartyChance += (ushort)(Politics.education[(int)citizen.EducationLevel, 2] << 1);
                    Politics.lPartyChance += (ushort)(Politics.education[(int)citizen.EducationLevel, 3] << 1);
                    Politics.nPartyChance += (ushort)(Politics.education[(int)citizen.EducationLevel, 4] << 1);

                    int idex = 14;
                    if (RealCityResidentAI.IsGoverment(citizen.m_workBuilding))
                    {
                        idex = 0;
                    }

                    switch (Singleton <BuildingManager> .instance.m_buildings.m_buffer[citizen.m_workBuilding].Info.m_class.m_subService)
                    {
                    case ItemClass.SubService.CommercialLow:
                    case ItemClass.SubService.CommercialHigh:
                        if (Singleton <BuildingManager> .instance.m_buildings.m_buffer[citizen.m_workBuilding].Info.m_class.m_level == ItemClass.Level.Level1)
                        {
                            idex = 1;
                        }
                        else if (Singleton <BuildingManager> .instance.m_buildings.m_buffer[citizen.m_workBuilding].Info.m_class.m_level == ItemClass.Level.Level2)
                        {
                            idex = 2;
                        }
                        else if (Singleton <BuildingManager> .instance.m_buildings.m_buffer[citizen.m_workBuilding].Info.m_class.m_level == ItemClass.Level.Level3)
                        {
                            idex = 3;
                        }
                        break;

                    case ItemClass.SubService.CommercialTourist:
                    case ItemClass.SubService.CommercialLeisure:
                        idex = 4; break;

                    case ItemClass.SubService.CommercialEco:
                        idex = 5; break;

                    case ItemClass.SubService.IndustrialGeneric:
                        if (Singleton <BuildingManager> .instance.m_buildings.m_buffer[citizen.m_workBuilding].Info.m_class.m_level == ItemClass.Level.Level1)
                        {
                            idex = 6;
                        }
                        else if (Singleton <BuildingManager> .instance.m_buildings.m_buffer[citizen.m_workBuilding].Info.m_class.m_level == ItemClass.Level.Level2)
                        {
                            idex = 7;
                        }
                        else if (Singleton <BuildingManager> .instance.m_buildings.m_buffer[citizen.m_workBuilding].Info.m_class.m_level == ItemClass.Level.Level3)
                        {
                            idex = 8;
                        }
                        break;

                    case ItemClass.SubService.IndustrialFarming:
                    case ItemClass.SubService.IndustrialForestry:
                    case ItemClass.SubService.IndustrialOil:
                    case ItemClass.SubService.IndustrialOre:
                        idex = 9; break;

                    case ItemClass.SubService.OfficeGeneric:
                        if (Singleton <BuildingManager> .instance.m_buildings.m_buffer[citizen.m_workBuilding].Info.m_class.m_level == ItemClass.Level.Level1)
                        {
                            idex = 10;
                        }
                        else if (Singleton <BuildingManager> .instance.m_buildings.m_buffer[citizen.m_workBuilding].Info.m_class.m_level == ItemClass.Level.Level2)
                        {
                            idex = 11;
                        }
                        else if (Singleton <BuildingManager> .instance.m_buildings.m_buffer[citizen.m_workBuilding].Info.m_class.m_level == ItemClass.Level.Level3)
                        {
                            idex = 12;
                        }
                        break;

                    case ItemClass.SubService.OfficeHightech:
                        idex = 13; break;
                    }

                    if (idex < 0 || idex > 14)
                    {
                        DebugLog.LogToFileOnly($"Error: GetVoteChance workplace idex {idex}");
                    }


                    Politics.cPartyChance += (ushort)(Politics.workplace[idex, 0] << 1);
                    Politics.gPartyChance += (ushort)(Politics.workplace[idex, 1] << 1);
                    Politics.sPartyChance += (ushort)(Politics.workplace[idex, 2] << 1);
                    Politics.lPartyChance += (ushort)(Politics.workplace[idex, 3] << 1);
                    Politics.nPartyChance += (ushort)(Politics.workplace[idex, 4] << 1);

                    if (CitizenUnitData.familyMoney[homeID] < 5000)
                    {
                        idex = 0;
                    }
                    else if (CitizenUnitData.familyMoney[homeID] >= 20000)
                    {
                        idex = 2;
                    }
                    else
                    {
                        idex = 1;
                    }

                    if (idex < 0 || idex > 3)
                    {
                        DebugLog.LogToFileOnly($"Error: GetVoteChance Invaid money idex = {idex}");
                    }
                    Politics.cPartyChance += (ushort)(Politics.money[idex, 0] << 1);
                    Politics.gPartyChance += (ushort)(Politics.money[idex, 1] << 1);
                    Politics.sPartyChance += (ushort)(Politics.money[idex, 2] << 1);
                    Politics.lPartyChance += (ushort)(Politics.money[idex, 3] << 1);
                    Politics.nPartyChance += (ushort)(Politics.money[idex, 4] << 1);

                    int temp = 0;

                    temp = (int)Citizen.GetAgeGroup(citizen.m_age) - 2;

                    if (temp < 0)
                    {
                        DebugLog.LogToFileOnly($"Error: GetVoteChance temp = {temp} < 0, GetAgeGroup = {Citizen.GetAgeGroup(citizen.m_age)}");
                    }

                    Politics.cPartyChance += Politics.age[temp, 0];
                    Politics.gPartyChance += Politics.age[temp, 1];
                    Politics.sPartyChance += Politics.age[temp, 2];
                    Politics.lPartyChance += Politics.age[temp, 3];
                    Politics.nPartyChance += Politics.age[temp, 4];

                    temp = (int)Citizen.GetGender(citizenID);


                    Politics.cPartyChance += Politics.gender[temp, 0];
                    Politics.gPartyChance += Politics.gender[temp, 1];
                    Politics.sPartyChance += Politics.gender[temp, 2];
                    Politics.lPartyChance += Politics.gender[temp, 3];
                    Politics.nPartyChance += Politics.gender[temp, 4];

                    if (RealCityEconomyExtension.partyTrend == 0)
                    {
                        Politics.cPartyChance += RealCityEconomyExtension.partyTrendStrength;
                    }
                    else if (RealCityEconomyExtension.partyTrend == 1)
                    {
                        Politics.gPartyChance += RealCityEconomyExtension.partyTrendStrength;
                    }
                    else if (RealCityEconomyExtension.partyTrend == 2)
                    {
                        Politics.sPartyChance += RealCityEconomyExtension.partyTrendStrength;
                    }
                    else if (RealCityEconomyExtension.partyTrend == 3)
                    {
                        Politics.lPartyChance += RealCityEconomyExtension.partyTrendStrength;
                    }
                    else if (RealCityEconomyExtension.partyTrend == 4)
                    {
                        Politics.nPartyChance += RealCityEconomyExtension.partyTrendStrength;
                    }
                    else
                    {
                        DebugLog.LogToFileOnly($"Error: GetVoteChance Invalid partyTrend = {RealCityEconomyExtension.partyTrend}");
                    }

                    GetVoteTickets();
                }
            }
        }