Class PlayerActions

java.lang.Object
com.deco2800.game.components.Component
com.deco2800.game.components.player.PlayerActions

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
    • toggleInventory

      public void toggleInventory()
      Pressing the 'I' button toggles the inventory menu UI opening/closing.
    • consumePotionSlot1

      public void consumePotionSlot1()
      Pressing the '1' button triggers the player to consume potion slot 1
    • consumePotionSlot2

      public void consumePotionSlot2()
      Pressing the '2' button triggers the player to consume potion slot 2
    • consumePotionSlot3

      public void consumePotionSlot3()
      Pressing the '3' button triggers the player to consume potion slot 3
    • walk

      public void walk(com.badlogic.gdx.math.Vector2 direction)
      Moves the player towards a given direction. Calls the walking sound effect. Only fully calls when the game is not paused.
      Parameters:
      direction - direction to move in
    • stopWalking

      public void stopWalking()
      Stops the player from walking.
    • updateMaxSpeed

      public void updateMaxSpeed(float newSpeed)
      Public function to set new max speed.
      Parameters:
      newSpeed - of the player character
    • getMaxSpeed

      public float getMaxSpeed()
      Return the scalar max speed of the player.
    • getSkillComponent

      public PlayerSkillComponent getSkillComponent()
      Gets a reference to the skill subcomponent of playeractions. This reference should be used sparingly as a way for external functionality to directly interact with skill states, and should avoid directly inducing any skill start fuctions using this reference. In future sprints skill start functions will not be able to called externally.
      Returns:
      the player skill component of player actions.
    • fireballUltimate

      public void fireballUltimate()
      Makes the player cast their ultimate fireball skill. Registers call of the ultimate function to the skill manager component.
    • coneProjectile

      public void coneProjectile()
      Makes the player cast their cone projectile skill. Registers call of the projectile function to the skill manager component.
    • invulnerabilitySkill

      public void invulnerabilitySkill()
    • getWalkDirection

      public com.badlogic.gdx.math.Vector2 getWalkDirection()
    • setSkillAnimator

      public void setSkillAnimator(Entity skillAnimator)
      Sets the skill animator for this actions component and passes it to the skill component so the skill component can alter the skill animation state.
      Parameters:
      skillAnimator - the skill animator entity which has subcomponents PlayerSkillAnimationController and AnimationRenderer