simpleAttackRange method

void simpleAttackRange({
  1. required Future<SpriteAnimation> animationRight,
  2. required Future<SpriteAnimation> animationDestroy,
  3. required Vector2 size,
  4. Vector2? destroySize,
  5. int? id,
  6. double speed = 150,
  7. double damage = 1,
  8. Direction? direction,
  9. int interval = 1000,
  10. bool withCollision = true,
  11. bool enableDiagonal = true,
  12. CollisionConfig? collision,
  13. VoidCallback? onDestroy,
  14. VoidCallback? execute,
  15. LightingConfig? lightingConfig,
})

Execute the ranged attack using a component with animation

Implementation

void simpleAttackRange({
  required Future<SpriteAnimation> animationRight,
  required Future<SpriteAnimation> animationDestroy,
  required Vector2 size,
  Vector2? destroySize,
  int? id,
  double speed = 150,
  double damage = 1,
  Direction? direction,
  int interval = 1000,
  bool withCollision = true,
  bool enableDiagonal = true,
  CollisionConfig? collision,
  VoidCallback? onDestroy,
  VoidCallback? execute,
  LightingConfig? lightingConfig,
}) {
  if (!checkInterval('attackRange', interval, dtUpdate)) return;

  if (isDead) return;

  Direction direct = direction ?? getComponentDirectionFromMe(gameRef.player);

  simpleAttackRangeByDirection(
    animationRight: animationRight,
    animationDestroy: animationDestroy,
    size: size,
    direction: direct,
    id: id,
    speed: speed,
    damage: damage,
    withCollision: withCollision,
    collision: collision,
    onDestroy: onDestroy,
    destroySize: destroySize,
    lightingConfig: lightingConfig,
    enableDiagonal: enableDiagonal,
    attackFrom: AttackFromEnum.ENEMY,
  );

  if (execute != null) execute();
}