diff --git a/bin/de/bricked/ui/LevelGUI.fxml b/bin/de/bricked/ui/LevelGUI.fxml index a7a89ceccb8585b54bd03922c9a000a5fcbeb8e1..716598d820007443d25ad648e97223005676b1ab 100644 --- a/bin/de/bricked/ui/LevelGUI.fxml +++ b/bin/de/bricked/ui/LevelGUI.fxml @@ -10,7 +10,14 @@ <AnchorPane fx:id="anchorPane" prefHeight="800.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.bricked.ui.LevelController"> <children> - <AnchorPane fx:id="anchorPaneGame" layoutX="22.0" layoutY="125.0" minHeight="650.0" minWidth="700.0" prefHeight="650.0" prefWidth="700.0" AnchorPane.bottomAnchor="25.0" AnchorPane.leftAnchor="22.0" AnchorPane.rightAnchor="78.0" AnchorPane.topAnchor="125.0" /> + <AnchorPane fx:id="anchorPaneGame" layoutX="22.0" layoutY="125.0" minHeight="650.0" minWidth="700.0" prefHeight="650.0" prefWidth="700.0" AnchorPane.bottomAnchor="25.0" AnchorPane.leftAnchor="22.0" AnchorPane.rightAnchor="78.0" AnchorPane.topAnchor="125.0"> + <children> + <Label fx:id="labelMultiplicator" alignment="CENTER" contentDisplay="CENTER" layoutX="301.0" layoutY="502.0" prefHeight="45.0" prefWidth="99.0" textAlignment="CENTER"> + <font> + <Font name="System Bold" size="30.0" /> + </font> + </Label> + </children></AnchorPane> <VBox fx:id="vboxPowerUps" layoutX="745.0" layoutY="125.0" minHeight="338.0" minWidth="40.0" prefHeight="402.0" prefWidth="40.0" AnchorPane.bottomAnchor="273.0" AnchorPane.rightAnchor="15.0" AnchorPane.topAnchor="125.0" /> <HBox alignment="CENTER" layoutX="34.0" layoutY="23.0" prefHeight="100.0" prefWidth="275.0" AnchorPane.leftAnchor="14.0" AnchorPane.rightAnchor="14.0" AnchorPane.topAnchor="14.0"> <children> diff --git a/src/de/bricked/game/board/Board.java b/src/de/bricked/game/board/Board.java index 4a2928dda2a337956374963529e306e5cbea74fe..e63e6845e159e1543946a5484ec67b12dec3c2eb 100644 --- a/src/de/bricked/game/board/Board.java +++ b/src/de/bricked/game/board/Board.java @@ -222,7 +222,7 @@ public class Board if(hittedBrick.getType().getPoints() > 0) { - game.getLevelController().showAnimatedPoints(row, col, hittedBrick.getType().getPoints()); + game.getLevelController().showAnimatedPoints(row, col, hittedBrick.getType().getPoints(), 15, false); } game.getLevelController().increaseMultiplicator(hittedBrick.getType().getPoints()); LevelController.redrawBrick(col, row, bricks.get(row).get(col), true); @@ -231,7 +231,6 @@ public class Board { LevelController.redrawBrick(col, row, bricks.get(row).get(col), false); } - } private void explodeBrick(int row, int col) diff --git a/src/de/bricked/ui/LevelController.java b/src/de/bricked/ui/LevelController.java index cf93c52988f6049745a371ee0a117e6ff6a0f503..73c9ada7210ba085ed73c742d7d306a22904a14f 100644 --- a/src/de/bricked/ui/LevelController.java +++ b/src/de/bricked/ui/LevelController.java @@ -34,6 +34,8 @@ import javafx.fxml.FXML; import javafx.geometry.Insets; import javafx.geometry.Point2D; import javafx.geometry.Pos; +import javafx.scene.Group; +import javafx.scene.Scene; import javafx.scene.control.Alert; import javafx.scene.control.Alert.AlertType; import javafx.scene.control.Button; @@ -51,6 +53,8 @@ import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; import javafx.scene.paint.Color; import javafx.scene.shape.Circle; +import javafx.scene.text.Font; +import javafx.scene.text.Text; import javafx.stage.Stage; import javafx.stage.WindowEvent; import javafx.util.Duration; @@ -66,6 +70,7 @@ public class LevelController @FXML private Label labelLevelPack; @FXML private Label labelPoints; @FXML private Label labelBlocksRemaining; + @FXML private Label labelMultiplicator; @FXML private AnchorPane anchorPaneGame; @FXML private Button buttonBack; @FXML private VBox vboxPowerUps; @@ -102,7 +107,13 @@ public class LevelController resetPowerUps(); anchorPaneGame.heightProperty().removeListener(heightListener); - anchorPaneGame.widthProperty().removeListener(widthListener); + anchorPaneGame.widthProperty().removeListener(widthListener); + + double yPosition = (gamePaneHeight / Board.HEIGHT) * (20); + labelMultiplicator.setLayoutX(0); + labelMultiplicator.setLayoutY(0); + labelMultiplicator.setTranslateX((gamePaneWidth - 100) / 2); + labelMultiplicator.setTranslateY(yPosition); // start random into left or right direction int random = new Random().nextInt(2); @@ -629,10 +640,15 @@ public class LevelController private void resetMultiplicator() { - game.applyMultiplicator(); - game.resetMultiplicator(); - game.resetPointsSinceLastMultiplicatorReset(); + game.applyMultiplicator(); labelPoints.setText(String.valueOf(game.getTotalPoints())); + labelMultiplicator.setText(""); + if(game.getMultiplicator() > 1) + { + showAnimatedPoints(20, 8, game.getPointsSinceLastMultiplicatorReset() * game.getMultiplicator(), 25, true); + } + game.resetPointsSinceLastMultiplicatorReset(); + game.resetMultiplicator(); } public void increaseMultiplicator(int points) @@ -641,43 +657,8 @@ public class LevelController game.increasePointsSinceLastMultiplicatorReset(points); 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(); + { + labelMultiplicator.setText("x" + game.getMultiplicator()); } } @@ -756,17 +737,29 @@ public class LevelController } } - public void showAnimatedPoints(int row, int col, int points) - { + public void showAnimatedPoints(int row, int col, int points, double fontSize, boolean centerInPane) + { + Text t = new Text("+" + points); + t.setFont(new Font(fontSize)); + new Scene(new Group(t)); + t.applyCss(); + double xPosition = (gamePaneWidth / Board.WIDTH) * (col); + if(centerInPane) + { + xPosition = (gamePaneWidth - t.getLayoutBounds().getWidth() + 10) / 2; + } double yPosition = (gamePaneHeight / Board.HEIGHT) * (row); Label labelNotification = new Label("+" + points); labelNotification.setTranslateX(xPosition); labelNotification.setTranslateY(yPosition); - labelNotification.setStyle("-fx-font-weight: bold; -fx-font-size: 15; "); + labelNotification.setStyle("-fx-font-weight: bold; -fx-font-size: " + fontSize + "; "); labelNotification.setAlignment(Pos.CENTER); - labelNotification.setPrefWidth(gamePaneWidth / Board.WIDTH); + + + + labelNotification.setPrefWidth(t.getLayoutBounds().getWidth() + 10); labelNotification.setPrefHeight(gamePaneHeight / Board.HEIGHT); anchorPaneGame.getChildren().add(labelNotification); diff --git a/src/de/bricked/ui/LevelGUI.fxml b/src/de/bricked/ui/LevelGUI.fxml index a7a89ceccb8585b54bd03922c9a000a5fcbeb8e1..dabc3a8a3ca5e10c4660fe58c2d4cdb16f18abda 100644 --- a/src/de/bricked/ui/LevelGUI.fxml +++ b/src/de/bricked/ui/LevelGUI.fxml @@ -10,7 +10,14 @@ <AnchorPane fx:id="anchorPane" prefHeight="800.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.bricked.ui.LevelController"> <children> - <AnchorPane fx:id="anchorPaneGame" layoutX="22.0" layoutY="125.0" minHeight="650.0" minWidth="700.0" prefHeight="650.0" prefWidth="700.0" AnchorPane.bottomAnchor="25.0" AnchorPane.leftAnchor="22.0" AnchorPane.rightAnchor="78.0" AnchorPane.topAnchor="125.0" /> + <AnchorPane fx:id="anchorPaneGame" layoutX="22.0" layoutY="125.0" minHeight="650.0" minWidth="700.0" prefHeight="650.0" prefWidth="700.0" AnchorPane.bottomAnchor="25.0" AnchorPane.leftAnchor="22.0" AnchorPane.rightAnchor="78.0" AnchorPane.topAnchor="125.0"> + <children> + <Label fx:id="labelMultiplicator" alignment="CENTER" contentDisplay="CENTER" layoutX="301.0" layoutY="502.0" prefHeight="45.0" prefWidth="100.0" textAlignment="CENTER"> + <font> + <Font name="System Bold" size="30.0" /> + </font> + </Label> + </children></AnchorPane> <VBox fx:id="vboxPowerUps" layoutX="745.0" layoutY="125.0" minHeight="338.0" minWidth="40.0" prefHeight="402.0" prefWidth="40.0" AnchorPane.bottomAnchor="273.0" AnchorPane.rightAnchor="15.0" AnchorPane.topAnchor="125.0" /> <HBox alignment="CENTER" layoutX="34.0" layoutY="23.0" prefHeight="100.0" prefWidth="275.0" AnchorPane.leftAnchor="14.0" AnchorPane.rightAnchor="14.0" AnchorPane.topAnchor="14.0"> <children>