Class EndDayDisplay
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.rendering.RenderComponent
com.csse3200.game.ui.UIComponent
com.csse3200.game.components.maingame.EndDayDisplay
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable,Renderable,Comparable<Renderable>
-
Field Summary
FieldsModifier and TypeFieldDescriptionFields inherited from class com.csse3200.game.ui.UIComponent
skin, stage -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a close button to the display that can hide this component.voidRegisters event listeners relevant to the end-of-day display operations, such as gold updates and customer events.voidAdds a spacer to the layout to manage vertical spacing between components.voidAnimates the change in gold displayed, making the transition smooth.voidcreate()Initializes and creates the end-of-day display components.voidSets up a white background for the display using a predefined image.com.badlogic.gdx.scenes.scene2d.ui.ImagecreateImage(String texturePath) Creates and returns an image actor for a given texture path.voiddraw(com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Draw the renderable.com.badlogic.gdx.scenes.scene2d.ui.ImagegetGame()com.badlogic.gdx.scenes.scene2d.ui.Tablecom.badlogic.gdx.scenes.scene2d.ui.Imagecom.badlogic.gdx.scenes.scene2d.ui.Imagecom.badlogic.gdx.scenes.scene2d.ui.ImagevoidhandleGoldUpdate(int gold) Handles updates to the gold display when the total gold changes.voidhandlePassedCustomer(String customerName) Handles the event when a customer has successfully completed their interaction, such as finishing an order.voidhide()Hides the display and triggers the game to continue.booleanvoidsetBirdImage(com.badlogic.gdx.scenes.scene2d.ui.Image birdImage) voidvoidsetLayout(com.badlogic.gdx.scenes.scene2d.ui.Table layout) voidsetPointImage1(com.badlogic.gdx.scenes.scene2d.ui.Image pointImage1) voidsetPointImage2(com.badlogic.gdx.scenes.scene2d.ui.Image pointImage2) voidsetPointImage3(com.badlogic.gdx.scenes.scene2d.ui.Image pointImage3) voidsetStage(com.badlogic.gdx.scenes.scene2d.Stage mock) voidSets up the lists displaying customer feedback.voidSets up the display for showing the current gold amount.voidSets up the images for various UI elements in the display.voidsetupUI()Sets up the user interface elements for the display.voidsetVisible(boolean visible) voidshow()Shows the end-of-day display.voidToggles the visibility of the display between visible and hidden.voidupdateBirdPosition(float delta) Updates the position of the bird image on the display.voidupdateCustomerList(String customerName) Updates the customer feedback lists when new customer feedback is received.Methods inherited from class com.csse3200.game.ui.UIComponent
getLayer, getZIndexMethods inherited from class com.csse3200.game.rendering.RenderComponent
compareTo, dispose, renderMethods inherited from class com.csse3200.game.components.Component
earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, updateMethods 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
-
customerNameArray
-
passedCustomerArray
-
failedCustomerArray
-
-
Constructor Details
-
EndDayDisplay
public EndDayDisplay()Constructor for the EndDayDisplay class.
-
-
Method Details
-
create
public void create()Initializes and creates the end-of-day display components. This method sets up the entire layout for the display including background, images, and interactive elements like buttons and lists.- Overrides:
createin classUIComponent
-
addListeners
public void addListeners()Registers event listeners relevant to the end-of-day display operations, such as gold updates and customer events. -
createBackground
public void createBackground()Sets up a white background for the display using a predefined image. This method loads a texture from the resource service and sets it as the background for the layout. The image used is specified in the texture path 'images/endday.png'. -
setupImages
public void setupImages()Sets up the images for various UI elements in the display. This method initializes and positions images that are used to enhance the visual representation of the display, such as birds and points icons. -
createImage
Creates and returns an image actor for a given texture path. This utility method simplifies the creation of an image actor from a texture, making it easier to manage image setup throughout the class.- Parameters:
texturePath- the path to the texture asset- Returns:
- an initialized Image actor with the specified texture
-
setupUI
public void setupUI()Sets up the user interface elements for the display. This method arranges all the interactive and non-interactive elements within the display, ensuring proper layout and functionality. -
addSpacer
public void addSpacer()Adds a spacer to the layout to manage vertical spacing between components. This method helps in aligning other UI components by adding customizable space in the layout table. -
setupGoldDisplay
public void setupGoldDisplay()Sets up the display for showing the current gold amount. This method configures a label to show the amount of gold collected, updating its value in real time during the display. -
setupCustomerLists
public void setupCustomerLists()Sets up the lists displaying customer feedback. This method configures two lists to show which customers passed and which failed, providing direct feedback to the player. -
addCloseButton
public void addCloseButton()Adds a close button to the display that can hide this component. This method creates a button that when clicked, will toggle the visibility of the end-of-day display, effectively closing it. -
handleGoldUpdate
public void handleGoldUpdate(int gold) Handles updates to the gold display when the total gold changes. This method is typically called by event listeners responding to changes in the game state related to gold accumulation.- Parameters:
gold- the new total amount of gold to display
-
handlePassedCustomer
Handles the event when a customer has successfully completed their interaction, such as finishing an order. This method adds the customer's name in uppercase to the list of passed customers and logs the event.- Parameters:
customerName- The name of the customer who passed.
-
updateCustomerList
Updates the customer feedback lists when new customer feedback is received. This method is called whenever there is new data about customer interactions, allowing the display to refresh its lists accordingly.- Parameters:
customerName- the name of the customer to add to the feedback list
-
updateBirdPosition
public void updateBirdPosition(float delta) Updates the position of the bird image on the display. This method is used to animate the bird image across the display, creating a dynamic visual effect.- Parameters:
delta- the time elapsed since the last frame update
-
animateGoldChange
public void animateGoldChange()Animates the change in gold displayed, making the transition smooth. This method gradually updates the displayed gold amount from the previous value to the current value, using a simple animation. -
show
public void show()Shows the end-of-day display. This method makes the display visible and updates all dynamic content to reflect the current game state. It is usually called in response to a game event. -
hide
public void hide()Hides the display and triggers the game to continue. This method is called when the close button is activated, hiding the display and signaling the game to proceed with post-display actions. -
toggleVisibility
public void toggleVisibility()Toggles the visibility of the display between visible and hidden. This method is a convenience for quickly showing or hiding the end-of-day display based on its current visibility state. -
draw
public void draw(com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Description copied from class:RenderComponentDraw the renderable. Should be called only by the renderer, not manually.- Specified by:
drawin classRenderComponent- Parameters:
batch- Batch to render to.
-
setStage
public void setStage(com.badlogic.gdx.scenes.scene2d.Stage mock) -
isVisible
public boolean isVisible() -
setVisible
public void setVisible(boolean visible) -
getLayout
public com.badlogic.gdx.scenes.scene2d.ui.Table getLayout() -
setLayout
public void setLayout(com.badlogic.gdx.scenes.scene2d.ui.Table layout) -
getGame
-
setGame
-
getBirdImage
public com.badlogic.gdx.scenes.scene2d.ui.Image getBirdImage() -
setBirdImage
public void setBirdImage(com.badlogic.gdx.scenes.scene2d.ui.Image birdImage) -
getPointImage1
public com.badlogic.gdx.scenes.scene2d.ui.Image getPointImage1() -
setPointImage1
public void setPointImage1(com.badlogic.gdx.scenes.scene2d.ui.Image pointImage1) -
getPointImage2
public com.badlogic.gdx.scenes.scene2d.ui.Image getPointImage2() -
setPointImage2
public void setPointImage2(com.badlogic.gdx.scenes.scene2d.ui.Image pointImage2) -
getPointImage3
public com.badlogic.gdx.scenes.scene2d.ui.Image getPointImage3() -
setPointImage3
public void setPointImage3(com.badlogic.gdx.scenes.scene2d.ui.Image pointImage3)
-