Implement market
This commit is contained in:
@@ -217,6 +217,29 @@ void drawGameUI(Game *game, f32 dt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (building.type == BUILDING_MARKET) {
|
||||||
|
// 50:10
|
||||||
|
if (uiGameTrade("Buy 50 (-10 gold)##food", foodRec, tex, playerRes->gold >= 10)) {
|
||||||
|
playerRes->food += 50;
|
||||||
|
playerRes->gold -= 10;
|
||||||
|
}
|
||||||
|
// 100:10
|
||||||
|
if (uiGameTrade("Sell 100 (+10 gold)##food", foodRec, tex, playerRes->food >= 100)) {
|
||||||
|
playerRes->food -= 100;
|
||||||
|
playerRes->gold += 10;
|
||||||
|
}
|
||||||
|
// 50:25
|
||||||
|
if (uiGameTrade("Buy 50 (-25 gold)##wood", woodRec, tex, playerRes->gold >= 25)) {
|
||||||
|
playerRes->wood += 50;
|
||||||
|
playerRes->gold -= 25;
|
||||||
|
}
|
||||||
|
// 100:25
|
||||||
|
if (uiGameTrade("Sell 100 (+25 gold)##wood", woodRec, tex, playerRes->wood >= 100)) {
|
||||||
|
playerRes->wood -= 100;
|
||||||
|
playerRes->gold += 25;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -422,6 +422,11 @@ void uiGameBuild(const char *label, Rectangle rec, Texture2D tex, bool canAfford
|
|||||||
|
|
||||||
bzUIPopParent(UI);
|
bzUIPopParent(UI);
|
||||||
}
|
}
|
||||||
|
bool uiGameTrade(const char *label, Rectangle rec, Texture2D tex, bool canAfford) {
|
||||||
|
bool selected = false;
|
||||||
|
uiGameBuild(label, rec, tex, canAfford, &selected);
|
||||||
|
return selected;
|
||||||
|
}
|
||||||
bool uiGameUnit(const char *label, i32 count, Rectangle rec, Texture2D tex) {
|
bool uiGameUnit(const char *label, i32 count, Rectangle rec, Texture2D tex) {
|
||||||
if (rec.height > 16)
|
if (rec.height > 16)
|
||||||
rec.y += 16;
|
rec.y += 16;
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ void uiGameResCount(i32 amount, i32 capacity, Rectangle icon, Texture2D texture)
|
|||||||
void uiGameRecruit(const char *label, Rectangle rec, Texture2D tex, i32 numRecruiting,
|
void uiGameRecruit(const char *label, Rectangle rec, Texture2D tex, i32 numRecruiting,
|
||||||
f32 progress, bool canAfford, bool *selected);
|
f32 progress, bool canAfford, bool *selected);
|
||||||
void uiGameBuild(const char *label, Rectangle rec, Texture2D tex, bool canAfford, bool *selected);
|
void uiGameBuild(const char *label, Rectangle rec, Texture2D tex, bool canAfford, bool *selected);
|
||||||
|
bool uiGameTrade(const char *label, Rectangle rec, Texture2D tex, bool canAfford);
|
||||||
bool uiGameUnit(const char *label, i32 count, Rectangle rec, Texture2D tex);
|
bool uiGameUnit(const char *label, i32 count, Rectangle rec, Texture2D tex);
|
||||||
|
|
||||||
#endif //PIXELDEFENSE_UI_WIDGETS_H
|
#endif //PIXELDEFENSE_UI_WIDGETS_H
|
||||||
|
|||||||
Reference in New Issue
Block a user