Class DragonflyAttackPattern
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.combat.attackpatterns.AttackPatternComponent
com.csse3200.game.components.combat.attackpatterns.DragonflyAttackPattern
- All Implemented Interfaces:
com.badlogic.gdx.utils.Json.Serializable
The Dragonfly attack pattern class defines the attack behavior of a Dragonfly entity in the game.
It allows the dragonfly to detect the player and plants and attack them when in range.
-
Field Summary
Fields inherited from class com.csse3200.game.components.combat.attackpatterns.AttackPatternComponent
attackFrequency, currentAttackEvent, interactionDetector
-
Constructor Summary
ConstructorsConstructorDescriptionDragonflyAttackPattern
(float attackFrequency, Supplier<Entity> projectileSupplier) -
Method Summary
Methods inherited from class com.csse3200.game.components.combat.attackpatterns.AttackPatternComponent
startAttack
Methods inherited from class com.csse3200.game.components.Component
dispose, earlyUpdate, getEntity, read, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update, write
-
Constructor Details
-
DragonflyAttackPattern
- Parameters:
attackFrequency
- How often the dragonfly attacks.projectileSupplier
- The projectile supplier for the Dragonfly's projectiles.
-
-
Method Details
-
create
public void create()Initialises the DragonFlyAttackPattern component when it is created. This method sets up event listeners and interaction detection for the Dragonfly.- Overrides:
create
in classAttackPatternComponent
-
attack
protected void attack()Performs the attack action, which involves determining the nearest entity, changing direction, triggering attack events, and scheduling the next attack. This will also change the attack performed depending on whether there is a plant or player.- Overrides:
attack
in classAttackPatternComponent
-