Package com.csse3200.game.components.npc
Class TamableComponent
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.npc.TamableComponent
- All Implemented Interfaces:
com.badlogic.gdx.utils.Json.Serializable
This the class for Tameable Component. These components should
only apply to animals. Tameable stats can be found in the NPCs.json file
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionTamableComponent
(Entity player, int tamingThreshold, double tamingProbability, String favouriteFood) Constructor for the Tameable Component class -
Method Summary
Modifier and TypeMethodDescriptionvoid
create()
Create the event and add it to the event hashmap so the function can be called and the player can observe the effects.Getter for favourite foodboolean
isTamed()
Function is used to check to see if the animal has been tamed.void
read
(com.badlogic.gdx.utils.Json json, com.badlogic.gdx.utils.JsonValue jsonMap) void
setTame
(boolean value) Function is used to set the tame value of the animals.void
write
(com.badlogic.gdx.utils.Json json) Writes to the json boolean of tamed.Methods inherited from class com.csse3200.game.components.Component
dispose, earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update
-
Constructor Details
-
TamableComponent
public TamableComponent(Entity player, int tamingThreshold, double tamingProbability, String favouriteFood) Constructor for the Tameable Component class- Parameters:
player
- The main player/user entitytamingThreshold
- An integer that number of times the animal can be fed to tame it.tamingProbability
- A double that represents chances to tame the animal.favouriteFood
- The animals favourite food.
-
-
Method Details
-
create
public void create()Create the event and add it to the event hashmap so the function can be called and the player can observe the effects. -
isTamed
public boolean isTamed()Function is used to check to see if the animal has been tamed.- Returns:
- True if the animal has been tamed, else false.
-
setTame
public void setTame(boolean value) Function is used to set the tame value of the animals. This is used for testing purposes and will be deleted in later sprint.- Parameters:
value
- Boolean value that will be used to set to the istamed variable.
-
write
public void write(com.badlogic.gdx.utils.Json json) Writes to the json boolean of tamed. -
read
public void read(com.badlogic.gdx.utils.Json json, com.badlogic.gdx.utils.JsonValue jsonMap) -
getFavouriteFood
Getter for favourite food- Returns:
- favourite food
-