Class CombatStatsDisplay

All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable, Renderable, Comparable<Renderable>

public class CombatStatsDisplay extends UIComponent
Displays the stats bars of both the player and the enemy on the CombatScreen.
  • Constructor Details

    • CombatStatsDisplay

      public CombatStatsDisplay(CombatStatsComponent playerStats, CombatStatsComponent enemyStats)
      Initialises the required components for the CombatStatsDisplays
      Parameters:
      playerStats - CombatStatsComponent of the player
      enemyStats - 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 class UIComponent
    • 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 changed
      statBarAnimation - The animation for the specific stat bar to be changed
      statBar - image that stores the current frame on the stage for the stat bar.
    • updateHealthUI

      public void updateHealthUI(CombatStatsComponent playerStats, CombatStatsComponent enemyStats)
      Updates the labels and animations associated with the player and enemy's stats
      Parameters:
      playerStats - CombatStatsComponent of the player
      enemyStats - CombatStatsComponent of the enemy
    • updatePlayerExperienceUI

      public void updatePlayerExperienceUI(CombatStatsComponent playerStats)
      Updates the experience label and bar of the character after defeating a specific enemy
      Parameters:
      playerStats - CombatStatsComponent of the player
    • updateHungerUI

      public void updateHungerUI(CombatStatsComponent playerStats, CombatStatsComponent enemyStats)
      Updates the hunger bar animation of the player
      Parameters:
      playerStats - The CombatStatsComponent of the player
    • updateStatusEffectUI

      public void updateStatusEffectUI(CombatStatsComponent.StatusEffect statusEffect)
      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 class RenderComponent
      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 interface com.badlogic.gdx.utils.Disposable
      Overrides:
      dispose in class RenderComponent