Class DancePartyUpgrade
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.rendering.RenderComponent
com.csse3200.game.ui.UIComponent
com.csse3200.game.components.upgrades.DancePartyUpgrade
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable,Upgrade,Renderable,Comparable<Renderable>
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
FieldsModifier and TypeFieldDescriptioncom.badlogic.gdx.scenes.scene2d.ui.Tablecom.badlogic.gdx.scenes.scene2d.ui.ProgressBarcom.badlogic.gdx.scenes.scene2d.ui.LabelFields inherited from class com.csse3200.game.ui.UIComponent
skin, stage -
Constructor Summary
ConstructorsConstructorDescriptionConstructor for DancePartyUpgrade that initializes the upgrade and sets up event listeners.DancePartyUpgrade(CombatStatsComponent combatStatsComponent) Constructor for DancePartyUpgrade with an explicit CombatStatsComponent. -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate()Activates the Dance Party Upgrade if conditions are met: by triggering Dancing in get Docketservice, pausing timevoidcreate()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).voidHandles the cost of the Dance Party upgrade, deducting gold from the player's CombatStatsComponent.voidDeactivates the Dance Party Upgrade by triggering UnDancing in get Docketservice, unpausing timevoiddispose()Disposes of assets and cleans up when the upgrade is no longer needed.protected voiddraw(com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Draw method required by the UIComponent class, but not used in this upgrade.floatRetrieves the remaining time for which the upgrade will stay active.booleanRetrieves the current state of the playSound flag, which indicates whether the upgrade's sound has been played.longRetrieves the total upgrade duration.booleanisActive()Gets the current active state of the Dance Party upgrade.voidsetStage(com.badlogic.gdx.scenes.scene2d.Stage mock) Sets the stage for the UI components, such as the layout, meter, and text.voidupdate()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, getZIndexMethods inherited from class com.csse3200.game.rendering.RenderComponent
compareTo, renderMethods inherited from class com.csse3200.game.components.Component
earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdateMethods 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
-
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
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:
createin classUIComponent
-
activate
public void activate()Activates the Dance Party Upgrade if conditions are met: by triggering Dancing in get Docketservice, pausing time -
deactivate
public void deactivate()Deactivates the Dance Party Upgrade by triggering UnDancing in get Docketservice, unpausing time- Specified by:
deactivatein interfaceUpgrade
-
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. -
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:
disposein interfacecom.badlogic.gdx.utils.Disposable- Overrides:
disposein classRenderComponent
-
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:
drawin classRenderComponent- 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:
setStagein interfaceRenderable- 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
-