Class PlayerActions
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.player.PlayerActions
- All Implemented Interfaces:
com.badlogic.gdx.utils.Json.Serializable
Action component for interacting with the player. Player events should be
initialised in create()
and when triggered should call methods within this class.
-
Nested Class Summary
Nested Classes -
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected com.badlogic.gdx.math.Vector2
Calculates the desired velocity vector, applying terrain movement modifiers, movement direction, and weather modifiers.void
create()
Called when the entity is created and registered.float
boolean
isMuted()
When in the tractor inputs should be muted, this handles that.boolean
void
setDamageMultiplier
(float multiplier) Sets damage multiplier of player to change sword and gun damageprotected void
setMoveDirection
(com.badlogic.gdx.math.Vector2 vector) Sets the moveDirection with a copy of the provided Vector2 instancevoid
setMuted
(boolean muted) void
setSpeedMultiplier
(float multiplier) Sets speed multiplier of player to change walking and running speed.void
Stops the player from moving.void
Removes the velocity increase of the player.void
update()
Called once per frame of the game, and should be used for most component logic.Methods inherited from class com.csse3200.game.components.Component
dispose, earlyUpdate, getEntity, read, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, write
-
Constructor Details
-
PlayerActions
public PlayerActions()
-
-
Method Details
-
create
public void create()Description copied from class:Component
Called when the entity is created and registered. Initial logic such as calls to GetComponent should be made here, not in the constructor which is called before an entity is finished. -
update
public void update()Description copied from class:Component
Called once per frame of the game, and should be used for most component logic. Not called if component is disabled. -
calculateVelocityVector
protected com.badlogic.gdx.math.Vector2 calculateVelocityVector()Calculates the desired velocity vector, applying terrain movement modifiers, movement direction, and weather modifiers.- Returns:
- the calculated velocity vector.
-
getPrevMoveDirection
public float getPrevMoveDirection() -
stopMoving
public void stopMoving()Stops the player from moving. -
stopRunning
public void stopRunning()Removes the velocity increase of the player. -
isMuted
public boolean isMuted()When in the tractor inputs should be muted, this handles that.- Returns:
- if the players inputs should be muted
-
setMuted
public void setMuted(boolean muted) -
isStunned
public boolean isStunned() -
setSpeedMultiplier
public void setSpeedMultiplier(float multiplier) Sets speed multiplier of player to change walking and running speed.- Parameters:
multiplier
- float in which to multiply speed by
-
setDamageMultiplier
public void setDamageMultiplier(float multiplier) Sets damage multiplier of player to change sword and gun damage- Parameters:
multiplier
- float in which to multiply damage by
-
setMoveDirection
protected void setMoveDirection(com.badlogic.gdx.math.Vector2 vector) Sets the moveDirection with a copy of the provided Vector2 instance- Parameters:
vector
- the Vector2 instance to update the moveDirection to
-