Class PlayerStatsDisplay

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

public class PlayerStatsDisplay extends UIComponent
AN ui component for displaying player stats, e.g. health.
  • Constructor Details

    • PlayerStatsDisplay

      public PlayerStatsDisplay()
  • Method Details

    • create

      public void create()
      Creates reusable ui styles and adds actors to the stage.
      Overrides:
      create in class UIComponent
    • 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

      public static void setPlayerStatsDisplay(PlayerStatsDisplay playerStatsDisplay)
      Sets the player stats display
      Parameters:
      playerStatsDisplay - : The Player stats display that is being set.
    • getInstance

      public static PlayerStatsDisplay 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 class RenderComponent
      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 interface com.badlogic.gdx.utils.Disposable
      Overrides:
      dispose in class RenderComponent
    • setStage

      public void setStage(com.badlogic.gdx.scenes.scene2d.Stage mock)
    • convertDigital

      public static String convertDigital(long x)
      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()