Class CombatStatsDisplay
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.rendering.RenderComponent
com.csse3200.game.ui.UIComponent
com.csse3200.game.components.combat.CombatStatsDisplay
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable
,Renderable
,Comparable<Renderable>
Displays the stats bars of both the player and the enemy on the CombatScreen.
-
Field Summary
Fields inherited from class com.csse3200.game.ui.UIComponent
skin, stage
-
Constructor Summary
ConstructorsConstructorDescriptionCombatStatsDisplay
(CombatStatsComponent playerStats, CombatStatsComponent enemyStats) Initialises the required components for the CombatStatsDisplays -
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.void
Initializes the animations for the health, hunger, and experience bars.void
setNewFrame
(int frameIndex, com.badlogic.gdx.graphics.g2d.Animation<com.badlogic.gdx.graphics.g2d.TextureRegion> statBarAnimation, com.badlogic.gdx.scenes.scene2d.ui.Image statBar) Sets a new frame for a stat bar animation on the stage.void
updateHealthUI
(CombatStatsComponent playerStats, CombatStatsComponent enemyStats) Updates the labels and animations associated with the player and enemy's statsvoid
updateHungerUI
(CombatStatsComponent playerStats, CombatStatsComponent enemyStats) Updates the hunger bar animation of the playervoid
updatePlayerExperienceUI
(CombatStatsComponent playerStats) Updates the experience label and bar of the character after defeating a specific enemyvoid
updateStatusEffectUI
(CombatStatsComponent.StatusEffect statusEffect) Method used to display the relevant status effect that the player is afflicted withMethods inherited from class com.csse3200.game.ui.UIComponent
getLayer, getZIndex, setStage
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
-
CombatStatsDisplay
Initialises the required components for the CombatStatsDisplays- Parameters:
playerStats
- CombatStatsComponent of the playerenemyStats
- CombatStatsComponent of the enemy
-
-
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
-
initBarAnimations
public void initBarAnimations()Initializes the animations for the health, hunger, and experience bars. Each bar's animation consist of series of consecutive frames from a texture atlas given in the asset folder. The animations reflect the current status of the player's health, hunger, and experience. -
setNewFrame
public void setNewFrame(int frameIndex, com.badlogic.gdx.graphics.g2d.Animation<com.badlogic.gdx.graphics.g2d.TextureRegion> statBarAnimation, com.badlogic.gdx.scenes.scene2d.ui.Image statBar) Sets a new frame for a stat bar animation on the stage.- Parameters:
frameIndex
- The index of the desired frame in the animation to be changedstatBarAnimation
- The animation for the specific stat bar to be changedstatBar
- image that stores the current frame on the stage for the stat bar.
-
updateHealthUI
Updates the labels and animations associated with the player and enemy's stats- Parameters:
playerStats
- CombatStatsComponent of the playerenemyStats
- CombatStatsComponent of the enemy
-
updatePlayerExperienceUI
Updates the experience label and bar of the character after defeating a specific enemy- Parameters:
playerStats
- CombatStatsComponent of the player
-
updateHungerUI
Updates the hunger bar animation of the player- Parameters:
playerStats
- The CombatStatsComponent of the player
-
updateStatusEffectUI
Method used to display the relevant status effect that the player is afflicted with- Parameters:
statusEffect
- An ENUM that stores the type of status effect the player has been afflicted with
-
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.
-
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
-