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

public class PlayerActions extends Component
Action component for interacting with the player. Player events should be initialised in create() and when triggered should call methods within this class.
  • 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.
      Overrides:
      create in class Component
    • 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.
      Overrides:
      update in class Component
    • 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