Subtract player resources when building
This commit is contained in:
@@ -263,6 +263,12 @@ void updatePlayerInput() {
|
|||||||
bool canPlace = canPlaceBuilding(game, input->building, tileX, tileY);
|
bool canPlace = canPlaceBuilding(game, input->building, tileX, tileY);
|
||||||
if (canPlace && isInputBtnDown(input, primaryBtn)) {
|
if (canPlace && isInputBtnDown(input, primaryBtn)) {
|
||||||
placeBuilding(game, input->building, tileX, tileY, game->player);
|
placeBuilding(game, input->building, tileX, tileY, game->player);
|
||||||
|
// Update player resources
|
||||||
|
i32 cost[RES_COUNT] = {0};
|
||||||
|
getBuildingCost(input->building, cost);
|
||||||
|
game->playerResources[game->player].wood -= cost[RES_WOOD];
|
||||||
|
game->playerResources[game->player].gold -= cost[RES_GOLD];
|
||||||
|
game->playerResources[game->player].food -= cost[RES_FOOD];
|
||||||
}
|
}
|
||||||
input->buildingCanPlace = canPlace;
|
input->buildingCanPlace = canPlace;
|
||||||
input->buildingPos = (Vec2i) {tileX, tileY};
|
input->buildingPos = (Vec2i) {tileX, tileY};
|
||||||
|
|||||||
Reference in New Issue
Block a user