Class CollectItemsAchievement


public class CollectItemsAchievement extends Achievement
An Achievement completed by collecting a certain number of items
  • Constructor Details

    • CollectItemsAchievement

      public CollectItemsAchievement(String name, int numberOfItems)
      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

      public void registerMission(EventHandler missionManagerEvents)
      Registers the Achievement with the MissionManager by listening to the ITEMS_COLLECTED Mission event.
      Specified by:
      registerMission in class Mission
      Parameters:
      missionManagerEvents - - A reference to the EventHandler on the MissionManager, 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 class Mission
      Returns:
      - True if player has cleared at least numberOfItemsToCollect, otherwise False.
    • getDescription

      public String getDescription()
      The description of the Achievement to give a representation of the player's progress in the Achievement.
      Specified by:
      getDescription in class Mission
      Returns:
      - Human-readable description of the CollectItemsAchievement.
    • getShortDescription

      public String getShortDescription()
      Gives the player's progress in the CollectItemsAchievement.
      Specified by:
      getShortDescription in class Mission
      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 class Mission
      Parameters:
      progress - The JsonValue representing the progress of the Mission as determined by the value returned in getProgress().
    • getProgress

      public Object getProgress()
      Get the number of debris the player has cleared since Achievements was registered.
      Specified by:
      getProgress in class Mission
      Returns:
      - number of items collected
    • resetState

      protected void resetState()
      Resets the number of debris cleared to 0.