Package com.mygdx.auber.entities
Class Player
- java.lang.Object
-
- com.badlogic.gdx.graphics.g2d.TextureRegion
-
- com.badlogic.gdx.graphics.g2d.Sprite
-
- com.mygdx.auber.entities.Player
-
- All Implemented Interfaces:
com.badlogic.gdx.InputProcessor
public final class Player extends com.badlogic.gdx.graphics.g2d.Sprite implements com.badlogic.gdx.InputProcessor
-
-
Field Summary
Fields Modifier and Type Field Description static floatMIN_TELEPORT_DISTANCEHow close Auber has to be to a teleporter in order to teleport.
-
Constructor Summary
Constructors Constructor Description Player(com.badlogic.gdx.graphics.g2d.Sprite newSprite, com.badlogic.gdx.utils.Array<com.badlogic.gdx.maps.tiled.TiledMapTileLayer> newCollisionLayer, boolean isDemo)Class constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidarrestUp(boolean inUse)Sets whether the player is using the arrest powerup.static booleancanHeal()Returns whether the player can currently heal.voiddispose()Called when this object is deleted.voiddraw(com.badlogic.gdx.graphics.g2d.Batch batch)Used to draw the player to the screen.voiddrawArrow(com.badlogic.gdx.graphics.g2d.Batch batch)Draws arrows pointing in the direction of key systems being destroyed.voiddrawCircle(com.badlogic.gdx.graphics.glutils.ShapeRenderer shapeRenderer)Draws the arrest radius for Auber.java.lang.Stringencode()Encodes this Player to a string.voidfindInfirmary(com.badlogic.gdx.maps.tiled.TiledMapTileLayer tileLayer)Finds the location of the infirmary on the map.voidfreezeUp(boolean inUse)Sets whether the player is using the freeze powerup.static booleangetFreeze()Gets whether the player is using the freeze powerup.floatgetHealth()Returns this player's health.static booleangetHighlight()Gets whether the player is using the highlight powerup.com.badlogic.gdx.math.Vector2getPosition()Gets the position of this Player.booleangetRequestedPause()Returns whether the user has requested pause.booleangetRequestedSave()Returns whether the user has requested save.static com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2>getTeleporterLocations(com.badlogic.gdx.maps.tiled.TiledMapTileLayer tileLayer)Get the location of the teleporters on the map.voidhandledSave()Called when the player has been saved.voidheal()Heal Auber for the full amount.voidheal(int amount)Heal Auber for a certain amount.voidhighlightUp(boolean inUse)Sets whether the player is using the highlight powerup.booleankeyDown(int keycode)When a key is pressed, this method is called.booleankeyTyped(char character)booleankeyUp(int keycode)When a key is lifted, this method is called.booleanmouseMoved(int screenX, int screenY)voidresetHealStopTime()Sets the heal stop time to 0.booleanscrolled(int amount)static voidsetCanHeal(boolean newCanHeal)Sets whether the player can heal.voidsetHealStopTime(float value)Sets when the player stopped healing.voidsetHealth(float newHealth)Sets this player's health.voidsetRequestedPause(boolean value)Sets whether the user has requested pause.voidsetTeleporters(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> newTeleporters)Sets the array of teleporter locations.voidsetUsingArrestPowerUp(boolean newArrestPowerUp)Sets whether the player is using the arrest powerup.voidsetUsingSpeedPowerUp(boolean newSpeedPowerUp)Sets whether the player is using the speed powerup.voidshieldUp(boolean inUse)Sets whether the player is using the freeze powerup.voidspeedUp(boolean inUse)Sets whether the player is using the speed powerup.voidtakeDamage(float amount)Take damage for amount given.voidteleport()Teleport player to the other teleporter.booleantouchDown(int screenX, int screenY, int pointer, int button)Called when a mouse left click is clicked.booleantouchDragged(int screenX, int screenY, int pointer)booleantouchUp(int screenX, int screenY, int pointer, int button)voidupdate(float delta)Used to update the player, move in direction, change scale, and check for collision.-
Methods inherited from class com.badlogic.gdx.graphics.g2d.Sprite
draw, flip, getBoundingRectangle, getColor, getHeight, getOriginX, getOriginY, getRotation, getScaleX, getScaleY, getVertices, getWidth, getX, getY, rotate, rotate90, scale, scroll, set, setAlpha, setBounds, setCenter, setCenterX, setCenterY, setColor, setColor, setFlip, setOrigin, setOriginBasedPosition, setOriginCenter, setPackedColor, setPosition, setRegion, setRotation, setScale, setScale, setSize, setU, setU2, setV, setV2, setX, setY, translate, translateX, translateY
-
Methods inherited from class com.badlogic.gdx.graphics.g2d.TextureRegion
getRegionHeight, getRegionWidth, getRegionX, getRegionY, getTexture, getU, getU2, getV, getV2, isFlipX, isFlipY, setRegion, setRegion, setRegion, setRegion, setRegionHeight, setRegionWidth, setRegionX, setRegionY, setTexture, split, split
-
-
-
-
Field Detail
-
MIN_TELEPORT_DISTANCE
public static final float MIN_TELEPORT_DISTANCE
How close Auber has to be to a teleporter in order to teleport.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Player
public Player(com.badlogic.gdx.graphics.g2d.Sprite newSprite, com.badlogic.gdx.utils.Array<com.badlogic.gdx.maps.tiled.TiledMapTileLayer> newCollisionLayer, boolean isDemo)Class constructor.- Parameters:
newSprite- The sprite to use for the player.newCollisionLayer- The collision layer the player will exist on.isDemo- Whether the game demo is running.
-
-
Method Detail
-
draw
public void draw(com.badlogic.gdx.graphics.g2d.Batch batch)
Used to draw the player to the screen.- Overrides:
drawin classcom.badlogic.gdx.graphics.g2d.Sprite- Parameters:
batch- Batch for the player to be drawn in
-
drawArrow
public void drawArrow(com.badlogic.gdx.graphics.g2d.Batch batch)
Draws arrows pointing in the direction of key systems being destroyed.- Parameters:
batch- Batch for the arrow to be rendered in
-
drawCircle
public void drawCircle(com.badlogic.gdx.graphics.glutils.ShapeRenderer shapeRenderer)
Draws the arrest radius for Auber.- Parameters:
shapeRenderer- Shape renderer to be used for drawing shapes.
-
findInfirmary
public void findInfirmary(com.badlogic.gdx.maps.tiled.TiledMapTileLayer tileLayer)
Finds the location of the infirmary on the map.- Parameters:
tileLayer- the TileLayer to search for infirmaries.
-
update
public void update(float delta)
Used to update the player, move in direction, change scale, and check for collision.- Parameters:
delta- The time since the previous frame, in seconds.
-
keyDown
public boolean keyDown(int keycode)
When a key is pressed, this method is called.- Specified by:
keyDownin interfacecom.badlogic.gdx.InputProcessor- Parameters:
keycode- Code of key that was pressed- Returns:
- true if successful
-
keyUp
public boolean keyUp(int keycode)
When a key is lifted, this method is called.- Specified by:
keyUpin interfacecom.badlogic.gdx.InputProcessor- Parameters:
keycode- Code of key that was lifted- Returns:
- true if successful
-
keyTyped
public boolean keyTyped(char character)
- Specified by:
keyTypedin interfacecom.badlogic.gdx.InputProcessor
-
touchDown
public boolean touchDown(int screenX, int screenY, int pointer, int button)Called when a mouse left click is clicked.- Specified by:
touchDownin interfacecom.badlogic.gdx.InputProcessor- Parameters:
screenX- X Screen coordinate of mouse pressscreenY- Y Screen coordinate of mouse presspointer- The pointer for the event.button- The button.- Returns:
- True if successful
-
touchUp
public boolean touchUp(int screenX, int screenY, int pointer, int button)- Specified by:
touchUpin interfacecom.badlogic.gdx.InputProcessor
-
touchDragged
public boolean touchDragged(int screenX, int screenY, int pointer)- Specified by:
touchDraggedin interfacecom.badlogic.gdx.InputProcessor
-
mouseMoved
public boolean mouseMoved(int screenX, int screenY)- Specified by:
mouseMovedin interfacecom.badlogic.gdx.InputProcessor
-
scrolled
public boolean scrolled(int amount)
- Specified by:
scrolledin interfacecom.badlogic.gdx.InputProcessor
-
heal
public void heal(int amount)
Heal Auber for a certain amount.- Parameters:
amount- Amount to heal by.
-
heal
public void heal()
Heal Auber for the full amount.
-
takeDamage
public void takeDamage(float amount)
Take damage for amount given.- Parameters:
amount- Amount of damage to deal.
-
teleport
public void teleport()
Teleport player to the other teleporter. There are only 2 so player is teleported to the furthest one.
-
getTeleporterLocations
public static com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> getTeleporterLocations(com.badlogic.gdx.maps.tiled.TiledMapTileLayer tileLayer)
Get the location of the teleporters on the map.- Parameters:
tileLayer- Tile map layer containing the teleporters.- Returns:
- Array of the positions of teleporters.
-
speedUp
public void speedUp(boolean inUse)
Sets whether the player is using the speed powerup.- Parameters:
inUse- Whether the player is using the speed powerup.
-
shieldUp
public void shieldUp(boolean inUse)
Sets whether the player is using the freeze powerup.- Parameters:
inUse- Whether the player is using the freeze powerup.
-
freezeUp
public void freezeUp(boolean inUse)
Sets whether the player is using the freeze powerup.- Parameters:
inUse- Whether the player is using the freeze powerup.
-
highlightUp
public void highlightUp(boolean inUse)
Sets whether the player is using the highlight powerup.- Parameters:
inUse- Whether the player is using the highlight powerup.
-
getFreeze
public static boolean getFreeze()
Gets whether the player is using the freeze powerup.- Returns:
- True if the player is using the freeze powerup, false otherwise.
-
getHighlight
public static boolean getHighlight()
Gets whether the player is using the highlight powerup.- Returns:
- True if the player is using the highlight powerup, false otherwise.
-
getHealth
public float getHealth()
Returns this player's health.- Returns:
- A float containing this player's health.
-
setHealth
public void setHealth(float newHealth)
Sets this player's health.- Parameters:
newHealth- The new value of the player's health.
-
setHealStopTime
public void setHealStopTime(float value)
Sets when the player stopped healing.- Parameters:
value- When the player stopped healing.
-
setUsingArrestPowerUp
public void setUsingArrestPowerUp(boolean newArrestPowerUp)
Sets whether the player is using the arrest powerup.- Parameters:
newArrestPowerUp- Whether the player is using the arrest powerup.
-
setUsingSpeedPowerUp
public void setUsingSpeedPowerUp(boolean newSpeedPowerUp)
Sets whether the player is using the speed powerup.- Parameters:
newSpeedPowerUp- Whether the player is using the speed powerup.
-
arrestUp
public void arrestUp(boolean inUse)
Sets whether the player is using the arrest powerup.- Parameters:
inUse- Whether the player is using the arrest powerup.
-
dispose
public void dispose()
Called when this object is deleted.
-
getPosition
public com.badlogic.gdx.math.Vector2 getPosition()
Gets the position of this Player.- Returns:
- A Vector2 containing the position of this player.
-
setCanHeal
public static void setCanHeal(boolean newCanHeal)
Sets whether the player can heal.- Parameters:
newCanHeal- The new value of canHeal.
-
resetHealStopTime
public void resetHealStopTime()
Sets the heal stop time to 0.
-
canHeal
public static boolean canHeal()
Returns whether the player can currently heal.- Returns:
- A boolean containing whether the player can currently heal.
-
setTeleporters
public void setTeleporters(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> newTeleporters)
Sets the array of teleporter locations.- Parameters:
newTeleporters- The array of teleporter locations.
-
getRequestedPause
public boolean getRequestedPause()
Returns whether the user has requested pause.- Returns:
- Whether the user has requested pause.
-
getRequestedSave
public boolean getRequestedSave()
Returns whether the user has requested save.- Returns:
- Whether the user has requested save.
-
setRequestedPause
public void setRequestedPause(boolean value)
Sets whether the user has requested pause.- Parameters:
value- Whether the user has requested pause.
-
handledSave
public void handledSave()
Called when the player has been saved.
-
encode
public java.lang.String encode()
Encodes this Player to a string.- Returns:
- This Player encoded as a string.
-
-