Ejemplo n.º 1
0
        public void AddTrafficFrom(Tile_Traffic Source)
        {
            Housing += Source.Housing;

            OriginJobsWorker   += Source.OriginJobsWorker;
            OriginJobsCommoner += Source.OriginJobsCommoner;
            OriginJobsElite    += Source.OriginJobsElite;

            OriginCommerceWorker += Source.OriginCommerceWorker;
            OriginProducts       += Source.OriginProducts;


            DestJobsWorker   += Source.DestJobsWorker;
            DestJobsCommoner += Source.DestJobsCommoner;
            DestJobsElite    += Source.DestJobsElite;

            DestCommerceWorker += Source.DestCommerceWorker;
            DestProducts       += Source.DestProducts;
        }
Ejemplo n.º 2
0
        public void AddTrafficToRoad(Tile_Traffic Source, int Split)
        {
            Housing += Source.Housing / Split;

            OriginJobsWorker   += Source.OriginJobsWorker / Split;
            OriginJobsCommoner += Source.OriginJobsCommoner / Split;
            OriginJobsElite    += Source.OriginJobsElite / Split;

            OriginCommerceWorker += Source.OriginCommerceWorker / Split;
            OriginProducts       += Source.OriginProducts / Split;



            DestJobsWorker   += Source.DestJobsWorker / Split;
            DestJobsCommoner += Source.DestJobsCommoner / Split;
            DestJobsElite    += Source.DestJobsElite / Split;

            DestCommerceWorker += Source.DestCommerceWorker / Split;
            DestProducts       += Source.DestProducts / Split;
        }
Ejemplo n.º 3
0
        public void Clear()
        {
            Housing = 0;

            OriginJobsWorker     = 0;
            OriginJobsCommoner   = 0;
            OriginJobsElite      = 0;
            OriginCommerceWorker = 0;
            OriginProducts       = 0;

            DestJobsWorker     = 0;
            DestJobsCommoner   = 0;
            DestJobsElite      = 0;
            DestCommerceWorker = 0;
            DestProducts       = 0;

            Parent = null;
            tier   = 0;
            ID     = 0;
        }
