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.Vector2Calculates the desired velocity vector, applying terrain movement modifiers, movement direction, and weather modifiers.voidcreate()Called when the entity is created and registered.floatbooleanisMuted()When in the tractor inputs should be muted, this handles that.booleanvoidsetDamageMultiplier(float multiplier) Sets damage multiplier of player to change sword and gun damageprotected voidsetMoveDirection(com.badlogic.gdx.math.Vector2 vector) Sets the moveDirection with a copy of the provided Vector2 instancevoidsetMuted(boolean muted) voidsetSpeedMultiplier(float multiplier) Sets speed multiplier of player to change walking and running speed.voidStops the player from moving.voidRemoves the velocity increase of the player.voidupdate()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:ComponentCalled 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:ComponentCalled 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
-
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
-
setMuted
public void setMuted(boolean muted) -
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
-