Package model.projectiles
Class ProjectileModel
java.lang.Object
model.entities.EntityModel
model.projectiles.ProjectileModel
- Direct Known Subclasses:
LightingProjectileModel,MaitaFireProjectileModel,PlayerBubbleProjectileModel
Abstract class representing the model of projectile objects in the game.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Constants.Directionprotected Constants.Projectiles.ProjectileStateprotected final PlayingTimerprotected Constants.Projectiles.ProjectileTypeFields inherited from class model.entities.EntityModel
active, height, hitbox, immune, levelManagerModel, width, x, y -
Constructor Summary
ConstructorsConstructorDescriptionProjectileModel(float x, float y, Constants.Direction direction, Constants.Projectiles.ProjectileType type) Constructs a ProjectileModel with the specified position, direction, and type. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidcheckEnemyHit(EnemyModel enemyModel, PlayerModel playerModel) Checks if the projectile hits an enemy.protected abstract voidcheckPlayerHit(PlayerModel playerModel) Checks if the projectile hits the player.Returns the direction of the projectile.getState()Returns the current state of the projectile.getType()Returns the type of the projectile.voidupdate()Updates the position and internal timers of the projectile.protected abstract voidUpdates the position of the projectile.protected voidUpdates the impact timer and deactivates the projectile if the timer reaches zero.Methods inherited from class model.entities.EntityModel
conpenetrationSafeUpdateXPos, deactivate, getHitbox, getTileX, getTileY, initHitbox, initLevelManager, isActive, isImmune, setActive, updateXPos
-
Field Details
-
timer
-
state
-
type
-
direction
-
-
Constructor Details
-
ProjectileModel
public ProjectileModel(float x, float y, Constants.Direction direction, Constants.Projectiles.ProjectileType type) Constructs a ProjectileModel with the specified position, direction, and type.- Parameters:
x- the x-coordinate of the projectiley- the y-coordinate of the projectiledirection- the direction of the projectiletype- the type of the projectile
-
-
Method Details
-
update
public void update()Updates the position and internal timers of the projectile. -
updatePos
protected abstract void updatePos()Updates the position of the projectile. -
checkEnemyHit
Checks if the projectile hits an enemy.- Parameters:
enemyModel- the enemy model to check againstplayerModel- the player model to check against
-
checkPlayerHit
Checks if the projectile hits the player.- Parameters:
playerModel- the player model to check against
-
updateTimer
protected void updateTimer()Updates the impact timer and deactivates the projectile if the timer reaches zero. -
getState
Returns the current state of the projectile.- Returns:
- the current state of the projectile
-
getType
Returns the type of the projectile.- Returns:
- the type of the projectile
-
getDirection
Returns the direction of the projectile.- Returns:
- the direction of the projectile
-