Fixed SpecialBubble
This commit is contained in:
parent
56d563ecd5
commit
b0d8b5806f
@ -14,6 +14,7 @@ import de.thdeg.greiner.superpangworld.graphics.moveable.SpecialBubble;
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* The manager which handles the gameplay.
|
||||
@ -85,9 +86,7 @@ public class GamePlayManager {
|
||||
destroyAllBubbles = false;
|
||||
specialBubblePresent = false;
|
||||
movementFroze = false;
|
||||
// Update HUD
|
||||
updateHUD();
|
||||
// Update background
|
||||
gameObjectManager.getBackground().setBackgroundImage(level.backgroundImage);
|
||||
}
|
||||
|
||||
@ -151,7 +150,7 @@ public class GamePlayManager {
|
||||
public void updateGamePlay(){
|
||||
updateHUD();
|
||||
|
||||
if(player.score>=level.neededOverallScore){
|
||||
if(!destroyAllBubbles && player.score>=level.neededOverallScore){
|
||||
nextLevel();
|
||||
}
|
||||
|
||||
@ -166,10 +165,14 @@ public class GamePlayManager {
|
||||
|
||||
if(destroyAllBubbles && gameView.timerExpired("DestroyAllBubbles","GamePlayManager")){
|
||||
List<Bubble> bubblesCopy = new ArrayList<>(gameObjectManager.getBubbles());
|
||||
if(bubblesCopy.size()>0) {
|
||||
for (Bubble bubble : bubblesCopy) {
|
||||
destroy(bubble);
|
||||
}
|
||||
gameView.setTimer("DestroyAllBubbles","GamePlayManager",500);
|
||||
gameView.setTimer("DestroyAllBubbles", "GamePlayManager", 300);
|
||||
}else{
|
||||
destroyAllBubbles = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -177,7 +180,7 @@ public class GamePlayManager {
|
||||
* Start the timer to destroy all bubbles.
|
||||
*/
|
||||
public void destroyAllBubbles(){
|
||||
gameView.setTimer("DestroyAllBubbles","GamePlayManager",500);
|
||||
gameView.setTimer("DestroyAllBubbles","GamePlayManager",300);
|
||||
spawnBubbles = false;
|
||||
destroyAllBubbles = true;
|
||||
movementFroze = false;
|
||||
@ -192,6 +195,7 @@ public class GamePlayManager {
|
||||
movementFroze = true;
|
||||
gameView.playSound("freeze.wav",false);
|
||||
gameView.setTimer("MovementFroze","GamePlayManager",freezeTime);
|
||||
gameObjectManager.getGameOverlay().showMessage("Freeze "+ TimeUnit.MILLISECONDS.toSeconds(freezeTime)+" sec",freezeTime);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -235,7 +239,7 @@ public class GamePlayManager {
|
||||
* - 10% special bubble
|
||||
*/
|
||||
private void addRandomBubble(){
|
||||
int randomNumber = specialBubblePresent ? random.nextInt(90) : random.nextInt(100);
|
||||
int randomNumber = specialBubblePresent ? random.nextInt(90) : random.nextInt(10000);
|
||||
ArrayList<CollidableGameObject> collidableGameObjects = new ArrayList<>();
|
||||
collidableGameObjects.add(gameObjectManager.getPlayerObject());
|
||||
collidableGameObjects.addAll(gameObjectManager.getHarpoons());
|
||||
|
@ -146,7 +146,7 @@ public abstract class Bubble extends CollidingGameObject implements MovingGameOb
|
||||
@Override
|
||||
public void reactToCollision(CollidableGameObject otherObject) {
|
||||
if (otherObject instanceof PlayerObject && !gamePlayManager.movementFroze) {
|
||||
gamePlayManager.looseLife();
|
||||
//gamePlayManager.looseLife();
|
||||
} else if (otherObject instanceof Harpoon && !spawning) {
|
||||
gamePlayManager.destroy((Harpoon) otherObject, this);
|
||||
}
|
||||
|
@ -30,8 +30,8 @@ public class GameOverlay extends GameObject {
|
||||
*
|
||||
* @param message the message to display
|
||||
*/
|
||||
public void showMessage(String message){
|
||||
gameView.setTimer("DisplayMessage","Overlay",3000);
|
||||
public void showMessage(String message, long duration){
|
||||
gameView.setTimer("DisplayMessage","Overlay",duration);
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ public class GameOverlay extends GameObject {
|
||||
@Override
|
||||
public void addToCanvas() {
|
||||
if(!gameView.timerExpired("DisplayMessage","Overlay")){
|
||||
gameView.addTextToCanvas(message,GameView.WIDTH/2.0, GameView.HEIGHT/2.0,30, Color.BLACK,0);
|
||||
gameView.addTextToCanvas(message, 250, 50,40, Color.GREEN.darker(), 0);
|
||||
}
|
||||
if(!gameView.timerExpired("FlashScreen","Overlay")){
|
||||
gameView.addRectangleToCanvas(HelperValues.FRAME_BORDER_WIDTH,HelperValues.FRAME_BORDER_WIDTH,GameView.WIDTH - (2*HelperValues.FRAME_BORDER_WIDTH),HelperValues.FRAME_WINDOW_HEIGHT+1,1,true,color);
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user