Esempio n. 1
0
        public void CalculateGameForPlayer()
        {
            long coins = Coins;

            foreach (Island island in Islands.ToList())
            {
                Buildings buildings = island.Buildings;
                List <ProductionBuilding> productionBuildings = new List <ProductionBuilding>
                {
                    new ChatkaRybacka(buildings.ChatkaRybacka),
                    new ChatkaDrwala(buildings.ChatkaDrwala),
                    new Tartak(buildings.Tartak),
                    new FarmaOwiec(buildings.FarmaOwiec),
                    new ZakladTkaczy(buildings.ZakladTkaczy),
                    new FarmaZiemniakow(buildings.FarmaZiemniakow),
                    new DestylarniaSznapsu(buildings.DestylarniaSznapsu)
                };
                List <Residence> residences = new List <Residence>
                {
                    new RezydencjaFarmerow(buildings.Farmerzy, buildings.RezydencjaFarmerow)
                };
                int neededFarmerzy = 0;
                //obliczanie potrzebnej ilości mieszkańców  w sumie
                foreach (ProductionBuilding productionBuilding in productionBuildings)
                {
                    neededFarmerzy += productionBuilding.NeededFarmers * productionBuilding.Number;
                }
                buildings.NeededFarmers = neededFarmerzy;
                if (neededFarmerzy > 0)
                {
                    double farmersProductivity = buildings.Farmerzy / neededFarmerzy;
                    //produkcja dla każdego rodzaju budynku produkcyjnego
                    foreach (ProductionBuilding productionBuilding in productionBuildings)
                    {
                        productionBuilding.Product(island.Resources, ref coins, farmersProductivity);
                    }
                }
                double actualFarmers = 0;
                if (buildings.FarmersSatisfaction == null)
                {
                    buildings.FarmersSatisfaction = new Resources();
                }
                residences[0].Satisfaction = buildings.FarmersSatisfaction;
                // wyżywnie ludzi z każdego typu budynku mieszkalnego
                foreach (Residence residence in residences)
                {
                    coins += residence.Consume(island.Resources, out actualFarmers);
                }
                buildings.FarmersSatisfaction = residences[0].Satisfaction;
                buildings.Farmerzy            = actualFarmers;
            }
            Coins = coins;
        }
Esempio n. 2
0
        public void ListToBuildings(Island island)
        {
            Buildings buildings1 = island.Buildings;

            buildings1.RezydencjaFarmerow = buildings[0].Number;
            buildings1.ChatkaRybacka      = buildings[1].Number;
            buildings1.ChatkaDrwala       = buildings[2].Number;
            buildings1.Tartak             = buildings[3].Number;
            buildings1.FarmaOwiec         = buildings[4].Number;
            buildings1.ZakladTkaczy       = buildings[5].Number;
            buildings1.FarmaZiemniakow    = buildings[6].Number;
            buildings1.DestylarniaSznapsu = buildings[7].Number;
        }
Esempio n. 3
0
        public BuildingList(Island island)
        {
            Buildings buildings1 = island.Buildings;

            buildings = new List <Building> {
                new RezydencjaFarmerow(buildings1.Farmerzy, buildings1.RezydencjaFarmerow),
                new ChatkaRybacka(buildings1.ChatkaRybacka),
                new ChatkaDrwala(buildings1.ChatkaDrwala),
                new Tartak(buildings1.Tartak),
                new FarmaOwiec(buildings1.FarmaOwiec),
                new ZakladTkaczy(buildings1.ZakladTkaczy),
                new FarmaZiemniakow(buildings1.FarmaZiemniakow),
                new DestylarniaSznapsu(buildings1.DestylarniaSznapsu)
            };
        }