Package com.csse3200.game.components
Class ProjectileAttackComponent
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.TouchAttackComponent
com.csse3200.game.components.ProjectileAttackComponent
A component that allows an entity to attack other entities upon collision, dealing damage and applying knockback.
This component should be added to a projectile entity. It requires the entity to have a
CombatStatsComponent
to define its damage capabilities and a HitboxComponent
to detect collisions.
When a collision is detected with an entity on the specified target layer, this component will deal damage to the
target if it has a CombatStatsComponent
.
The projectile is then disposed of after the collision.
-
Field Summary
Fields inherited from class com.csse3200.game.components.TouchAttackComponent
combatStats, hitboxComponent, targetLayer
-
Constructor Summary
ConstructorsConstructorDescriptionProjectileAttackComponent
(short targetLayer, int damage, Entity target) Constructs a ProjectileAttackComponent for handling attacks on entities upon collision. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
onCollisionStart
(com.badlogic.gdx.physics.box2d.Fixture me, com.badlogic.gdx.physics.box2d.Fixture other) Methods inherited from class com.csse3200.game.components.TouchAttackComponent
checkHitboxAndLayer, create
Methods inherited from class com.csse3200.game.components.Component
dispose, earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update
-
Constructor Details
-
ProjectileAttackComponent
Constructs a ProjectileAttackComponent for handling attacks on entities upon collision. The component is configured to target entities in a specific physics layer.- Parameters:
targetLayer
- The physics layer of the target entities' collider.damage
- the amount of damage this projectile does
-
-
Method Details
-
onCollisionStart
protected void onCollisionStart(com.badlogic.gdx.physics.box2d.Fixture me, com.badlogic.gdx.physics.box2d.Fixture other) - Overrides:
onCollisionStart
in classTouchAttackComponent
-