Class DancePartyUpgrade

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

public class DancePartyUpgrade extends UIComponent implements Upgrade
The DancePartyUpgrade class represents an upgrade that, when activated, triggers a "Dancing" which causes current dockets within the game to pause Their time, within the MainGameOrderTicketDisplay
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    com.badlogic.gdx.scenes.scene2d.ui.Table
     
    com.badlogic.gdx.scenes.scene2d.ui.ProgressBar
     
    com.badlogic.gdx.scenes.scene2d.ui.Label
     

    Fields inherited from class com.csse3200.game.ui.UIComponent

    skin, stage

    Fields inherited from class com.csse3200.game.components.Component

    enabled, entity
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor for DancePartyUpgrade that initializes the upgrade and sets up event listeners.
    Constructor for DancePartyUpgrade with an explicit CombatStatsComponent.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Activates the Dance Party Upgrade if conditions are met: by triggering Dancing in get Docketservice, pausing time
    void
    Initializes the Dance Party upgrade by loading necessary assets, such as textures and sound effects, and setting up the UI components (progress meter and label).
    void
    Handles the cost of the Dance Party upgrade, deducting gold from the player's CombatStatsComponent.
    void
    Deactivates the Dance Party Upgrade by triggering UnDancing in get Docketservice, unpausing time
    void
    Disposes of assets and cleans up when the upgrade is no longer needed.
    protected void
    draw(com.badlogic.gdx.graphics.g2d.SpriteBatch batch)
    Draw method required by the UIComponent class, but not used in this upgrade.
    float
    Retrieves the remaining time for which the upgrade will stay active.
    boolean
    Retrieves the current state of the playSound flag, which indicates whether the upgrade's sound has been played.
    long
    Retrieves the total upgrade duration.
    boolean
    Gets the current active state of the Dance Party upgrade.
    void
    setStage(com.badlogic.gdx.scenes.scene2d.Stage mock)
    Sets the stage for the UI components, such as the layout, meter, and text.
    void
    Checks and updates the remaining time for the Dance Party upgrade, updating the progress bar meter.

    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

    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
  • Field Details

    • layout

      public com.badlogic.gdx.scenes.scene2d.ui.Table layout
    • text

      public com.badlogic.gdx.scenes.scene2d.ui.Label text
    • meter

      public com.badlogic.gdx.scenes.scene2d.ui.ProgressBar meter
  • Constructor Details

    • DancePartyUpgrade

      public DancePartyUpgrade()
      Constructor for DancePartyUpgrade that initializes the upgrade and sets up event listeners. It listens for "playerCreated" and "Dance party" events.
    • DancePartyUpgrade

      public DancePartyUpgrade(CombatStatsComponent combatStatsComponent)
      Constructor for DancePartyUpgrade with an explicit CombatStatsComponent. This initializes the upgrade and registers the same event listeners as the default constructor.
      Parameters:
      combatStatsComponent - the CombatStatsComponent for the player
  • Method Details

    • create

      public void create()
      Initializes the Dance Party upgrade by loading necessary assets, such as textures and sound effects, and setting up the UI components (progress meter and label). This method is called when the component is created.
      Overrides:
      create in class UIComponent
    • activate

      public void activate()
      Activates the Dance Party Upgrade if conditions are met: by triggering Dancing in get Docketservice, pausing time
      Specified by:
      activate in interface Upgrade
    • deactivate

      public void deactivate()
      Deactivates the Dance Party Upgrade by triggering UnDancing in get Docketservice, unpausing time
      Specified by:
      deactivate in interface Upgrade
    • dancePartyCost

      public void dancePartyCost()
      Handles the cost of the Dance Party upgrade, deducting gold from the player's CombatStatsComponent.
    • update

      public void update()
      Checks and updates the remaining time for the Dance Party upgrade, updating the progress bar meter. It also checks if the upgrade's time has run out and deactivates it accordingly.
      Overrides:
      update in class Component
    • dispose

      public void dispose()
      Disposes of assets and cleans up when the upgrade is no longer needed. Unloads the textures used by the upgrade.
      Specified by:
      dispose in interface com.badlogic.gdx.utils.Disposable
      Overrides:
      dispose in class RenderComponent
    • draw

      protected void draw(com.badlogic.gdx.graphics.g2d.SpriteBatch batch)
      Draw method required by the UIComponent class, but not used in this upgrade.
      Specified by:
      draw in class RenderComponent
      Parameters:
      batch - the SpriteBatch used to draw
    • setStage

      public void setStage(com.badlogic.gdx.scenes.scene2d.Stage mock)
      Sets the stage for the UI components, such as the layout, meter, and text.
      Specified by:
      setStage in interface Renderable
      Parameters:
      mock - the Stage to which the UI components belong
    • isActive

      public boolean isActive()
      Gets the current active state of the Dance Party upgrade.
      Returns:
      true if the upgrade is currently active, false otherwise
    • getActiveTimeRemaining

      public float getActiveTimeRemaining()
      Retrieves the remaining time for which the upgrade will stay active.
      Returns:
      the remaining active time in milliseconds
    • getUpgradeDuration

      public long getUpgradeDuration()
      Retrieves the total upgrade duration.
      Returns:
      the total duration of the upgrade in milliseconds
    • getPlaySound

      public boolean getPlaySound()
      Retrieves the current state of the playSound flag, which indicates whether the upgrade's sound has been played.
      Returns:
      true if the sound has been played, false otherwise