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.
-
Field Summary
Fields inherited from class com.csse3200.game.ui.UIComponent
skin, stage -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringconvertDigital(long x) Converts a time value in milliseconds into a formatted digital time (MM:SS).voidcreate()Creates reusable ui styles and adds actors to the stage.voiddispose()Called when the component is disposed.voiddraw(com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Draw the renderable.com.badlogic.gdx.scenes.scene2d.ui.LabelGets the current day labelstatic PlayerStatsDisplayGets the current Player stats displaystatic com.badlogic.gdx.scenes.scene2d.ui.LabelGets the current timer labelstatic voidreset()voidsetDayLabel(com.badlogic.gdx.scenes.scene2d.ui.Label label) Sets the label for the daystatic voidsetPlayerStatsDisplay(PlayerStatsDisplay playerStatsDisplay) Sets the player stats displayvoidsetStage(com.badlogic.gdx.scenes.scene2d.Stage mock) static voidsetTimer(long time) Sets the timer to a specific time and starts counting downstatic voidsetTimerLabel(com.badlogic.gdx.scenes.scene2d.ui.Label label) Sets the label for the timervoidUpdates the displayed current day on the UI.voidupdatePlayerGoldUI(int gold) Updates the player's gold on the ui.static voidupdateTime(long time) Updates the remaining time for the current day on the UI.Methods inherited from class com.csse3200.game.ui.UIComponent
getLayer, getZIndexMethods inherited from class com.csse3200.game.rendering.RenderComponent
compareTo, 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
public PlayerStatsDisplay()
-
-
Method Details
-
create
public void create()Creates reusable ui styles and adds actors to the stage.- Overrides:
createin classUIComponent
-
setTimer
public static void setTimer(long time) Sets the timer to a specific time and starts counting down- Parameters:
time- the time you want to set the timer to count down from in seconds
-
setDayLabel
public void setDayLabel(com.badlogic.gdx.scenes.scene2d.ui.Label label) Sets the label for the day- Parameters:
label- : The label being set
-
getDayLabel
public com.badlogic.gdx.scenes.scene2d.ui.Label getDayLabel()Gets the current day label- Returns:
- The current day label
-
setTimerLabel
public static void setTimerLabel(com.badlogic.gdx.scenes.scene2d.ui.Label label) Sets the label for the timer- Parameters:
label- : The label being set
-
getTimerLabel
public static com.badlogic.gdx.scenes.scene2d.ui.Label getTimerLabel()Gets the current timer label- Returns:
- The current timer label
-
setPlayerStatsDisplay
Sets the player stats display- Parameters:
playerStatsDisplay- : The Player stats display that is being set.
-
getInstance
Gets the current Player stats display- Returns:
- the current player stats display
-
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.
-
updatePlayerGoldUI
public void updatePlayerGoldUI(int gold) Updates the player's gold on the ui.- Parameters:
gold- player gold
-
updateDay
public void updateDay()Updates the displayed current day on the UI. -
updateTime
public static void updateTime(long time) Updates the remaining time for the current day on the UI. Decreases the timer by one second and updates the displayed time. -
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
-
setStage
public void setStage(com.badlogic.gdx.scenes.scene2d.Stage mock) -
convertDigital
Converts a time value in milliseconds into a formatted digital time (MM:SS).- Parameters:
x- The time in milliseconds.- Returns:
- A string representing the time in "MM:SS" format.
-
reset
public static void reset()
-