Class AttackPatternComponent
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.combat.attackpatterns.AttackPatternComponent
- All Implemented Interfaces:
com.badlogic.gdx.utils.Json.Serializable
- Direct Known Subclasses:
BatAttackPattern
,DragonflyAttackPattern
,OxygenEaterAttackPattern
The AttackPatternComponent is responsible for managing the attack patterns
of entities within the game. It allows entities to initiate attacks with a specified
frequency and provides methods for starting and scheduling attacks.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final float
Frequency of attacks in secondsprotected ScheduledEvent
Scheduled attack eventprotected InteractionDetector
Entity's interaction detector -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
attack()
Attacks and schedules next attack.void
create()
Initializes the HostileAttackPattern component when it is created.protected void
startAttack
(Entity target) Initiates an attack loop.Methods inherited from class com.csse3200.game.components.Component
dispose, earlyUpdate, getEntity, read, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update, write
-
Field Details
-
attackFrequency
protected final float attackFrequencyFrequency of attacks in seconds -
interactionDetector
Entity's interaction detector -
currentAttackEvent
Scheduled attack event
-
-
Constructor Details
-
AttackPatternComponent
public AttackPatternComponent(float attackFrequency)
-
-
Method Details
-
create
public void create()Initializes the HostileAttackPattern component when it is created. This method sets up event listeners and interaction detection for the oxygen eater. -
startAttack
Initiates an attack loop.- Parameters:
target
- The detected target entity. needed for event listener, unused
-
attack
protected void attack()Attacks and schedules next attack.
-