Class CompanionStatsDisplay
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.rendering.RenderComponent
com.csse3200.game.ui.UIComponent
com.csse3200.game.components.Companion.CompanionStatsDisplay
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable,Renderable,Comparable<Renderable>
A UI component for displaying Companion stats, e.g., health.
-
Field Summary
FieldsModifier and TypeFieldDescriptioncom.badlogic.gdx.scenes.scene2d.ui.Labelcom.badlogic.gdx.scenes.scene2d.ui.Labelcom.badlogic.gdx.scenes.scene2d.ui.LabelThe player entity associated with this CompanionStatsDisplay.com.badlogic.gdx.scenes.scene2d.ui.LabelThe UI playerLowHealthLabel for displaying the companion's health.Fields inherited from class com.csse3200.game.ui.UIComponent
skin, stage -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAlert(int health) Add an alert when the player's health is low.voidcreate()Creates reusable UI styles and adds actors to the stage.voidcreateInventoryButton(com.badlogic.gdx.scenes.scene2d.ui.Table statsTable) voiddispose()remove all labels form the screen when disposingvoiddraw(com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Draw the renderable.longvoidReset the companion's image.voidsetDuration(long duration) voidToggle infinite health for the companion.voidToggle invincibility for the companion.voidupdateCompanionHealthUI(int health) Updates the companion's health UI.voidupdateCompanionModeUI(String newMode) updating the companion UI to include the modevoidupdatePlayerHealthUI(int health) Update the player's health UI.Methods 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
-
Field Details
-
player
The player entity associated with this CompanionStatsDisplay. -
companion
-
playerLowHealthLabel
public com.badlogic.gdx.scenes.scene2d.ui.Label playerLowHealthLabelThe UI playerLowHealthLabel for displaying the companion's health. -
companionHealthLabel
public com.badlogic.gdx.scenes.scene2d.ui.Label companionHealthLabel -
companionUIHeaderLabel
public com.badlogic.gdx.scenes.scene2d.ui.Label companionUIHeaderLabel -
companionModeLabel
public com.badlogic.gdx.scenes.scene2d.ui.Label companionModeLabel
-
-
Constructor Details
-
CompanionStatsDisplay
public CompanionStatsDisplay()Default constructor for CompanionStatsDisplay.
-
-
Method Details
-
create
public void create()Creates reusable UI styles and adds actors to the stage.- Overrides:
createin classUIComponent
-
createInventoryButton
public void createInventoryButton(com.badlogic.gdx.scenes.scene2d.ui.Table statsTable) -
toggleInvincibility
public void toggleInvincibility()Toggle invincibility for the companion. -
resetImage
public void resetImage()Reset the companion's image. -
toggleInfiniteHealth
public void toggleInfiniteHealth()Toggle infinite health for the companion. -
addAlert
public void addAlert(int health) Add an alert when the player's health is low.- Parameters:
health- The current health value.
-
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) Update the player's health UI.- Parameters:
health- The current health value of the player.
-
updateCompanionHealthUI
public void updateCompanionHealthUI(int health) Updates the companion's health UI.- Parameters:
health- The updated health value to display.
-
updateCompanionModeUI
updating the companion UI to include the mode- Parameters:
newMode- - the mode sent by the CompanionActions trigger to be put on screen
-
dispose
public void dispose()remove all labels form the screen when disposing- Specified by:
disposein interfacecom.badlogic.gdx.utils.Disposable- Overrides:
disposein classRenderComponent
-
setDuration
public void setDuration(long duration) -
getDuration
public long getDuration()
-