diff --git a/bin/de/bricked/ui/LevelGUI.fxml b/bin/de/bricked/ui/LevelGUI.fxml index 5f50361fb02cf496a0cd9cd29132c71d470fd7a5..a7a89ceccb8585b54bd03922c9a000a5fcbeb8e1 100644 --- a/bin/de/bricked/ui/LevelGUI.fxml +++ b/bin/de/bricked/ui/LevelGUI.fxml @@ -57,16 +57,11 @@ </Label> </children> </HBox> - <VBox fx:id="vboxLives" layoutX="745.0" layoutY="603.0" minHeight="71.0" minWidth="40.0" prefHeight="183.0" prefWidth="40.0" AnchorPane.bottomAnchor="24.0" AnchorPane.rightAnchor="15.0" /> + <VBox fx:id="vboxLives" layoutX="745.0" layoutY="603.0" minHeight="71.0" minWidth="40.0" prefHeight="227.0" prefWidth="40.0" AnchorPane.bottomAnchor="24.0" AnchorPane.rightAnchor="15.0" /> <Label fx:id="labelFPS" layoutX="770.0" layoutY="6.0" text="0" AnchorPane.rightAnchor="8.0" AnchorPane.topAnchor="8.0"> <font> <Font name="System Bold" size="16.0" /> </font> </Label> - <Label fx:id="labelMultiplicator" alignment="CENTER_RIGHT" layoutX="736.0" layoutY="543.0" prefHeight="30.0" prefWidth="49.0" text="x0" textAlignment="JUSTIFY" AnchorPane.rightAnchor="18.0" AnchorPane.topAnchor="543.0"> - <font> - <Font name="System Bold" size="20.0" /> - </font> - </Label> </children> </AnchorPane> diff --git a/src/de/bricked/ui/LevelController.java b/src/de/bricked/ui/LevelController.java index 90055ef6a1f2c9a02029b75e30ed8df89c81bcd6..f0014dab9a07cae56a01b518fd73466a0f5bdc9c 100644 --- a/src/de/bricked/ui/LevelController.java +++ b/src/de/bricked/ui/LevelController.java @@ -70,7 +70,6 @@ public class LevelController @FXML private VBox vboxPowerUps; @FXML private VBox vboxLives; @FXML private Label labelFPS; - @FXML private Label labelMultiplicator; public Stage stage; public Image icon = new Image("de/bricked/resources/icon.png"); @@ -137,7 +136,7 @@ public class LevelController if(gameState.equals(GameState.WAITING)) { startGame(); - } + } event.consume(); anchorPaneGame.requestFocus(); } @@ -501,7 +500,7 @@ public class LevelController } // move powerups - movePowerUps(); + movePowerUps(); } }; } @@ -632,7 +631,6 @@ public class LevelController game.applyMultiplicator(); game.resetMultiplicator(); game.resetPointsSinceLastMultiplicatorReset(); - labelMultiplicator.setText("x0"); labelPoints.setText(String.valueOf(game.getTotalPoints())); } @@ -640,7 +638,46 @@ public class LevelController { game.increaseMultiplicator(); game.increasePointsSinceLastMultiplicatorReset(points); - labelMultiplicator.setText("x" + game.getMultiplicator()); + + if(game.getMultiplicator() > 1) + { + double xPosition = (gamePaneWidth / Board.WIDTH) * (7); + double yPosition = (gamePaneHeight / Board.HEIGHT) * (20); + + Label labelNotification = new Label("x" + game.getMultiplicator()); + labelNotification.setTranslateX(xPosition); + labelNotification.setTranslateY(yPosition); + labelNotification.setStyle("-fx-font-weight: bold; -fx-font-size: 30; "); + labelNotification.setAlignment(Pos.CENTER); + labelNotification.setPrefWidth((gamePaneWidth / Board.WIDTH) * 3); + labelNotification.setPrefHeight((gamePaneHeight / Board.HEIGHT) * 2); + anchorPaneGame.getChildren().add(labelNotification); + + FadeTransition fadeTransition = new FadeTransition(Duration.millis(800), labelNotification); + fadeTransition.setFromValue(1.0); + fadeTransition.setToValue(0.0); + fadeTransition.setCycleCount(1); + fadeTransition.setAutoReverse(false); + TranslateTransition translateTransition = new TranslateTransition(Duration.millis(800), labelNotification); + translateTransition.setFromY(yPosition); + translateTransition.setToY(yPosition - (gamePaneHeight / Board.HEIGHT) * 3); + translateTransition.setCycleCount(1); + translateTransition.setAutoReverse(false); + + ParallelTransition parallelTransition = new ParallelTransition(); + parallelTransition.getChildren().addAll(fadeTransition, translateTransition); + parallelTransition.setCycleCount(1); + parallelTransition.setOnFinished(new EventHandler<ActionEvent>() + { + @Override + public void handle(ActionEvent event) + { + anchorPaneGame.getChildren().remove(labelNotification); + } + }); + + parallelTransition.play(); + } } private void movePaddleLeft() @@ -789,7 +826,7 @@ public class LevelController HitLocation hitLocation = game.collides(labelPosition, paddlePosition, paddle.getWidth(), paddle.getHeight(), true); if(hitLocation != null && (hitLocation.equals(HitLocation.PADDLE) || hitLocation.equals(HitLocation.CORNER))) - { + { Logger.log(LogLevel.DEBUG, "Collected PowerUp with ID = " + currentPowerUp.getID()); if(!currentPowerUp.isPermanent()) { @@ -809,7 +846,7 @@ public class LevelController } } } - + private void addTimedPowerUp(PowerUp powerUp) { Label labelPowerUp = new Label(String.valueOf(powerUp.getDurationInSeconds())); @@ -833,8 +870,8 @@ public class LevelController movingPowerUps = new ArrayList<>(); timedPowerUps = new ArrayList<>(); vboxPowerUps.getChildren().clear(); - } - + } + public void deactivatePowerUp(Label label) { int counter = 0; @@ -847,13 +884,13 @@ public class LevelController counter++; } } - - //if no other power ups of same kind are active + + // if no other power ups of same kind are active if(counter <= 1) { vboxPowerUps.getChildren().remove(label); timedPowerUps.remove(label); - powerUp.deactivate(this, game); + powerUp.deactivate(this, game); } } @@ -893,7 +930,7 @@ public class LevelController anchorPaneGame.requestFocus(); } - + /* * PowerUP-Functions */ @@ -903,10 +940,10 @@ public class LevelController double translateY = stackPaneBall.getTranslateY(); Point2D direction = game.getBall().getDirection(); game.setBall(newBall); - + initBall(game.getBall().getType()); stackPaneBall.setTranslateX(translateX); - stackPaneBall.setTranslateY(translateY); + stackPaneBall.setTranslateY(translateY); game.getBall().setDirection(game.getNewSpeedDirection(direction, newBall.getType().getSpeedFactor())); } } \ No newline at end of file diff --git a/src/de/bricked/ui/LevelGUI.fxml b/src/de/bricked/ui/LevelGUI.fxml index 5f50361fb02cf496a0cd9cd29132c71d470fd7a5..a7a89ceccb8585b54bd03922c9a000a5fcbeb8e1 100644 --- a/src/de/bricked/ui/LevelGUI.fxml +++ b/src/de/bricked/ui/LevelGUI.fxml @@ -57,16 +57,11 @@ </Label> </children> </HBox> - <VBox fx:id="vboxLives" layoutX="745.0" layoutY="603.0" minHeight="71.0" minWidth="40.0" prefHeight="183.0" prefWidth="40.0" AnchorPane.bottomAnchor="24.0" AnchorPane.rightAnchor="15.0" /> + <VBox fx:id="vboxLives" layoutX="745.0" layoutY="603.0" minHeight="71.0" minWidth="40.0" prefHeight="227.0" prefWidth="40.0" AnchorPane.bottomAnchor="24.0" AnchorPane.rightAnchor="15.0" /> <Label fx:id="labelFPS" layoutX="770.0" layoutY="6.0" text="0" AnchorPane.rightAnchor="8.0" AnchorPane.topAnchor="8.0"> <font> <Font name="System Bold" size="16.0" /> </font> </Label> - <Label fx:id="labelMultiplicator" alignment="CENTER_RIGHT" layoutX="736.0" layoutY="543.0" prefHeight="30.0" prefWidth="49.0" text="x0" textAlignment="JUSTIFY" AnchorPane.rightAnchor="18.0" AnchorPane.topAnchor="543.0"> - <font> - <Font name="System Bold" size="20.0" /> - </font> - </Label> </children> </AnchorPane>