Class CollectItemsAchievement
java.lang.Object
com.csse3200.game.missions.Mission
com.csse3200.game.missions.achievements.Achievement
com.csse3200.game.missions.achievements.CollectItemsAchievement
An
Achievement
completed by collecting a certain number of items-
Constructor Summary
ConstructorsConstructorDescriptionCollectItemsAchievement
(String name, int numberOfItems) An achievement where player is required to collect a certain number of items -
Method Summary
Modifier and TypeMethodDescriptionThe description of the Achievement to give a representation of the player's progress in the Achievement.Get the number of debris the player has cleared since Achievements was registered.Gives the player's progress in the CollectItemsAchievement.boolean
Checks if the CollectItemsAchievement is completevoid
readProgress
(com.badlogic.gdx.utils.JsonValue progress) Read in the number of items the player has collected from a JsonValue.void
registerMission
(EventHandler missionManagerEvents) Registers the Achievement with theMissionManager
by listening to the ITEMS_COLLECTED Mission event.protected void
Resets the number of debris cleared to 0.protected void
Updating the state of the CollectItemsAchievement.Methods inherited from class com.csse3200.game.missions.achievements.Achievement
write
Methods inherited from class com.csse3200.game.missions.Mission
getName, notifyUpdate
-
Constructor Details
-
CollectItemsAchievement
An achievement where player is required to collect a certain number of items- Parameters:
name
- - Human-readable name of the Achievement.numberOfItems
- - Amount of items the player needs to collect.
-
-
Method Details
-
registerMission
Registers the Achievement with theMissionManager
by listening to the ITEMS_COLLECTED Mission event.- Specified by:
registerMission
in classMission
- Parameters:
missionManagerEvents
- - A reference to theEventHandler
on theMissionManager
, with which relevant events should be listened to.
-
updateState
protected void updateState()Updating the state of the CollectItemsAchievement. If called this method will increment the numberOfItemsCollected and then notifyUpdate(). -
isCompleted
public boolean isCompleted()Checks if the CollectItemsAchievement is complete- Specified by:
isCompleted
in classMission
- Returns:
- - True if player has cleared at least numberOfItemsToCollect, otherwise False.
-
getDescription
The description of the Achievement to give a representation of the player's progress in the Achievement.- Specified by:
getDescription
in classMission
- Returns:
- - Human-readable description of the CollectItemsAchievement.
-
getShortDescription
Gives the player's progress in the CollectItemsAchievement.- Specified by:
getShortDescription
in classMission
- Returns:
- - Human-readable String of how many items the player has collected and how many they have left to collect
-
readProgress
public void readProgress(com.badlogic.gdx.utils.JsonValue progress) Read in the number of items the player has collected from a JsonValue.- Specified by:
readProgress
in classMission
- Parameters:
progress
- TheJsonValue
representing the progress of theMission
as determined by the value returned ingetProgress()
.
-
getProgress
Get the number of debris the player has cleared since Achievements was registered.- Specified by:
getProgress
in classMission
- Returns:
- - number of items collected
-
resetState
protected void resetState()Resets the number of debris cleared to 0.
-