Class TowerCombatTask

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

public class TowerCombatTask extends DefaultTask implements PriorityTask
The TowerCombatTask runs the AI for the WeaponTower class. The tower will scan for targets in a straight line from its center point until a point at (x + maxRange, y), where x,y are the cooridinates of the tower's center position. This component should be added to an AiTaskComponent attached to the tower instance.
  • Constructor Details

    • TowerCombatTask

      public TowerCombatTask(int priority, float maxRange)
      Parameters:
      priority - Task priority when targets are detected (0 when nothing detected). Must be a positive integer.
      maxRange - Maximum effective range of the weapon tower. This determines the detection distance of targets
    • TowerCombatTask

      public TowerCombatTask(int priority, float maxRange, float fireRate)
      THIS IS REDUNDANT AND NOT USED
      Parameters:
      priority - Task priority when targets are detected (0 when nothing detected). Must be a positive integer.
      maxRange - Maximum effective range of the weapon tower. This determines the detection distance of targets
      fireRate - The number of times per second this tower should fire its weapon
  • Method Details

    • start

      public void start()
      Starts the Task running, triggers the initial "idleStart" event.
      Specified by:
      start in interface Task
      Overrides:
      start in class DefaultTask
    • update

      public void update()
      The update method is what is run every time the TaskRunner in the AiTaskComponent calls update(). triggers events depending on the presence or otherwise of targets in the detection range
      Specified by:
      update in interface Task
      Overrides:
      update in class DefaultTask
    • updateTowerState

      public void updateTowerState()
      Weapon tower state machine. Updates tower state by scanning for mobs, and triggers the appropriate events corresponding to the STATE enum.
    • stop

      public void stop()
      For stopping the running task
      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:
      active priority value if targets detected, inactive priority otherwise
    • getFireRateInterval

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