public class Player extends Human
Human.Direction, Human.Mode, Human.State
Modifier and Type | Field and Description |
---|---|
static float |
COLLIDER_HEIGHT |
static float |
COLLIDER_WIDTH
Stores the width and height of the player's rectangle collider in world units.
|
static float |
COMBAT_JUMP_SPEED
Stores the jump speed of the player in the vertical direction when in COMBAT mode.
|
static float |
DEFAULT_HEALTH
Holds the player's default health.
|
static float |
EXPLORATION_JUMP_SPEED
Stores the jump speed of the player in the vertical direction when in EXPLORING mode.
|
static float |
FALL_SPEED
Stores the downwards speed at which the player falls through a TerrainLayer.
|
static float |
INVULNERABLE_TIME
Holds the amount of time that the player is invulnerable when hit.
|
static float |
MAX_WALK_SPEED
Stores the maximum walk speed of the player in the horizontal direction.
|
Constructor and Description |
---|
Player()
Creates a player whose bottom-center is at position (0, 0).
|
Player(float x,
float y)
Creates a player whose bottom-center is at position (x, y).
|
Modifier and Type | Method and Description |
---|---|
boolean |
canTarget()
Override the canTarget method as always returning false since the Player can never be targetted.
|
void |
charge()
Makes the player start to charge his gun.
|
void |
chopTree()
Makes the player start chopping a tree
|
boolean |
didWin()
Returns true if the player has won the game.
|
void |
fall()
Makes the player fall through one layer.
|
void |
fire()
Makes the player fire his ranged weapon
|
float |
getChargeCompletion()
Returns a float between 0 and 1 representing the charge completion of the player's ranged weapon.
|
Line |
getCrosshair()
Returns the crosshair line, which dictates where the player's ranged weapon will fire and where the bullet will travel.
|
Vector2 |
getCrosshairPoint()
Returns the position where the weapon crosshair should be placed on the player in world units.
|
Inventory |
getInventory()
Gets the loadout which stores the items held by the player.
|
Loadout |
getLoadout()
Retrieves the player's loadout containing the player's weapons.
|
MeleeWeapon |
getMeleeWeapon()
Returns the melee weapon that the player has equipped.
|
Rectangle |
getMeleeWeaponCollider()
Returns the Collider of the player's melee weapon.
|
RangedWeapon |
getRangedWeapon()
Returns the ranged weapon that the player has equipped.
|
Zombie |
getZombieToFight()
Returns the zombie that the player should fight once he enters combat mode.
|
boolean |
hasMeleeWeapon()
Returns true if the player has a melee weapon equipped.
|
boolean |
hasRangedWeapon()
Returns true if the player has a ranged weapon equipped.
|
boolean |
hasRangedWeaponOut()
Returns true if the player has his ranged weapon out and visible.
|
void |
hitHead(Zombie zombie)
Called when the player hits a zombie's head.
|
void |
hitTree()
Called when the player has hit the tree stored as his target.
|
void |
jump()
Makes the player jump.
|
void |
loseLoot()
Makes the player lose all of the items in his inventory.
|
void |
loseTarget()
Called when the player loses his target.
|
void |
makeInvulnerable()
Makes the player invulnerable from attacks for a given amount of seconds.
|
void |
melee()
Makes the player swing his melee weapon if he has one.
|
void |
meleeHit(Zombie zombie)
Deals damage to the zombie with the player's melee weapon.
|
void |
regenerate()
Regenerates the player to default health.
|
void |
setInventory(Inventory inventory)
Sets the loadout which stores the items held by the player.
|
void |
setListener(PlayerListener listener)
Sets the given listener to have its methods delegated by the player instance.
|
void |
setLoadout(Loadout loadout)
Sets the player's loadout.
|
void |
setZombieToFight(Zombie zombieToFight)
Sets the zombie the player should fight once he enters combat mode.
|
void |
takeDamage(float amount)
Overrides the takeDamage() method to take note of when the player dies, in order to display the KO animation.
|
void |
update(float deltaTime)
Updates the player's internal game logic.
|
getDirection, getHealth, getInvulnerabilityTime, getMode, getPreviousState, getState, getTarget, getWalkSpeed, isDead, isFacing, isInvulnerable, isTargetReached, reset, setDirection, setHealth, setInvulnerabilityTime, setMode, setPreviousState, setState, setTarget, setTargetReached, setWalkSpeed
getAcceleration, getCollider, getObjectId, getPosition, getPreviousPosition, getSkeleton, getStateTime, getTerrainCell, getVelocity, getX, getY, isAbove, moveTo, setAcceleration, setCollider, setObjectId, setPosition, setSkeleton, setStateTime, setTerrainCell, setVelocity, setVelocityX, setVelocityY, setX, setY, updateCollider, updatePosition
public static final float COLLIDER_WIDTH
public static final float COLLIDER_HEIGHT
public static final float DEFAULT_HEALTH
public static final float MAX_WALK_SPEED
public static final float EXPLORATION_JUMP_SPEED
public static final float COMBAT_JUMP_SPEED
public static final float FALL_SPEED
public static final float INVULNERABLE_TIME
public Player()
public Player(float x, float y)
public void update(float deltaTime)
public void jump()
public void fall()
public void chopTree()
public void melee()
public void charge()
public void fire()
public void meleeHit(Zombie zombie)
public void hitTree()
public void hitHead(Zombie zombie)
public float getChargeCompletion()
public void regenerate()
public void takeDamage(float amount)
takeDamage
in class Human
public void loseLoot()
public void loseTarget()
loseTarget
in class Human
public boolean didWin()
public boolean canTarget()
canTarget
in class GameObject
public MeleeWeapon getMeleeWeapon()
public RangedWeapon getRangedWeapon()
public boolean hasMeleeWeapon()
public boolean hasRangedWeapon()
public boolean hasRangedWeaponOut()
public Rectangle getMeleeWeaponCollider()
public Line getCrosshair()
public Vector2 getCrosshairPoint()
public void makeInvulnerable()
makeInvulnerable
in class Human
public Loadout getLoadout()
public void setLoadout(Loadout loadout)
public Inventory getInventory()
public void setInventory(Inventory inventory)
public Zombie getZombieToFight()
public void setZombieToFight(Zombie zombieToFight)
public void setListener(PlayerListener listener)