Package model.projectiles
Class LightingProjectileModel
java.lang.Object
model.entities.EntityModel
model.projectiles.ProjectileModel
model.projectiles.LightingProjectileModel
Represents a logic of a lighting projectile in the game.
-
Field Summary
Fields inherited from class model.projectiles.ProjectileModel
direction, state, timer, typeFields inherited from class model.entities.EntityModel
active, height, hitbox, immune, levelManagerModel, width, x, y -
Constructor Summary
ConstructorsConstructorDescriptionLightingProjectileModel(float x, float y, Constants.Projectiles.ProjectileType type) Constructs a LightingProjectileModel with the specified position and type. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckEnemyHit(EnemyModel enemyModel, PlayerModel playerModel) Checks if the projectile hits an enemy.protected voidcheckPlayerHit(PlayerModel playerModel) Checks if the projectile hits the player.protected voidUpdates the position of the projectile.Methods inherited from class model.projectiles.ProjectileModel
getDirection, getState, getType, update, updateTimerMethods inherited from class model.entities.EntityModel
conpenetrationSafeUpdateXPos, deactivate, getHitbox, getTileX, getTileY, initHitbox, initLevelManager, isActive, isImmune, setActive, updateXPos
-
Constructor Details
-
LightingProjectileModel
Constructs a LightingProjectileModel with the specified position and type.- Parameters:
x- the x-coordinate of the projectiley- the y-coordinate of the projectiletype- the type of the projectile
-
-
Method Details
-
updatePos
protected void updatePos()Updates the position of the projectile.Moves the projectile left or right based on its direction and deactivates it if it hits a perimeter wall tile.
- Specified by:
updatePosin classProjectileModel
-
checkEnemyHit
Checks if the projectile hits an enemy.If the projectile hits an active enemy, it instantly kills the enemy and deactivates the projectile.
- Specified by:
checkEnemyHitin classProjectileModel- Parameters:
enemyModel- the enemy model to check againstplayerModel- the player model to add score to if the enemy is killed
-
checkPlayerHit
Checks if the projectile hits the player.This method is not used as lighting projectiles cannot hit players.
- Specified by:
checkPlayerHitin classProjectileModel- Parameters:
playerModel- the player model to check against
-