Package cl.cromer.azaraka.object
Class Player
- java.lang.Object
-
- cl.cromer.azaraka.object.Object
-
- cl.cromer.azaraka.object.Player
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface cl.cromer.azaraka.Constants
Constants.AIHeuristic, Constants.LogLevel, Constants.PlayerAIType
-
-
Field Summary
Fields Modifier and Type Field Description static int
MAX_HEALTH
The maximum health of the player-
Fields inherited from interface cl.cromer.azaraka.Constants
AI_HEURISTIC, APPEND_LOGS, CELL_PIXELS, CHESTS, ENEMIES, ENEMY_AI, EXPORT_SCENE, FONT, FONT_SIZE, GENERATE_SCENE, GLOBAL_LOG, HORIZONTAL_CELLS, LOG_TO_FILE, OBSTACLES, PLAYER_AI, PRETTY_JSON, TITLE, VERTICAL_CELLS, VOLUME
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
attacked()
This is called when the player gets attackedvoid
deleteInstance()
Delete the Player instancevoid
gainHealth(int amount)
Gain a variable amount of healthAI
getAi()
Get the AI in use by the playerint
getGemCount()
Get the number of gems the player hasint
getHealth()
Get the current health of the playerstatic Player
getInstance(Scene scene, Cell cell)
Create the Player instancejava.util.List<Gem>
getInventoryGems(boolean all)
Get the gems the player hasboolean
hasKey()
Checks if the player has a keyboolean
hasTaintedGem()
Check if player has a tainted gem in his inventoryvoid
interact()
Interact with an object in the gamevoid
keyPressed(int keyCode)
Handle keys being pressed in the gamevoid
keyPressed(java.awt.event.KeyEvent event)
Handle keys being pressed in the gamevoid
loseHealth(int amount)
Lose a variable amount of healthprotected boolean
moveDown()
Move the player downprotected boolean
moveLeft()
Move the player to the leftprotected boolean
moveRight()
Move the player to the rightprotected boolean
moveUp()
Move the player upvoid
run()
This runs when the thread starts-
Methods inherited from class cl.cromer.azaraka.object.Object
changeDirection, drawAnimation, getActive, getAnimation, getCell, getLogger, getScene, getX, getY, loadCharacter, setActive, setAnimation, setCell, setLogger, setUseOffset, setXScale, setYScale
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface cl.cromer.azaraka.Constants
getLogger, initializeLogger, random
-
-
-
-
Field Detail
-
MAX_HEALTH
public static final int MAX_HEALTH
The maximum health of the player- See Also:
- Constant Field Values
-
-
Method Detail
-
getInstance
public static Player getInstance(Scene scene, Cell cell)
Create the Player instance- Parameters:
scene
- The scene the player is incell
- The cell the player is in- Returns:
- Returns the instance
-
deleteInstance
public void deleteInstance()
Delete the Player instance
-
keyPressed
public void keyPressed(java.awt.event.KeyEvent event)
Handle keys being pressed in the game- Parameters:
event
- The event from the keyboard
-
keyPressed
public void keyPressed(int keyCode)
Handle keys being pressed in the game- Parameters:
keyCode
- The key code to handle
-
moveUp
protected boolean moveUp()
Move the player up
-
moveDown
protected boolean moveDown()
Move the player down
-
moveLeft
protected boolean moveLeft()
Move the player to the left
-
moveRight
protected boolean moveRight()
Move the player to the right
-
interact
public void interact()
Interact with an object in the game
-
hasKey
public boolean hasKey()
Checks if the player has a key- Returns:
- Returns true if the player has a key or false if they have no keys
-
hasTaintedGem
public boolean hasTaintedGem()
Check if player has a tainted gem in his inventory- Returns:
- Returns true if he has one or false otherwise
-
getGemCount
public int getGemCount()
Get the number of gems the player has- Returns:
- Returns the number of gems the player has
-
attacked
public void attacked()
This is called when the player gets attacked
-
getHealth
public int getHealth()
Get the current health of the player- Returns:
- Returns the health value
-
getAi
public AI getAi()
Get the AI in use by the player- Returns:
- Returns the current AI in use
-
getInventoryGems
public java.util.List<Gem> getInventoryGems(boolean all)
Get the gems the player has- Parameters:
all
- Whether or not to return the gems that are still in transition to inventory- Returns:
- Returns an array of the gems the player is carrying
-
loseHealth
public void loseHealth(int amount)
Lose a variable amount of health- Parameters:
amount
- The amount to lose
-
gainHealth
public void gainHealth(int amount)
Gain a variable amount of health- Parameters:
amount
- The amount of health to gain
-
-