Ejemplo n.º 4
0
        public void Calculate_JPC()
        {
            //ResidentialDemand = 0;
            //CommercialDemand = 0;
            //IndustrialDemand = 0;

            ResidentialDemandCap = 0;
            CommercialDemandCap  = 0;
            IndustrialDemandCap  = 0;

            foreach (var district in districts)
            {
                //Add Traffic
                district.ClearJPC();
                Tile_Traffic Traff = new Tile_Traffic();
                for (int x = district.Area.Left; x < district.Area.Right; x++)
                {
                    for (int y = district.Area.Top; y < district.Area.Bottom; y++)
                    {
                        //Temp setup
                        City_Tyle T = TileMap[x, y];

                        if (_e.Dictionaryof_BuildItems[T.Type].BuildingType == Listof_BuildTypes.Road)
                        {
                            Traff.AddTrafficFrom(T.Traffic);
                        }
                        //Add Education
                        if (_e.Dictionaryof_BuildItems[T.Type].BuildingType == Listof_BuildTypes.Structure)
                        {
                            district.Education[0] += _e.Dictionaryof_BuildItems[T.Type].Education[0];
                            district.Education[1] += _e.Dictionaryof_BuildItems[T.Type].Education[1];
                            district.Education[2] += _e.Dictionaryof_BuildItems[T.Type].Education[2];
                            district.Education[3] += _e.Dictionaryof_BuildItems[T.Type].Education[3];
                        }
                    }
                }

                //Education Growth
                district.EducationGrowth[0] += (int)Math.Floor(district.Education[0] * 0.1);



                //int WorkersSupply = 0, ProductsSupply = 0, CommerceSupply = 0;
                //int WorkersDemand = 0, ProductsDemand = 0, CommerceDemand = 0;
                //int ProductsAfterCommerce = 0;

                //float MaxGrowthRate = 5;
                //double WorkerMarket = 0, ProductsMarket = 0, CommerceMarket = 0;

                WorkersSupply = Convert.ToInt32(Traff.OriginJobsWorker);
                WorkersDemand = Convert.ToInt32(Traff.DestJobsWorker);

                CommonerSupply = Convert.ToInt32(Traff.OriginJobsCommoner);
                //WorkersDemand = Convert.ToInt32(Traff.DestJobsWorker);

                //Worker to Job Ratio
                if (WorkersDemand > 0)
                {
                    WorkerMarket = (double)WorkersSupply / WorkersDemand;
                }
                else
                {
                    WorkerMarket = 0;
                }
                //Job market ratio cap
                if (WorkerMarket > 1)
                {
                    WorkerMarket = 1;
                }

                ProductsSupply = Convert.ToInt32(Math.Floor(Traff.OriginProducts * WorkerMarket));
                ProductsDemand = Convert.ToInt32(Math.Floor(Traff.DestProducts * WorkerMarket));


                ExcessProducts = ProductsSupply - ProductsDemand;
                ExcessCommerce = CommerceSupply - CommerceDemand;

                double CommerceBoost = 0;
                double IndustryBoost = 0;

                //Industry To Commerce
                if (ProductsDemand > 0)
                {
                    ProductsMarket = (double)ProductsSupply / ProductsDemand;
                    if (ProductsMarket > 1)
                    {
                        ProductsMarket = 1;
                    }
                    CommerceSupply = Convert.ToInt32(Math.Floor(Traff.OriginCommerceWorker * ProductsMarket));

                    IndustryBoost = WorkerMarket;
                }
                else
                {
                    CommerceSupply = 0;
                }

                CommerceDemand = Convert.ToInt32(Math.Floor(Traff.DestCommerceWorker));


                //Commerce To Residential
                if (CommerceDemand > 0)
                {
                    CommerceMarket = (double)CommerceSupply / CommerceDemand;
                    if (CommerceMarket > 1)
                    {
                        CommerceMarket = 1;
                    }
                    CommerceBoost = 0.5 + (0.5 * CommerceMarket);
                }
                else
                {
                    CommerceMarket = 0;
                }


                district.Workers     = WorkersSupply;
                district.Jobs[0]     = WorkersDemand;
                district.JobMarket   = WorkerMarket;
                district.Products    = ExcessProducts;
                district.Commerce[0] = CommerceSupply;


                //ResidentialDemand = WorkersDemand - (WorkersSupply * CommerceBoost);

                //ResidentialDemand += (Traff.DestJobs * 1.15) - Traff.OriginJobs - Projected_Traffic.OriginJobs;
                //CommercialDemand += (Traff.DestCommerce * 1.10) - Traff.OriginCommerce - Projected_Traffic.OriginCommerce;
                //IndustrialDemand += (Traff.DestProducts * 1.10) - Traff.OriginProducts - Projected_Traffic.OriginProducts;


                //(CommerceMarket - 0.5)

                double Unemployment = 0;

                if (WorkersSupply > 0)
                {
                    Unemployment = 1 - (double)WorkersDemand / (double)WorkersSupply;
                }
                else
                {
                    Unemployment = 0;
                }

                Unemployment *= 100;

                // WorkerHappiness sets move in rates, they will move in based on the job market up to 10 + 1% of population over the jobs available.
                double WorkerHappiness = ((100 + Traff.DestJobsWorker) * 1.1) / (100 + Traff.OriginJobsWorker);
                if (WorkerHappiness > 1)
                {
                    WorkerHappiness = 1;
                }
                WorkerHappiness -= 0.9;
                WorkerHappiness *= 100;
                if (WorkerHappiness > 10 + Traff.OriginJobsWorker * 0.001)
                {
                    WorkerHappiness = 10 + Traff.OriginJobsWorker * 0.001;
                }


                //10% unemployment
                if (Unemployment > 10)
                {
                    WorkerHappiness = 0;
                }
                else
                {
                    WorkerHappiness = Math.Floor((10 + Traff.OriginJobsWorker * 0.001));
                }
                if (Traff.Housing == 0)
                {
                    WorkerHappiness = 0;
                }

                ResidentialGrowth += Math.Floor(WorkerHappiness);



                //if (ResidentialGrowth > 0 && WorkersSupply > 0 && WorkersDemand > 0)
                //ResidentialGrowthOverflow += ResidentialGrowth;

                if (WorkersSupply > 0 && ResidentialGrowth > WorkersSupply * 0.1)
                {
                    ResidentialGrowth = WorkersSupply * 0.1;
                }



                //1 - (decimal)_city.WorkersDemand / (decimal)_city.WorkersSupply,


                //ResidentialGrowth = Math.Floor((10 + Traff.OriginJobsWorker * 0.001));


                //ResidentialDemand = 40 + (100 * CommerceMarket) + (Traff.OriginJobsWorker * 0.01) + (Traff.DestJobsWorker * CommerceMarket) - Traff.Housing - Projected_Traffic.Housing;

                //6% unemployment is max until it slows population growth
                ResidentialDemand = 1000; //128 + (Traff.OriginJobsWorker * 0.01) + Traff.DestJobsWorker - Traff.Housing - Projected_Traffic.Housing;



                CommercialDemandWorker = (Traff.DestCommerceWorker * 1.1 - Traff.OriginCommerceWorker) - Projected_Traffic.OriginCommerceWorker;
                IndustrialDemandBasic  = (Traff.DestProducts * 1.1 - Traff.OriginProducts) - Projected_Traffic.OriginProducts;


                IndustrialDemandIntermediate = (Traff.OriginJobsCommoner - Traff.DestJobsCommoner) - Projected_Traffic.DestJobsCommoner;


                //IndustrialDemandAdvanced = (Traff.DestProducts - Traff.OriginProducts) - Projected_Traffic.OriginProducts;
                //if (ResidentialDemand > ResidentialDemandCap) ResidentialDemand = ResidentialDemandCap;
                //if (CommercialDemand > CommercialDemandCap) CommercialDemand = CommercialDemandCap;
                //if (IndustrialDemand > IndustrialDemandCap) IndustrialDemand = IndustrialDemandCap;
            }
        }