simpleAttackRange method
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,
- ShapeHitbox? collision,
- VoidCallback? onDestroy,
- VoidCallback? execute,
- 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,
ShapeHitbox? collision,
VoidCallback? onDestroy,
VoidCallback? execute,
LightingConfig? lightingConfig,
}) {
if (!checkInterval('attackRange', interval, dtUpdate)) return;
if (isDead) return;
Direction direct = direction ??
(gameRef.player != null
? getComponentDirectionFromMe(gameRef.player!)
: lastDirection);
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,
attackFrom: AttackOriginEnum.ENEMY,
);
execute?.call();
}