Currency (Gold) - UQcsse3200/2024-studio-3 GitHub Wiki
Usage
In combat stats component: addGold(int gold)
, getGold()
, setGold()
Use in your class:
public CombatStatsComponent combatStatsComponent;
ServiceLocator.getPlayerService().getEvents().addListener("playerCreated", (Entity player) -> {
combatStatsComponent = player.getComponent(CombatStatsComponent.class);
});
// increment player gold on UI
combatStatsComponent.addGold(1);
// get gold
combatStatsComponent.getGold();
Integration
The gold is set from the player.json
config and changes when adding gold are visible on the main game screen.