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 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
-
Method Summary
Modifier and TypeMethodDescriptionint
float
Function for getting the turret's fire rate.int
int
returns the current priority of the taskgetState()
boolean
Searches for enemies/mobs in a straight line from the centre of the tower to maxRange in a straight line.void
start()
Starts the task running and starts the Idle animationvoid
stop()
stops the current animation and switches back the state of the tower to IDLE.void
update()
updates the current state of the tower based on the current state of the game.void
This 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:
start
in interfaceTask
- Overrides:
start
in 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:
update
in interfaceTask
- Overrides:
update
in 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:
stop
in interfaceTask
- Overrides:
stop
in classDefaultTask
-
getPriority
public int getPriority()returns the current priority of the task- Specified by:
getPriority
in 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
-