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 String
convertDigital
(long x) Converts a time value in milliseconds into a formatted digital time (MM:SS).void
create()
Creates reusable ui styles and adds actors to the stage.void
dispose()
Called when the component is disposed.void
draw
(com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Draw the renderable.com.badlogic.gdx.scenes.scene2d.ui.Label
Gets the current day labelstatic PlayerStatsDisplay
Gets the current Player stats displaystatic com.badlogic.gdx.scenes.scene2d.ui.Label
Gets the current timer labelstatic void
reset()
void
setDayLabel
(com.badlogic.gdx.scenes.scene2d.ui.Label label) Sets the label for the daystatic void
setPlayerStatsDisplay
(PlayerStatsDisplay playerStatsDisplay) Sets the player stats displayvoid
setStage
(com.badlogic.gdx.scenes.scene2d.Stage mock) static void
setTimer
(long time) Sets the timer to a specific time and starts counting downstatic void
setTimerLabel
(com.badlogic.gdx.scenes.scene2d.ui.Label label) Sets the label for the timervoid
Updates the displayed current day on the UI.void
updatePlayerGoldUI
(int gold) Updates the player's gold on the ui.static void
updateTime
(long time) Updates the remaining time for the current day on the UI.Methods inherited from class com.csse3200.game.ui.UIComponent
getLayer, getZIndex
Methods inherited from class com.csse3200.game.rendering.RenderComponent
compareTo, render
Methods inherited from class com.csse3200.game.components.Component
earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Comparable
compareTo
Methods 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:
create
in 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:RenderComponent
Draw the renderable. Should be called only by the renderer, not manually.- Specified by:
draw
in 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: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
-
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()
-