Class StunTowerCombatTask
java.lang.Object
com.csse3200.game.ai.tasks.DefaultTask
com.csse3200.game.components.tasks.StunTowerCombatTask
- All Implemented Interfaces:
PriorityTask,Task
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.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface com.csse3200.game.ai.tasks.Task
Task.Status -
Field Summary
FieldsFields inherited from class com.csse3200.game.ai.tasks.DefaultTask
owner, status -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintfloatFunction for getting the turret's fire rate.intintreturns the current priority of the taskgetState()booleanSearches for enemies/mobs in a straight line from the centre of the tower to maxRange in a straight line.voidstart()Starts the task running and starts the Idle animationvoidstop()stops the current animation and switches back the state of the tower to IDLE.voidupdate()updates the current state of the tower based on the current state of the game.voidThis method acts is the state machine for StunTower.Methods inherited from class com.csse3200.game.ai.tasks.DefaultTask
create, getStatus
-
Field Details
-
IDLE
- See Also:
-
ATTACK
- See Also:
-
DEATH
- See Also:
-
towerState
-
-
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:
startin interfaceTask- Overrides:
startin classDefaultTask
-
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:
updatein interfaceTask- Overrides:
updatein classDefaultTask
-
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
-
stop
public void stop()stops the current animation and switches back the state of the tower to IDLE.- Specified by:
stopin interfaceTask- Overrides:
stopin classDefaultTask
-
getPriority
public int getPriority()returns the current priority of the task- Specified by:
getPriorityin interfacePriorityTask- 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
-