Example #1
0
        public void UpdateWhenCreate(BuildingType building)
        {
            _nbResources["wood"]      -= building.Wood;
            _nbResources["rock"]      -= building.Rock;
            _nbResources["metal"]     -= building.Metal;
            _nbResources["coins"]     -= building.Coin;
            _nbResources["pollution"] -= building.Pollution;
            if (Equals(building, _ctx.BuildingTypes[10]))
            {
                PumpingStationType pumpingStation = (PumpingStationType)building;
                _nbResources["water"] += pumpingStation.WaterProduction;
            }
            else
            {
                _nbResources["water"] -= building.Water;
            }

            if (Equals(building, _ctx.BuildingTypes[9]))
            {
                PowerPlantType powerPlant = (PowerPlantType)building;
                _nbResources["electricity"] += powerPlant.ElectricityProduction;
            }
            else
            {
                _nbResources["electricity"] -= building.Electricity;
            }
            _nbResources["cost"] += building.Cost;

            if (building.Type == "habitation")
            {
                _maxPopulation += building.NbPeople;
            }
        }
Example #2
0
 public void UpdateWhenDestroy(BuildingType building)
 {
     if (building.Type == "habitation")
     {
         _maxPopulation           = _maxPopulation - building.NbPeople < 0 ? 0 : _maxPopulation - building.NbPeople;
         _nbResources["nbPeople"] = _nbResources["nbPeople"] - building.NbPeople < 0 ? 0 : _nbResources["nbPeople"] - building.NbPeople;
     }
     if (Equals(building, _ctx.BuildingTypes[9]))
     {
         PowerPlantType a = (PowerPlantType)_ctx.BuildingTypes.ElementAt(9);
         _nbResources["electricity"] -= a.ElectricityProduction;
     }
     if (Equals(building, _ctx.BuildingTypes[10]))
     {
         PumpingStationType pumping = (PumpingStationType)_ctx.BuildingTypes.ElementAt(10);
         _nbResources["water"] -= pumping.WaterProduction;
     }
 }