Package com.csse3200.game.components
Class ButtonManagerComponent
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.ButtonManagerComponent
Manages a group of buttons that form one full button puzzle in which all buttons in manager
must be pressed in a set amount of time
Tracks button states, handles puzzle timing, triggers even on success and resets all buttons on failure
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addButton
(ButtonComponent button) Adds a button to the list of buttons managed by this managerReturns list of buttons being managed by this puzzle button managerfloat
Gets time remaining before puzzle fails i.e.boolean
Checks if puzzle successfully completedvoid
Called when any button is pressed, starts the timer if the puzzle isn't already activevoid
Resets puzzle state by clearing progress, deactivating puzzle and unpressing all buttons being controlled by the managervoid
update()
Updates the puzzle timer and checks button state If all buttons pressed before timer expires, puzzle completed and event triggered If time runs out before buttons all marked as pressed, all buttons are reset by forceUnpress()Methods inherited from class com.csse3200.game.components.Component
create, dispose, earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate
-
Constructor Details
-
ButtonManagerComponent
public ButtonManagerComponent()
-
-
Method Details
-
addButton
Adds a button to the list of buttons managed by this manager- Parameters:
button
- the ButtonComponent to add
-
onButtonPressed
public void onButtonPressed()Called when any button is pressed, starts the timer if the puzzle isn't already active -
update
public void update()Updates the puzzle timer and checks button state If all buttons pressed before timer expires, puzzle completed and event triggered If time runs out before buttons all marked as pressed, all buttons are reset by forceUnpress() -
isPuzzleCompleted
public boolean isPuzzleCompleted()Checks if puzzle successfully completed- Returns:
- true of puzzle completed, false otherwise
-
resetPuzzle
public void resetPuzzle()Resets puzzle state by clearing progress, deactivating puzzle and unpressing all buttons being controlled by the manager -
getTimeLeft
public float getTimeLeft()Gets time remaining before puzzle fails i.e. time left to complete- Returns:
- time left if puzzle active, 0 otherwise
-
getButtons
Returns list of buttons being managed by this puzzle button manager- Returns:
- list of ButtonComponents being managed
-