/// <summary> Decrement BuildingCost from Inventory, otherwise return GoodsCollection of missing goods </summary> public virtual GoodsCollection TryStartConstruction(GoodsCollection inventory) { var missingGoods = new GoodsCollection(); //check required materials foreach (Good good in BuildingCost.Keys) { var foo = inventory[good] - BuildingCost[good]; if (foo < 0) { missingGoods.Add(good, -foo); } } if (missingGoods.Count > 0) { return(missingGoods); } //+- goods foreach (Good good in inventory.Keys.ToArray()) { if (BuildingCost.ContainsKey(good)) { inventory[good] -= BuildingCost[good]; } } return(missingGoods); }
void OnClick() { Globals.BuildingManager.HandleBuildingsOnEndTurn(); Globals.CityManager.AddTurns(1); //TODO: refactor this to somewhere else _collection.Add(Globals.BuildingManager.IncomeInventory); if (Globals.CityManager.Turns % 4 == 0) { Globals.NextTurnModal.ShowNextTurnModal(_collection, Globals.GameEventManager.GetText()); _collection = new GoodsCollection(0); } }