Class CurrentWaveDisplay
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.rendering.RenderComponent
com.csse3200.game.ui.UIComponent
com.csse3200.game.components.waves.CurrentWaveDisplay
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable
,Renderable
,Comparable<Renderable>
A UI component for displaying the current wave number. Shows the current wave and can be updated
when waves change. Now integrated with the WaveManager system.
-
Field Summary
Fields inherited from class com.csse3200.game.ui.UIComponent
skin, stage
Fields inherited from class com.csse3200.game.rendering.RenderComponent
colour
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new current wave display component.CurrentWaveDisplay
(WaveManager waveManager) Creates a new current wave display component. -
Method Summary
Modifier and TypeMethodDescriptionvoid
create()
Called when the entity is created and registered.void
dispose()
Called when the component is disposed.void
draw
(com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Draw the renderable.int
Gets the current wave number being displayed.Gets the current wave being displayed as a formatted string.void
setWave
(int waveNumber) Manually trigger a wave change for testing purposes.void
updateWaveDisplay
(int waveNumber) Updates the wave display on the UI.Methods inherited from class com.csse3200.game.ui.UIComponent
getLayer, getZIndex
Methods inherited from class com.csse3200.game.rendering.RenderComponent
compareTo, getColour, render, setColour
Methods inherited from class com.csse3200.game.components.Component
earlyUpdate, getEntity, getPriority, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update
-
Constructor Details
-
CurrentWaveDisplay
public CurrentWaveDisplay()Creates a new current wave display component. -
CurrentWaveDisplay
Creates a new current wave display component.- Parameters:
waveManager
- the WaveManager to listen to for wave events
-
-
Method Details
-
create
public void create()Description copied from class:Component
Called when the entity is created and registered. Initial logic such as calls to GetComponent should be made here, not in the constructor which is called before an entity is finished.- Overrides:
create
in classUIComponent
-
draw
public void draw(com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Description copied from class:RenderComponent
Draw the renderable. Should be called only by the renderer, not manually.- Specified by:
draw
in classRenderComponent
- Parameters:
batch
- Batch to render to.
-
updateWaveDisplay
public void updateWaveDisplay(int waveNumber) Updates the wave display on the UI. This method is called by the event system when "waveChanged" or "newWaveStarted" events are triggered.- Parameters:
waveNumber
- the new wave number to display
-
getCurrentWaveNumber
public int getCurrentWaveNumber()Gets the current wave number being displayed.- Returns:
- current wave number
-
getCurrentWaveString
Gets the current wave being displayed as a formatted string. Returns "Wave X" for active waves or "No Wave Active" for wave 0.- Returns:
- formatted wave string for display
-
setWave
public void setWave(int waveNumber) Manually trigger a wave change for testing purposes.- Parameters:
waveNumber
- the new wave number
-
dispose
public void dispose()Description copied from class:Component
Called when the component is disposed. Dispose of any internal resources here.- Specified by:
dispose
in interfacecom.badlogic.gdx.utils.Disposable
- Overrides:
dispose
in classRenderComponent
-