Class Player
The entity that will be controller by user input, this functions just like
a base
Entity but with an inventory to hold keys.- Author:
- Abdul
-
Nested Class Summary
Nested classes/interfaces inherited from class nz.ac.vuw.ecs.swen225.gp22.domain.Entity
Entity.Action, Entity.Direction -
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionPlayer(Maze.Point entityPos, Entity.Direction facingDir) Default constructor, sets the position and direction of the player. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddKey(ColorableTile.Color color) Adds a key to the player's inventory.voidconsumeKey(ColorableTile.Color color) Consumes a key from the player's inventory.booleanhasKey(ColorableTile.Color color) Checks if the player has a key of a certain color.intkeyCount()voidCombines methods setDir() and move().voidping()Non-player entities will act based on how often this is called.voidClears all the keys that the player has.voidunping()Undoes the effects of ping().Methods inherited from class nz.ac.vuw.ecs.swen225.gp22.domain.Entity
deleteEntity, getDir, getPos, hasAction, id, move, move, move, move, pollAction, setDir, setPosMethods inherited from class nz.ac.vuw.ecs.swen225.gp22.domain.Observable
addObserver, removeObserver, updateObservers
-
Constructor Details
-
Player
Default constructor, sets the position and direction of the player.- Parameters:
entityPos- Point to set the position field to.facingDir- Direction to set the direction field to.
-
-
Method Details
-
ping
public void ping()Description copied from class:EntityNon-player entities will act based on how often this is called. -
unping
public void unping()Description copied from class:EntityUndoes the effects of ping(). -
moveAndTurn
Description copied from class:EntityCombines methods setDir() and move().- Overrides:
moveAndTurnin classEntity<Player>- Parameters:
dir- The new direction of the entity.
-
resetItems
public void resetItems()Clears all the keys that the player has. -
addKey
Adds a key to the player's inventory.- Parameters:
color- Color of the key.
-
consumeKey
Consumes a key from the player's inventory.- Parameters:
color- Color of the key.
-
hasKey
Checks if the player has a key of a certain color.- Parameters:
color- Color of the key.- Returns:
- Whether or not the key is in the player's inventory.
-
keyCount
public int keyCount()- Returns:
- The number of keys the player has.
-
getAllKeys
- Returns:
- An immutable list of the keys collected.
-