-
Notifications
You must be signed in to change notification settings - Fork 0
Currency System
The Currency System introduces collectible resources that players can gather and spend on building, upgrading, and unlocking game features. It uses an ECS-based design with components for managing currencies, handling collection, and updating the UI. Three types of currencies exist: Metal Scrap (common), Titanium Core (rare), and Neurochip (epic). A factory ensures consistent entity creation, while event-driven updates keep the UI in sync.
A component that stores the type and value of a currency item. Each CurrencyComponentis associated with exactly one CurrencyType. For example, a metal scrap worth 1 unit would be represented here.
- Method
getTypereturns the type of this currency. - Method
getValuereturns the currency value.
A component that makes an entity collectible by the player. It checks for clicks near the entity and, if collected, triggers events such as collectCurrencyso that the manager can update totals.
- Method
updatehandles player interaction for collecting the entity. - Method
getCameragets the camera from the current Renderer. - Method
isCollectedreturns true if the component has been collected, false otherwise.
A component that tracks all the currencies collected by the player. It maintains a list of currency entities and a map of CurrencyType → amount. It listens for collectCurrencyevents and updates the player’s currency balance. It also triggers the updateScrap event to refresh the UI display.
- Method
addCurrencyAmountadds a specified amount of the given currency type. - Method
subtractCurrencyAmountsubtracts a specified amount of the given currency type. - Method
getCurrencyAmountreturns the current amount of the specified currency or 0 if none exists. - Method
addCurrencyEntityadds the currency entity to the list if it is not already present. - Method
getCurrencyListreturns the current list of currency entities. - Method
collectCurrencyincrements the counter and triggers to update UI. - Method
dropCurrencyupdates currency amount on UI when enemy drop currency. - Method
canAffordAndSpendCurrencydeducts the player's currencies according to the cost map if the player can afford it; otherwise, it returns false and leaves the currencies unchanged. - Method
refundCurrencyrefunds a portion of the cost according to the specified refund rate. - Method
updateCurrencyUIupdates UI rendering for a specific currency type. - Method
updateAllCurrencyUIupdates UI rendering for all currency types.
A utility class for creating currency entities. It combines CurrencyComponent, CollectibleComponent, and rendering into a complete Entity.
- Method
createCurrencycreates a new currency entity with the given parameters and returns a fully initialized currency entity.
An enum representing the different types of currency in the game, currently it includes METAL_SCRAP.
-
Factory Pattern →
CurrencyFactoryencapsulates creation logic, ensuring consistency and easier extension. -
Observer Pattern → Event system decouples
collectCurrencyfrom UI updates. -
Component Pattern (ECS) → Flexible entity composition with
CurrencyComponent,CollectibleComponent, etc. -
MVC Separation → Game logic (currency) is independent of UI rendering.
A basic and plentiful resource, scavenged from the battlefield. Useful for early upgrades and essential constructions.

A rare and valuable resource, often obtained from tougher enemies. Needed for powerful upgrades and advanced technology.

A highly advanced implant once designed to enhance human intelligence, now repurposed by AI to control and outsmart its creators. Extremely rare and vital for high-level upgrades.
-
Component: The superclass for all components in the game.
https://github.com/UQcsse3200/2025-studio-4/wiki/Currency-System's-Test-Plan