Class AchievementsStatsComponent
java.lang.Object
com.deco2800.game.components.Component
com.deco2800.game.components.achievements.AchievementsStatsComponent
public class AchievementsStatsComponent extends Component
The class listens to game statistics given the forest area lifecycle
and emits new achievement events
-
Field Summary
-
Constructor Summary
Constructors Constructor Description AchievementsStatsComponent()
-
Method Summary
Modifier and Type Method Description void
create()
Called when the entity is created and registered.static java.util.List<BaseAchievementConfig>
getAchievements()
Returns a list of all achievementsstatic java.util.List<BaseAchievementConfig>
getUnlockedAchievements()
Returns a list of unlocked achievementsvoid
handleItemPickup(java.lang.String itemName)
void
increment(java.lang.String propertyName)
Fetches the value for that particular property and increments itstatic void
resetAchievements()
Lock all the achievements againvoid
setDistance(double distance)
Maintains the distance traveled by the main player character in metersvoid
setFirstAidByVal(int firstAids)
void
setGoldByVal(int gold)
void
setHealth(int health)
Maintains the current health of playervoid
setItemCount()
Maintains the count of the number of items picked upvoid
setItemCountByVal(int itemCount)
void
setScore(int score)
Maintains the current scorevoid
setSpaceshipAvoidSuccess()
Maintains the spaceshipAvoidSuccess status of the playervoid
setTime(long time)
Maintains the in game timevoid
update()
Called once per frame of the game, and should be used for most component logic.void
updateConditionsAndRevalidate(java.lang.String propertyName, double val)
Updates the game variables in concern and checks if an achievement has been unlockedMethods inherited from class com.deco2800.game.components.Component
dispose, earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate
-
Constructor Details
-
AchievementsStatsComponent
public AchievementsStatsComponent()
-
-
Method Details
-
getAchievements
Returns a list of all achievements- Returns:
- achievements
-
getUnlockedAchievements
Returns a list of unlocked achievements- Returns:
- unlockedAchievements
-
resetAchievements
public static void resetAchievements()Lock all the achievements again -
create
public void create()Description copied from class:Component
Called when the entity is created and registered. Initial logic such as calls to GetComponent should be made here, not in the constructor which is called before an entity is finished. -
setSpaceshipAvoidSuccess
public void setSpaceshipAvoidSuccess()Maintains the spaceshipAvoidSuccess status of the player -
setDistance
public void setDistance(double distance)Maintains the distance traveled by the main player character in meters -
setHealth
public void setHealth(int health)Maintains the current health of player- Parameters:
health
- player's changed health
-
setTime
public void setTime(long time)Maintains the in game time- Parameters:
time
- current game time
-
setScore
public void setScore(int score)Maintains the current score- Parameters:
score
- the current game score
-
update
public void update()Description copied from class:Component
Called once per frame of the game, and should be used for most component logic. Not called if component is disabled. -
handleItemPickup
public void handleItemPickup(java.lang.String itemName) -
increment
public void increment(java.lang.String propertyName)Fetches the value for that particular property and increments it- Parameters:
propertyName
- name of the achievement condition
-
setFirstAidByVal
public void setFirstAidByVal(int firstAids) -
setGoldByVal
public void setGoldByVal(int gold) -
setItemCount
public void setItemCount()Maintains the count of the number of items picked up -
setItemCountByVal
public void setItemCountByVal(int itemCount) -
updateConditionsAndRevalidate
public void updateConditionsAndRevalidate(java.lang.String propertyName, double val)Updates the game variables in concern and checks if an achievement has been unlocked- Parameters:
propertyName
- name of propertyval
- property value
-