Class TNTTowerCombatTask
java.lang.Object
com.csse3200.game.ai.tasks.DefaultTask
com.csse3200.game.components.tasks.TNTTowerCombatTask
- All Implemented Interfaces:
PriorityTask
,Task
The TNTTowerCombatTask runs the AI for the TNTTower 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 coordinates of the tower's center
position. This component should be added to an AiTaskComponent attached to the tower instance.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.csse3200.game.ai.tasks.Task
Task.Status
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
boolean
Fields inherited from class com.csse3200.game.ai.tasks.DefaultTask
owner, status
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
Returns the current priority of the task.getState()
Returns the current state of the tower.boolean
boolean
Uses a raycast to determine whether there are any targets in detection rangevoid
start()
Starts the Task running, triggers the initial "defaultStart" event.void
stop()
For stopping the running taskvoid
update()
The update method is what is run every time the TaskRunner in the AiTaskComponent calls update().void
TNT tower state machine.Methods inherited from class com.csse3200.game.ai.tasks.DefaultTask
create, getStatus
-
Field Details
-
DIG
- See Also:
-
EXPLOSION
- See Also:
-
DEFAULT
- See Also:
-
DAMAGE
- See Also:
-
readToDelete
public boolean readToDelete
-
-
Constructor Details
-
TNTTowerCombatTask
public TNTTowerCombatTask(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
-
-
Method Details
-
start
public void start()Starts the Task running, triggers the initial "defaultStart" event.- Specified by:
start
in interfaceTask
- Overrides:
start
in classDefaultTask
-
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 interfaceTask
- Overrides:
update
in classDefaultTask
-
updateTowerState
public void updateTowerState()TNT 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 interfaceTask
- Overrides:
stop
in classDefaultTask
-
getPriority
public int getPriority()Returns the current priority of the task.- Specified by:
getPriority
in interfacePriorityTask
- Returns:
- active priority value if targets detected, inactive priority otherwise
-
getState
Returns the current state of the tower.- Returns:
- the current state of the tower.
-
isTargetVisible
public boolean isTargetVisible()Uses a raycast to determine whether there are any targets in detection range- Returns:
- true if a target is visible, false otherwise
-
isReadyToDelete
public boolean isReadyToDelete()
-