Class AttackTask
java.lang.Object
com.csse3200.game.ai.tasks.DefaultTask
com.csse3200.game.components.tasks.TargetDetectionTasks
com.csse3200.game.components.tasks.AttackTask
- All Implemented Interfaces:
PriorityTask
,Task
Allows an entity to attack the closest target entity from a list of potential targets. This task
runs when there is a target within the entities range of attack
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.csse3200.game.ai.tasks.Task
Task.Status
-
Field Summary
Fields inherited from class com.csse3200.game.components.tasks.TargetDetectionTasks
attackRange, debugRenderer, hit, physics
Fields inherited from class com.csse3200.game.ai.tasks.DefaultTask
owner, status
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected int
getActivePriority
(float dst, Entity target) Determines the tasks priority when the task is running.protected int
getInactivePriority
(float dst, Entity target) Computes the priority when the task is inactive.void
start()
Starts the attack task.void
update()
Updates the task each game frameMethods inherited from class com.csse3200.game.components.tasks.TargetDetectionTasks
getAllTargets, getDistanceToTarget, getNearestVisibleTarget, getPriority, isTargetVisible
Methods inherited from class com.csse3200.game.ai.tasks.DefaultTask
create, getStatus, stop
-
Constructor Details
-
AttackTask
public AttackTask(float attackRange) Creates an attack task- Parameters:
attackRange
- the maximum distance the entity can find a target to attack
-
-
Method Details
-
start
public void start()Starts the attack task. The closest visible target within the entity's attack range is found and ATTACK LOGIC BEGINS.- Specified by:
start
in interfaceTask
- Overrides:
start
in classDefaultTask
-
update
public void update()Updates the task each game frame- Specified by:
update
in interfaceTask
- Overrides:
update
in classDefaultTask
-
getActivePriority
Determines the tasks priority when the task is running.- Specified by:
getActivePriority
in classTargetDetectionTasks
- Parameters:
dst
- the distance to the targettarget
- the target entity- Returns:
1
if a target is visible and within attack range, otherwise-1
-
getInactivePriority
Computes the priority when the task is inactive.- Specified by:
getInactivePriority
in classTargetDetectionTasks
- Parameters:
dst
- the distance to the targettarget
- the target entity- Returns:
1
if the target is visible and within attack range, otherwise-1
-