Class Player


public class Player extends Entity<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
  • Constructor Details

    • Player

      public Player(Maze.Point entityPos, Entity.Direction facingDir)
      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: Entity
      Non-player entities will act based on how often this is called.
      Specified by:
      ping in class Entity<Player>
    • unping

      public void unping()
      Description copied from class: Entity
      Undoes the effects of ping().
      Specified by:
      unping in class Entity<Player>
    • moveAndTurn

      public void moveAndTurn(Entity.Direction dir)
      Description copied from class: Entity
      Combines methods setDir() and move().
      Overrides:
      moveAndTurn in class Entity<Player>
      Parameters:
      dir - The new direction of the entity.
    • resetItems

      public void resetItems()
      Clears all the keys that the player has.
    • addKey

      public void addKey(ColorableTile.Color color)
      Adds a key to the player's inventory.
      Parameters:
      color - Color of the key.
    • consumeKey

      public void consumeKey(ColorableTile.Color color)
      Consumes a key from the player's inventory.
      Parameters:
      color - Color of the key.
    • hasKey

      public boolean hasKey(ColorableTile.Color color)
      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

      public List<ColorableTile.Color> getAllKeys()
      Returns:
      An immutable list of the keys collected.