Class WeaponControllerComponent

java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.Weapons.WeaponControllerComponent
Direct Known Subclasses:
BoomerangController, MeleeSwingController, ProjectileController, StaticController

public abstract class WeaponControllerComponent extends Component
Class to control the movement of weapons that have been spawned
  • Field Details

    • config

      protected WeaponConfig config
    • remainingDuration

      protected int remainingDuration
    • currentRotation

      protected float currentRotation
    • player

      protected final Entity player
    • attackNum

      protected int attackNum
  • Constructor Details

    • WeaponControllerComponent

      public WeaponControllerComponent(WeaponConfig config, float attackDirection, Entity player, int attackNum)
      Class to store variables of a spawned weapon
    • WeaponControllerComponent

      public WeaponControllerComponent(WeaponConfig config, float attackDirection, Entity player)
      Class to store variables of a spawned weapon
  • Method Details

    • create

      public void create()
      Create class - implemented class implement initial weapon setup including adding required animations and controlling initial movement direction and animation
      Overrides:
      create in class Component
    • update

      public void update()
      Function to control projectile movement once it has spawned
      Overrides:
      update in class Component
    • add_animations

      protected void add_animations(AnimationRenderComponent animator)
      Function to add animations based on standard animation configurations (Overidable)
    • initial_rotation

      protected abstract void initial_rotation()
      Set initial rotation (defaults to attack direction)
    • initial_position

      protected abstract void initial_position()
      Set initial position
    • initial_animation

      protected abstract void initial_animation(AnimationRenderComponent animator)
      Set intial animation
      Parameters:
      animator - - animation component for the entity
    • rotate

      protected abstract void rotate()
      Update entity rotation every tick
    • move

      protected abstract void move()
      Update entity location every tick
    • reanimate

      protected abstract void reanimate()
      Update entity animation if required
    • positionInDirection

      protected com.badlogic.gdx.math.Vector2 positionInDirection(float direction, float distance)
      Returns the game position in a given direction at a given distance relative to the player to center a given attack entity
      Parameters:
      direction - direction the position should be in
      distance - distance infront of the player
      Returns:
      position in the given direction at the distance