Class DragonflyAttackPattern

All Implemented Interfaces:
com.badlogic.gdx.utils.Json.Serializable

public class DragonflyAttackPattern extends AttackPatternComponent
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.
  • Constructor Details

    • DragonflyAttackPattern

      public DragonflyAttackPattern(float attackFrequency, Supplier<Entity> projectileSupplier)
      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 class AttackPatternComponent
    • 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 class AttackPatternComponent