Class LightingProjectileModel


public class LightingProjectileModel extends ProjectileModel
Represents a logic of a lighting projectile in the game.
  • Constructor Details

    • LightingProjectileModel

      public LightingProjectileModel(float x, float y, Constants.Projectiles.ProjectileType type)
      Constructs a LightingProjectileModel with the specified position and type.
      Parameters:
      x - the x-coordinate of the projectile
      y - the y-coordinate of the projectile
      type - 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:
      updatePos in class ProjectileModel
    • checkEnemyHit

      protected void checkEnemyHit(EnemyModel enemyModel, PlayerModel playerModel)
      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:
      checkEnemyHit in class ProjectileModel
      Parameters:
      enemyModel - the enemy model to check against
      playerModel - the player model to add score to if the enemy is killed
    • checkPlayerHit

      protected void checkPlayerHit(PlayerModel playerModel)
      Checks if the projectile hits the player.

      This method is not used as lighting projectiles cannot hit players.

      Specified by:
      checkPlayerHit in class ProjectileModel
      Parameters:
      playerModel - the player model to check against