Class PlayerStatsDisplay
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.rendering.RenderComponent
com.csse3200.game.ui.UIComponent
com.csse3200.game.components.player.PlayerStatsDisplay
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable,Renderable,Comparable<Renderable>
An ui component for displaying player stats, e.g. health, dodge cool down and player lives
-
Field Summary
Fields inherited from class com.csse3200.game.ui.UIComponent
skin, stage -
Constructor Summary
ConstructorsConstructorDescriptionPlayerStatsDisplay(PlayerConfig config) Constructor for the PlayerStatsDisplay -
Method Summary
Modifier and TypeMethodDescriptionvoidcreate()Creates reusable ui styles and adds actors to the stage.voidcreateAmmoBar(com.badlogic.gdx.scenes.scene2d.ui.Table parentTable) Creates the weapons ammo UI for the HUDvoidcreateDodgeBar(com.badlogic.gdx.scenes.scene2d.ui.Table parentTable) Creates the dodge bar for the HUDvoidcreateHealthBar(com.badlogic.gdx.scenes.scene2d.ui.Table parentTable) Creates the heath bar for the player HUDvoidcreateLivesBar(com.badlogic.gdx.scenes.scene2d.ui.Table parentTable) Creates the player lives UI for the HUDvoidcreateUpgradeTreeButton(com.badlogic.gdx.scenes.scene2d.ui.Table table) voiddispose()Called when the component is disposed.voiddraw(com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Draw the renderable.voidCreates an alert for if the maximum number of lives (3) has been reached.voidupdateAmmo(int currentAmmo, int maxAmmo, int ammoUse) Updates the current and max ammo displaying in the player HUDvoidUpdates the visible avaliability of the dodge when it becomes availablevoidUpdates the visible avaliability of the dodge movement when used by the playervoidupdatePlayerHealthUI(int health) Updates the player's health on the ui.voidupdatePlayerLives(int lives) Updates the number of lives displayed in the player HUDvoidupdateWeapon(WeaponType weapon) Updates the weapon equipped in the player HUDMethods inherited from class com.csse3200.game.ui.UIComponent
getLayer, getZIndexMethods inherited from class com.csse3200.game.rendering.RenderComponent
compareTo, overrideZIndex, renderMethods inherited from class com.csse3200.game.components.Component
earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, updateMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Comparable
compareToMethods inherited from interface com.csse3200.game.rendering.Renderable
render
-
Constructor Details
-
PlayerStatsDisplay
Constructor for the PlayerStatsDisplay- Parameters:
config- the player config file
-
-
Method Details
-
create
public void create()Creates reusable ui styles and adds actors to the stage.- Overrides:
createin classUIComponent
-
createUpgradeTreeButton
public void createUpgradeTreeButton(com.badlogic.gdx.scenes.scene2d.ui.Table table) - Parameters:
table- - Used to add Column/Rows and define the actors createUpgradeTreeButton() - creating button and defining it on the top left also playing the sound when on tapping it
-
createHealthBar
public void createHealthBar(com.badlogic.gdx.scenes.scene2d.ui.Table parentTable) Creates the heath bar for the player HUD- Parameters:
parentTable- the table which the health bar is contained within
-
createDodgeBar
public void createDodgeBar(com.badlogic.gdx.scenes.scene2d.ui.Table parentTable) Creates the dodge bar for the HUD- Parameters:
parentTable- the table which the dodge bar is contained within
-
createLivesBar
public void createLivesBar(com.badlogic.gdx.scenes.scene2d.ui.Table parentTable) Creates the player lives UI for the HUD- Parameters:
parentTable- the table which the player lives information is contained within
-
createAmmoBar
public void createAmmoBar(com.badlogic.gdx.scenes.scene2d.ui.Table parentTable) Creates the weapons ammo UI for the HUD- Parameters:
parentTable- the table which the ammo information is contained within
-
draw
public void draw(com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Description copied from class:RenderComponentDraw the renderable. Should be called only by the renderer, not manually.- Specified by:
drawin classRenderComponent- Parameters:
batch- Batch to render to.
-
updatePlayerHealthUI
public void updatePlayerHealthUI(int health) Updates the player's health on the ui.- Parameters:
health- player health
-
updateDodgeUsed
public void updateDodgeUsed()Updates the visible avaliability of the dodge movement when used by the player -
updateDodgeRefreshed
public void updateDodgeRefreshed()Updates the visible avaliability of the dodge when it becomes available -
updatePlayerLives
public void updatePlayerLives(int lives) Updates the number of lives displayed in the player HUD- Parameters:
lives- the number that is being updated to
-
updateAmmo
public void updateAmmo(int currentAmmo, int maxAmmo, int ammoUse) Updates the current and max ammo displaying in the player HUD- Parameters:
currentAmmo- the current ammo of the weapon equippedmaxAmmo- the max ammo of the weapon equipped
-
updateWeapon
Updates the weapon equipped in the player HUD- Parameters:
weapon- the new weapon
-
maxLivesReached
public void maxLivesReached()Creates an alert for if the maximum number of lives (3) has been reached. Used when player picks up Powerup ('Plus one life'). -
dispose
public void dispose()Description copied from class:ComponentCalled when the component is disposed. Dispose of any internal resources here.- Specified by:
disposein interfacecom.badlogic.gdx.utils.Disposable- Overrides:
disposein classRenderComponent
-