Class EnemyBubbleModel
This class extends the EmptyBubbleModel and provides specific behavior for enemy bubbles. Enemy bubbles contain an enemy model and have additional logic for handling the enemy's state and interactions.
-
Field Summary
Fields inherited from class model.bubbles.playerBubbles.PlayerBubbleModel
bubbleManagerFields inherited from class model.bubbles.BubbleModel
active, blinkingTimer, bubbleType, direction, externalCollisionBox, internalCollisionBox, levelManagerModel, normalTimer, popped, popTimer, previousDirection, previousState, redTimer, shake, shakeTimer, state, timer, xSpeed, ySpeed -
Constructor Summary
ConstructorsConstructorDescriptionEnemyBubbleModel(EnemyModel enemyModel, float x, float y, Constants.Direction direction) Constructs a new EnemyBubbleModel. -
Method Summary
Modifier and TypeMethodDescriptionbooleanvoidplayerPop(PlayerModel playerModel) Handles the player popping the enemy bubble.voidplayerPop(PlayerModel playerModel, int EnemyBubblePopCounter, ChainReactionManager chainReactionManager) Handles the player popping the bubble, this method is only used by theChainReactionManager.voidpop()Pops the bubble and updates its state.voidRespawns the enemy if the bubble was not popped by the player.protected voidUpdates the bubble's movement after it has been popped by the player.Methods inherited from class model.bubbles.playerBubbles.PlayerBubbleModel
checkCollisionWithPlayer, update, updateTimersMethods inherited from class model.bubbles.BubbleModel
bounceDown, bubbleShaking, changeDirection, getBubbleType, getCenter, getDirection, getState, handlePlayerPush, initCollisionBoxes, isActive, isPlayerJumpingOnBubble, isPlayerPoppingBubble, isPlayerTouchingBubble, isPopped, pacManEffect, setActive, updateCollisionBoxes, updateDirection, updatePositionMethods inherited from class model.entities.EntityModel
conpenetrationSafeUpdateXPos, deactivate, getHitbox, getTileX, getTileY, initHitbox, initLevelManager, isImmune, updateXPos
-
Constructor Details
-
EnemyBubbleModel
Constructs a new EnemyBubbleModel.- Parameters:
enemyModel- the enemy model of the captured enemyx- the starting x coordinatey- the starting y coordinatedirection- the starting direction
-
-
Method Details
-
respawnEnemy
public void respawnEnemy()Respawns the enemy if the bubble was not popped by the player.If the bubble was not popped by the player, this method resets the enemy's state, repositions the enemy to the bubble's current coordinates, and sets the enemy to an active state.
-
updateDeadAction
protected void updateDeadAction()Updates the bubble's movement after it has been popped by the player.This method handles the bubble's movement based on its current state and direction.
If the bubble is moving upwards, it updates the y-coordinate and checks for perimeter wall collisions to change direction if necessary.
If the bubble is moving downwards, it updates the y-coordinate and checks for collisions with solid objects to stop the bubble and spawn a reward.
- Overrides:
updateDeadActionin classEmptyBubbleModel
-
pop
public void pop()Pops the bubble and updates its state.If the bubble's current state is not POP\_NORMAL or POP\_RED, this method changes the state to the appropriate pop state based on the previous state.
Additionally, it sets the enemy's alive status to false.
- Overrides:
popin classEmptyBubbleModel
-
playerPop
public void playerPop(PlayerModel playerModel, int EnemyBubblePopCounter, ChainReactionManager chainReactionManager) Handles the player popping the bubble, this method is only used by theChainReactionManager.If the bubble has not been popped yet, this method increases the enemy bubble pop counter, updates the consecutive pops counter, and adds a chain reaction reward.
Then, it calls the
playerPop(PlayerModel)method to handle the actual popping logic.- Overrides:
playerPopin classEmptyBubbleModel- Parameters:
playerModel- the player modelEnemyBubblePopCounter- the number of enemy bubbles poppedchainReactionManager- the chain explosion manager
-
playerPop
Handles the player popping the enemy bubble.This method calculates the speed and direction of the bubble after it has been popped by the player.
It sets the bubble's state to DEAD, marks it as popped, and updates the enemy's alive status to false.
- Parameters:
playerModel- the player model
-
getEnemyModel
-
isPlayerPopped
public boolean isPlayerPopped()
-