Class BombChaseTask
java.lang.Object
com.csse3200.game.ai.tasks.DefaultTask
com.csse3200.game.components.tasks.BombChaseTask
- All Implemented Interfaces:
PriorityTask,Task
Task that makes a bomber chase and position itself optimally above a target
when detected by its cone light.
-
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.ai.tasks.DefaultTask
owner, status -
Constructor Summary
ConstructorsConstructorDescriptionBombChaseTask(Entity target, int priority, float maxChaseDistance, float optimalHeight, float heightTolerance) Creates a chase task for a bomber that uses cone light detection. -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate()Activates the chase task.voidcreate(TaskRunner owner) Create the task and attach it to the task runner.voidDeactivates the chase task.intGet current priority of the task.booleanCheck if the chase task has acquired a target via cone light detection.voidstart()Initialise and starts movement toward the chase target.voidstop()Stop the taskvoidupdate()Update the chase, positioning bomber at optimal height above target.Methods inherited from class com.csse3200.game.ai.tasks.DefaultTask
getStatus
-
Constructor Details
-
BombChaseTask
public BombChaseTask(Entity target, int priority, float maxChaseDistance, float optimalHeight, float heightTolerance) Creates a chase task for a bomber that uses cone light detection.- Parameters:
target- the entity to chasepriority- task priority when chasingmaxChaseDistance- maximum distance before chasing stopsoptimalHeight- optimal height to maintain above target for bombingheightTolerance- tolerance for height positioning
-
-
Method Details
-
create
Description copied from interface:TaskCreate the task and attach it to the task runner.- Specified by:
createin interfaceTask- Overrides:
createin classDefaultTask- Parameters:
owner- Task runner to attach to
-
activate
public void activate()Activates the chase task. The priority will be raised, allowing the task to run. -
deactivate
public void deactivate()Deactivates the chase task. The priority will be set to -1, stopping the task. -
start
public void start()Initialise and starts movement toward the chase target.- Specified by:
startin interfaceTask- Overrides:
startin classDefaultTask
-
update
public void update()Update the chase, positioning bomber at optimal height above target.- Specified by:
updatein interfaceTask- Overrides:
updatein classDefaultTask
-
stop
public void stop()Stop the task- Specified by:
stopin interfaceTask- Overrides:
stopin classDefaultTask
-
getPriority
public int getPriority()Get current priority of the task. Priority system: - Returns priority when cone light has detected target - Returns lower priority (5) when searching for lost target - Returns -1 if target too far or at correct position for bombing- Specified by:
getPriorityin interfacePriorityTask
-
hasTarget
public boolean hasTarget()Check if the chase task has acquired a target via cone light detection.- Returns:
- true if target acquired, false otherwise
-