Class StunTowerCombatTask

java.lang.Object
com.csse3200.game.ai.tasks.DefaultTask
com.csse3200.game.components.tasks.StunTowerCombatTask
All Implemented Interfaces:
PriorityTask, Task

public class StunTowerCombatTask extends DefaultTask implements PriorityTask
The StunTowerCombatTask runs the AI for the StunTower class. The tower scans for mobs and targets in a straight line from its centre coordinate and executes the trigger phrases for animations depending on the current state of tower.
  • Field Details

  • Constructor Details

    • StunTowerCombatTask

      public StunTowerCombatTask(int priority, float maxRange)
      Parameters:
      priority - Task priority when targets are detected (0 when nothing is present)
      maxRange - Maximum effective range of the StunTower.
  • Method Details

    • start

      public void start()
      Starts the task running and starts the Idle animation
      Specified by:
      start in interface Task
      Overrides:
      start in class DefaultTask
    • update

      public void update()
      updates the current state of the tower based on the current state of the game. If enemies are detected, attack state is activated and otherwise idle state remains.
      Specified by:
      update in interface Task
      Overrides:
      update in class DefaultTask
    • updateTowerState

      public void updateTowerState()
      This method acts is the state machine for StunTower. Relevant animations are triggered based on relevant state of the game. If enemies are detected, state of the tower is changed to attack state.
    • getState

      public StunTowerCombatTask.STATE getState()
    • stop

      public void stop()
      stops the current animation and switches back the state of the tower to IDLE.
      Specified by:
      stop in interface Task
      Overrides:
      stop in class DefaultTask
    • getPriority

      public int getPriority()
      returns the current priority of the task
      Specified by:
      getPriority in interface PriorityTask
      Returns:
      (int) active priority if target is visible and inactive priority otherwise
    • getActivePriority

      public int getActivePriority()
    • getInactivePriority

      public int getInactivePriority()
    • isTargetVisible

      public boolean isTargetVisible()
      Searches for enemies/mobs in a straight line from the centre of the tower to maxRange in a straight line.
      Returns:
      true if targets are detected, false otherwise
    • getFireRateInterval

      public float getFireRateInterval()
      Function for getting the turret's fire rate.
      Returns:
      The fireRateInterval variable