diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000000000000000000000000000000000000..dd4c951ef44ebdc37bbe4a453aab974c815ca6f6 --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,7 @@ +<component name="InspectionProjectProfileManager"> + <settings> + <option name="PROJECT_PROFILE" value="Default" /> + <option name="USE_PROJECT_PROFILE" value="false" /> + <version value="1.0" /> + </settings> +</component> \ No newline at end of file diff --git a/README.md b/README.md index 36649891de9120708f42d1e77509733f2abd6a23..eab1454caa44dab8605d96de620ae2ec8ebbe63c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,17 @@ ## Hier könnte ihre Werbung stehn ### Known issues: - - Videos sometimes don't load in Windows 11 especially on weaker systems + - JavaFX Mediaplayer is buggy under Windows 11. Videos can have weird behaviors and sometimes won't load at all - SQL server is very slow (thanks Oracle) + +<br><br> +#### FAQ: +Why is the Game loading so long? <br> - cry about it + +Why can't I connect to the Multiplayer? <br> - cry about it + +The character is moving too quickly <br> - cry about it + +The UI is too small <br> - cry about it + +Why doesn't the intro load? <br> - cry about it \ No newline at end of file diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/CommunityMapController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/CommunityMapController.java index be1256f441fa09604694e890557db0bd53131531..db877f9ad027ae08a96f1365690014eace49f1d9 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Controller/CommunityMapController.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/CommunityMapController.java @@ -24,7 +24,7 @@ public class CommunityMapController implements Initializable { @FXML private TableColumn<DataItem, String> name; - Rectangle2D screen = Screen.getPrimary().getVisualBounds(); + private final Rectangle2D screen = Screen.getPrimary().getVisualBounds(); @Override public void initialize(URL url, ResourceBundle resourceBundle) { @@ -54,7 +54,7 @@ public class CommunityMapController implements Initializable { parent.getChildren().add(new SceneLoader().loadScene("MapForge")); } -// test values TODO: replace with db + // test values TODO: replace with db public static class DataItem { private final SimpleStringProperty name; diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/CreateAccountController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/CreateAccountController.java index 826cb76c7ba083c1cd0608fe5d6d83e28ef68733..26fedf89d991531bea80c5d98b1b4022bf3d81ff 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Controller/CreateAccountController.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/CreateAccountController.java @@ -11,6 +11,8 @@ import javafx.scene.control.RadioButton; import javafx.scene.control.TextField; import javafx.scene.control.ToggleGroup; import javafx.scene.layout.VBox; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import java.net.URL; import java.util.ResourceBundle; @@ -26,10 +28,10 @@ public class CreateAccountController implements Initializable { private TextField playerName, password; @FXML private Label errorMessage, passwordLabel; - - String selectedButton; - SceneLoader sceneLoader = new SceneLoader(); - Persistence persistence = Persistence.getInstance(); + private String selectedButton; + private final SceneLoader sceneLoader = new SceneLoader(); + private final Persistence persistence = Persistence.getInstance(); + private static final Logger log = LogManager.getLogger(SceneLoader.class); @Override public void initialize(URL url, ResourceBundle resourceBundle) { @@ -41,7 +43,7 @@ public class CreateAccountController implements Initializable { if (statistics.getSelectedToggle() != null) { RadioButton selectedToggle = (RadioButton) statistics.getSelectedToggle(); selectedButton = selectedToggle.getText(); - System.out.println(selectedButton); + log.info("Statistics tracking set to: " + selectedButton); } if (local.isSelected()) { password.setEditable(false); @@ -73,9 +75,11 @@ public class CreateAccountController implements Initializable { persistence.createAccount(playerName.getText(), password.getText(), accountType); persistence.resetPlayerStatistics(); persistence.loadPlayerStatistics(); + log.info(accountType + " Account created"); switchScene("MainMenu"); } catch (DatabaseException e) { errorMessage.setText(e.getMessage()); + log.debug(e.getMessage()); } } diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/CreditsController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/CreditsController.java index bd8d67fc8262984ee946d5890286b10d08f2c77f..a056de0b757b1aa75cb1537a0aaf17b16d2e9540 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Controller/CreditsController.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/CreditsController.java @@ -1,7 +1,8 @@ package de.hdm_stuttgart.battlearena.Controller; +import de.hdm_stuttgart.battlearena.Controller.Enum.GameState; import de.hdm_stuttgart.battlearena.Controller.Utilities.CreateMediaPlayer; -import de.hdm_stuttgart.battlearena.Controller.Utilities.MusicPlayerSingleton; +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.RuntimeInfo; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.fxml.Initializable; @@ -29,7 +30,6 @@ public class CreditsController implements Initializable { parent.setStyle("-fx-background-color: black;"); parent.setCursor(Cursor.NONE); createMediaPlayer(); - MusicPlayerSingleton.getInstance().getMediaPlayer().dispose(); } private void createMediaPlayer() { @@ -44,6 +44,7 @@ public class CreditsController implements Initializable { private void videoEnd() { try { // I don't know how to return to the options scene, so it just goes back to the main menu :( + RuntimeInfo.getInstance().setGameState(GameState.MENU); mediaPlayer.dispose(); parent.getChildren().clear(); parent.getScene().setRoot(FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/MenuBorderPane.fxml")))); diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/Enum/GameState.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/Enum/GameState.java index 1ea713b41a90fa593348760d6a6be8c9f0ed1a62..c1e336dc772e780443b68d79e2dc185c08cefae3 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Controller/Enum/GameState.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/Enum/GameState.java @@ -1,9 +1,21 @@ package de.hdm_stuttgart.battlearena.Controller.Enum; public enum GameState { - MENU, - PAUSE, - PLAYING, - LOST, - WON + NONE(""), + MENU("src/main/resources/sound/music/menu"), + PAUSE("src/main/resources/sound/music/game"), + PLAYING("src/main/resources/sound/music/game"), + LOST(""), + WON(""), + PLACEHOLDER("src/main/resources/sound/music/placeholder"), + MEMES("src/main/resources/sound/music/memes"); + + private String path; + GameState(String path){ + this.path = path; + } + + public String getPath(){ + return path; + } } \ No newline at end of file diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/GameSceneController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/GameSceneController.java index 6f3448c0559f8b78862486fbf01c9504fc9c653a..cf14c9bff0a9ccd3ea90f4fdf36ca9d624623501 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Controller/GameSceneController.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/GameSceneController.java @@ -1,5 +1,7 @@ package de.hdm_stuttgart.battlearena.Controller; +import de.hdm_stuttgart.battlearena.Controller.Utilities.SceneLoader; +import de.hdm_stuttgart.battlearena.Controller.Utilities.ScreenDimensionCalculator; import de.hdm_stuttgart.battlearena.Controller.Enum.GameMode; import de.hdm_stuttgart.battlearena.Controller.Enum.GameState; import de.hdm_stuttgart.battlearena.Controller.Enum.PlayerMode; @@ -16,100 +18,59 @@ import de.hdm_stuttgart.battlearena.Model.Map.TileManager; import javafx.animation.AnimationTimer; import javafx.fxml.FXML; import javafx.fxml.Initializable; +import javafx.geometry.Rectangle2D; +import javafx.scene.Node; import javafx.scene.canvas.Canvas; import javafx.scene.canvas.GraphicsContext; +import javafx.scene.control.Label; +import javafx.scene.effect.GaussianBlur; +import javafx.scene.layout.*; +import javafx.scene.shape.Rectangle; +import javafx.scene.text.Font; +import javafx.stage.Screen; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; import java.net.URL; -import java.util.List; -import java.util.ResourceBundle; +import java.util.*; import java.util.stream.Collectors; public class GameSceneController implements Initializable { - private static final Logger log = LogManager.getLogger(GameSceneController.class); - + @FXML + private BorderPane gameScene; @FXML private Canvas canvas2D; + @FXML + private Rectangle playerHealth, enemyHealth; + @FXML + private Pane playerPane, enemyPane; + @FXML + private Label playerHp, enemyHp, time, round; + @FXML + private StackPane stackPane; + private final Pane pause = new SceneLoader().loadScene("Pause"); - private GraphicsContext graphicsContext2D; + private final long targetFrameTime = 1_000_000_000 / 80; // sets the target frame time to 12.5 ms (80fps) + private long lastFrame = 0; + private boolean wasPaused; + private final Screen screen = Screen.getPrimary(); + private final Rectangle2D visualBounds = screen.getVisualBounds(); + final private double healthBarWidth = screen.getBounds().getWidth() / 5; + ScreenDimensionCalculator screenCalculator = new ScreenDimensionCalculator(); + private GraphicsContext graphicsContext2D; InputHandler inputHandler = InputHandler.getInstance(); - RuntimeInfo runtimeInfo = RuntimeInfo.getInstance(); - GameMode gameMode = runtimeInfo.getGameMode(); - IEntity player; IEntity enemy; - EntityClass playerOneClass = runtimeInfo.getPlayerOneClass(); EntityClass playerTwoClass = runtimeInfo.getPlayerTwoClass(); - TileManager tileManager; //map data - - /*String mapString = "10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 " + - "10 1 1 1 20 1 20 1 20 1 20 1 20 1 20 1 1 10 " + - "10 1 1 20 10 20 10 20 10 20 10 20 10 20 10 20 1 10 " + - "10 1 20 1 20 1 20 1 20 1 20 1 20 1 20 1 20 10 " + - "10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 10 " + - "10 1 20 1 20 1 20 1 20 1 20 1 20 1 20 1 20 10 " + - "10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 10 " + - "10 1 20 1 20 1 20 1 20 1 20 1 20 1 20 1 20 10 " + - "10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 10 " + - "10 1 20 1 20 1 20 1 20 1 20 1 20 1 20 1 20 10 " + - "10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 10 " + - "10 1 20 1 20 1 20 1 20 1 20 1 20 1 20 1 20 10 " + - "10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 10 " + - "10 1 20 1 20 1 20 1 20 1 20 1 20 1 20 1 20 10 " + - "10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 10 " + - "10 1 20 1 20 1 20 1 20 1 20 1 20 1 20 1 1 10 " + - "10 1 1 20 10 20 10 20 10 20 10 20 10 20 10 1 1 10 " + - "10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 ";*/ - - String mapString = "12 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 12 " + - "13 1 1 20 20 20 20 20 20 20 20 20 20 20 20 1 1 14 " + - "13 1 10 20 10 20 10 20 10 10 20 10 20 10 20 10 1 14 " + - "13 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 14 " + - "13 20 10 20 10 20 10 20 10 10 20 10 20 10 20 10 20 14 " + - "13 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 14 " + - "13 20 10 20 10 20 10 20 10 10 20 10 20 10 20 10 20 14 " + - "13 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 14 " + - "13 20 10 20 10 20 10 20 10 10 20 10 20 10 20 10 20 14 " + - "13 20 10 20 10 20 10 20 10 10 20 10 20 10 20 10 20 14 " + - "13 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 14 " + - "13 20 10 20 10 20 10 20 10 10 20 10 20 10 20 10 20 14 " + - "13 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 14 " + - "13 20 10 20 10 20 10 20 10 10 20 10 20 10 20 10 20 14 " + - "13 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 14 " + - "13 1 10 20 10 20 10 20 10 10 20 10 20 10 20 10 1 14 " + - "13 1 1 20 20 20 20 20 20 20 20 20 20 20 20 1 1 14 " + - "12 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 12 "; - - - /*String mapString = "11 10 13 10 13 10 10 12 14 14 11 10 10 13 10 13 10 12 " + - "11 0 0 0 0 0 16 0 2 2 0 3 0 0 0 3 0 12 " + - "11 0 16 0 0 0 0 0 1 2 0 0 0 0 16 0 1 12 " + - "11 16 0 0 3 0 16 0 2 2 0 0 3 0 0 0 0 12 " + - "11 0 3 0 0 16 0 1 1 2 0 0 0 0 16 0 0 12 " + - "11 0 0 16 16 0 0 0 1 2 0 0 0 0 3 16 0 12 " + - "11 16 0 0 12 10 10 15 12 2 11 15 16 15 15 11 0 12 " + - "11 0 0 0 12 0 1 1 0 2 0 0 0 0 0 11 0 12 " + - "11 0 0 16 12 5 5 5 5 4 5 5 5 5 0 11 1 12 " + - "11 0 0 0 12 11 10 10 10 2 12 0 0 1 0 11 0 12 " + - "11 0 0 0 12 1 0 0 11 2 12 16 0 1 0 11 0 12 " + - "11 0 0 0 12 0 1 0 11 2 12 0 16 0 0 11 0 12 " + - "11 0 1 0 12 0 0 12 11 2 12 11 13 10 13 11 0 12 " + - "11 0 0 0 12 0 0 0 0 2 0 0 0 0 0 0 0 12 " + - "11 0 0 0 12 15 13 10 12 14 11 10 13 10 13 12 0 12 " + - "11 1 0 0 1 0 0 0 0 2 0 0 1 1 0 0 0 12 " + - "11 0 0 1 0 0 1 0 0 2 0 0 1 0 0 1 0 12 " + - "11 10 15 15 10 10 15 10 12 14 11 10 10 15 10 15 10 12";*/ - int horizontalTileCount = 18; int verticalTileCount = 18; int diffTileCount = 30; @@ -118,6 +79,8 @@ public class GameSceneController implements Initializable { @Override public void initialize(URL url, ResourceBundle resourceBundle) { + setScene(); + graphicsContext2D = canvas2D.getGraphicsContext2D(); graphicsContext2D.setImageSmoothing(false); @@ -132,17 +95,29 @@ public class GameSceneController implements Initializable { } tileManager = new TileManager(graphicsContext2D, diffTileCount, horizontalTileCount, - verticalTileCount, mapString, biom); + verticalTileCount, runtimeInfo.getMapDataGame(), biom); + runtimeInfo.setGameState(GameState.PLAYING); AnimationTimer gameLoop = new AnimationTimer() { @Override - public void handle(long l) { + public void handle(long now) { if (!inputHandler.isPause()) { - graphicsContext2D.clearRect(0, 0, canvas2D.getWidth(), canvas2D.getHeight()); - renderContent(graphicsContext2D); - updateContent(); + if (now - lastFrame >= targetFrameTime) { // If short frame time (high fps) it will skip updateContent(). Next Frame has higher frame time and updates the frame + graphicsContext2D.clearRect(0, 0, canvas2D.getWidth(), canvas2D.getHeight()); + renderContent(graphicsContext2D); + updateContent(); + lastFrame = now; + } +// remove blur + if (wasPaused) { + resume(); + } + } else { + if (!wasPaused) { + pauseMenu(); + } } } }; @@ -150,6 +125,61 @@ public class GameSceneController implements Initializable { log.debug("Game loop started"); } + private void setScene() { +// for some reason scene builder overwrites css fonts + playerHp.setFont(Font.loadFont(getClass().getResourceAsStream("/fonts/StarshipShadow.ttf"), 55)); + enemyHp.setFont(Font.loadFont(getClass().getResourceAsStream("/fonts/StarshipShadow.ttf"), 55)); + playerHp.setText("100%"); + playerHp.setMinWidth(120); + playerHp.setMaxWidth(120); + enemyHp.setText("100%"); + enemyHp.setMinWidth(120); + +// stopping the VBox from shrinking when health bar gets smaller + playerPane.setMinWidth(healthBarWidth); + playerPane.setMaxWidth(healthBarWidth); + enemyPane.setMinWidth(healthBarWidth); + enemyPane.setMaxWidth(healthBarWidth); + + playerHealth.setWidth(healthBarWidth); + enemyHealth.setWidth(healthBarWidth); + +// make it responsive + stackPane.heightProperty().addListener((observableValue, oldValue, newValue) -> { + canvas2D.setScaleY(newValue.doubleValue() / 870); + canvas2D.setScaleX(newValue.doubleValue() / 870); + }); + } + + private void pauseMenu() { +// setting blur in for loop otherwise all child node will inherit blur from root including pause menu + for (Node child : gameScene.getChildren()) { + if (child != stackPane) { + child.setEffect(new GaussianBlur(20)); + } + } + for (Node child : stackPane.getChildren()) { + if (child != pause) { + child.setEffect(new GaussianBlur(20)); + } + } + stackPane.getChildren().add(pause); + wasPaused = true; + log.info("Game paused"); + } + + private void resume() { + for (Node child : gameScene.getChildren()) { + child.setEffect(null); + } + for (Node child : stackPane.getChildren()) { + child.setEffect(null); + } + stackPane.getChildren().remove(pause); + wasPaused = false; + log.info("Game resumed"); + } + private void updateContent() { player.updateEntity(this, graphicsContext2D); enemy.updateEntity(this, graphicsContext2D); @@ -159,8 +189,25 @@ public class GameSceneController implements Initializable { updateExplosionspawns(); player.checkGameplayObjectInteraction(player, graphicsContext2D); enemy.checkGameplayObjectInteraction(enemy, graphicsContext2D); + player.placeBombAction(player, graphicsContext2D); enemy.placeBombAction(enemy, graphicsContext2D); + double playerHP = (double) getPlayer().getHealth() / getPlayer().getMaxEntityHealth(); + double enemyHP = (double) getEnemy().getHealth() / getEnemy().getMaxEntityHealth(); + if (playerHP >= 0) { + playerHealth.setWidth(healthBarWidth * (playerHP)); + double playerPercentage = playerHP * 100; + playerHp.setText((int) playerPercentage + "%"); + } else { + playerHp.setText(0 + "%"); + } + if (enemyHP >= 0) { + enemyHealth.setWidth(healthBarWidth * (enemyHP)); + double enemyPercentage = enemyHP * 100; + enemyHp.setText((int) enemyPercentage + "%"); + } else { + enemyHp.setText(0 + "%"); + } } private void renderContent(GraphicsContext graphicsContext) { @@ -169,7 +216,7 @@ public class GameSceneController implements Initializable { enemy.renderEntity(graphicsContext); renderGameplayObjects(graphicsContext); } - + private void renderGameplayObjects(GraphicsContext graphicsContext) { List<IEntity> gameplayObjects = runtimeInfo.getGameplayObjects(); for (IEntity gameplayObject : gameplayObjects) { @@ -207,4 +254,8 @@ public class GameSceneController implements Initializable { public int getScaledTileSize() { return scaledTileSize; } + + public InputHandler getInputHandler() { + return inputHandler; + } } \ No newline at end of file diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/IntroController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/IntroController.java index 6a99c538617e193578e4a80332c60baa7c0bcf5e..f875d299f5c512438c5f1934ef0b51367fa5331b 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Controller/IntroController.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/IntroController.java @@ -19,25 +19,23 @@ import java.util.Objects; import java.util.ResourceBundle; public class IntroController implements Initializable { - @FXML private MediaView mediaView; @FXML private BorderPane introParent; private final String fileName = "src/main/resources/videos/"; - // nextVideo() will iterate through this array so the next video will be played TODO: change the videos to non memes lmao - private final String[] videos = {"sony.mp4", "gamecube.mp4", "gameboy.mp4", "monke.mp4"}; + // nextVideo() will iterate through this array so the next video will be played + private final String[] videos = {"black.mp4", "EngineIntro.mp4", "DigitalGlitch.mp4", "BattleArenaIntro.mp4"}; private File file = new File(fileName + videos[0]); private int counter = 0; private MediaPlayer mediaPlayer; - private final Persistence persistence = Persistence.getInstance(); - private static final Logger log = LogManager.getLogger(Persistence.class); @Override public void initialize(URL url, ResourceBundle resourceBundle) { introParent.setStyle("-fx-background-color: black;"); introParent.setCursor(Cursor.NONE); createMediaPlayer(); + mediaPlayer.setOnReady(() -> introParent.requestFocus()); } private void createMediaPlayer() { @@ -53,7 +51,14 @@ public class IntroController implements Initializable { } }); -// TODO: make any button pressed work + introParent.setOnKeyPressed((keyEvent -> { + if (counter == videos.length - 1) { + videoEnd(); + } else { + nextVideo(); + } + })); + introParent.setOnMouseClicked((mouseEvent) -> { if (counter == videos.length - 1) { videoEnd(); diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/LoadingScreenController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/LoadingScreenController.java index a7aa8a685f37286da95ba3edda224fc8c78f30d4..91c701f8632b2dc261ca0a48b6bb5a60b69009ac 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Controller/LoadingScreenController.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/LoadingScreenController.java @@ -1,8 +1,10 @@ package de.hdm_stuttgart.battlearena.Controller; +import de.hdm_stuttgart.battlearena.Controller.Enum.GameState; import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.ENUMs.AccountType; import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Exceptions.DatabaseException; import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Persistence; +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.RuntimeInfo; import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.ThreadStartup1; import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.ThreadStartup2; import javafx.application.Platform; @@ -28,8 +30,6 @@ public class LoadingScreenController implements Initializable { private BorderPane parent; @FXML private ImageView logo, throbber; - - boolean isReady = false; private int counter = 0; private boolean statsLoaded = false; private final String[] loadingTips = { @@ -49,33 +49,52 @@ public class LoadingScreenController implements Initializable { "Get the BattleArena Ultimate-Edition for only 420,69€.", "To move left, press one of the keys on your keyboard.", "To use the gravity-gun, close the game and start Half Life 2.", - "Buying this game was a good decision! (no refunds)." + "Buying this game was a good decision! (no refunds).", + "Apparently Jonas is above the law.", + "Jonas has lost his Game Dev Role in Discord.", + "Maxe is a light mode user. Poor soul...", + "Did you know, that Elias almost destroyed our GitLab Repo?", + "This Game is sponsored by ChatGPT™" }; private final List<String> shuffledTips = Arrays.asList(loadingTips); private static final Logger log = LogManager.getLogger(Persistence.class); - Rectangle2D screen = Screen.getPrimary().getVisualBounds(); - ThreadStartup1 thread1 = new ThreadStartup1(); - ThreadStartup2 thread2 = new ThreadStartup2(); - Persistence persistence = Persistence.getInstance(); + private final Rectangle2D screen = Screen.getPrimary().getVisualBounds(); + private final ThreadStartup1 thread1 = new ThreadStartup1(); + private final ThreadStartup2 thread2 = new ThreadStartup2(); + private final Persistence persistence = Persistence.getInstance(); Thread tipsThread = new Thread(() -> { try { setLoadingTips(); + log.debug("Executing tipsThread"); } catch (InterruptedException e) { log.info("Data finished loading"); } }); - Thread loadingDataThread = new Thread(() -> { + Thread loadStatistics = new Thread(() -> { try { - Thread.sleep(4000); - loadData(); + log.debug("Executing loadStatistics thread"); + Thread.sleep(5000); + loadStatistics(); } catch (IOException e) { + log.error(e); throw new RuntimeException(); + } catch (InterruptedException e) { + log.error(e); + throw new RuntimeException(e); + } + }); + + Thread waitingForThread1 = new Thread(() -> { + try { + log.debug("Executing waitingForThread1"); + thread1.join(); } catch (InterruptedException e) { throw new RuntimeException(e); } + thread2.start(); }); @Override @@ -85,24 +104,12 @@ public class LoadingScreenController implements Initializable { tipsThread.start(); thread1.start(); - - boolean threadOneIsRunning = true, threadTwoIsRunning = false; - while (!isReady) { - if (!thread1.isAlive() && threadOneIsRunning) { - thread2.start(); - threadTwoIsRunning = true; - threadOneIsRunning = false; - } - if (!thread2.isAlive() && threadTwoIsRunning) { - isReady = true; - } - } - loadingDataThread.start(); + waitingForThread1.start(); // basically thread1.join() but making it in separate thread otherwise it will block JavaFX thread + loadStatistics.start(); } private void setImages() { logo.setTranslateY(screen.getHeight() * 0.08); - System.out.println(screen.getHeight()); logo.setFitWidth(screen.getWidth() * 0.3); throbber.setFitWidth(screen.getWidth() * 0.07); logo.setPreserveRatio(true); @@ -125,9 +132,14 @@ public class LoadingScreenController implements Initializable { setLoadingTips(); } } + if (counter == loadingTips.length) { + Collections.shuffle(shuffledTips); + counter = 0; + setLoadingTips(); + } } - private void loadData() throws IOException { + private void loadStatistics() throws IOException { if (persistence.getAccount().getAccountType() != AccountType.NONE) { try { persistence.loadPlayerStatistics(); @@ -137,7 +149,15 @@ public class LoadingScreenController implements Initializable { } } - Platform.runLater(tipsThread::interrupt); - parent.getScene().setRoot(FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/MenuBorderPane.fxml")))); + Platform.runLater(() -> { + try { + tipsThread.interrupt(); + RuntimeInfo.getInstance().setGameState(GameState.MENU); + parent.getScene().setRoot(FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/MenuBorderPane.fxml")))); + } catch (Exception e) { + log.error(e); + throw new RuntimeException(e); + } + }); } } diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/LocalCreateController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/LocalCreateController.java index 69b2cb5b336306ffa11e72ad169745d1c83c9cd4..9284a0f05631f669f065ee4e3b8235b06b713322 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Controller/LocalCreateController.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/LocalCreateController.java @@ -1,12 +1,15 @@ package de.hdm_stuttgart.battlearena.Controller; import de.hdm_stuttgart.battlearena.Controller.Utilities.SceneLoader; +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Persistence; import javafx.fxml.FXML; import javafx.fxml.Initializable; import javafx.scene.control.TitledPane; import javafx.scene.control.ToggleButton; import javafx.scene.control.ToggleGroup; import javafx.scene.layout.VBox; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import java.net.URL; import java.util.ResourceBundle; @@ -19,6 +22,8 @@ public class LocalCreateController implements Initializable { @FXML private ToggleGroup rounds; private final SceneLoader sceneLoader = new SceneLoader(); + private static final Logger log = LogManager.getLogger(Persistence.class); + @Override public void initialize(URL url, ResourceBundle resourceBundle) { @@ -26,9 +31,11 @@ public class LocalCreateController implements Initializable { if (rounds.getSelectedToggle() != null) { ToggleButton selected = (ToggleButton) rounds.getSelectedToggle(); roundsTitledPane.setText(selected.getText()); + log.info("Match rounds: " + selected.getText()); } }); } + @FXML private void backButton() { parent.getChildren().clear(); @@ -40,5 +47,4 @@ public class LocalCreateController implements Initializable { parent.getChildren().clear(); parent.getChildren().add(sceneLoader.loadScene("SkinSelection")); } - } diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/LoginController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/LoginController.java index 6e3fd79dd026c1b1db894041b1782058cd819ab8..1cf040890ea9f3498669680c7ddeefb72e69964d 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Controller/LoginController.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/LoginController.java @@ -2,14 +2,14 @@ package de.hdm_stuttgart.battlearena.Controller; import de.hdm_stuttgart.battlearena.Controller.Utilities.SceneLoader; import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Exceptions.DatabaseException; -import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Exceptions.ParserException; import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Persistence; -import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Utilities.Parser; import javafx.application.Platform; import javafx.fxml.FXML; import javafx.scene.control.Label; import javafx.scene.control.TextField; import javafx.scene.layout.VBox; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import java.security.NoSuchAlgorithmException; @@ -20,9 +20,9 @@ public class LoginController { private TextField playerName, password; @FXML private Label errorMessage; - - SceneLoader sceneLoader = new SceneLoader(); - Persistence persistence = Persistence.getInstance(); + private final SceneLoader sceneLoader = new SceneLoader(); + private final Persistence persistence = Persistence.getInstance(); + private static final Logger log = LogManager.getLogger(Persistence.class); private void switchScene(String name) { parent.getChildren().clear(); @@ -31,18 +31,22 @@ public class LoginController { @FXML private void login() { + errorMessage.setMaxWidth(parent.getWidth()); errorMessage.setText("Loading an eternity because of slow SQL server..."); thread.start(); } Thread thread = new Thread(() -> { try { + log.info("Login Player: " + playerName); persistence.login(playerName.getText(), password.getText()); persistence.loadPlayerStatistics(); Platform.runLater(() -> switchScene("MainMenu")); } catch (NoSuchAlgorithmException e) { + log.error(e); throw new RuntimeException(e); } catch (DatabaseException e) { + log.debug(e.getMessage()); Platform.runLater(() -> errorMessage.setText(e.getMessage())); } }); diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/MainMenuController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/MainMenuController.java index 83a6d92e8b0dbe60af7cbbbe09a263afdb51a6b5..fb877b68420a3898f7a8c6e700093816342d0bbe 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Controller/MainMenuController.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/MainMenuController.java @@ -3,23 +3,23 @@ package de.hdm_stuttgart.battlearena.Controller; import de.hdm_stuttgart.battlearena.Controller.Utilities.SceneLoader; import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Exceptions.DatabaseException; import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Persistence; +import de.hdm_stuttgart.battlearena.Model.Sound.MusicPlayer; import javafx.fxml.FXML; -import javafx.fxml.Initializable; import javafx.scene.control.Button; import javafx.scene.layout.VBox; -import javafx.stage.Screen; import javafx.stage.Stage; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; -import java.net.URL; -import java.util.ResourceBundle; - -public class MainMenuController implements Initializable { +public class MainMenuController { @FXML private VBox parent; @FXML private Button exitButton; private final SceneLoader sceneLoader = new SceneLoader(); private final Persistence persistence = Persistence.getInstance(); + private final MusicPlayer player = MusicPlayer.getInstance(); + private static final Logger log = LogManager.getLogger(Persistence.class); private void switchScene(String name) { parent.getChildren().clear(); @@ -48,20 +48,11 @@ public class MainMenuController implements Initializable { @FXML private void exit() throws DatabaseException { + player.getScheduler().shutdown(); persistence.savePlayerStatistics(); persistence.saveSettings(); + log.info("Exiting game"); Stage stage = (Stage) exitButton.getScene().getWindow(); stage.close(); } - - @Override - public void initialize(URL url, ResourceBundle resourceBundle) { - Screen screen = Screen.getPrimary(); - if (screen.getDpi() >= 119) { - parent.setSpacing(30); - parent.setStyle("-fx-font-size: 40"); - } else { - parent.setStyle("-fx-font-size: 50"); - } - } } diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/MapForgeController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/MapForgeController.java index 784361391329dab062e1c64e5aee944381861ff1..b090af45bfe7414142f40b22791e111d9e4caf28 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Controller/MapForgeController.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/MapForgeController.java @@ -1,9 +1,10 @@ package de.hdm_stuttgart.battlearena.Controller; -import de.hdm_stuttgart.battlearena.Controller.Utilities.MusicPlayerSingleton; +import de.hdm_stuttgart.battlearena.Controller.Enum.GameState; import de.hdm_stuttgart.battlearena.Controller.Utilities.SceneLoader; import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Exceptions.DatabaseException; import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Persistence; +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.RuntimeInfo; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.scene.layout.VBox; @@ -14,14 +15,14 @@ import java.util.Objects; public class MapForgeController { @FXML private VBox parent; - SceneLoader sceneLoader = new SceneLoader(); + private final SceneLoader sceneLoader = new SceneLoader(); private final Persistence persistence = Persistence.getInstance(); @FXML private void mapEditorScene() { try { - parent.getScene().setRoot(FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/PlayerCreateScene.fxml")))); - MusicPlayerSingleton.getInstance().getMediaPlayer().dispose(); + RuntimeInfo.getInstance().setGameState(GameState.PLACEHOLDER); + parent.getScene().setRoot(FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/Placeholder.fxml")))); } catch (IOException e) { throw new RuntimeException(); } diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/MapSelectionController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/MapSelectionController.java index d821334354bd487632d52077ffa4a3c21f6a1914..bd769f0765bc5ad4b966062eef20363e93bbf090 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Controller/MapSelectionController.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/MapSelectionController.java @@ -1,17 +1,18 @@ package de.hdm_stuttgart.battlearena.Controller; -import de.hdm_stuttgart.battlearena.Controller.Utilities.MusicPlayerSingleton; +import de.hdm_stuttgart.battlearena.Controller.Enum.GameState; import de.hdm_stuttgart.battlearena.Controller.Utilities.SceneLoader; import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.MapData; import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Persistence; import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.RuntimeInfo; +import de.hdm_stuttgart.battlearena.Model.Map.Biom; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.fxml.Initializable; +import javafx.scene.control.TitledPane; import javafx.scene.control.ToggleButton; import javafx.scene.control.ToggleGroup; import javafx.scene.layout.VBox; -import javafx.scene.text.Text; import java.io.IOException; import java.net.URL; @@ -19,24 +20,62 @@ import java.util.ArrayList; import java.util.Objects; import java.util.ResourceBundle; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; + public class MapSelectionController implements Initializable { @FXML private VBox boxBox, parent; @FXML - private Text selectedMapText; + private TitledPane maps, textures; + @FXML + private ToggleGroup textureToggle; - private int selectedMap; + private String selectedTexture, selectedMap; + private int mapIndex; private final SceneLoader sceneLoader = new SceneLoader(); - private final ArrayList<MapData> coreMaps = Persistence.getInstance().getCoreMaps(); + private static final Logger log = LogManager.getLogger(MapSelectionController.class); + private final RuntimeInfo runtimeInfo = RuntimeInfo.getInstance(); @Override public void initialize(URL url, ResourceBundle resourceBundle) { + setTexture(); + setMap(); + } + + private void setTexture() { + textureToggle.selectedToggleProperty().addListener(((observableValue, oldToggle, newToggle) -> { + if (textureToggle != null) { + ToggleButton selected = (ToggleButton) textureToggle.getSelectedToggle(); + selectedTexture = selected.getText(); + switch (selectedTexture) { + case "Bomberman": + runtimeInfo.setMapBiom(Biom.BOMBERMAN); + textures.setText(selectedTexture); + break; + case "Dark Lands": + runtimeInfo.setMapBiom(Biom.DARK_LANDS); + textures.setText(selectedTexture); + break; + case "Forrest": + runtimeInfo.setMapBiom(Biom.FORREST); + textures.setText(selectedTexture); + break; + case "Grass": + runtimeInfo.setMapBiom(Biom.GRASS); + textures.setText(selectedTexture); + } + } + })); + } + + private void setMap() { ToggleGroup group = new ToggleGroup(); - for (int i = 0; i < coreMaps.size(); i++) { - ToggleButton toggleButton = new ToggleButton(coreMaps.get(i).getMapName()); + for (MapData coreMap : coreMaps) { + ToggleButton toggleButton = new ToggleButton(coreMap.getMapName()); toggleButton.setToggleGroup(group); boxBox.getChildren().add(toggleButton); } @@ -44,11 +83,9 @@ public class MapSelectionController implements Initializable { group.selectedToggleProperty().addListener((observableValue, oldToggle, newToggle) -> { if (group.getSelectedToggle() != null) { ToggleButton selected = (ToggleButton) group.getSelectedToggle(); - selectedMap = boxBox.getChildren().indexOf(selected); - System.out.println(selectedMap); - String value = selected.getText(); - selectedMapText.setText(value); - System.out.println(value); + mapIndex = boxBox.getChildren().indexOf(selected); + selectedMap = selected.getText(); + maps.setText(selectedMap); } }); } @@ -56,10 +93,13 @@ public class MapSelectionController implements Initializable { @FXML private void gameScene() { try { - RuntimeInfo.getInstance().setGameMap(coreMaps.get(selectedMap)); - MusicPlayerSingleton.getInstance().getMediaPlayer().dispose(); + RuntimeInfo.getInstance().setGameMap(coreMaps.get(mapIndex)); + log.info("Selected map: " + selectedMap); + log.info("Selected texture: " + selectedTexture); parent.getScene().setRoot(FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/GameScene.fxml")))); + RuntimeInfo.getInstance().setGameState(GameState.PLAYING); } catch (IOException e) { + log.error(e); throw new RuntimeException(); } } diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/MenuBorderPaneController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/MenuBorderPaneController.java index 75315ab525f8037751af3070d1402fe0c9ed7f71..8b861d21b43392e78fa90bbac0297ed08817a49f 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Controller/MenuBorderPaneController.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/MenuBorderPaneController.java @@ -1,18 +1,17 @@ package de.hdm_stuttgart.battlearena.Controller; +import de.hdm_stuttgart.battlearena.Controller.Enum.GameState; import de.hdm_stuttgart.battlearena.Controller.Utilities.CreateMediaPlayer; -import de.hdm_stuttgart.battlearena.Controller.Utilities.MusicPlayerSingleton; import de.hdm_stuttgart.battlearena.Controller.Utilities.SceneLoader; import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.ENUMs.AccountType; import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Persistence; +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.RuntimeInfo; import javafx.fxml.FXML; import javafx.fxml.Initializable; import javafx.geometry.Rectangle2D; import javafx.scene.control.Button; import javafx.scene.image.ImageView; -import javafx.scene.layout.BorderPane; import javafx.scene.layout.StackPane; -import javafx.scene.media.Media; import javafx.scene.media.MediaPlayer; import javafx.scene.media.MediaView; import javafx.stage.Screen; @@ -22,8 +21,6 @@ import java.net.URL; import java.util.*; public class MenuBorderPaneController implements Initializable { - @FXML - private BorderPane parent; @FXML private Button btnRight, btnLeft; @FXML @@ -32,16 +29,16 @@ public class MenuBorderPaneController implements Initializable { private StackPane center; private int musicCounter = 1, videoCounter = 0; private final SceneLoader sceneLoader = new SceneLoader(); - private MediaPlayer musicPlayer, mediaPlayer; + private MediaPlayer mediaPlayer; private MediaView mediaView; - private final String[] videoFiles = {"depression", "allMyFellas", "wooOOoo", "myMind", "dogCheese", "gta", "cat", "bobama", "roomba", "firework", "cheezburger", - "kangaroo", "lifeCouldBeMonke", "seal", "rolling", "imNotYou", "parkingTickets", "russianKid", "rejectHumanity", "horse", "catSitting", "pablo", "holyCrap", - "lessGoo", "sadCat", "basketball", "yoinkySploinky", "msPuff", "=D", "banana", "chaCha", "async", "sadHorse", "minecraftCat", "muecke", "top10Cats", "dog", - "pot", "mineCraftCat2", "catEating", "catJump", "bear", "pancake", "frog", "gtfo", "carl", "dog2", "slippery", "wolf", "legCat", "sad", "waaahhh"}; + private final String[] videoFiles = {"depression", "cpr", "allMyFellas", "minecraftCat3", "steak", "wooOOoo", "myMind", "gender", "dogCheese", "gta", "cat", "bobama", "roomba", "firework", "cheezburger", + "kangaroo", "lifeCouldBeMonke", "seal", "humping", "slap", "rolling", "spoderman", "imNotYou", "email", "parkingTickets", "russianKid", "rejectHumanity", "horse", "catSitting", "pablo", "holyCrap", + "lessGoo", "sadCat", "basketball", "yoinkySploinky", "spinSlot", "justTheTwoOfUs", "denied", "msPuff", "=D", "banana", "chaCha", "async", "sadHorse", "minecraftCat", "muecke", "top10Cats", "dog", + "pot", "catRave", "mineCraftCat2", "defense", "singingCat", "tutel", "catEating", "catJump", "bear", "pancake", "frog", "gtfo", "carl", "dog2", "slippery", "wolf", "legCat", "sad", "waaahhh"}; List<String> shuffledVideos = Arrays.asList(videoFiles); - Rectangle2D screen = Screen.getPrimary().getVisualBounds(); + RuntimeInfo runtimeInfo = RuntimeInfo.getInstance(); @Override public void initialize(URL url, ResourceBundle resourceBundle) { @@ -57,7 +54,6 @@ public class MenuBorderPaneController implements Initializable { imgLeft.setFitWidth(imageWidth); imgLeft.setPreserveRatio(true); - backgroundMusic("cocBackgroundMusicTest.mp3"); easterEgg(); // shuffle meme order @@ -66,57 +62,35 @@ public class MenuBorderPaneController implements Initializable { private void easterEgg() { btnRight.setOnMouseClicked(mouseEvent -> { - System.out.println(center.getWidth()); musicCounter++; - switch (musicCounter) { - case 5: - musicPlayer.dispose(); - backgroundMusic("spongeBob.mp3"); - break; - case 12: - musicPlayer.dispose(); - backgroundMusic("stadiumRave.mp3"); - break; - case 20: - musicPlayer.dispose(); - backgroundMusic("wii.mp3"); - break; + if (musicCounter == 4) { + runtimeInfo.setGameState(GameState.MEMES); } }); + btnLeft.setOnMouseClicked(mouseEvent -> { // make background music continue play after there is no meme left - if (!musicPlayer.isAutoPlay()) { - musicPlayer.play(); + if (videoCounter == shuffledVideos.size()) { + runtimeInfo.setGameState(GameState.MENU); } - // if a meme is already running, current mediaPlayer will be removed if (mediaPlayer != null) { mediaPlayer.dispose(); center.getChildren().remove(mediaView); } - if (videoCounter < videoFiles.length) { String nextVideo = shuffledVideos.get(videoCounter); - musicPlayer.stop(); + runtimeInfo.setGameState(GameState.NONE); mediaPlayer = new CreateMediaPlayer().getMediaPlayer(mediaView, new File("src/main/resources/videos/" + nextVideo + ".mp4"), false); mediaView = new MediaView(mediaPlayer); center.getChildren().add(mediaView); mediaPlayer.setOnEndOfMedia(() -> { center.getChildren().remove(mediaView); - musicPlayer.play(); + runtimeInfo.setGameState(GameState.MENU); }); } videoCounter++; }); } - - private void backgroundMusic(String file) { - Media media = new Media(new File("src/main/resources/sound/music/" + file).toURI().toString()); - musicPlayer = new MediaPlayer(media); - musicPlayer.setVolume((double) Persistence.getInstance().getSettings().getMusicVolume() / 100); - musicPlayer.setCycleCount(MediaPlayer.INDEFINITE); - musicPlayer.play(); - MusicPlayerSingleton.getInstance().setMediaPlayer(musicPlayer); - } } diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/PauseController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/PauseController.java new file mode 100644 index 0000000000000000000000000000000000000000..c5b3394d55b4e7cea699d4bf6784b9c953828bc0 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/PauseController.java @@ -0,0 +1,35 @@ +package de.hdm_stuttgart.battlearena.Controller; + +import de.hdm_stuttgart.battlearena.Controller.Enum.GameState; +import de.hdm_stuttgart.battlearena.Controller.Utilities.SceneLoader; +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.RuntimeInfo; +import de.hdm_stuttgart.battlearena.Model.Inputs.InputHandler; +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.scene.layout.VBox; + +import java.io.IOException; +import java.util.Objects; + +public class PauseController { + @FXML + private VBox parent; + + @FXML + private void resume() { + InputHandler.getInstance().setPause(false); + } + + @FXML + private void settings() { + parent.getChildren().clear(); + parent.getChildren().add(new SceneLoader().loadScene("PauseSettings")); + } + + @FXML + private void mainMenu() throws IOException { +// TODO: stop game scene + parent.getScene().setRoot(FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/MenuBorderPane.fxml")))); + RuntimeInfo.getInstance().setGameState(GameState.MENU); + } +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/PauseSettingsController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/PauseSettingsController.java new file mode 100644 index 0000000000000000000000000000000000000000..b30e6262fd3d3b0c313ee42c7743e517994cc325 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/PauseSettingsController.java @@ -0,0 +1,55 @@ +package de.hdm_stuttgart.battlearena.Controller; + +import de.hdm_stuttgart.battlearena.Controller.Utilities.SceneLoader; +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Persistence; +import de.hdm_stuttgart.battlearena.Model.Sound.MusicPlayer; +import de.hdm_stuttgart.battlearena.Model.Sound.SoundEffects; +import javafx.fxml.FXML; +import javafx.fxml.Initializable; +import javafx.scene.control.Slider; +import javafx.scene.layout.VBox; + +import java.net.URL; +import java.util.ResourceBundle; + +public class PauseSettingsController implements Initializable { + @FXML + private VBox parent; + @FXML + private Slider musicSlider, sfxSlider; + private final SceneLoader sceneLoader = new SceneLoader(); + private int musicVolume, sfxVolume; + private final Persistence persistence = Persistence.getInstance(); + private final MusicPlayer player = MusicPlayer.getInstance(); + private final SoundEffects sfx = new SoundEffects(); + + @Override + public void initialize(URL url, ResourceBundle resourceBundle) { + setMusicVolume(); + setSfxVolume(); + } + + @FXML + private void backButton() { + parent.getChildren().clear(); + parent.getChildren().add(sceneLoader.loadScene("Pause")); + } + + private void setMusicVolume() { + musicSlider.setValue(persistence.getSettings().getMusicVolume()); + musicSlider.valueProperty().addListener((observableValue, oldValue, newValue) -> { + musicVolume = newValue.intValue(); + player.setVolume(musicVolume); + //persistence.getSettings().setMusicVolume(musicVolume); + }); + } + + private void setSfxVolume(){ + sfxSlider.setValue(persistence.getSettings().getSfxVolume()); + sfxSlider.valueProperty().addListener(((observableValue, oldValue, newValue) -> { + sfxVolume = newValue.intValue(); + sfx.setSfxVolume(sfxVolume); +// sfxPlayer.getMediaPlayer().setVolume((double) sfxVolume / 100); + })); + } +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/PlaceholderController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/PlaceholderController.java index a018d9e82ae12e61b22762484397f479597ff0c1..139f1cd114edb2e156f3bcf9fdeeae75cfbf4eb3 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Controller/PlaceholderController.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/PlaceholderController.java @@ -1,6 +1,8 @@ package de.hdm_stuttgart.battlearena.Controller; +import de.hdm_stuttgart.battlearena.Controller.Enum.GameState; import de.hdm_stuttgart.battlearena.Controller.Utilities.CreateMediaPlayer; +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.RuntimeInfo; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.fxml.Initializable; @@ -33,15 +35,10 @@ public class PlaceholderController implements Initializable { mediaPlayer.setCycleCount(MediaPlayer.INDEFINITE); parent.setStyle("-fx-font-size: 50; -fx-text-fill: white; -fx-font-family: 'Arial Black'"); - Media musicMedia = new Media(new File("src/main/resources/sound/music/constructionJazz.mp3").toURI().toString()); - musicPlayer = new MediaPlayer(musicMedia); - musicPlayer.setCycleCount(MediaPlayer.INDEFINITE); - musicPlayer.setAutoPlay(true); - button.setOnMouseClicked(mouseEvent -> { try { mediaPlayer.dispose(); - musicPlayer.dispose(); + RuntimeInfo.getInstance().setGameState(GameState.MENU); parent.getScene().setRoot(FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/MenuBorderPane.fxml")))); } catch (IOException e) { throw new RuntimeException(); diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/PlayerCreateController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/PlayerCreateController.java index 56f73045145a2c36b567f177e7423cd86f0bcd07..0d86f9f932645df2dfb7c1692b319b7ee992a444 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Controller/PlayerCreateController.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/PlayerCreateController.java @@ -8,8 +8,7 @@ import javafx.stage.Stage; public class PlayerCreateController { @FXML private VBox parent; - - SceneLoader sceneLoader = new SceneLoader(); + private final SceneLoader sceneLoader = new SceneLoader(); private void switchScene(String name) { parent.getChildren().clear(); diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/SettingsController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/SettingsController.java index 836c9cf9df4f8f17b7633fac1c0867d9b00bac02..195aaaa6af32a6356b9e4ee94d1e704d96b45fae 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Controller/SettingsController.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/SettingsController.java @@ -1,8 +1,11 @@ package de.hdm_stuttgart.battlearena.Controller; -import de.hdm_stuttgart.battlearena.Controller.Utilities.MusicPlayerSingleton; +import de.hdm_stuttgart.battlearena.Controller.Enum.GameState; import de.hdm_stuttgart.battlearena.Controller.Utilities.SceneLoader; import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Persistence; +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.RuntimeInfo; +import de.hdm_stuttgart.battlearena.Model.Sound.MusicPlayer; +import de.hdm_stuttgart.battlearena.Model.Sound.SoundEffects; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.fxml.Initializable; @@ -19,10 +22,11 @@ public class SettingsController implements Initializable { private VBox parent; @FXML private Slider musicSlider, sfxSlider; - SceneLoader sceneLoader = new SceneLoader(); + private final SceneLoader sceneLoader = new SceneLoader(); private int musicVolume, sfxVolume; - MusicPlayerSingleton musicPlayer = MusicPlayerSingleton.getInstance(); - Persistence persistence = Persistence.getInstance(); + private final Persistence persistence = Persistence.getInstance(); + private final MusicPlayer player = MusicPlayer.getInstance(); + private final SoundEffects sfx = new SoundEffects(); @Override public void initialize(URL url, ResourceBundle resourceBundle) { @@ -32,6 +36,7 @@ public class SettingsController implements Initializable { @FXML private void creditScene() throws IOException { + RuntimeInfo.getInstance().setGameState(GameState.NONE); parent.getChildren().clear(); parent.getScene().setRoot(FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/credits.fxml")))); } @@ -55,8 +60,7 @@ public class SettingsController implements Initializable { musicSlider.setValue(persistence.getSettings().getMusicVolume()); musicSlider.valueProperty().addListener((observableValue, oldValue, newValue) -> { musicVolume = newValue.intValue(); - persistence.getSettings().setMusicVolume(musicVolume); - musicPlayer.getMediaPlayer().setVolume((double) musicVolume / 100); + player.setVolume(musicVolume); }); } @@ -64,8 +68,7 @@ public class SettingsController implements Initializable { sfxSlider.setValue(persistence.getSettings().getSfxVolume()); sfxSlider.valueProperty().addListener(((observableValue, oldValue, newValue) -> { sfxVolume = newValue.intValue(); - persistence.getSettings().setSfxVolume(sfxVolume); -// sfxPlayer.getMediaPlayer().setVolume((double) sfxVolume / 100); + sfx.setSfxVolume(sfxVolume); })); } } diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/SkinSelectionController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/SkinSelectionController.java index 9e27cab1e0a87b52e01a1ea63b84ba6cf6b46006..6c33ca6e90bf1e51034774959e53b53f7b2c1aa0 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Controller/SkinSelectionController.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/SkinSelectionController.java @@ -1,9 +1,9 @@ package de.hdm_stuttgart.battlearena.Controller; -import de.hdm_stuttgart.battlearena.Controller.Utilities.MusicPlayerSingleton; import de.hdm_stuttgart.battlearena.Controller.Utilities.SceneLoader; +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.RuntimeInfo; +import de.hdm_stuttgart.battlearena.Model.Entity.EntityClass; import javafx.fxml.FXML; -import javafx.fxml.FXMLLoader; import javafx.fxml.Initializable; import javafx.geometry.Rectangle2D; import javafx.scene.control.ToggleButton; @@ -11,35 +11,67 @@ import javafx.scene.control.ToggleGroup; import javafx.scene.image.ImageView; import javafx.scene.layout.VBox; import javafx.stage.Screen; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; -import java.io.IOException; import java.net.URL; -import java.util.Objects; import java.util.ResourceBundle; public class SkinSelectionController implements Initializable { @FXML private VBox parent; @FXML - private ToggleGroup selectionButton; + private ToggleGroup playerOne, playerTwo; @FXML - private ImageView selection1, selection2, selection3; + private ImageView playerOne1, playerOne2, playerOne3, playerTwo1, playerTwo2, playerTwo3; + private String playerOneSkin, playerTwoSkin; + private final RuntimeInfo runtimeInfo = RuntimeInfo.getInstance(); + private static final Logger log = LogManager.getLogger(MapSelectionController.class); @Override public void initialize(URL url, ResourceBundle resourceBundle) { - selectionButton.selectedToggleProperty().addListener((observableValue, oldToggle, newToggle) -> { - if (selectionButton.getSelectedToggle() != null) { - ToggleButton selected = (ToggleButton) selectionButton.getSelectedToggle(); - String value = selected.getText(); - System.out.println(value); + skinSelection(playerOne); + skinSelection(playerTwo); + setImageWidth(playerOne1, playerOne2, playerOne3, playerTwo1, playerTwo2, playerTwo3); + } + + private void skinSelection(ToggleGroup player) { + player.selectedToggleProperty().addListener((observableValue, oldToggle, newToggle) -> { + if (player.getSelectedToggle() != null) { + ToggleButton selected = (ToggleButton) player.getSelectedToggle(); + + if (player == playerOne) { + playerOneSkin = selected.getText(); + switch (playerOneSkin) { + case "High Born": + runtimeInfo.setPlayerOneClass(EntityClass.HIGH_BORN); + break; + case "Human": + runtimeInfo.setPlayerOneClass(EntityClass.HUMAN); + break; + case "Sentinel": + runtimeInfo.setPlayerOneClass(EntityClass.SENTINELS); + } + } else { + playerTwoSkin = selected.getText(); + switch (playerTwoSkin) { + case "High Born": + runtimeInfo.setPlayerTwoClass(EntityClass.HIGH_BORN); + break; + case "Human": + runtimeInfo.setPlayerTwoClass(EntityClass.HUMAN); + break; + case "Sentinel": + runtimeInfo.setPlayerTwoClass(EntityClass.SENTINELS); + } + } } }); - setImageWidth(selection1, selection2, selection3); } private void setImageWidth(ImageView... imageViews) { // the ... allows for zero or more arguments seperated by a comma, will pass argument as an array Rectangle2D screen = Screen.getPrimary().getVisualBounds(); - final double imageWidth = screen.getWidth() * 0.2; + final double imageWidth = screen.getWidth() * 0.1; for (ImageView image : imageViews) { image.setFitWidth(imageWidth); image.setPreserveRatio(true); @@ -54,8 +86,8 @@ public class SkinSelectionController implements Initializable { @FXML private void gameScene() { - - + log.info("Player 1 skin: " + playerOneSkin); + log.info("Player 2 skin: " + playerTwoSkin); parent.getChildren().clear(); parent.getChildren().add(new SceneLoader().loadScene("MapSelection")); } diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/StatisticsController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/StatisticsController.java index ee8ccd517fc9c48f3178e792d136dba3f20783e8..da4785be1762fa46a442be0e1d635a13ac357fe7 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Controller/StatisticsController.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/StatisticsController.java @@ -15,16 +15,14 @@ import java.net.URL; import java.util.ResourceBundle; public class StatisticsController implements Initializable { - @FXML private Text blocks, deaths, gameTime, gamesLost, gamesWon, kills; @FXML private VBox parent; @FXML private PieChart kd, wl; - SceneLoader sceneLoader = new SceneLoader(); - - Persistence persistence = Persistence.getInstance(); + private final SceneLoader sceneLoader = new SceneLoader(); + private final Persistence persistence = Persistence.getInstance(); public void mainMenuScene() { parent.getChildren().clear(); diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/Utilities/MusicPlayerSingleton.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/Utilities/MusicPlayerSingleton.java deleted file mode 100644 index df8991982ff1b19ed4442b9e541b85b1d27397a4..0000000000000000000000000000000000000000 --- a/src/main/java/de/hdm_stuttgart/battlearena/Controller/Utilities/MusicPlayerSingleton.java +++ /dev/null @@ -1,23 +0,0 @@ -package de.hdm_stuttgart.battlearena.Controller.Utilities; -import javafx.scene.media.MediaPlayer; - -public class MusicPlayerSingleton { -// creating a singleton, so it can be stopped from other controller classes - private static final MusicPlayerSingleton instance = new MusicPlayerSingleton(); - private MediaPlayer mediaPlayer; - - private MusicPlayerSingleton() {} - - public static MusicPlayerSingleton getInstance() { - return instance; - } - - public MediaPlayer getMediaPlayer() { - return mediaPlayer; - } - - public void setMediaPlayer(MediaPlayer mediaPlayer) { - this.mediaPlayer = mediaPlayer; - } -} - diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/Utilities/SceneLoader.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/Utilities/SceneLoader.java index 8c0e8b4a9487316777dd42b0823e07b737386208..6d89e2b373ccb0260f0593609158518990005b09 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Controller/Utilities/SceneLoader.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/Utilities/SceneLoader.java @@ -9,9 +9,7 @@ import org.apache.logging.log4j.Logger; import java.net.URL; public class SceneLoader { - private static final Logger log = LogManager.getLogger(SceneLoader.class); - private Pane view; //helper method for loading fxml files in the scene @@ -25,11 +23,11 @@ public class SceneLoader { new FXMLLoader(); view = FXMLLoader.load(filePath); + log.info("Scene switched to " + filePath); } catch (Exception e) { log.debug("Scene " + fileName + " not found"); } return view; } - } \ No newline at end of file diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/Utilities/ScreenClasses.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/Utilities/ScreenClasses.java deleted file mode 100644 index 469d628a724f3761c23b14fc85f602966e3d0720..0000000000000000000000000000000000000000 --- a/src/main/java/de/hdm_stuttgart/battlearena/Controller/Utilities/ScreenClasses.java +++ /dev/null @@ -1,28 +0,0 @@ -package de.hdm_stuttgart.battlearena.Controller.Utilities; - -public enum ScreenClasses { -// enums have a range because the screen calculations are not precise, especially with screen scaling in the OS settings - INCH27(26, 28), - INCH24(23, 25), - INCH13_SURFACE(12, 14); - - final int lBound, uBound; - - ScreenClasses(int lBound, int uBound) { - this.lBound = lBound; - this.uBound = uBound; - } - - public static ScreenClasses inRange(int inches) { - for (ScreenClasses screens : ScreenClasses.values()) { - if (screens.isInRange(inches)) { - return screens; - } - } - return null; - } - - private boolean isInRange(int inches) { - return inches >= lBound && inches <= uBound; - } -} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/Utilities/ToggleButtonTransition.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/Utilities/ToggleButtonTransition.java index 94d51e4b2524cc0428678adadcf57b01e61dd643..a4c5684591d138be026fad29a6c05c188ad21ce9 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Controller/Utilities/ToggleButtonTransition.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/Utilities/ToggleButtonTransition.java @@ -6,17 +6,14 @@ import javafx.scene.control.skin.ToggleButtonSkin; import javafx.util.Duration; public class ToggleButtonTransition extends ToggleButtonSkin { - private final FadeTransition fadeIn; - private final FadeTransition fadeOut; - public ToggleButtonTransition(ToggleButton toggleButton) { super(toggleButton); - fadeIn = new FadeTransition(Duration.millis(150)); + FadeTransition fadeIn = new FadeTransition(Duration.millis(150)); fadeIn.setNode(toggleButton); fadeIn.setToValue(1); - fadeOut = new FadeTransition(Duration.millis(150)); + FadeTransition fadeOut = new FadeTransition(Duration.millis(150)); fadeOut.setNode(toggleButton); fadeOut.setToValue(0.5); diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Main/Driver.java b/src/main/java/de/hdm_stuttgart/battlearena/Main/Driver.java index 66f93ada9d0e18cccb86262356517c4f79d881e3..83297700dd3dff0d7550224eef882ca59a72d8e4 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Main/Driver.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Main/Driver.java @@ -1,10 +1,13 @@ package de.hdm_stuttgart.battlearena.Main; -import de.hdm_stuttgart.battlearena.Model.Sound.SoundManager; + import de.hdm_stuttgart.battlearena.Model.Inputs.InputHandler; +import de.hdm_stuttgart.battlearena.Model.Sound.MusicPlayer; import javafx.application.Application; +import javafx.application.Platform; +import javafx.event.EventHandler; import javafx.fxml.FXMLLoader; import javafx.geometry.Rectangle2D; import javafx.scene.Parent; @@ -15,6 +18,7 @@ import javafx.stage.Screen; import javafx.stage.Stage; import javafx.stage.StageStyle; +import javafx.stage.WindowEvent; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -27,18 +31,17 @@ public class Driver extends Application { InputHandler inputHandler = InputHandler.getInstance(); - SoundManager soundManager = new SoundManager(); + @Override public void start(Stage stage) throws Exception { - // loading font in start() because CSS can't handle whitespace in folder names Font.loadFont(getClass().getResourceAsStream("/fonts/StarshipShadow.ttf"), 50); Font.loadFont(getClass().getResourceAsStream("/fonts/AmaticSC-Bold.ttf"), 50); Font.loadFont(getClass().getResourceAsStream("/fonts/Arthemis-mLA22.ttf"), 50); Font.loadFont(getClass().getResourceAsStream("/fonts/ShadowsIntoLight-Regular.ttf"), 50); - Parent root = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/LoadingScreen.fxml"))); + Parent root = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/Intro.fxml"))); Scene scene = new Scene(root); @@ -56,12 +59,11 @@ public class Driver extends Application { stage.initStyle(StageStyle.UNDECORATED); scene.getStylesheets().add(Objects.requireNonNull(this.getClass().getResource("/styles/style.css")).toExternalForm()); stage.setScene(scene); + MusicPlayer player = MusicPlayer.getInstance(); + player.startGameStateMonitoring(); + + stage.setOnCloseRequest(windowEvent -> MusicPlayer.getInstance().getScheduler().shutdown()); - stage.setOnCloseRequest(event -> { - if (soundManager != null) { - soundManager.stopMusic(); - } - }); stage.show(); log.debug("Project started successfully!"); diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Main/Main.java b/src/main/java/de/hdm_stuttgart/battlearena/Main/Main.java index 77261800125e391620b0facc16c47a6ee3217f79..ef9b5f942107fb43d0b9512cd454840d0140da79 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Main/Main.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Main/Main.java @@ -4,6 +4,7 @@ import javafx.application.Application; public class Main { public static void main(String[] args) { + System.setProperty("prism.allowhidpi", "false"); Application.launch(Driver.class, args); } } diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/Persistence.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/Persistence.java index 9291ee84f4f5721980c84957f9e7f58532f46e8c..b5577ef44a09e762123913b3be6e7af0b4eaa126 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/Persistence.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/Persistence.java @@ -59,7 +59,7 @@ public class Persistence { return communityMapsListRemote; } - public void loadPlayerAccount() throws DatabaseException { + public synchronized void loadPlayerAccount() throws DatabaseException { try { account = gsonHandler.loadAccount(); log.info("Player account successfully loaded!"); @@ -70,7 +70,7 @@ public class Persistence { } } - public void loadPlayerStatistics() throws DatabaseException { + public synchronized void loadPlayerStatistics() throws DatabaseException { try { if (account.getAccountType() == AccountType.LOCAL) { statistics = gsonHandler.loadStats(); @@ -99,7 +99,7 @@ public class Persistence { } } - public void loadCoreMaps() throws DatabaseException { + public synchronized void loadCoreMaps() throws DatabaseException { try { coreMaps = gsonHandler.loadMaps(MapType.COREMAP); log.info("Core-Maps successfully loaded from file!"); @@ -111,7 +111,7 @@ public class Persistence { } } - public void loadCommunityMaps() throws DatabaseException { + public synchronized void loadCommunityMaps() throws DatabaseException { try { communityMaps = gsonHandler.loadMaps(MapType.COMMUNITYMAP); log.info("Community-Maps successfully loaded from file!"); @@ -123,7 +123,7 @@ public class Persistence { } } - public void loadSettings() throws DatabaseException { + public synchronized void loadSettings() throws DatabaseException { try { settings = gsonHandler.loadSettings(); log.info("Application settings successfully loaded from file!"); @@ -134,7 +134,7 @@ public class Persistence { } } - public void updateCoreMaps() throws DatabaseException { + public synchronized void updateCoreMaps() throws DatabaseException { try { coreMaps = db.getCoreMaps(); gsonHandler.saveMaps(coreMaps, MapType.COREMAP); @@ -152,7 +152,7 @@ public class Persistence { } } - public void getCommunityMap(String mapID) throws DatabaseException { + public synchronized void getCommunityMap(String mapID) throws DatabaseException { for(int i = 0; communityMaps.size() > i; i++){ if(communityMaps.get(i).getMapID().equals(mapID)){ throw new DatabaseException("Identical map already saved locally. See map name: " + communityMaps.get(i).getMapID()); @@ -178,7 +178,7 @@ public class Persistence { } } - public void saveSettings(){ + public synchronized void saveSettings(){ try{ gsonHandler.saveSettings(settings); } @@ -187,7 +187,7 @@ public class Persistence { } } - public void savePlayerStatistics() throws DatabaseException{ //on shutdown of game + public synchronized void savePlayerStatistics() throws DatabaseException{ //on shutdown of game try { Parser.playerStatsValid(statistics); if (account.getAccountType() == AccountType.LOCAL) { @@ -202,7 +202,7 @@ public class Persistence { } } - public void saveCreatedMap(MapData map, boolean doUpload) throws DatabaseException { + public synchronized void saveCreatedMap(MapData map, boolean doUpload) throws DatabaseException { String part1 = ""; try { for(int i = 0; communityMaps.size() > i; i++){ @@ -238,7 +238,7 @@ public class Persistence { } } - public void updatePlayerStatistics(int kills, int deaths, int gameTime, int blocksDestroyed, boolean gameWon) throws DatabaseException{ //after game round; only update stats in RAM, not in persistence (run savePlayerStatistics() method at end of program to save stats to persistence) + public synchronized void updatePlayerStatistics(int kills, int deaths, int gameTime, int blocksDestroyed, boolean gameWon) throws DatabaseException{ //after game round; only update stats in RAM, not in persistence (run savePlayerStatistics() method at end of program to save stats to persistence) try { Parser.playerStatsValid(new PlayerStatistics(0, 0, kills, deaths, blocksDestroyed, gameTime)); //temp instance of PLayerStatistics to validate new values statistics.addKills(kills); @@ -251,6 +251,7 @@ public class Persistence { else{ statistics.addGamesLost(); } + RuntimeInfo.getInstance().resetGameStats(); log.info("Statistics successfully updated!"); } catch(Exception e){ @@ -258,7 +259,7 @@ public class Persistence { } } - public void createAccount(String playerName, String password, AccountType type) throws DatabaseException { + public synchronized void createAccount(String playerName, String password, AccountType type) throws DatabaseException { //for local account submit empty string try { Parser.usernameValid(playerName); if(type == AccountType.LOCAL) { @@ -298,7 +299,7 @@ public class Persistence { } } - public void createRemoteCommunityMapsList(){ //for Map-Browser + public synchronized void createRemoteCommunityMapsList(){ //for Map-Browser try { communityMapsListRemote = db.getCommunityMapsList(); log.info("MapList successfully retrieved from server!"); @@ -309,7 +310,7 @@ public class Persistence { } } - public void verifyPlayerAccount() throws DatabaseException { + public synchronized void verifyPlayerAccount() throws DatabaseException { try { if (account.getAccountType() == AccountType.NONE) { throw new DatabaseException("Must create playerAccount first!"); @@ -349,7 +350,7 @@ public class Persistence { } } - public void verifyCoreMaps() throws DatabaseException{ + public synchronized void verifyCoreMaps() throws DatabaseException{ try { for (int i = 0; coreMaps.size() > i; i++) { Parser.mapDataValid(coreMaps.get(i).getMapData()); @@ -367,7 +368,7 @@ public class Persistence { } } - public void verifyCommunityMaps() throws DatabaseException{ + public synchronized void verifyCommunityMaps() throws DatabaseException{ try { for (int i = 0; communityMaps.size() > i; i++) { Parser.mapDataValid(communityMaps.get(i).getMapData()); @@ -385,7 +386,7 @@ public class Persistence { } } - public void verifyAppSettings() throws DatabaseException{ + public synchronized void verifyAppSettings() throws DatabaseException{ try { Parser.volumeValid(settings.getSfxVolume()); Parser.volumeValid(settings.getMusicVolume()); @@ -397,7 +398,7 @@ public class Persistence { } } - public void resetPlayerAccount() throws DatabaseException{ + public synchronized void resetPlayerAccount() throws DatabaseException{ try{ account = new PlayerAccount("", "", AccountType.NONE); gsonHandler.saveAccount(account); @@ -408,7 +409,7 @@ public class Persistence { } } - public void resetPlayerStatistics() throws DatabaseException{ + public synchronized void resetPlayerStatistics() throws DatabaseException{ try { if (account.getAccountType() == AccountType.LOCAL) { statistics = new PlayerStatistics(0, 0, 0, 0, 0, 0); @@ -425,7 +426,7 @@ public class Persistence { } } - public void resetSettings(){ + public synchronized void resetSettings(){ try { settings = new AppSettings(50, 50); gsonHandler.saveSettings(settings); @@ -435,11 +436,11 @@ public class Persistence { } } - public void resetCoreMaps(){ + public synchronized void resetCoreMaps(){ try { coreMaps = new ArrayList<MapData>(); - coreMaps.add(new MapData("09a02b54d05b5b7ebc29a4383ca12d3dda846b72", "Arena1", 18, 18, "12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12")); - coreMaps.add(new MapData("0ab15557ab6dc4be60dfe6a9b0288bac3036bd97", "Arena2", 18, 18, "12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12 12 1 1 1 1 1 1 1 5 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12")); + coreMaps.add(new MapData("b8f5da1a3619a3585978a6d9c8c683c3210193e6", "Arena1", 18, 18, "11 10 13 10 13 10 10 12 14 14 11 10 10 13 10 13 10 12 11 0 0 0 0 0 16 0 2 2 0 3 0 0 0 3 0 12 11 0 16 0 0 0 0 0 1 2 0 0 0 0 16 0 1 12 11 16 0 0 3 0 16 0 2 2 0 0 3 0 0 0 0 12 11 0 3 0 0 16 0 1 1 2 0 0 0 0 16 0 0 12 11 0 0 16 16 0 0 0 1 2 0 0 0 0 3 16 0 12 11 16 0 0 12 10 10 15 12 2 11 15 16 15 15 11 0 12 11 0 0 0 12 0 1 1 0 2 0 0 0 0 0 11 0 12 11 0 0 16 12 5 5 5 5 4 5 5 5 5 0 11 1 12 11 0 0 0 12 11 10 10 10 2 12 0 0 1 0 11 0 12 11 0 0 0 12 1 0 0 11 2 12 16 0 1 0 11 0 12 11 0 0 0 12 0 1 0 11 2 12 0 16 0 0 11 0 12 11 0 1 0 12 0 0 12 11 2 12 11 13 10 13 11 0 12 11 0 0 0 12 0 0 0 0 2 0 0 0 0 0 0 0 12 11 0 0 0 12 15 13 10 12 14 11 10 13 10 13 12 0 12 11 1 0 0 1 0 0 0 0 2 0 0 1 1 0 0 0 12 11 0 0 1 0 0 1 0 0 2 0 0 1 0 0 1 0 12 11 10 15 15 10 10 15 10 12 14 11 10 10 15 10 15 10 12")); + coreMaps.add(new MapData("6b9ff964a4afc821672645d5c2bb8fb2b0dcb2e8", "Outpost", 18, 18, "16 16 16 16 16 16 16 16 16 16 10 12 13 11 12 14 11 12 16 0 16 0 0 1 0 0 0 0 1 0 0 1 0 2 0 12 16 0 0 0 0 0 16 16 0 0 15 3 0 0 0 2 1 12 16 0 0 2 16 0 0 1 16 0 15 15 3 3 0 2 0 12 11 10 12 2 11 10 12 0 16 0 0 15 15 3 1 2 0 12 11 0 0 2 0 0 12 0 0 16 0 0 15 3 0 2 0 12 11 0 10 2 10 0 12 0 0 16 0 0 15 15 12 2 11 12 11 0 10 2 10 0 12 0 0 0 0 0 0 0 0 2 0 16 11 0 1 2 10 0 12 16 0 0 11 10 0 10 12 2 0 16 11 0 10 2 10 0 1 0 0 16 11 3 0 0 12 0 1 16 11 0 10 2 10 0 12 0 16 0 11 0 0 1 12 2 0 16 11 0 10 2 10 0 12 0 0 0 11 0 0 0 12 2 0 16 11 0 0 1 0 0 12 16 0 0 11 0 0 0 12 0 0 16 11 10 12 2 11 10 12 0 16 0 11 0 10 10 12 2 0 16 16 0 0 2 16 0 0 0 0 0 11 0 0 3 12 0 11 12 16 0 16 16 16 0 0 16 0 0 1 0 0 0 0 2 0 12 16 0 0 0 0 0 0 0 0 0 11 0 0 1 0 2 0 12 16 16 16 16 16 16 16 16 16 16 11 12 13 11 12 14 11 12")); gsonHandler.saveMaps(coreMaps, MapType.COREMAP); log.info("Core maps successfully reset on local storage!"); } @@ -448,7 +449,7 @@ public class Persistence { } } - public void resetCommunityMaps(){ + public synchronized void resetCommunityMaps(){ try { communityMaps = new ArrayList<MapData>(); communityMaps.add(new MapData("fbf44184867512faecc195ae75ca55d5ab7bad2d", "Arena3", 18, 18, "12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12 12 1 1 1 1 1 1 1 8 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12")); @@ -461,7 +462,7 @@ public class Persistence { } } - public void login(String userName, String password) throws NoSuchAlgorithmException, RuntimeException, DatabaseException { + public synchronized void login(String userName, String password) throws NoSuchAlgorithmException, RuntimeException, DatabaseException { try { String hash = HashGenerator.hashAndHex(password); if (hash.equals(db.checkCredentials(userName))) { diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/RuntimeInfo.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/RuntimeInfo.java index 3f66342114ed6025687eb4f6fa1677641f1d295b..30d2ba1fcd4d47519db2a1a4c8fec007398ffcbb 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/RuntimeInfo.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/RuntimeInfo.java @@ -22,14 +22,14 @@ public class RuntimeInfo { private String mapDataGame; private MapData mapGame; private boolean offlineMode; //if Account-Type is online but no SQL connection: start game without stats tracking - private GameState gameState = GameState.MENU; //Default value: MENU + private GameState gameState = GameState.NONE; //Default value: MENU private GameMode gameMode = GameMode.LOCAL; //Default value: LOCAL //Default value: HUMAN private EntityClass playerOneClass = EntityClass.HUMAN; private EntityClass playerTwoClass = EntityClass.HUMAN; - private Biom mapBiom = Biom.BOMBERMAN; //Default value: GRASS + private Biom mapBiom = Biom.GRASS; //Default value: GRASS private List<IEntity> gameplayObjects = new ArrayList<>(); @@ -37,17 +37,16 @@ public class RuntimeInfo { //Stats Tracking during Gameplay - private int kills; - private int deaths; - private int blocksDestroyed; - private int gameTime; - private boolean gameWon; + private int kills = 0; + private int deaths = 0; + private int blocksDestroyed = 0; + private int gameTime = 0; + private boolean gameWon = true; private RuntimeInfo() { } - ; public static RuntimeInfo getInstance() { return runtimeInfoSingleton; @@ -73,6 +72,14 @@ public class RuntimeInfo { } } + public void resetGameStats() { + kills = 0; + deaths = 0; + blocksDestroyed = 0; + gameTime = 0; + gameWon = true; + } + public GameState getGameState() { return gameState; } diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/Utilities/Parser.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/Utilities/Parser.java index b7a04381a3f69ba1c3083c64986b73794d6ac51c..7c5d0a7c1f7ec30da9e0279a3dc8c797fa8deb75 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/Utilities/Parser.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/Utilities/Parser.java @@ -56,7 +56,7 @@ public class Parser { } public static void mapNameValid(String mapName) throws ParserException { - int minMapNameLength = 4; + int minMapNameLength = 3; int maxMapNameLength = 30; if(mapName.length() < minMapNameLength){ diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Scripts/DDL_Script_AzureDB.sql b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Scripts/DDL_Script_AzureDB.sql index bd3b7cc0344912f98142b0a01760952356a327b7..d98f718bfa310c5060e88919eff6069fe10412be 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Scripts/DDL_Script_AzureDB.sql +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Scripts/DDL_Script_AzureDB.sql @@ -33,18 +33,18 @@ CREATE TABLE players( INSERT INTO coremaps (map_id, map_name, map_width, map_height, map_data) -VALUES ('09a02b54d05b5b7ebc29a4383ca12d3dda846b72', +VALUES ('b8f5da1a3619a3585978a6d9c8c683c3210193e6', 'Arena1', 18, 18, - '12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12'); + '11 10 13 10 13 10 10 12 14 14 11 10 10 13 10 13 10 12 11 0 0 0 0 0 16 0 2 2 0 3 0 0 0 3 0 12 11 0 16 0 0 0 0 0 1 2 0 0 0 0 16 0 1 12 11 16 0 0 3 0 16 0 2 2 0 0 3 0 0 0 0 12 11 0 3 0 0 16 0 1 1 2 0 0 0 0 16 0 0 12 11 0 0 16 16 0 0 0 1 2 0 0 0 0 3 16 0 12 11 16 0 0 12 10 10 15 12 2 11 15 16 15 15 11 0 12 11 0 0 0 12 0 1 1 0 2 0 0 0 0 0 11 0 12 11 0 0 16 12 5 5 5 5 4 5 5 5 5 0 11 1 12 11 0 0 0 12 11 10 10 10 2 12 0 0 1 0 11 0 12 11 0 0 0 12 1 0 0 11 2 12 16 0 1 0 11 0 12 11 0 0 0 12 0 1 0 11 2 12 0 16 0 0 11 0 12 11 0 1 0 12 0 0 12 11 2 12 11 13 10 13 11 0 12 11 0 0 0 12 0 0 0 0 2 0 0 0 0 0 0 0 12 11 0 0 0 12 15 13 10 12 14 11 10 13 10 13 12 0 12 11 1 0 0 1 0 0 0 0 2 0 0 1 1 0 0 0 12 11 0 0 1 0 0 1 0 0 2 0 0 1 0 0 1 0 12 11 10 15 15 10 10 15 10 12 14 11 10 10 15 10 15 10 12'); INSERT INTO coremaps (map_id, map_name, map_width, map_height, map_data) -VALUES ('0ab15557ab6dc4be60dfe6a9b0288bac3036bd97', - 'Arena2', +VALUES ('6b9ff964a4afc821672645d5c2bb8fb2b0dcb2e8', + 'Outpost', 18, 18, - '12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12 12 1 1 1 1 1 1 1 5 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12'); + '16 16 16 16 16 16 16 16 16 16 10 12 13 11 12 14 11 12 16 0 16 0 0 1 0 0 0 0 1 0 0 1 0 2 0 12 16 0 0 0 0 0 16 16 0 0 15 3 0 0 0 2 1 12 16 0 0 2 16 0 0 1 16 0 15 15 3 3 0 2 0 12 11 10 12 2 11 10 12 0 16 0 0 15 15 3 1 2 0 12 11 0 0 2 0 0 12 0 0 16 0 0 15 3 0 2 0 12 11 0 10 2 10 0 12 0 0 16 0 0 15 15 12 2 11 12 11 0 10 2 10 0 12 0 0 0 0 0 0 0 0 2 0 16 11 0 1 2 10 0 12 16 0 0 11 10 0 10 12 2 0 16 11 0 10 2 10 0 1 0 0 16 11 3 0 0 12 0 1 16 11 0 10 2 10 0 12 0 16 0 11 0 0 1 12 2 0 16 11 0 10 2 10 0 12 0 0 0 11 0 0 0 12 2 0 16 11 0 0 1 0 0 12 16 0 0 11 0 0 0 12 0 0 16 11 10 12 2 11 10 12 0 16 0 11 0 10 10 12 2 0 16 16 0 0 2 16 0 0 0 0 0 11 0 0 3 12 0 11 12 16 0 16 16 16 0 0 16 0 0 1 0 0 0 0 2 0 12 16 0 0 0 0 0 0 0 0 0 11 0 0 1 0 2 0 12 16 16 16 16 16 16 16 16 16 16 11 12 13 11 12 14 11 12'); INSERT INTO communitymaps (map_id, map_name, map_width, map_height, map_data, map_downloads) VALUES ('fbf44184867512faecc195ae75ca55d5ab7bad2d', diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Scripts/DDL_Script_Oracle.sql b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Scripts/DDL_Script_Oracle.sql index 22de38024bc74b449f2ca80e2afa3cc063aea840..63b515d5f848f494f59dd9d541356972153a4338 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Scripts/DDL_Script_Oracle.sql +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Scripts/DDL_Script_Oracle.sql @@ -42,18 +42,18 @@ ALTER USER battlearenadata QUOTA 500M ON communitymaps; ALTER USER battlearenadata QUOTA 500M ON players; INSERT INTO battlearenadata.coremaps (map_id, map_name, map_width, map_height, map_data) -VALUES ('09a02b54d05b5b7ebc29a4383ca12d3dda846b72', +VALUES ('b8f5da1a3619a3585978a6d9c8c683c3210193e6', 'Arena1', 18, 18, - '12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12'); + '11 10 13 10 13 10 10 12 14 14 11 10 10 13 10 13 10 12 11 0 0 0 0 0 16 0 2 2 0 3 0 0 0 3 0 12 11 0 16 0 0 0 0 0 1 2 0 0 0 0 16 0 1 12 11 16 0 0 3 0 16 0 2 2 0 0 3 0 0 0 0 12 11 0 3 0 0 16 0 1 1 2 0 0 0 0 16 0 0 12 11 0 0 16 16 0 0 0 1 2 0 0 0 0 3 16 0 12 11 16 0 0 12 10 10 15 12 2 11 15 16 15 15 11 0 12 11 0 0 0 12 0 1 1 0 2 0 0 0 0 0 11 0 12 11 0 0 16 12 5 5 5 5 4 5 5 5 5 0 11 1 12 11 0 0 0 12 11 10 10 10 2 12 0 0 1 0 11 0 12 11 0 0 0 12 1 0 0 11 2 12 16 0 1 0 11 0 12 11 0 0 0 12 0 1 0 11 2 12 0 16 0 0 11 0 12 11 0 1 0 12 0 0 12 11 2 12 11 13 10 13 11 0 12 11 0 0 0 12 0 0 0 0 2 0 0 0 0 0 0 0 12 11 0 0 0 12 15 13 10 12 14 11 10 13 10 13 12 0 12 11 1 0 0 1 0 0 0 0 2 0 0 1 1 0 0 0 12 11 0 0 1 0 0 1 0 0 2 0 0 1 0 0 1 0 12 11 10 15 15 10 10 15 10 12 14 11 10 10 15 10 15 10 12'); INSERT INTO battlearenadata.coremaps (map_id, map_name, map_width, map_height, map_data) -VALUES ('0ab15557ab6dc4be60dfe6a9b0288bac3036bd97', - 'Arena2', +VALUES ('6b9ff964a4afc821672645d5c2bb8fb2b0dcb2e8', + 'Outpost', 18, 18, - '12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12 12 1 1 1 1 1 1 1 5 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12'); + '16 16 16 16 16 16 16 16 16 16 10 12 13 11 12 14 11 12 16 0 16 0 0 1 0 0 0 0 1 0 0 1 0 2 0 12 16 0 0 0 0 0 16 16 0 0 15 3 0 0 0 2 1 12 16 0 0 2 16 0 0 1 16 0 15 15 3 3 0 2 0 12 11 10 12 2 11 10 12 0 16 0 0 15 15 3 1 2 0 12 11 0 0 2 0 0 12 0 0 16 0 0 15 3 0 2 0 12 11 0 10 2 10 0 12 0 0 16 0 0 15 15 12 2 11 12 11 0 10 2 10 0 12 0 0 0 0 0 0 0 0 2 0 16 11 0 1 2 10 0 12 16 0 0 11 10 0 10 12 2 0 16 11 0 10 2 10 0 1 0 0 16 11 3 0 0 12 0 1 16 11 0 10 2 10 0 12 0 16 0 11 0 0 1 12 2 0 16 11 0 10 2 10 0 12 0 0 0 11 0 0 0 12 2 0 16 11 0 0 1 0 0 12 16 0 0 11 0 0 0 12 0 0 16 11 10 12 2 11 10 12 0 16 0 11 0 10 10 12 2 0 16 16 0 0 2 16 0 0 0 0 0 11 0 0 3 12 0 11 12 16 0 16 16 16 0 0 16 0 0 1 0 0 0 0 2 0 12 16 0 0 0 0 0 0 0 0 0 11 0 0 1 0 2 0 12 16 16 16 16 16 16 16 16 16 16 11 12 13 11 12 14 11 12'); INSERT INTO battlearenadata.communitymaps (map_id, map_name, map_width, map_height, map_data, map_downloads) VALUES ('fbf44184867512faecc195ae75ca55d5ab7bad2d', diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/CollisionHandler.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/CollisionHandler.java index 9d860c1af101e6002e51c846e70d219cee7772e1..675946aeef36f7e8453278393e233e854c76b04c 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/CollisionHandler.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/CollisionHandler.java @@ -48,19 +48,19 @@ public class CollisionHandler { case UP: tileOne = tileMap[nextPlayerTop][leftColumn]; tileTwo = tileMap[nextPlayerTop][rightColumn]; - return tileSet[tileOne].getCollision() || tileSet[tileTwo].getCollision(); + return tileSet[tileOne].getCollision() && tileSet[tileTwo].getCollision(); case DOWN: tileOne = tileMap[nextPlayerBottom][leftColumn]; tileTwo = tileMap[nextPlayerBottom][rightColumn]; - return tileSet[tileOne].getCollision() || tileSet[tileTwo].getCollision(); + return tileSet[tileOne].getCollision() && tileSet[tileTwo].getCollision(); case LEFT: tileOne = tileMap[topRow][nextPlayerLeft]; tileTwo = tileMap[bottomRow][nextPlayerLeft]; - return tileSet[tileOne].getCollision() || tileSet[tileTwo].getCollision(); + return tileSet[tileOne].getCollision() && tileSet[tileTwo].getCollision(); case RIGHT: tileOne = tileMap[topRow][nextPlayerRight]; tileTwo = tileMap[bottomRow][nextPlayerRight]; - return tileSet[tileOne].getCollision() || tileSet[tileTwo].getCollision(); + return tileSet[tileOne].getCollision() && tileSet[tileTwo].getCollision(); default: return true; } diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/BigBomb.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/BigBomb.java index f1b78b0efd2e7df0fbec0012266ac14876d388d2..19debfc0250626a78605dd8607737e4bf7dae03e 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/BigBomb.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/BigBomb.java @@ -312,4 +312,14 @@ public class BigBomb implements IEntity { return 0; } + @Override + public int getHealth() { + return 0; + } + + @Override + public int getMaxEntityHealth() { + return 0; + } + } diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/BigBombItemFrame.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/BigBombItemFrame.java index 08aeae8a588a618306f4dddf226fd36ef9029a1c..442b1d287d94128f63fd6789af450137f51b6c7c 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/BigBombItemFrame.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/BigBombItemFrame.java @@ -152,5 +152,15 @@ public class BigBombItemFrame implements IEntity { public int getplayer() { return 0; } + + @Override + public int getHealth() { + return 0; + } + + @Override + public int getMaxEntityHealth() { + return 0; + } } diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/BlastDownItemFrame.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/BlastDownItemFrame.java index 77e65cade3f0c45633dba49d1efc51fbc9644a0d..0bca8c9f47862d873f9594f135e5d0825a793725 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/BlastDownItemFrame.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/BlastDownItemFrame.java @@ -150,4 +150,14 @@ public class BlastDownItemFrame implements IEntity { public int getplayer() { return 0; } + + @Override + public int getHealth() { + return 0; + } + + @Override + public int getMaxEntityHealth() { + return 0; + } } diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/BlastUpItemFrame.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/BlastUpItemFrame.java index 4651559b51bb88a56a20916d1ec16a8397b2584c..7b242d0a590a7a1da232db5890fa9ea762b2a2b3 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/BlastUpItemFrame.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/BlastUpItemFrame.java @@ -147,7 +147,18 @@ public class BlastUpItemFrame implements IEntity { } @Override + public int getplayer() { return 0; } -} + + public int getHealth() { + return 0; + } + + @Override + public int getMaxEntityHealth() { + return 0; + } + +} \ No newline at end of file diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/Bomb.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/Bomb.java index ac60f9274827713ec78d2e971dd91ff066d3fb8a..f919ee7c7a3b950ef8e36911448d6235a9bc9c06 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/Bomb.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/Bomb.java @@ -6,7 +6,12 @@ import de.hdm_stuttgart.battlearena.Model.Entity.EntityDirection; import de.hdm_stuttgart.battlearena.Model.Entity.EntityFactory; import de.hdm_stuttgart.battlearena.Model.Entity.IEntity; + import de.hdm_stuttgart.battlearena.Model.Map.TileManager; + +import de.hdm_stuttgart.battlearena.Model.Sound.SFX; +import de.hdm_stuttgart.battlearena.Model.Sound.SoundEffects; + import javafx.geometry.BoundingBox; import javafx.scene.canvas.GraphicsContext; import javafx.scene.image.Image; @@ -29,9 +34,13 @@ public class Bomb implements IEntity { private BoundingBox boxCollider; private final ObjectType OBJECT_TYPE = ObjectType.BOMB; private ObjectStatus OBJECT_STATUS = ObjectStatus.UNUSED; + private final int scaledTileSize = 48; private int blastradius; + //private SoundEffects soundEffects; + + public Bomb(int posX, int posY, GraphicsContext graphicsContext, int blastradius) { this.posX = posX; this.posY = posY; @@ -87,13 +96,19 @@ public class Bomb implements IEntity { frameCounter++; if (frameCounter > 17) { + if (frameIndex == 0) { frameIndex = 1; } else if (frameIndex == 1) { frameIndex = 2; } else if (frameIndex == 2) { frameIndex = 3; + checkExplosionSpawn(graphicsContext, blastradius); + + //soundEffects.playSoundEffectOnce(SFX.BOMB); + + OBJECT_STATUS = ObjectStatus.USED; } frameCounter = 0; @@ -310,4 +325,14 @@ public class Bomb implements IEntity { return 0; } + @Override + public int getHealth() { + return 0; + } + + @Override + public int getMaxEntityHealth() { + return 0; + } + } diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/BombClockItemFrame.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/BombClockItemFrame.java index eed22f29de45a9ebd753c85a1489122d3956ccd0..d1fbbb357926b7fb947ac987918e10c13e881953 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/BombClockItemFrame.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/BombClockItemFrame.java @@ -149,5 +149,15 @@ public class BombClockItemFrame implements IEntity { public int getplayer() { return 0; } + + @Override + public int getHealth() { + return 0; + } + + @Override + public int getMaxEntityHealth() { + return 0; + } } diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/Explosion.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/Explosion.java index af8e8380ac9a292af77f6d1e315c984780c10671..c0edb59df1d96100d297b5fe89343ad57e073d56 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/Explosion.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/Explosion.java @@ -136,7 +136,16 @@ public class Explosion implements IEntity { } @Override - public int getplayer() { + public int getplayer() { return 0;} + + @Override + public int getHealth() { + return 0; + } + + @Override + public int getMaxEntityHealth() { + return 0; } diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/Heart.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/Heart.java index b9008f9159468df17dde180895c0ddcdbc465d95..0245be324c69a0f99fb53b5b3b51aba876ae421f 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/Heart.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/Heart.java @@ -36,7 +36,7 @@ public class Heart implements IEntity { @Override public void initializeEntity() { loadEntitySprites(); - boxCollider = new BoundingBox(posX+12, posY+12, 24, 24); + boxCollider = new BoundingBox(posX + 12, posY + 12, 24, 24); } @Override @@ -129,4 +129,14 @@ public class Heart implements IEntity { return 0; } + @Override + public int getHealth() { + return 0; + } + + @Override + public int getMaxEntityHealth() { + return 0; + } + } \ No newline at end of file diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/Marker.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/Marker.java index 139e0f2aea190770b622363a6a85a8b66395f185..428abb7a82ab72ff63718c8ee8e64865ca6db296 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/Marker.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/Marker.java @@ -137,5 +137,15 @@ public class Marker implements IEntity { return player; } + @Override + public int getHealth() { + return 0; + } + + @Override + public int getMaxEntityHealth() { + return 0; + } + } diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/TeleportationItemFrame.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/TeleportationItemFrame.java index e35ebc1d6504c0432fd0b54b2d7a245a42021a32..447266fa9b65a3e9c6e517f765e75ea949673861 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/TeleportationItemFrame.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/GameplayObjects/TeleportationItemFrame.java @@ -147,6 +147,16 @@ public class TeleportationItemFrame implements IEntity { public int getplayer() { return 0; } + + @Override + public int getHealth() { + return 0; + } + + @Override + public int getMaxEntityHealth() { + return 0; + } } diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/IEntity.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/IEntity.java index 47e681a77da905d9cbb218aa72aef7717c14330f..336332169b1e9c5e90438cc9672426bf53a84838 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/IEntity.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/IEntity.java @@ -46,4 +46,8 @@ public interface IEntity { void setObjectStatus(ObjectStatus objectStatus); int getplayer(); + + int getHealth(); + int getMaxEntityHealth(); + } \ No newline at end of file diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/NetworkPlayerTwo.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/NetworkPlayerTwo.java index 0e6141da5ee1915e6682a6d81c16fd8897e3b759..cdd2277a1710c10a8ec54d9539123fda0e22161c 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/NetworkPlayerTwo.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/NetworkPlayerTwo.java @@ -117,8 +117,18 @@ class NetworkPlayerTwo implements IEntity{ } @Override + public int getplayer() { return 0; } + public int getHealth() { + return health; + } + + @Override + public int getMaxEntityHealth() { + return 0; + } + } \ No newline at end of file diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/Player.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/Player.java index 2f186bcd9cf8a525d3f0da1c36d314e50c5c902a..2203eaa5cbe9b440a8b3da2f529ef3ffaa45a2f5 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/Player.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/Player.java @@ -7,6 +7,8 @@ import de.hdm_stuttgart.battlearena.Model.Entity.GameplayObjects.ObjectStatus; import de.hdm_stuttgart.battlearena.Model.Entity.GameplayObjects.ObjectType; import de.hdm_stuttgart.battlearena.Model.Inputs.InputHandler; import de.hdm_stuttgart.battlearena.Model.Map.TileManager; +import de.hdm_stuttgart.battlearena.Model.Sound.SFX; +import de.hdm_stuttgart.battlearena.Model.Sound.SoundEffects; import javafx.geometry.BoundingBox; import javafx.scene.canvas.GraphicsContext; @@ -15,7 +17,10 @@ import javafx.scene.image.Image; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; -import java.util.*; +import java.io.IOException; +import java.util.List; +import java.util.Objects; + class Player implements IEntity { @@ -35,6 +40,8 @@ class Player implements IEntity { private BoundingBox boxCollider; + private SoundEffects sfx = new SoundEffects(); + private Image directionDownOne, directionDownTwo, directionUpOne, @@ -55,7 +62,7 @@ class Player implements IEntity { private int spriteNumber = 1; private final int playerWidth = 19; - private final int playerHeight = 35; + private final int playerHeight = 20; private int scaledTileSize; @@ -211,7 +218,7 @@ class Player implements IEntity { } @Override - public void updateEntity(GameSceneController gameScene,GraphicsContext graphicsContext) { + public void updateEntity(GameSceneController gameScene, GraphicsContext graphicsContext) { if (PLAYER_MODE == PlayerMode.PLAYER_ONE) { updateInvincibility(); updateAttackRate(); @@ -293,12 +300,12 @@ class Player implements IEntity { int pos; - if(PLAYER_MODE == PlayerMode.PLAYER_ONE && !markerPlacedPlayerOne){ + if (PLAYER_MODE == PlayerMode.PLAYER_ONE && !markerPlacedPlayerOne) { markerPlacedPlayerOne = findNearestTpTile(yTile, xTile, graphicsContext); } - if(PLAYER_MODE == PlayerMode.PLAYER_TWO && !markerPlacedPlayerTwo){ + if (PLAYER_MODE == PlayerMode.PLAYER_TWO && !markerPlacedPlayerTwo) { markerPlacedPlayerTwo = findNearestTpTile(yTile, xTile, graphicsContext); } @@ -306,6 +313,13 @@ class Player implements IEntity { lastMapPosX = mapPosX; lastMapPosY = mapPosY; + try { + sfx.playSoundEffect(gameSceneController); + } catch (IOException e) { + throw new RuntimeException(e); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } if (isWalkableTile) { switch (playerDirection) { @@ -325,119 +339,122 @@ class Player implements IEntity { xTile = (pixelpadding + mapPosX) / scaledTileSize; yTile = (pixelpadding + mapPosY) / scaledTileSize; - if(PLAYER_MODE == PlayerMode.PLAYER_ONE && lastxTile != xTile || PLAYER_MODE == PlayerMode.PLAYER_ONE && lastyTile != yTile){ + if (PLAYER_MODE == PlayerMode.PLAYER_ONE && lastxTile != xTile || PLAYER_MODE == PlayerMode.PLAYER_ONE && lastyTile != yTile) { markerPlacedPlayerOne = removeMarker(markerPlacedPlayerOne); } - if(PLAYER_MODE == PlayerMode.PLAYER_TWO && lastxTile != xTile || PLAYER_MODE == PlayerMode.PLAYER_TWO && lastyTile != yTile){ + if (PLAYER_MODE == PlayerMode.PLAYER_TWO && lastxTile != xTile || PLAYER_MODE == PlayerMode.PLAYER_TWO && lastyTile != yTile) { markerPlacedPlayerTwo = removeMarker(markerPlacedPlayerTwo); } } - private boolean placeMarker(int yTile, int xTile, GraphicsContext graphicsContext){ + + private boolean placeMarker(int yTile, int xTile, GraphicsContext graphicsContext) { List<IEntity> gameplayObjects = runtimeInfo.getGameplayObjects(); int player = 0; - if (isTeleportItemFrame && TileManager.tileMap[yTile][xTile] < 10 && PLAYER_MODE == PlayerMode.PLAYER_ONE) { - player = 1; - IEntity marker = EntityFactory.createMarker(ObjectType.MARKER, xTile * scaledTileSize, yTile * scaledTileSize, graphicsContext, player); - gameplayObjects.add(marker); - runtimeInfo.setGameplayObjects(gameplayObjects); - log.debug("Player 1 marker placed"); - //isTeleportItemFrame = false; - } else if(isTeleportItemFrame && TileManager.tileMap[yTile][xTile] < 10 && PLAYER_MODE == PlayerMode.PLAYER_TWO){ - player = 2; - IEntity marker = EntityFactory.createMarker(ObjectType.MARKER, xTile * scaledTileSize, yTile * scaledTileSize, graphicsContext, player); - gameplayObjects.add(marker); - runtimeInfo.setGameplayObjects(gameplayObjects); - log.debug("Player 2 marker placed"); - //isTeleportItemFrame = false; - } + if (isTeleportItemFrame && TileManager.tileMap[yTile][xTile] < 10 && PLAYER_MODE == PlayerMode.PLAYER_ONE) { + player = 1; + IEntity marker = EntityFactory.createMarker(ObjectType.MARKER, xTile * scaledTileSize, yTile * scaledTileSize, graphicsContext, player); + gameplayObjects.add(marker); + runtimeInfo.setGameplayObjects(gameplayObjects); + log.debug("Player 1 marker placed"); + //isTeleportItemFrame = false; + } else if (isTeleportItemFrame && TileManager.tileMap[yTile][xTile] < 10 && PLAYER_MODE == PlayerMode.PLAYER_TWO) { + player = 2; + IEntity marker = EntityFactory.createMarker(ObjectType.MARKER, xTile * scaledTileSize, yTile * scaledTileSize, graphicsContext, player); + gameplayObjects.add(marker); + runtimeInfo.setGameplayObjects(gameplayObjects); + log.debug("Player 2 marker placed"); + //isTeleportItemFrame = false; + } - //checkTilePlacing(yTile, xTile); + //checkTilePlacing(yTile, xTile); return true; - } - private boolean findNearestTpTile(int yTile, int xTile, GraphicsContext graphicsContext){ - - final int minTpLength = 1; - final int maxTpLength = 18; - boolean isAbleToPlace = false; - boolean stopDown = false, stopUp = false, stopRight = false, stopLeft = false; - boolean markerSet = false; - int yUp = yTile - minTpLength; - int yDown = yTile + minTpLength; - int xLeft = xTile - minTpLength; - int xRight = xTile + minTpLength; - - for(int i = minTpLength; i < maxTpLength; i++){ - if(playerDirection == EntityDirection.UP){ - yUp -=1; - isAbleToPlace = checkTilePlacing(yUp,xTile); - if(isAbleToPlace && !stopUp){ - placeMarker(yUp,xTile,graphicsContext); - - stopUp = true; - markerSet = true; - } - }else if(playerDirection == EntityDirection.DOWN){ - yDown +=1; - isAbleToPlace = checkTilePlacing(yDown,xTile); - if(isAbleToPlace && !stopDown){ - placeMarker(yDown,xTile,graphicsContext); - - stopDown = true; - markerSet = true; - } - }else if(playerDirection == EntityDirection.LEFT) { - xLeft -=1; - isAbleToPlace = checkTilePlacing(yTile,xLeft); - if(isAbleToPlace && !stopLeft){ - placeMarker(yTile,xLeft,graphicsContext); - - stopLeft = true; - markerSet = true; - } - }else if(playerDirection == EntityDirection.RIGHT) { - xRight +=1 ; - isAbleToPlace = checkTilePlacing(yTile,xRight); - if(isAbleToPlace && !stopRight){ - placeMarker(yTile,xRight,graphicsContext); - - stopRight = true; - markerSet = true; - } + } + + private boolean findNearestTpTile(int yTile, int xTile, GraphicsContext graphicsContext) { + + final int minTpLength = 1; + final int maxTpLength = 18; + boolean isAbleToPlace = false; + boolean stopDown = false, stopUp = false, stopRight = false, stopLeft = false; + boolean markerSet = false; + int yUp = yTile - minTpLength; + int yDown = yTile + minTpLength; + int xLeft = xTile - minTpLength; + int xRight = xTile + minTpLength; + + for (int i = minTpLength; i < maxTpLength; i++) { + if (playerDirection == EntityDirection.UP) { + yUp -= 1; + isAbleToPlace = checkTilePlacing(yUp, xTile); + if (isAbleToPlace && !stopUp) { + placeMarker(yUp, xTile, graphicsContext); + + stopUp = true; + markerSet = true; + } + } else if (playerDirection == EntityDirection.DOWN) { + yDown += 1; + isAbleToPlace = checkTilePlacing(yDown, xTile); + if (isAbleToPlace && !stopDown) { + placeMarker(yDown, xTile, graphicsContext); + + stopDown = true; + markerSet = true; + } + } else if (playerDirection == EntityDirection.LEFT) { + xLeft -= 1; + isAbleToPlace = checkTilePlacing(yTile, xLeft); + if (isAbleToPlace && !stopLeft) { + placeMarker(yTile, xLeft, graphicsContext); + + stopLeft = true; + markerSet = true; + } + } else if (playerDirection == EntityDirection.RIGHT) { + xRight += 1; + isAbleToPlace = checkTilePlacing(yTile, xRight); + if (isAbleToPlace && !stopRight) { + placeMarker(yTile, xRight, graphicsContext); + + stopRight = true; + markerSet = true; } } - return markerSet; } + return markerSet; + } + public boolean checkTilePlacing(int y, int x) { //Change it with a DestructionHandler like CollisionHandler //tileSet[xTile].getDestruction(); - if(y < 18 && y > 0 && x < 18 && x > 0 && TileManager.tileMap[y][x] < 10) { + if (y < 18 && y > 0 && x < 18 && x > 0 && TileManager.tileMap[y][x] < 10) { return true; } return false; } - private boolean removeMarker(boolean markerPlacedPlayer) { - List<IEntity> gameplayObjects = runtimeInfo.getGameplayObjects(); - if(markerPlacedPlayer == markerPlacedPlayerOne) { - for (IEntity gameplayObject : gameplayObjects) { - if (gameplayObject.getOBJECT_TYPE() == ObjectType.MARKER && gameplayObject.getplayer() == 1) { - log.debug("Removed Marker Player 1"); + private boolean removeMarker(boolean markerPlacedPlayer) { + List<IEntity> gameplayObjects = runtimeInfo.getGameplayObjects(); + if (markerPlacedPlayer == markerPlacedPlayerOne) { + for (IEntity gameplayObject : gameplayObjects) { + if (gameplayObject.getOBJECT_TYPE() == ObjectType.MARKER && gameplayObject.getplayer() == 1) { + log.debug("Removed Marker Player 1"); - gameplayObject.setObjectStatus(ObjectStatus.USED); - } + gameplayObject.setObjectStatus(ObjectStatus.USED); } - } else if(markerPlacedPlayer == markerPlacedPlayerTwo){ - for (IEntity gameplayObject : gameplayObjects) { - if (gameplayObject.getOBJECT_TYPE() == ObjectType.MARKER && gameplayObject.getplayer() == 2) { - log.debug("Removed Marker Player 2"); + } + } else if (markerPlacedPlayer == markerPlacedPlayerTwo) { + for (IEntity gameplayObject : gameplayObjects) { + if (gameplayObject.getOBJECT_TYPE() == ObjectType.MARKER && gameplayObject.getplayer() == 2) { + log.debug("Removed Marker Player 2"); - gameplayObject.setObjectStatus(ObjectStatus.USED); - } + gameplayObject.setObjectStatus(ObjectStatus.USED); } - } //TODO: Marker - AND other Bombs - get ONLY visually removed when explosion is set to USED ?? - return false; - } + } + } //TODO: Marker - AND other Bombs - get ONLY visually removed when explosion is set to USED ?? + return false; + } private void performEntityCollision(boolean isEntityCollision) { if (isEntityCollision) { @@ -452,7 +469,7 @@ class Player implements IEntity { } } - boxCollider = new BoundingBox(mapPosX + 15, mapPosY + 10, playerWidth, playerHeight); + boxCollider = new BoundingBox(mapPosX + 15, mapPosY + 20, playerWidth, playerHeight); } @Override @@ -490,32 +507,34 @@ class Player implements IEntity { blastradius = updateBlastradius(blastradius); gameplayObject.setObjectStatus(ObjectStatus.USED); } - }else if (gameplayObject.getOBJECT_TYPE() == ObjectType.BOMBCLOCK_ITEMFRAME) { + } else if (gameplayObject.getOBJECT_TYPE() == ObjectType.BOMBCLOCK_ITEMFRAME) { if (gameplayObject.getBoxCollider().intersects(boxCollider)) { log.info("Collision with bombClockItemFrame"); isBombClockItemFrame = true; bombPlacementRate = updateBombPlacementRate(bombPlacementRate); gameplayObject.setObjectStatus(ObjectStatus.USED); } - }else if (gameplayObject.getOBJECT_TYPE() == ObjectType.TELEPORT_ITEMFRAME) { + } else if (gameplayObject.getOBJECT_TYPE() == ObjectType.TELEPORT_ITEMFRAME) { if (gameplayObject.getBoxCollider().intersects(boxCollider)) { isTeleportItemFrame = true; log.info("Collision with teleportItemFrame"); gameplayObject.setObjectStatus(ObjectStatus.USED); - } } } } + } + @Override public void placeBombAction(IEntity entity, GraphicsContext graphicsContext) { List<IEntity> gameplayObjects = runtimeInfo.getGameplayObjects(); if (inputHandler.isBomb() && PLAYER_MODE == PlayerMode.PLAYER_ONE && bombPlacementRate == 0 || inputHandler.isSdBomb() && PLAYER_MODE == PlayerMode.PLAYER_TWO && bombPlacementRate == 0) { + sfx.playSoundEffectOnce(SFX.BOMB); blastradius = updateBlastradius(blastradius); - if(isBigBombItemFrame && !isTeleportItemFrame) { + if (isBigBombItemFrame && !isTeleportItemFrame) { log.debug("We have Big_Bomb ItemFrames in the List"); bombPlacementRate = updateBombPlacementRate(bombPlacementRate); int xTile = (pixelpadding + mapPosX) / scaledTileSize; @@ -528,8 +547,7 @@ class Player implements IEntity { log.debug("Bigbomb placed"); isBigBombItemFrame = false; } - } - else if(PLAYER_MODE == PlayerMode.PLAYER_ONE && isTeleportItemFrame){ + } else if (PLAYER_MODE == PlayerMode.PLAYER_ONE && isTeleportItemFrame) { bombPlacementRate = 25; for (IEntity gameplayObject : gameplayObjects) { if (gameplayObject.getOBJECT_TYPE() == ObjectType.MARKER && gameplayObject.getplayer() == 1) { @@ -541,8 +559,7 @@ class Player implements IEntity { } removeMarker(markerPlacedPlayerOne); isTeleportItemFrame = false; - } - else if(PLAYER_MODE == PlayerMode.PLAYER_TWO && isTeleportItemFrame){ + } else if (PLAYER_MODE == PlayerMode.PLAYER_TWO && isTeleportItemFrame) { bombPlacementRate = 25; for (IEntity gameplayObject : gameplayObjects) { if (gameplayObject.getOBJECT_TYPE() == ObjectType.MARKER && gameplayObject.getplayer() == 2) { @@ -554,25 +571,24 @@ class Player implements IEntity { } removeMarker(markerPlacedPlayerTwo); isTeleportItemFrame = false; - } - else if(!isTeleportItemFrame){ - log.debug("No Big_Bomb ItemFrames in the List"); + } else if (!isTeleportItemFrame) { + log.debug("No BigBomb Itemframes in the List"); bombPlacementRate = bombReducedPlacementRate; - bombPlacementRate = updateBombPlacementRate(bombPlacementRate); - int xTile = (pixelpadding + mapPosX) / scaledTileSize; - int yTile = (pixelpadding + mapPosY) / scaledTileSize; + int xTile = mapPosX / scaledTileSize; + int yTile = mapPosY / scaledTileSize; if (TileManager.tileMap[yTile][xTile] < 10) { IEntity bomb = EntityFactory.createBombs(ObjectType.BOMB, xTile * scaledTileSize, yTile * scaledTileSize, graphicsContext, blastradius); gameplayObjects.add(bomb); runtimeInfo.setGameplayObjects(gameplayObjects); - log.debug("bomb placed"); + log.info("bomb placed"); } } } } - private int updateBombPlacementRate(int bombPlacementRate){ - if(isBombClockItemFrame && bombReducedPlacementRate > 10){ + + private int updateBombPlacementRate(int bombPlacementRate) { + if (isBombClockItemFrame && bombReducedPlacementRate > 10) { bombReducedPlacementRate -= 10; log.info("Reducing bomb Placementrate:" + bombReducedPlacementRate); isBombClockItemFrame = false; @@ -580,19 +596,21 @@ class Player implements IEntity { return bombReducedPlacementRate; } - public int updateBlastradius(int blastradius){ - if(isBlastUpItemFrame){ - blastradius ++; + public int updateBlastradius(int blastradius) { + if (isBlastUpItemFrame) { + blastradius++; log.info("Upping blastradius:" + blastradius); isBlastUpItemFrame = false; - } else if(isBlastDownItemFrame){ - if(blastradius > 1) { + } else if (isBlastDownItemFrame) { + if (blastradius > 1) { blastradius--; log.info("Lowering blastradius:" + blastradius); } isBlastDownItemFrame = false; } + return blastradius; + } @Override @@ -606,7 +624,13 @@ class Player implements IEntity { if (inputHandler.isAttack() && PLAYER_MODE == PlayerMode.PLAYER_ONE && attackRate == 0 || inputHandler.isSdAttack() && PLAYER_MODE == PlayerMode.PLAYER_TWO && attackRate == 0) { + attackRate = 50; + + + sfx.playSoundEffectOnce(SFX.SWORD_SWING); + + if (playerDirection == EntityDirection.UP) { hitBox = new BoundingBox(mapPosX + playerWidth, mapPosY - 10, attackWidth, attackRange); graphicsContext.strokeRect(mapPosX + playerWidth, mapPosY - 10, attackWidth, attackRange); @@ -637,6 +661,7 @@ class Player implements IEntity { private void hitEnemy(IEntity entity, BoundingBox hitBox) { if (hitBox.intersects(entity.getBoxCollider())) { + sfx.playSoundEffectOnce(SFX.SWORD_HIT); entity.gotHit(damage); log.info("Hit enemy"); } @@ -645,7 +670,6 @@ class Player implements IEntity { @Override public void updateEntityWalkAnimation() { spriteCounter++; - if (spriteCounter > 10) { if (spriteNumber == 1) { spriteNumber = 2; @@ -705,22 +729,27 @@ class Player implements IEntity { public void gotHit(int damageDone) { int damagedHealth = health - damageDone; if (iFrameCounter == 0) { - if(damagedHealth > 0){ + if (damagedHealth > 0) { health -= damageDone; iFrameCounter = 100; - }else{ + } else { + health = 0; log.info("Dead"); } log.info("DamageTaken, current Health: " + health); } + } @Override public void healPlayer(int healthRegenerated) { int regeneratedHealth = health + healthRegenerated; + sfx.playSoundEffectOnce(SFX.POWERUP); + if (regeneratedHealth < maxPlayerHealth && regeneratedHealth > 0) { + health += healthRegenerated; } else { health = maxPlayerHealth; @@ -765,12 +794,20 @@ class Player implements IEntity { @Override public void setObjectStatus(ObjectStatus objectStatus) { + } + @Override + public int getHealth() { + return health; + } + + @Override + public int getMaxEntityHealth() { + return maxPlayerHealth; } @Override public int getplayer() { return 0; } - } \ No newline at end of file diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Inputs/InputHandler.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Inputs/InputHandler.java index 619475fd0efe408e8a82d4a020a599f6fb87a6c5..324829b13054eb7fb6f3f2e3d7d3a611e90e3468 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Inputs/InputHandler.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Inputs/InputHandler.java @@ -1,5 +1,6 @@ package de.hdm_stuttgart.battlearena.Model.Inputs; +import de.hdm_stuttgart.battlearena.Model.Sound.SoundEffects; import javafx.scene.input.KeyCode; import javafx.scene.input.KeyEvent; @@ -128,6 +129,10 @@ public class InputHandler { return isPause; } + public void setPause(boolean pause) { + isPause = pause; + } + public boolean isMoveUp() { return moveUp; } diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/BackgroundTile.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/BackgroundTile.java index b17fb79d9742336e3d008bce528846433d1db394..75ec8fc3846abe20d4fc2d51966a192aa3f41b2b 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/BackgroundTile.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/BackgroundTile.java @@ -1,5 +1,6 @@ package de.hdm_stuttgart.battlearena.Model.Map; +import de.hdm_stuttgart.battlearena.Model.Sound.SFXLoop; import javafx.scene.image.Image; import org.apache.logging.log4j.Logger; @@ -11,11 +12,13 @@ class BackgroundTile implements ITile{ private final Image tileSprite; private final boolean isWalkable, isDestructible; + private SFXLoop soundeffect; - public BackgroundTile(Image tileSprite, boolean isWalkable, boolean isDestructible) { + public BackgroundTile(Image tileSprite, boolean isWalkable, boolean isDestructible, SFXLoop sfx) { this.tileSprite = tileSprite; this.isWalkable = isWalkable; this.isDestructible = isDestructible; + this.soundeffect = sfx; } @Override @@ -34,4 +37,10 @@ class BackgroundTile implements ITile{ log.debug("Image returned"); return tileSprite; } + + @Override + public SFXLoop getSoundeffect(){ + log.debug("SFX returned"); + return soundeffect; + } } \ No newline at end of file diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/ITile.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/ITile.java index 58f711083e43f6be1046bd4d394adf7a3b6e8825..f0290e1bceb21f6a78d5c07f873c11391dd822fa 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/ITile.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/ITile.java @@ -1,9 +1,11 @@ package de.hdm_stuttgart.battlearena.Model.Map; +import de.hdm_stuttgart.battlearena.Model.Sound.SFXLoop; import javafx.scene.image.Image; public interface ITile { boolean getCollision(); boolean getDestruction(); Image getTileSprite(); + SFXLoop getSoundeffect(); } \ No newline at end of file diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/TileFactory.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/TileFactory.java index 0c4808476ce548d23e532e68da2b8f58b4e2b3cc..7c10e8b13b9d11b5cda2f27af0be4a882118fa18 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/TileFactory.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/TileFactory.java @@ -1,5 +1,6 @@ package de.hdm_stuttgart.battlearena.Model.Map; +import de.hdm_stuttgart.battlearena.Model.Sound.SFXLoop; import javafx.scene.image.Image; import org.apache.logging.log4j.Logger; @@ -9,19 +10,20 @@ public class TileFactory { private static final Logger log = LogManager.getLogger(TileFactory.class); - public static ITile createTile(TileType tileType, TileType destructible, Image tileSprite) { - if (tileType == TileType.WALKABLE && destructible == TileType.DESTRUCTIBLE) { - log.debug("Tile with type: " + tileType + " " + destructible + " created."); - return new BackgroundTile(tileSprite, true, true); - }else if (tileType == TileType.WALKABLE && destructible == TileType.NON_DESTRUCTIBLE) { - log.debug("Tile with type: " + tileType + " " + destructible +" created."); - return new BackgroundTile(tileSprite, true, false); - }else if (tileType == TileType.NON_WALKABLE && destructible == TileType.DESTRUCTIBLE) { - log.debug("Tile with type: " + tileType + " " + destructible +" created."); - return new BackgroundTile(tileSprite, false, true); - }else if (tileType == TileType.NON_WALKABLE && destructible == TileType.NON_DESTRUCTIBLE) { - log.debug("Tile with type: " + tileType + " " + destructible +" created."); - return new BackgroundTile(tileSprite, false, false); + + public static ITile createTile(TileType tileType, TileType tileType2, Image tileSprite, SFXLoop sfx) { + if (tileType == TileType.WALKABLE && tileType2 == TileType.DESTRUCTIBLE) { + log.info("Tile with type: " + tileType + " " + tileType2 + " created."); + return new BackgroundTile(tileSprite, true, true, sfx); + }else if (tileType == TileType.WALKABLE && tileType2 == TileType.NON_DESTRUCTIBLE) { + log.info("Tile with type: " + tileType + " " + tileType2 +" created."); + return new BackgroundTile(tileSprite, true, false, sfx); + }else if (tileType == TileType.NON_WALKABLE && tileType2 == TileType.DESTRUCTIBLE) { + log.info("Tile with type: " + tileType + " " + tileType2 +" created."); + return new BackgroundTile(tileSprite, false, true, sfx); + }else if (tileType == TileType.NON_WALKABLE && tileType2 == TileType.NON_DESTRUCTIBLE) { + log.info("Tile with type: " + tileType + " " + tileType2 +" created."); + return new BackgroundTile(tileSprite, false, false, sfx); } log.error("TileType: " + tileType + " not supported!"); diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/TileManager.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/TileManager.java index a87d6655b9b14046a227ffc9f24d2d3e7154ba90..7a16ccab61c682931409be6ca486023c52cd5f9c 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/TileManager.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Map/TileManager.java @@ -1,5 +1,7 @@ package de.hdm_stuttgart.battlearena.Model.Map; +import de.hdm_stuttgart.battlearena.Model.Sound.SFXLoop; + import javafx.scene.canvas.GraphicsContext; import javafx.scene.image.Image; @@ -38,274 +40,274 @@ public class TileManager { try { //Textures of walkable tiles tileSet[0] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/grass_biom/ground/GrassGrassLand00.png")))); + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/grass_biom/ground/GrassGrassLand00.png"))), SFXLoop.GRASS); tileSet[1] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/grass_biom/ground/GrassGrassLand01.png")))); + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/grass_biom/ground/GrassGrassLand01.png"))), SFXLoop.GRASS); tileSet[2] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/grass_biom/ground/GrassPathGrassLand02.png")))); + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/grass_biom/ground/GrassPathGrassLand02.png"))), SFXLoop.GRASS); tileSet[3] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/grass_biom/ground/GrassGrassLand03.png")))); + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/grass_biom/ground/GrassGrassLand03.png"))), SFXLoop.GRASS); tileSet[4] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/grass_biom/ground/GrassStoneRemains.png"))), SFXLoop.GRASS); tileSet[5] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/grass_biom/ground/GrassPathHorizontal.png"))), SFXLoop.GRASS); tileSet[6] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/grass_biom/ground/GrassPathCrossway.png"))), SFXLoop.GRASS); tileSet[7] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); tileSet[8] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); tileSet[9] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); //Textures of solid tiles + non destructible - tileSet[10] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/grass_biom/building/StoneGrassLand00.png")))); - tileSet[11] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/grass_biom/building/StoneEndLeftGrassLand01.png")))); - tileSet[12] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/grass_biom/building/StoneEndRightGrassLand02.png")))); - tileSet[13] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/grass_biom/building/StoneWindowGrassLand03.png")))); - tileSet[14] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/grass_biom/building/StoneGateGrassLand04.png")))); - tileSet[15] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/grass_biom/building/StoneGrassLand05.png")))); - tileSet[16] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/grass_biom/ground/GrassGrassLand04.png")))); - tileSet[17] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[18] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[19] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[10] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/grass_biom/building/StoneGrassLand00.png"))), SFXLoop.GRASS); + tileSet[11] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/grass_biom/building/StoneEndLeftGrassLand01.png"))), SFXLoop.GRASS); + tileSet[12] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/grass_biom/building/StoneEndRightGrassLand02.png"))), SFXLoop.GRASS); + tileSet[13] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/grass_biom/building/StoneWindowGrassLand03.png"))), SFXLoop.GRASS); + tileSet[14] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/grass_biom/building/StoneGateGrassLand04.png"))), SFXLoop.GRASS); + tileSet[15] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/grass_biom/building/StoneGrassLand05.png"))), SFXLoop.GRASS); + tileSet[16] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/grass_biom/ground/GrassGrassLand04.png"))), SFXLoop.GRASS); + tileSet[17] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.GRASS); + tileSet[18] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.GRASS); + tileSet[19] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.GRASS); + //Textures of destructible tiles + tileSet[20] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/grass_biom/objects/Crate.png"))), SFXLoop.NONE); + tileSet[21] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/grass_biom/building/StoneBriddleStone.png"))), SFXLoop.NONE); + tileSet[22] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + tileSet[23] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + tileSet[24] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + tileSet[25] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + tileSet[26] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + tileSet[27] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + tileSet[28] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + tileSet[29] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + } catch (Exception e) { + log.error(e); + } + } else if (biom == Biom.DARK_LANDS) { + try { + //Textures of walkable tiles + tileSet[0] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/dark_lands_biom/ground/GrassDarkLand00.png"))), SFXLoop.NONE); + tileSet[1] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/dark_lands_biom/ground/GrassDarkLand01.png"))), SFXLoop.NONE); + tileSet[2] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/dark_lands_biom/ground/GrassPathDarkLand02.png"))), SFXLoop.NONE); + tileSet[3] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/dark_lands_biom/ground/GrassDarkLand03.png"))), SFXLoop.NONE); + tileSet[4] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + tileSet[5] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + tileSet[6] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + tileSet[7] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + tileSet[8] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + tileSet[9] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + //Textures of solid tiles + tileSet[10] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/dark_lands_biom/building/StoneDarkLand00.png"))), SFXLoop.NONE); + tileSet[11] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/dark_lands_biom/building/StoneEndLeftDarkLand01.png"))), SFXLoop.NONE); + tileSet[12] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/dark_lands_biom/building/StoneEndRightDarkLand02.png"))), SFXLoop.NONE); + tileSet[13] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/dark_lands_biom/building/StoneWindowDarkLand03.png"))), SFXLoop.NONE); + tileSet[14] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/dark_lands_biom/building/StoneGateDarkLand04.png"))), SFXLoop.NONE); + tileSet[15] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + tileSet[16] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + tileSet[17] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + tileSet[18] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + tileSet[19] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); //Textures of destructible tiles - tileSet[20] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/grass_biom/building/box.png")))); - tileSet[21] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[22] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[23] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[24] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[25] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[26] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[27] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[28] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[29] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[20] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/dark_lands_biom/building/box.png"))), SFXLoop.NONE); + tileSet[21] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + tileSet[22] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + tileSet[23] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + tileSet[24] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + tileSet[25] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + tileSet[26] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + tileSet[27] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + tileSet[28] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + tileSet[29] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); } catch (Exception e) { log.error(e); } - }else if(biom == Biom.DARK_LANDS){ + } else if (biom == Biom.BOMBERMAN) { try { //Textures of walkable tiles tileSet[0] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/dark_lands_biom/ground/GrassDarkLand00.png")))); + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/ground/GrassBombLand00.png"))), SFXLoop.GRASS); tileSet[1] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/dark_lands_biom/ground/GrassDarkLand01.png")))); + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/ground/GrassBombLand01.png"))), SFXLoop.NONE); tileSet[2] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/dark_lands_biom/ground/GrassPathDarkLand02.png")))); + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); tileSet[3] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/dark_lands_biom/ground/GrassDarkLand03.png")))); + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/ground/GrassBombLand03.png"))), SFXLoop.NONE); tileSet[4] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/ground/GrassBombLand04.png"))), SFXLoop.NONE); tileSet[5] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); tileSet[6] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); tileSet[7] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); tileSet[8] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); tileSet[9] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); //Textures of solid tiles - tileSet[10] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/dark_lands_biom/building/StoneDarkLand00.png")))); - tileSet[11] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/dark_lands_biom/building/StoneEndLeftDarkLand01.png")))); - tileSet[12] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/dark_lands_biom/building/StoneEndRightDarkLand02.png")))); - tileSet[13] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/dark_lands_biom/building/StoneWindowDarkLand03.png")))); - tileSet[14] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/dark_lands_biom/building/StoneGateDarkLand04.png")))); - tileSet[15] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[16] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[17] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[18] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[19] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); + tileSet[10] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/building/StoneBombLand00.png"))), SFXLoop.NONE); + tileSet[11] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/building/StoneBombLand01.png"))), SFXLoop.NONE); + tileSet[12] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/building/StoneBombLand02.png"))), SFXLoop.NONE); + tileSet[13] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/building/StoneBombLand03.png"))), SFXLoop.NONE); + tileSet[14] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/building/StoneBombLand04.png"))), SFXLoop.NONE); + tileSet[15] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/building/StoneBombLand05.png"))), SFXLoop.NONE); + tileSet[16] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/building/StoneBombLand06.png"))), SFXLoop.NONE); + tileSet[17] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/building/StoneBombLand07.png"))), SFXLoop.NONE); + tileSet[18] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/building/StoneBombLand08.png"))), SFXLoop.NONE); + tileSet[19] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); //Textures of destructible tiles - tileSet[20] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/dark_lands_biom/building/box.png")))); - tileSet[21] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[22] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[23] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[24] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[25] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[26] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[27] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[28] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[29] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - } catch (Exception e) { + tileSet[20] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/building/Box.png"))), SFXLoop.NONE); + tileSet[21] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/building/Brick.png"))), SFXLoop.NONE); + tileSet[22] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/building/BlackBrick.png"))), SFXLoop.NONE); + tileSet[23] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/building/GrassBrick.png"))), SFXLoop.NONE); + tileSet[24] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/building/MossyBrick.png"))), SFXLoop.NONE); + tileSet[25] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/building/OldMossyBrick.png"))), SFXLoop.NONE); + tileSet[26] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/building/MoreMossyOldBrick.png"))), SFXLoop.NONE); + tileSet[27] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/building/DarkMossyOldBrick.png"))), SFXLoop.NONE); + tileSet[28] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + tileSet[29] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + } catch (Exception e) { + log.error(e); + } + } else if (biom == Biom.FORREST) { + try { + //Textures of walkable tiles + tileSet[0] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/forrest_biom/ground/GrassWoodLand00.png"))), SFXLoop.NONE); + tileSet[1] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/forrest_biom/ground/GrassWoodLand01.png"))), SFXLoop.NONE); + tileSet[2] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/forrest_biom/ground/GrassPathWoodLand02.png"))), SFXLoop.NONE); + tileSet[3] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/forrest_biom/ground/GrassWoodLand03.png"))), SFXLoop.NONE); + tileSet[4] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + tileSet[5] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + tileSet[6] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + tileSet[7] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + tileSet[8] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + tileSet[9] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + //Textures of solid tiles + tileSet[10] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + tileSet[11] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + tileSet[12] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + tileSet[13] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + tileSet[14] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + tileSet[15] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + tileSet[16] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + tileSet[17] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + tileSet[18] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + tileSet[19] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.NON_DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + //Textures of destructible tiles + tileSet[20] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/forrest_biom/building/Box.png"))), SFXLoop.NONE); + tileSet[21] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/forrest_biom/building/Brick.png"))), SFXLoop.NONE); + tileSet[22] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/forrest_biom/building/BlackBrick.png"))), SFXLoop.NONE); + tileSet[23] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/forrest_biom/building/GrassBrick.png"))), SFXLoop.NONE); + tileSet[24] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/forrest_biom/building/MossyBrick.png"))), SFXLoop.NONE); + tileSet[25] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/forrest_biom/building/OldMossyBrick.png"))), SFXLoop.NONE); + tileSet[26] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/forrest_biom/building/MoreMossyOldBrick.png"))), SFXLoop.NONE); + tileSet[27] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/forrest_biom/building/DarkMossyOldBrick.png"))), SFXLoop.NONE); + tileSet[28] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + tileSet[29] = TileFactory.createTile(TileType.NON_WALKABLE, TileType.DESTRUCTIBLE, + new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png"))), SFXLoop.NONE); + } catch (Exception e) { log.error(e); } - }else if(biom == Biom.BOMBERMAN){ - try { - //Textures of walkable tiles - tileSet[0] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/ground/GrassBombLand00.png")))); - tileSet[1] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/ground/GrassBombLand01.png")))); - tileSet[2] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[3] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/ground/GrassBombLand03.png")))); - tileSet[4] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/ground/GrassBombLand04.png")))); - tileSet[5] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[6] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[7] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[8] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[9] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - //Textures of solid tiles - tileSet[10] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/building/StoneBombLand00.png")))); - tileSet[11] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/building/StoneBombLand01.png")))); - tileSet[12] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/building/StoneBombLand02.png")))); - tileSet[13] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/building/StoneBombLand03.png")))); - tileSet[14] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/building/StoneBombLand04.png")))); - tileSet[15] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/building/StoneBombLand05.png")))); - tileSet[16] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/building/StoneBombLand06.png")))); - tileSet[17] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/building/StoneBombLand07.png")))); - tileSet[18] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/building/StoneBombLand08.png")))); - tileSet[19] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - //Textures of destructible tiles - tileSet[20] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/building/Box.png")))); - tileSet[21] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/building/Brick.png")))); - tileSet[22] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/building/BlackBrick.png")))); - tileSet[23] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/building/GrassBrick.png")))); - tileSet[24] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/building/MossyBrick.png")))); - tileSet[25] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/building/OldMossyBrick.png")))); - tileSet[26] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/building/MoreMossyOldBrick.png")))); - tileSet[27] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/bomberman/building/DarkMossyOldBrick.png")))); - tileSet[28] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[29] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - } catch (Exception e) { - log.error(e); - } - }else if(biom == Biom.FORREST){ - try { - //Textures of walkable tiles - tileSet[0] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/forrest_biom/ground/GrassWoodLand00.png")))); - tileSet[1] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/forrest_biom/ground/GrassWoodLand01.png")))); - tileSet[2] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/forrest_biom/ground/GrassPathWoodLand02.png")))); - tileSet[3] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/forrest_biom/ground/GrassWoodLand03.png")))); - tileSet[4] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[5] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[6] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[7] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[8] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[9] = TileFactory.createTile(TileType.WALKABLE, TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - //Textures of solid tiles - tileSet[10] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[11] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[12] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[13] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[14] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[15] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[16] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[17] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[18] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[19] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.NON_DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - //Textures of destructible tiles - tileSet[20] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/forrest_biom/building/Box.png")))); - tileSet[21] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/forrest_biom/building/Brick.png")))); - tileSet[22] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/forrest_biom/building/BlackBrick.png")))); - tileSet[23] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/forrest_biom/building/GrassBrick.png")))); - tileSet[24] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/forrest_biom/building/MossyBrick.png")))); - tileSet[25] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/forrest_biom/building/OldMossyBrick.png")))); - tileSet[26] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/forrest_biom/building/MoreMossyOldBrick.png")))); - tileSet[27] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/forrest_biom/building/DarkMossyOldBrick.png")))); - tileSet[28] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - tileSet[29] = TileFactory.createTile(TileType.NON_WALKABLE,TileType.DESTRUCTIBLE, - new Image(Objects.requireNonNull(getClass().getResourceAsStream("/textures/map/NoTexture.png")))); - } catch (Exception e) { - log.error(e); - } } } diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Multiplayer/Client.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Multiplayer/Client.java index 23b1c65ccd218152576cc9c7d366e68c65d1c591..9817c0d2601718d4b0ce6d731097a6466eb2abe9 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Multiplayer/Client.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Multiplayer/Client.java @@ -30,14 +30,13 @@ public class Client { public static int[] convertStringToArray(String inputString) { // Remove brackets and split by comma - String[] parts = inputString.substring(1, inputString.length() - 1).split(","); + String[] parts = inputString.substring(1, inputString.length() - 1).split(","); //1 .length() -1 // Convert each part to integer int[] result = new int[parts.length]; for (int i = 0; i < parts.length; i++) { result[i] = Integer.parseInt(parts[i].trim()); } - return result; } diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Multiplayer/ConnectionHandler.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Multiplayer/ConnectionHandler.java index b47419daa11eea14e292ecab5dac7e0ae483f2b6..c1caafadcea8175884a736e19db31a4164e9bb08 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Multiplayer/ConnectionHandler.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Multiplayer/ConnectionHandler.java @@ -1,5 +1,7 @@ package de.hdm_stuttgart.battlearena.Model.Multiplayer; +import de.hdm_stuttgart.battlearena.Model.Entity.EntityClass; +import de.hdm_stuttgart.battlearena.Model.Entity.EntityDirection; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -14,7 +16,16 @@ public class ConnectionHandler { private static int enemyX = 0; private static int enemyY = 0; private static int playerID = 0; - private static int[] coordinates = {pX,pY,playerID}; + + private static int playerAttacking = 1; + private static int enemyAttacking = 0; + private static int playerClass = 0; + private static int enemyClass = 0; + private static int playerWalkDirection = 2; + private static int enemyWalkDirection = 0; + private static int playerHealth = 10; + private static int enemyHealth = 10; + private static int[] coordinates = {pX,pY,playerID,playerAttacking,playerClass,playerWalkDirection,playerHealth}; private static String ipaddress = "localhost"; private static final Logger log = LogManager.getLogger(ConnectionHandler.class); @@ -41,16 +52,20 @@ public class ConnectionHandler { int[] cords = client.sendcords(coordinates); enemyX = cords[0]; enemyY = cords[1]; - // System.out.println("Enemy X: " + enemyX); - // System.out.println("Enemy Y: " + enemyY); - // System.out.println("Your PlayerID is " + cords[2]); playerID = cords[2]; + enemyAttacking = cords[3]; + enemyClass = cords[4]; + enemyWalkDirection = cords[5]; + enemyHealth = cords[6]; // Assign the Values to the message to send: coordinates[0] = pX; coordinates[1] = pY; coordinates[2] = playerID; - - Thread.sleep(16); + coordinates[3] = playerAttacking; + coordinates[4] = playerClass; + coordinates[5] = playerWalkDirection; + coordinates[6] = playerHealth; + Thread.sleep(60); } } catch (InterruptedException | IOException e) { e.printStackTrace(); // Handle the exception as needed @@ -79,12 +94,160 @@ public class ConnectionHandler { } public int getEnemyX() { + return enemyX; } public int getEnemyY() { + return enemyY; } + //Getters and Setter for all other information that are not coordinates: + + public static boolean getPlayerAttacking() { + if (playerAttacking == 1){ + return true; + } else { + return false; + } + } + + public static void setPlayerAttacking(boolean attack) { + if (attack){ + ConnectionHandler.playerAttacking = 1; + } else { + ConnectionHandler.playerAttacking = 0; + } + } + + public static boolean getEnemyAttacking() { + if (enemyAttacking == 1){ + return true; + } else { + return false; + } + } + + public static void setEnemyAttacking(boolean attack) { + if (attack){ + ConnectionHandler.enemyAttacking = 1; + } else { + ConnectionHandler.enemyAttacking = 0; + } + } + + public static EntityClass getPlayerClass() { + if (playerClass == 1) { + return EntityClass.HIGH_BORN; + } else if (playerClass == 2) { + return EntityClass.LOW_BORN; + } else if (playerClass == 3) { + return EntityClass.SENTINELS; + } else { + return EntityClass.HUMAN; + } + } + + public static void setPlayerClass(EntityClass player) { + if (player == EntityClass.HUMAN){ + ConnectionHandler.playerClass = 0; + } else if (player == EntityClass.HIGH_BORN) { + ConnectionHandler.playerClass = 1; + } else if (player == EntityClass.LOW_BORN){ + ConnectionHandler.playerClass = 2; + } else { + ConnectionHandler.playerClass = 3; + } + } + + public static EntityClass getEnemyClass() { + if (enemyClass == 1) { + return EntityClass.HIGH_BORN; + } else if (enemyClass == 2) { + return EntityClass.LOW_BORN; + } else if (enemyClass == 3) { + return EntityClass.SENTINELS; + } else { + return EntityClass.HUMAN; + } + } + + public static void setEnemyClass(EntityClass player) { + if (player == EntityClass.HUMAN){ + ConnectionHandler.enemyClass = 0; + } else if (player == EntityClass.HIGH_BORN) { + ConnectionHandler.enemyClass = 1; + } else if (player == EntityClass.LOW_BORN){ + ConnectionHandler.enemyClass = 2; + } else { + ConnectionHandler.enemyClass = 3; + } + } + + public static EntityDirection getPlayerWalkDirection() { + if (playerWalkDirection == 1){ + return EntityDirection.RIGHT; + } else if (playerWalkDirection == 2){ + return EntityDirection.DOWN; + } else if (playerWalkDirection == 3){ + return EntityDirection.LEFT; + } else { + return EntityDirection.UP; + } + } + + public static void setPlayerWalkDirection(EntityDirection walk) { + if (walk == EntityDirection.RIGHT) { + ConnectionHandler.playerWalkDirection = 1; + } else if (walk == EntityDirection.DOWN) { + ConnectionHandler.playerWalkDirection = 2; + } else if (walk == EntityDirection.LEFT) { + ConnectionHandler.playerWalkDirection = 3; + } else { + ConnectionHandler.playerWalkDirection = 0; + } + } + + public static EntityDirection getEnemyWalkDirection() { + if (enemyWalkDirection == 1){ + return EntityDirection.RIGHT; + } else if (enemyWalkDirection == 2){ + return EntityDirection.DOWN; + } else if (enemyWalkDirection == 3){ + return EntityDirection.LEFT; + } else { + return EntityDirection.UP; + } + } + + public static void setEnemyWalkDirection(EntityDirection walk) { + if (walk == EntityDirection.RIGHT) { + ConnectionHandler.enemyWalkDirection = 1; + } else if (walk == EntityDirection.DOWN) { + ConnectionHandler.enemyWalkDirection = 2; + } else if (walk == EntityDirection.LEFT) { + ConnectionHandler.enemyWalkDirection = 3; + } else { + ConnectionHandler.enemyWalkDirection = 0; + } + } + + public static int getPlayerHealth() { + return playerHealth; + } + + public static void setPlayerHealth(int playerHealth) { + ConnectionHandler.playerHealth = playerHealth; + } + + public static int getEnemyHealth() { + return enemyHealth; + } + + public static void setEnemyHealth(int enemyHealth) { + ConnectionHandler.enemyHealth = enemyHealth; + } + public static void setIpaddress(String ipaddress) { ConnectionHandler.ipaddress = ipaddress; } diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Multiplayer/Server.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Multiplayer/Server.java index fddc2fae68590bac4fc51d13f466b7bd8684012c..32ee4320d12999d77fc19bb1b4deae32433d779e 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Multiplayer/Server.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Multiplayer/Server.java @@ -17,37 +17,55 @@ public class Server { private static boolean isServerRunning = true; private static int px; private static int py; - private static int enemyx = 0; private static int enemyy = 0; private static int playerID; + + private static int playerAttacking = 0; + private static int enemyAttacking = 0; + private static int playerClass = 0; + private static int enemyClass = 0; + private static int playerWalkDirection = 0; + private static int enemyWalkDirection = 0; + private static int playerHealth = 0; + private static int enemyHealth = 0; private static int playercount = 0; private static int[] cords; - private static int[] returncords = {enemyx,enemyy,playerID}; + private static int[] returncords = {enemyx,enemyy,playerID,enemyAttacking,enemyClass,enemyWalkDirection,enemyHealth}; private boolean started = false; private static String ipaddress = "localhost"; //Uncomment these lines to test the server starting manually: - /* public static void main(String[] args) throws IOException { //main method for testing purposes + /* public static void main(String[] args) throws IOException { //main method for testing purposes Server server = new Server(); log.info("server starting..."); - server.start(ipaddress, 4444); + server.start(4444); } */ //use this method to start the server from another class - public void startServer() throws IOException { + public void startServer() throws IOException { Server server = new Server(); log.info("server starting..."); - server.start(ipaddress,4444); + server.start(4444); } - public void start(String host_ip, int port) throws IOException { + public void start(int port) throws IOException { serverSocket = new ServerSocket(port); log.info("server started!"); started = true; - while (true){ - new ServerHandler(serverSocket.accept()).start(); - } + + log.info("server accepting Thread starting..."); + Thread serverThread = new Thread(() -> { + while (true) { + try { + new ServerHandler(serverSocket.accept()).start(); + } catch (IOException e) { + e.printStackTrace(); + } + } + }); + serverThread.start(); + log.info("requests accepting Thread started!"); } private static class ServerHandler extends Thread { @@ -95,28 +113,45 @@ public class Server { } else if(playercount == 2){ //check which client has connected - if (cords[2] == 1) { //player + if (cords[2] == 1) { + //player px = cords[0]; py = cords[1]; + playerAttacking = cords[3]; + playerClass = cords[4]; + playerWalkDirection = cords[5]; + playerHealth = cords[6]; //set the cords to return: returncords[0] = enemyx; returncords[1] = enemyy; + returncords[3] = enemyAttacking; + returncords[4] = enemyClass; + returncords[5] = enemyWalkDirection; + returncords[6] = enemyHealth; //set playerID: returncords[2] = 1; - } else if(cords[2] == 2) { //enemy + } else if(cords[2] == 2) { + //enemy enemyx = cords[0]; enemyy = cords[1]; + enemyAttacking = cords[3]; + enemyClass = cords[4]; + enemyWalkDirection = cords[5]; + enemyHealth = cords[6]; //set the cords to return: returncords[0] = px; returncords[1] = py; + returncords[3] = playerAttacking; + returncords[4] = playerClass; + returncords[5] = playerWalkDirection; + returncords[6] = playerHealth; //set playerID: returncords[2] = 2; - } } @@ -124,10 +159,10 @@ public class Server { localOut.flush(); } - log.info("Player X / Y : " + px + " / " + py + " Enemy X / Y : " + enemyx + " / " + enemyy); - + log.info("Player (X Y) : " + px + " " + py + " Attacking : " + playerAttacking + " direction : " + playerWalkDirection + " HP: " + playerHealth); + log.info("Enemy (X Y) : " + enemyx + " " + enemyy + " Attacking : " + enemyAttacking + " direction : " + enemyWalkDirection + " HP: " + enemyHealth); - //check if server was shut down: + //check if server was shut down:W if (!isServerRunning) { executorService.shutdown(); try { @@ -158,7 +193,6 @@ public class Server { public boolean isStarted() { return started; } - public static void setIpaddress(String ipaddress) { - Server.ipaddress = ipaddress; - } + + } diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/ISoundManager.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/ISoundManager.java deleted file mode 100644 index 7f31c780e19380b4f58e02ab5a854d8b25ea2019..0000000000000000000000000000000000000000 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/ISoundManager.java +++ /dev/null @@ -1,16 +0,0 @@ -package de.hdm_stuttgart.battlearena.Model.Sound; - -import java.io.IOException; -import java.net.MalformedURLException; -import java.nio.file.Path; -import java.util.List; - -public interface ISoundManager { - - - - void playSoundEffect() throws InterruptedException, MalformedURLException; //plays sound effects only - - List<Path> getFilePathsFromResources(Path folderPath) throws IOException; // gets file-paths in a Folder as a list - -} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/MusicPlayer.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/MusicPlayer.java new file mode 100644 index 0000000000000000000000000000000000000000..f77fa54d23b8a291380e4ab5bb036e9689312540 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/MusicPlayer.java @@ -0,0 +1,114 @@ +package de.hdm_stuttgart.battlearena.Model.Sound; + + +import de.hdm_stuttgart.battlearena.Controller.Enum.GameState; +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.AppSettings; +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Persistence; +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.RuntimeInfo; +import javafx.application.Platform; +import javafx.fxml.Initializable; +import javafx.scene.media.Media; +import javafx.scene.media.MediaPlayer; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; + + +import java.io.IOException; +import java.net.URL; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; +import java.util.ResourceBundle; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + +public class MusicPlayer{ + + + + private static final Logger log = LogManager.getLogger(MusicPlayer.class); + + private static final MusicPlayer musicPlayerSingleton = new MusicPlayer(); + + private final Persistence persistence = Persistence.getInstance(); + private MediaPlayer mediaPlayer; + private GameState currentGameState; + private SoundFileManager fileManager = new SoundFileManager(); + + private ScheduledExecutorService scheduler; + + private MusicPlayer(){} + + + + + public void startGameStateMonitoring(){ + scheduler = Executors.newSingleThreadScheduledExecutor(); + scheduler.scheduleAtFixedRate(()->{ + GameState newGameState = RuntimeInfo.getInstance().getGameState(); + if(currentGameState != newGameState){ + currentGameState = newGameState; + updateMusic(); + } + },0,1, TimeUnit.MILLISECONDS); + + } + + private void updateMusic(){ + stopMusic(); + playRandomMusic(); + } + + private void playRandomMusic() { + String path = currentGameState.getPath(); + log.info(path); + if(!path.isEmpty()) { + Path pathTypeOfMusic = Paths.get(path); + + List<Path> musicPaths; + try { + musicPaths = fileManager.getFilePathsFromResources(pathTypeOfMusic); + } catch (IOException e) { + throw new RuntimeException(e); + } + + String randomPath = fileManager.getRandomFilePath(musicPaths); + String resource = fileManager.convertPathToResourcePath(randomPath); + musicPaths.clear(); + + Thread thread = new Thread(() -> { + Media media = new Media(getClass().getResource(resource).toExternalForm()); + mediaPlayer = new MediaPlayer(media); + mediaPlayer.setOnEndOfMedia(()->playRandomMusic()); + mediaPlayer.setVolume((double) persistence.getSettings().getMusicVolume() / 100); + mediaPlayer.play(); + log.info("Music is playing"); + }); + thread.setDaemon(true); + thread.start(); + + } + } + + + private void stopMusic(){ + if (mediaPlayer != null) { + mediaPlayer.dispose(); // Dispose of the MediaPlayer instance to ensure stoping + } + } + + + public void setVolume(int volume){ + persistence.getSettings().setMusicVolume(volume); + mediaPlayer.setVolume((double) volume / 100); + } + + public int getVolume(){ + return persistence.getSettings().getMusicVolume(); + } + public ScheduledExecutorService getScheduler(){return scheduler;} + + public static MusicPlayer getInstance(){return musicPlayerSingleton;} + +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/MusicType.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/MusicType.java deleted file mode 100644 index b7d5924e85a9559d88db4bf4a295fd235fc2aa5b..0000000000000000000000000000000000000000 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/MusicType.java +++ /dev/null @@ -1,16 +0,0 @@ -package de.hdm_stuttgart.battlearena.Model.Sound; - -public enum MusicType { - MENU("src/main/resources/sound/music/menu"), - OPTIONS("src/main/resources/sound/music/options"), - GAME("src/main/resources/sound/music/game"); - - private String path; - MusicType(String path){ - this.path = path; - } - - public String getPath(){ - return path; - } -} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/SFX.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/SFX.java index 4c4dae812049378d829bd1a0c1d6d3504e350530..e4c38057c02294e1dc8e200ea275a6d00bc493fa 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/SFX.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/SFX.java @@ -1,17 +1,31 @@ package de.hdm_stuttgart.battlearena.Model.Sound; public enum SFX { - GRASS("/sound/sfx/steps/grass"), - STONE("/sound/sfx/steps/stone"), - COLLISION("/sound/sfx/collision"), - ATTACK("/sound/sfx/attack"); + //Poweup Sounds + POWERUP("src/main/resources/sound/sfx/otSFX/powerup.mp3"), + COIN_COLLECTED("src/main/resources/sound/sfx/otSFX/powerups/drop-coins.mp3"), + + //Bomb + BOMB("src/main/resources/sound/sfx/otSFX/bomb/BombSound.wav"), + + + //Attack Sounds + SWORD_HIT("src/main/resources/sound/sfx/otSFX/attack/Sword_hit1.wav"), + SWORD_SWING("src/main/resources/sound/sfx/otSFX/attack/Sword_swing.wav"), + + //Destruction Sounds + WOOD_Destruction("src/main/resources/sound/sfx/otSFX/destruction/WoodDestruction.wav"), + + //Die Sounds + DEAD("src/main/resources/sound/sfx/otSFX/dieSounds/body-falling-to-ground.mp3"); private String path; - SFX(String path){ + + SFX(String path) { this.path = path; } - public String getPath(){ + public String getPath() { return path; } } diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/SFXLoop.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/SFXLoop.java new file mode 100644 index 0000000000000000000000000000000000000000..4ba107d82289306dac34ec6d9ffe1824c61c7124 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/SFXLoop.java @@ -0,0 +1,18 @@ +package de.hdm_stuttgart.battlearena.Model.Sound; + +public enum SFXLoop { + NONE(""), + GRASS("src/main/resources/sound/sfx/steps/grass"), + STONE("src/main/resources/sound/sfx/steps/stone"); + + + + private String path; + SFXLoop(String path){ + this.path = path; + } + + public String getPath(){ + return path; + } +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/SoundEffects.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/SoundEffects.java new file mode 100644 index 0000000000000000000000000000000000000000..6460e778b691242c60b72c0a0937a6dde1b62e59 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/SoundEffects.java @@ -0,0 +1,84 @@ +package de.hdm_stuttgart.battlearena.Model.Sound; + +import de.hdm_stuttgart.battlearena.Controller.GameSceneController; +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.AppSettings; +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Persistence; +import de.hdm_stuttgart.battlearena.Model.Entity.IEntity; +import de.hdm_stuttgart.battlearena.Model.Inputs.InputHandler; +import de.hdm_stuttgart.battlearena.Model.Map.ITile; +import de.hdm_stuttgart.battlearena.Model.Map.TileManager; + +import javafx.scene.media.AudioClip; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; + +import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; + + +public class SoundEffects { + private static final Logger log = LogManager.getLogger(SoundEffects.class); + + + + + private SoundFileManager fileManager = new SoundFileManager(); + private Persistence persistence = Persistence.getInstance(); + + + + public void playSoundEffect(GameSceneController gameSceneController) throws IOException, InterruptedException { + TileManager tileManager = gameSceneController.getTileManager(); + IEntity player = gameSceneController.getPlayer(); + ITile[] tileSet = tileManager.getTileSet(); + int[][] map = tileManager.getTileMap(); + int playerPosX = player.getMapPosX(); + int playerPosY = player.getMapPosY(); + int mapTile = map[playerPosY/48][playerPosX/48]; + SFXLoop sfx = tileSet[mapTile].getSoundeffect(); + if(!(sfx == SFXLoop.NONE)) { + Path path = Paths.get(sfx.getPath()); + List<Path> sfxPaths = fileManager.getFilePathsFromResources(path); + String randomPath = fileManager.getRandomFilePath(sfxPaths); + String resource = fileManager.convertPathToResourcePath(randomPath); + Thread sfxLoop = new Thread(() -> { + AudioClip effect = new AudioClip(getClass().getResource(resource).toString()); + effect.setVolume((double) persistence.getSettings().getSfxVolume() /100); + effect.play(); + }); + sfxLoop.setDaemon(true); + sfxLoop.start(); + sfxPaths.clear(); + } + } + + + public void playSoundEffectOnce(SFX soundEffect){ + String path = soundEffect.getPath(); + String resource = path.substring(18); // Begins at Ressource Folder + Thread sfx = new Thread(()->{ + AudioClip audioClip = new AudioClip(getClass().getResource(resource).toExternalForm()); + audioClip.setVolume((double) persistence.getSettings().getSfxVolume()/100); + audioClip.play(); + + }); + sfx.setDaemon(true); + sfx.start(); + + + } + + + public void setSfxVolume(int volume){ + persistence.getSettings().setSfxVolume(volume); + } + + public int getVolume(){ + return Persistence.getInstance().getSettings().getSfxVolume(); + } + + + +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/SoundFileManager.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/SoundFileManager.java new file mode 100644 index 0000000000000000000000000000000000000000..374036a8ff834065a960166e5e82fa97b7bebb9e --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/SoundFileManager.java @@ -0,0 +1,39 @@ +package de.hdm_stuttgart.battlearena.Model.Sound; + +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; +import java.util.Random; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +class SoundFileManager { + private static final Logger log = LogManager.getLogger(SoundFileManager.class); + protected List<Path> getFilePathsFromResources(Path folderPath) throws IOException { + List<Path> result; + try (Stream<Path> walk = Files.walk(folderPath)) { + result = walk.filter(Files::isRegularFile) + .collect(Collectors.toList()); + } + return result; + } + + protected String getRandomFilePath(List<Path> paths){ + Random random = new Random(); + int min = 0; + int max = paths.size() - 1; + int randomIndex = random.nextInt(max - min + 1 ) + min; + String randomPath = paths.get(randomIndex).toString(); + return randomPath; + } + protected String convertPathToResourcePath(String randomPath){ + String normalizedPath = Paths.get(randomPath).toString().replace('\\', '/'); + String resource = normalizedPath.substring(18); //18 = Begins at a at resourceFolder Level + return resource; + } +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/SoundManager.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/SoundManager.java deleted file mode 100644 index 41af98775814a73c36d2b5273f29540449d2bbbb..0000000000000000000000000000000000000000 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/SoundManager.java +++ /dev/null @@ -1,85 +0,0 @@ -package de.hdm_stuttgart.battlearena.Model.Sound; - - -import javafx.scene.media.Media; -import javafx.scene.media.MediaPlayer; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.LogManager; - -import javafx.scene.media.AudioClip; - - -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URL; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.Random; -import java.util.concurrent.Executors; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -public class SoundManager implements ISoundManager { - private static final Logger log = LogManager.getLogger(SoundManager.class); - - - private final ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(5); - private final List<SFX> soundEffectsRunning = new ArrayList<>(); - private MediaPlayer mediaPlayer; - - private final boolean stopLoop = false; - private List<Path> walkingSFXPaths; - - //Todo Make music play - public void playMusic(MusicType musicType) throws IOException { - Path pathTypeOfMusic = Paths.get(musicType.getPath()); - List<Path> musicPaths = getFilePathsFromResources(pathTypeOfMusic); - Random random = new Random(); - int min = 0; - int max = musicPaths.size() - 1; - int randomIndex = random.nextInt(max - min + 1 ) + min; - String randomMusic = musicPaths.get(randomIndex).toString(); - String normalizedPath = Paths.get(randomMusic).toString().replace('\\', '/'); - String resource = normalizedPath.substring(18); - log.info(resource); - Thread thread = new Thread(() -> { - Media media = new Media(getClass().getResource(resource).toExternalForm()); - mediaPlayer = new MediaPlayer(media); - mediaPlayer.setCycleCount(MediaPlayer.INDEFINITE); - mediaPlayer.play(); - log.info("Music is playing"); - - }); - thread.setDaemon(true); - thread.start(); - } - - public void stopMusic(){ - if (mediaPlayer != null) { - mediaPlayer.dispose(); // Dispose of the MediaPlayer instance - } - } - - @Override - public void playSoundEffect() throws InterruptedException, MalformedURLException { - - } - - - - public List<Path> getFilePathsFromResources(Path folderPath) throws IOException { - List<Path> result; - try (Stream<Path> walk = Files.walk(folderPath)) { - result = walk.filter(Files::isRegularFile) - .collect(Collectors.toList()); - } - return result; - } - -} diff --git a/src/main/resources/fxml/GameScene.fxml b/src/main/resources/fxml/GameScene.fxml index f046db58280a8ea339f035b1879ac8e6e73b8115..fcac9451049054bb9d6bb1fd3f5234f2db55be84 100644 --- a/src/main/resources/fxml/GameScene.fxml +++ b/src/main/resources/fxml/GameScene.fxml @@ -1,15 +1,78 @@ <?xml version="1.0" encoding="UTF-8"?> +<?import javafx.geometry.Insets?> <?import javafx.scene.canvas.Canvas?> -<?import javafx.scene.layout.AnchorPane?> +<?import javafx.scene.control.Label?> +<?import javafx.scene.layout.BorderPane?> +<?import javafx.scene.layout.HBox?> +<?import javafx.scene.layout.Pane?> <?import javafx.scene.layout.StackPane?> +<?import javafx.scene.layout.VBox?> +<?import javafx.scene.shape.Rectangle?> -<AnchorPane prefHeight="864.0" prefWidth="864.0" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.GameSceneController"> - <children> - <StackPane prefHeight="400.0" prefWidth="600.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> +<BorderPane fx:id="gameScene" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.GameSceneController"> + <center> + <StackPane fx:id="stackPane" prefHeight="400.0" prefWidth="600.0" BorderPane.alignment="CENTER"> <children> <Canvas fx:id="canvas2D" height="864.0" width="864.0" /> </children> + <BorderPane.margin> + <Insets /> + </BorderPane.margin> </StackPane> - </children> -</AnchorPane> + </center> + <top> + <VBox BorderPane.alignment="CENTER"> + <children> + <Pane prefHeight="50.0" VBox.vgrow="ALWAYS" /> + <HBox alignment="CENTER" spacing="30.0"> + <children> + <HBox alignment="CENTER_RIGHT" fillHeight="false" spacing="10.0"> + <children> + <Label text="Player HP" /> + <Pane fx:id="playerPane" nodeOrientation="RIGHT_TO_LEFT"> + <children> + <Rectangle fx:id="playerHealth" arcHeight="5.0" arcWidth="5.0" fill="#c92c1a" height="50.0" stroke="BLACK" strokeType="INSIDE" strokeWidth="0.0" width="900.0" /> + </children> + </Pane> + <Label fx:id="playerHp" alignment="CENTER_RIGHT" /> + </children> + </HBox> + <HBox alignment="CENTER_LEFT" fillHeight="false" spacing="10.0"> + <children> + <Label fx:id="enemyHp" /> + <Pane fx:id="enemyPane" HBox.hgrow="ALWAYS"> + <children> + <Rectangle fx:id="enemyHealth" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="50.0" stroke="BLACK" strokeType="INSIDE" strokeWidth="0.0" width="900.0" /> + </children> + </Pane> + <Label text="Enemy HP" /> + </children> + </HBox> + </children> + </HBox> + </children> + </VBox> + </top> + <left> + <VBox alignment="CENTER" prefHeight="200.0" prefWidth="300.0" BorderPane.alignment="CENTER" /> + </left> + <right> + <HBox BorderPane.alignment="CENTER"> + <children> + <VBox prefHeight="200.0"> + <children> + <Pane VBox.vgrow="ALWAYS" /> + <Label text="Time:" /> + <Label fx:id="time" text="00:30" /> + <Pane VBox.vgrow="ALWAYS" /> + <Label text="Round:" /> + <Label fx:id="round" text="1/3" /> + <Pane VBox.vgrow="ALWAYS" /> + </children> + </VBox> + <Pane prefWidth="200.0" HBox.hgrow="ALWAYS" /> + </children> + </HBox> + </right> +</BorderPane> diff --git a/src/main/resources/fxml/LocalCreate.fxml b/src/main/resources/fxml/LocalCreate.fxml index f100d9b68a8eab3fc0d6554e02f8cbd29cd16373..50ecdfe94ed078789b47d315fe133810e54bdc28 100644 --- a/src/main/resources/fxml/LocalCreate.fxml +++ b/src/main/resources/fxml/LocalCreate.fxml @@ -14,17 +14,17 @@ <?import javafx.scene.layout.VBox?> <?import javafx.scene.text.Text?> -<VBox fx:id="parent" alignment="CENTER" prefHeight="400.0" prefWidth="600.0" spacing="20.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.LocalCreateController"> +<VBox fx:id="parent" alignment="BOTTOM_CENTER" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.LocalCreateController"> <children> <Pane VBox.vgrow="ALWAYS" /> - <HBox alignment="TOP_CENTER" spacing="20.0"> + <HBox alignment="CENTER" spacing="20.0"> <children> <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Rounds:" /> <Accordion> <panes> <TitledPane fx:id="roundsTitledPane" text="Select"> <content> - <ScrollPane minViewportHeight="40.0"> + <ScrollPane minViewportHeight="100.0"> <content> <VBox fx:id="boxBox"> <children> @@ -51,7 +51,8 @@ <Insets /> </VBox.margin> </HBox> - <HBox alignment="TOP_CENTER" maxWidth="-Infinity" minWidth="-Infinity" prefHeight="25.0" prefWidth="213.0" spacing="20.0"> + <Pane VBox.vgrow="ALWAYS" /> + <HBox alignment="CENTER" spacing="20.0"> <children> <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Time:" /> <Accordion> @@ -65,6 +66,7 @@ </Accordion> </children> </HBox> + <Pane VBox.vgrow="ALWAYS" /> <HBox alignment="TOP_CENTER" spacing="10.0"> <children> <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Players:" /> @@ -77,6 +79,7 @@ <RadioButton mnemonicParsing="false" text="4" toggleGroup="$group31" /> </children> </HBox> + <Pane VBox.vgrow="ALWAYS" /> <HBox alignment="TOP_CENTER" spacing="10.0"> <children> <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Text:" /> @@ -88,6 +91,7 @@ <RadioButton mnemonicParsing="false" selected="true" text="No" toggleGroup="$group1" /> </children> </HBox> + <Pane VBox.vgrow="ALWAYS" /> <HBox alignment="TOP_CENTER" spacing="10.0"> <children> <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Text:" /> @@ -99,6 +103,7 @@ <RadioButton mnemonicParsing="false" selected="true" text="No" toggleGroup="$group2" /> </children> </HBox> + <Pane VBox.vgrow="ALWAYS" /> <HBox alignment="TOP_CENTER" spacing="10.0"> <children> <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Text:" /> @@ -110,12 +115,13 @@ <RadioButton mnemonicParsing="false" selected="true" text="No" toggleGroup="$group3" /> </children> </HBox> - <Button mnemonicParsing="false" onAction="#skinSelectionScene" text="Start" /> + <Pane VBox.vgrow="ALWAYS" /> + <Button mnemonicParsing="false" onAction="#skinSelectionScene" text="Next" /> + <Pane VBox.vgrow="ALWAYS" /> <Button mnemonicParsing="false" onAction="#backButton" text="Back"> <VBox.margin> - <Insets bottom="50.0" /> + <Insets /> </VBox.margin> </Button> - <Pane VBox.vgrow="ALWAYS" /> </children> </VBox> diff --git a/src/main/resources/fxml/Login.fxml b/src/main/resources/fxml/Login.fxml index a63c7c127ff2c30d0499ffc963851e061324bf58..dfcd6fa97371ba712724ebf519e92331ce46af5c 100644 --- a/src/main/resources/fxml/Login.fxml +++ b/src/main/resources/fxml/Login.fxml @@ -17,7 +17,7 @@ <TextField fx:id="playerName" alignment="CENTER" /> <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Password:" /> <TextField fx:id="password" alignment="CENTER" /> - <Label fx:id="errorMessage" /> + <Label fx:id="errorMessage" alignment="CENTER" contentDisplay="CENTER" /> <Button mnemonicParsing="false" onAction="#login" text="Login" /> <Button mnemonicParsing="false" onAction="#back" text="Back" /> <Pane VBox.vgrow="ALWAYS" /> diff --git a/src/main/resources/fxml/MainMenu.fxml b/src/main/resources/fxml/MainMenu.fxml index 39b45c2b7b94147fc779dda696f89e11fafa9e44..6d98ad687f5bd8b0b49c50f1249b06567fa0fbfc 100644 --- a/src/main/resources/fxml/MainMenu.fxml +++ b/src/main/resources/fxml/MainMenu.fxml @@ -6,20 +6,24 @@ <?import javafx.scene.layout.VBox?> <?import javafx.scene.text.Text?> -<VBox fx:id="parent" alignment="CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" spacing="50.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.MainMenuController"> +<VBox fx:id="parent" alignment="CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" spacing="10.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.MainMenuController"> <children> <Pane VBox.vgrow="ALWAYS" /> <Text id="gameTitle" strokeType="OUTSIDE" strokeWidth="0.0" text="Battlearena" /> + <Pane VBox.vgrow="ALWAYS" /> <Button mnemonicParsing="false" onAction="#playScene" text="Play" VBox.vgrow="ALWAYS"> <VBox.margin> <Insets top="20.0" /> </VBox.margin> </Button> + <Pane VBox.vgrow="ALWAYS" /> <Button mnemonicParsing="false" onAction="#mapScene" text="Map Forge" VBox.vgrow="ALWAYS" /> + <Pane VBox.vgrow="ALWAYS" /> <Button mnemonicParsing="false" onAction="#statisticsScene" text="Statistics" VBox.vgrow="ALWAYS" /> + <Pane VBox.vgrow="ALWAYS" /> <Button mnemonicParsing="false" onAction="#settingsScene" text="Settings" /> + <Pane VBox.vgrow="ALWAYS" /> <Button fx:id="exitButton" alignment="CENTER" mnemonicParsing="false" onAction="#exit" text="Exit" /> - <Pane VBox.vgrow="ALWAYS" /> <Pane layoutX="10.0" layoutY="395.0" VBox.vgrow="ALWAYS" /> </children> </VBox> diff --git a/src/main/resources/fxml/MapSelection.fxml b/src/main/resources/fxml/MapSelection.fxml index 1be6734bac78aa59dd7db7a771411adfd64dd828..0d975539ecdb7d9a755ef8584c8fddb424ab7459 100644 --- a/src/main/resources/fxml/MapSelection.fxml +++ b/src/main/resources/fxml/MapSelection.fxml @@ -5,46 +5,84 @@ <?import javafx.scene.control.Button?> <?import javafx.scene.control.ScrollPane?> <?import javafx.scene.control.TitledPane?> +<?import javafx.scene.control.ToggleButton?> +<?import javafx.scene.control.ToggleGroup?> <?import javafx.scene.layout.HBox?> <?import javafx.scene.layout.Pane?> <?import javafx.scene.layout.VBox?> <?import javafx.scene.text.Text?> -<VBox fx:id="parent" alignment="CENTER" prefHeight="400.0" prefWidth="600.0" spacing="20.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.MapSelectionController"> + +<HBox xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.MapSelectionController"> <children> - <Pane VBox.vgrow="ALWAYS" /> - <HBox alignment="TOP_CENTER" spacing="20.0"> + <Pane HBox.hgrow="ALWAYS" /> + <VBox fx:id="parent" alignment="CENTER" prefHeight="400.0" prefWidth="600.0" spacing="20.0"> <children> - <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Maps:" /> - <Accordion> - <panes> - <TitledPane fx:id="roundsTitledPane" text="Select"> - <content> - <ScrollPane minViewportHeight="40.0"> + <Pane VBox.vgrow="ALWAYS" /> + <HBox alignment="CENTER_LEFT" spacing="20.0"> + <children> + <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Maps:" /> + <Accordion> + <panes> + <TitledPane fx:id="maps" text="Select"> <content> - <VBox fx:id="boxBox" /> + <ScrollPane minViewportHeight="200.0"> + <content> + <VBox fx:id="boxBox" /> + </content> + </ScrollPane> </content> - </ScrollPane> - </content> - </TitledPane> - </panes> - </Accordion> - </children> - <VBox.margin> - <Insets /> - </VBox.margin> - </HBox> - <HBox alignment="TOP_CENTER" maxWidth="-Infinity" minWidth="-Infinity" prefHeight="25.0" prefWidth="213.0" spacing="20.0"> - <children> - <Text fx:id="selectedMapText" strokeType="OUTSIDE" strokeWidth="0.0" /> + </TitledPane> + </panes> + </Accordion> + </children> + <VBox.margin> + <Insets /> + </VBox.margin> + </HBox> + <HBox alignment="CENTER_LEFT" spacing="20.0"> + <children> + <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Texture pack:" /> + <Accordion> + <panes> + <TitledPane fx:id="textures" text="Select"> + <content> + <ScrollPane minViewportHeight="200.0"> + <content> + <VBox fx:id="boxBox1" alignment="CENTER_LEFT"> + <children> + <ToggleButton mnemonicParsing="false" text="Bomberman"> + <toggleGroup> + <ToggleGroup fx:id="textureToggle" /> + </toggleGroup> + </ToggleButton> + <ToggleButton mnemonicParsing="false" text="Dark Lands" toggleGroup="$textureToggle" /> + <ToggleButton mnemonicParsing="false" text="Forrest" toggleGroup="$textureToggle" /> + <ToggleButton mnemonicParsing="false" text="Grass" toggleGroup="$textureToggle" /> + </children> + </VBox> + </content> + </ScrollPane> + </content> + </TitledPane> + </panes> + </Accordion> + </children> + </HBox> + <HBox alignment="TOP_CENTER" maxWidth="-Infinity" minWidth="-Infinity" prefHeight="25.0" prefWidth="213.0" spacing="20.0"> + <children> + <Text fx:id="selectedMapText" strokeType="OUTSIDE" strokeWidth="0.0" /> + </children> + </HBox> + <Button mnemonicParsing="false" onAction="#gameScene" text="Start" /> + <Button mnemonicParsing="false" onAction="#backButton" text="Back"> + <VBox.margin> + <Insets bottom="50.0" /> + </VBox.margin> + </Button> + <Pane VBox.vgrow="ALWAYS" /> </children> - </HBox> - <Button mnemonicParsing="false" onAction="#gameScene" text="Start" /> - <Button mnemonicParsing="false" onAction="#backButton" text="Back"> - <VBox.margin> - <Insets bottom="50.0" /> - </VBox.margin> - </Button> - <Pane VBox.vgrow="ALWAYS" /> + </VBox> + <Pane HBox.hgrow="ALWAYS" /> </children> -</VBox> +</HBox> diff --git a/src/main/resources/fxml/MenuBorderPane.fxml b/src/main/resources/fxml/MenuBorderPane.fxml index ed87f4119563968953eef9ff3013783e8ce18a5e..24a64f9fcb594294872951120ed280565e40b334 100644 --- a/src/main/resources/fxml/MenuBorderPane.fxml +++ b/src/main/resources/fxml/MenuBorderPane.fxml @@ -7,7 +7,7 @@ <?import javafx.scene.layout.StackPane?> <?import javafx.scene.text.Font?> -<BorderPane id="mainMenu" fx:id="parent" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.MenuBorderPaneController"> +<BorderPane id="mainMenu" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.MenuBorderPaneController"> <right> <Button fx:id="btnRight" mnemonicParsing="false" prefWidth="111.0" BorderPane.alignment="BOTTOM_CENTER"> <graphic> diff --git a/src/main/resources/fxml/MultiplayerCreate.fxml b/src/main/resources/fxml/MultiplayerCreate.fxml index f95e2126f13aee4f89541b835ef2c90ffbbc7d9b..d12125df3dd7a924880ef1b6ea27e85e567c9a40 100644 --- a/src/main/resources/fxml/MultiplayerCreate.fxml +++ b/src/main/resources/fxml/MultiplayerCreate.fxml @@ -16,16 +16,16 @@ <HBox alignment="TOP_CENTER" spacing="20.0"> <children> <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Text:" /> - <TextField /> + <TextField alignment="CENTER" /> </children> <VBox.margin> <Insets top="50.0" /> </VBox.margin> </HBox> - <HBox alignment="TOP_CENTER" maxWidth="-Infinity" minWidth="-Infinity" prefHeight="25.0" prefWidth="213.0" spacing="20.0"> + <HBox alignment="TOP_CENTER" maxWidth="-Infinity" spacing="20.0"> <children> <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Text:" /> - <TextField /> + <TextField alignment="CENTER" /> </children> </HBox> <HBox alignment="TOP_CENTER" spacing="10.0"> @@ -47,7 +47,7 @@ <Insets top="20.0" /> </VBox.margin> </AnchorPane> - <Button mnemonicParsing="false" onAction="#start" text="Start" /> + <Button mnemonicParsing="false" text="Start" /> <Button mnemonicParsing="false" onAction="#backButton" text="Back" /> <Pane VBox.vgrow="ALWAYS" /> <Pane VBox.vgrow="ALWAYS" /> diff --git a/src/main/resources/fxml/MultiplayerJoin.fxml b/src/main/resources/fxml/MultiplayerJoin.fxml index 117cf38cd7ba79fb3f41209f4a4b869e4a11e889..50328301d12e960ca362bc1a19d067f58d41a4d9 100644 --- a/src/main/resources/fxml/MultiplayerJoin.fxml +++ b/src/main/resources/fxml/MultiplayerJoin.fxml @@ -10,7 +10,7 @@ <children> <Pane maxHeight="1.7976931348623157E308" prefHeight="200.0" prefWidth="200.0" /> <Text strokeType="OUTSIDE" strokeWidth="0.0" text="IP Adress:" /> - <TextField maxWidth="-Infinity" /> + <TextField alignment="CENTER" maxWidth="-Infinity" /> <Button mnemonicParsing="false" text="Connect" VBox.vgrow="ALWAYS" /> <Text strokeType="OUTSIDE" strokeWidth="0.0" text="[Error Message]" /> <Pane maxHeight="1.7976931348623157E308" prefHeight="200.0" prefWidth="200.0" VBox.vgrow="ALWAYS" /> diff --git a/src/main/resources/fxml/Pause.fxml b/src/main/resources/fxml/Pause.fxml new file mode 100644 index 0000000000000000000000000000000000000000..798d429b8acb6ce40ba7e2a42f060847fd9c2be4 --- /dev/null +++ b/src/main/resources/fxml/Pause.fxml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.scene.control.Button?> +<?import javafx.scene.layout.VBox?> + +<VBox fx:id="parent" alignment="CENTER" prefHeight="400.0" prefWidth="600.0" spacing="20.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.PauseController"> + <children> + <Button mnemonicParsing="false" onAction="#resume" style="-fx-text-fill: white;" text="Continue" /> + <Button mnemonicParsing="false" style="-fx-text-fill: white;" text="Restart" /> + <Button mnemonicParsing="false" onAction="#settings" style="-fx-text-fill: white;" text="Settings" /> + <Button mnemonicParsing="false" onAction="#mainMenu" style="-fx-text-fill: white;" text="Main Menu" /> + </children> +</VBox> diff --git a/src/main/resources/fxml/PauseSettings.fxml b/src/main/resources/fxml/PauseSettings.fxml new file mode 100644 index 0000000000000000000000000000000000000000..50f26c6e80fbf470c2802cbb2ff2a52178716748 --- /dev/null +++ b/src/main/resources/fxml/PauseSettings.fxml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.scene.control.Button?> +<?import javafx.scene.control.Slider?> +<?import javafx.scene.layout.HBox?> +<?import javafx.scene.layout.VBox?> +<?import javafx.scene.text.Text?> + +<VBox fx:id="parent" alignment="CENTER" prefHeight="400.0" prefWidth="600.0" spacing="20.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.PauseSettingsController"> + <children> + <HBox alignment="CENTER"> + <children> + <VBox alignment="TOP_CENTER" spacing="10.0"> + <children> + <VBox alignment="CENTER" VBox.vgrow="ALWAYS"> + <children> + <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Music volume:" /> + <Slider fx:id="musicSlider" blockIncrement="25.0" majorTickUnit="100.0" minorTickCount="1" prefHeight="14.0" prefWidth="480.0" showTickLabels="true" value="75.0" VBox.vgrow="NEVER" /> + </children> + </VBox> + <VBox alignment="CENTER" VBox.vgrow="ALWAYS"> + <children> + <Text strokeType="OUTSIDE" strokeWidth="0.0" text="SFX volume:" /> + <Slider fx:id="sfxSlider" blockIncrement="25.0" majorTickUnit="100.0" minorTickCount="1" prefHeight="14.0" prefWidth="480.0" showTickLabels="true" value="75.0" /> + </children> + </VBox> + </children> + </VBox> + </children> + </HBox> + <Button mnemonicParsing="false" onAction="#backButton" style="-fx-text-fill: white;" text="Back" /> + </children> +</VBox> diff --git a/src/main/resources/fxml/SkinSelection.fxml b/src/main/resources/fxml/SkinSelection.fxml index b98b91af38434be6169c8cdfead739ef20587460..8e074b509d60f361acb6c7a63073fd407d51dfcc 100644 --- a/src/main/resources/fxml/SkinSelection.fxml +++ b/src/main/resources/fxml/SkinSelection.fxml @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <?import javafx.scene.control.Button?> +<?import javafx.scene.control.Label?> <?import javafx.scene.control.ToggleButton?> <?import javafx.scene.control.ToggleGroup?> <?import javafx.scene.image.Image?> @@ -10,41 +11,77 @@ <VBox fx:id="parent" alignment="CENTER" prefHeight="400.0" prefWidth="600.0" spacing="20.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.SkinSelectionController"> <children> + <Label text="Player 1" /> <HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0" spacing="40.0"> <children> - <ToggleButton contentDisplay="TOP" mnemonicParsing="false" styleClass="skinSelection" text="Elias"> + <ToggleButton contentDisplay="TOP" mnemonicParsing="false" styleClass="skinSelection" text="High Born"> <graphic> - <ImageView fx:id="selection1" fitHeight="700.0" fitWidth="700.0" pickOnBounds="true" preserveRatio="true"> + <ImageView fx:id="playerOne1" fitHeight="700.0" fitWidth="700.0" pickOnBounds="true" preserveRatio="true"> <image> - <Image url="@../textures/images/elias.png" /> + <Image url="@../textures/player/high_res/highBorn.png" /> </image> </ImageView> </graphic> <toggleGroup> - <ToggleGroup fx:id="selectionButton" /> + <ToggleGroup fx:id="playerOne" /> </toggleGroup> </ToggleButton> - <ToggleButton contentDisplay="TOP" mnemonicParsing="false" styleClass="skinSelection" text="Erzan" toggleGroup="$selectionButton"> + <ToggleButton contentDisplay="TOP" mnemonicParsing="false" styleClass="skinSelection" text="Human" toggleGroup="$playerOne"> <graphic> - <ImageView fx:id="selection2" fitHeight="700.0" fitWidth="700.0" pickOnBounds="true" preserveRatio="true"> + <ImageView fx:id="playerOne2" fitHeight="700.0" fitWidth="700.0" pickOnBounds="true" preserveRatio="true"> <image> - <Image url="@../textures/images/erzan.png" /> + <Image url="@../textures/player/high_res/human.png" /> </image> </ImageView> </graphic> </ToggleButton> - <ToggleButton contentDisplay="TOP" mnemonicParsing="false" styleClass="skinSelection" text="Martin" toggleGroup="$selectionButton"> + <ToggleButton contentDisplay="TOP" mnemonicParsing="false" styleClass="skinSelection" text="Sentinel" toggleGroup="$playerOne"> <graphic> - <ImageView fx:id="selection3" fitHeight="700.0" fitWidth="700.0" pickOnBounds="true" preserveRatio="true"> + <ImageView fx:id="playerOne3" fitHeight="700.0" fitWidth="700.0" pickOnBounds="true" preserveRatio="true"> <image> - <Image url="@../textures/images/martin.png" /> + <Image url="@../textures/player/high_res/sentinel.png" /> </image> </ImageView> </graphic> </ToggleButton> </children> </HBox> - <Button mnemonicParsing="false" onAction="#gameScene" text="Start" /> + <Label text="Player 2" /> + <HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0" spacing="40.0"> + <children> + <ToggleButton contentDisplay="TOP" mnemonicParsing="false" styleClass="skinSelection" text="High Born"> + <graphic> + <ImageView fx:id="playerTwo1" fitHeight="700.0" fitWidth="700.0" pickOnBounds="true" preserveRatio="true"> + <image> + <Image url="@../textures/player/high_res/highBorn.png" /> + </image> + </ImageView> + </graphic> + <toggleGroup> + <ToggleGroup fx:id="playerTwo" /> + </toggleGroup> + </ToggleButton> + <ToggleButton contentDisplay="TOP" mnemonicParsing="false" styleClass="skinSelection" text="Human" toggleGroup="$playerTwo"> + <graphic> + <ImageView fx:id="playerTwo2" fitHeight="700.0" fitWidth="700.0" pickOnBounds="true" preserveRatio="true"> + <image> + <Image url="@../textures/player/high_res/human.png" /> + </image> + </ImageView> + </graphic> + </ToggleButton> + <ToggleButton contentDisplay="TOP" mnemonicParsing="false" styleClass="skinSelection" text="Sentinel" toggleGroup="$playerTwo"> + <graphic> + <ImageView fx:id="playerTwo3" fitHeight="700.0" fitWidth="700.0" pickOnBounds="true" preserveRatio="true"> + <image> + <Image url="@../textures/player/high_res/sentinel.png" /> + </image> + </ImageView> + </graphic> + </ToggleButton> + </children> + </HBox> + <Button mnemonicParsing="false" onAction="#gameScene" text="Next" /> <Button mnemonicParsing="false" onAction="#backButton" text="Back" /> </children> </VBox> diff --git a/src/main/resources/maps/coreMaps.json b/src/main/resources/maps/coreMaps.json index ba63b040f5afc06edf39a660e0cd815b3bb7963b..91ba5f980c0de2786626cbf6394bd3d1e1beac92 100644 --- a/src/main/resources/maps/coreMaps.json +++ b/src/main/resources/maps/coreMaps.json @@ -1,16 +1,65 @@ [ { - "mapID": "09a02b54d05b5b7ebc29a4383ca12d3dda846b72", - "mapName": "Arena1", + "mapID": "b3d1910a7c4f0c5f4987e9af701a8fdd841b9cb2", + "mapName": "SE3", "mapWidth": 18, "mapHeight": 18, - "mapData": "12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12" + "mapData": "10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 0 0 0 16 0 0 0 16 0 16 16 16 0 0 0 0 10 10 0 0 0 16 0 0 0 16 0 16 0 0 0 0 0 0 10 10 0 0 0 16 0 0 0 16 0 16 16 16 0 0 0 0 10 10 0 0 0 16 0 16 0 16 0 16 0 0 0 0 0 0 10 10 0 0 0 0 16 0 16 0 0 16 16 16 0 0 0 0 10 10 0 1 1 0 1 1 0 0 0 0 1 1 0 1 1 0 10 10 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 10 10 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1 10 10 0 1 0 0 0 1 0 0 0 0 1 0 0 0 1 0 10 10 0 0 1 0 1 0 0 0 0 0 0 1 0 1 0 0 10 10 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 10 10 0 0 11 10 10 0 11 10 10 0 0 11 10 10 0 0 10 10 0 0 11 0 0 0 11 0 0 0 0 0 0 11 0 0 10 10 0 0 11 10 10 0 11 10 10 0 0 11 10 10 0 0 10 10 0 0 0 0 11 0 11 0 0 0 0 0 0 11 0 0 10 10 0 0 11 10 10 0 11 10 10 0 0 11 10 10 0 0 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10" }, { - "mapID": "0ab15557ab6dc4be60dfe6a9b0288bac3036bd97", - "mapName": "Arena2", + "mapID": "b8f5da1a3619a3585978a6d9c8c683c3210193e6", + "mapName": "Ruins", "mapWidth": 18, "mapHeight": 18, - "mapData": "12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12 12 1 1 1 1 1 1 1 5 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12" + "mapData": "11 10 13 10 13 10 10 12 14 14 11 10 10 13 10 13 10 12 11 0 0 0 0 0 16 0 2 2 0 3 0 0 0 3 0 12 11 0 16 0 0 0 0 0 1 2 0 0 0 0 16 0 1 12 11 16 0 0 3 0 16 0 2 2 0 0 3 0 0 0 0 12 11 0 3 0 0 16 0 1 1 2 0 0 0 0 16 0 0 12 11 0 0 16 16 0 0 0 1 2 0 0 0 0 3 16 0 12 11 16 0 0 12 10 10 15 12 2 11 15 16 15 15 11 0 12 11 0 0 0 12 0 1 1 0 2 0 0 0 0 0 11 0 12 11 0 0 16 12 5 5 5 5 4 5 5 5 5 0 11 1 12 11 0 0 0 12 11 10 10 10 2 12 0 0 1 0 11 0 12 11 0 0 0 12 1 0 0 11 2 12 16 0 1 0 11 0 12 11 0 0 0 12 0 1 0 11 2 12 0 16 0 0 11 0 12 11 0 1 0 12 0 0 12 11 2 12 11 13 10 13 11 0 12 11 0 0 0 12 0 0 0 0 2 0 0 0 0 0 0 0 12 11 0 0 0 12 15 13 10 12 14 11 10 13 10 13 12 0 12 11 1 0 0 1 0 0 0 0 2 0 0 1 1 0 0 0 12 11 0 0 1 0 0 1 0 0 2 0 0 1 0 0 1 0 12 11 10 15 15 10 10 15 10 12 14 11 10 10 15 10 15 10 12" + }, + { + "mapID": "f482b89b32ab4315a85108d83fb57ec09cdb7e09", + "mapName": "Outpost", + "mapWidth": 18, + "mapHeight": 18, + "mapData": "16 16 16 16 16 16 16 16 16 16 10 12 13 11 12 14 11 12 16 0 16 0 0 1 0 0 0 0 21 0 0 1 0 2 0 12 16 0 0 0 0 0 16 16 0 0 15 3 0 0 0 2 1 12 16 0 0 2 16 0 0 1 16 0 15 15 3 3 0 2 0 12 11 10 12 2 11 10 12 0 16 0 0 15 15 3 1 2 0 12 11 0 0 2 0 0 12 0 0 16 0 0 15 3 0 2 0 12 11 0 10 2 10 0 12 0 0 16 0 0 15 15 12 2 11 12 11 0 10 2 10 0 12 0 0 0 0 0 0 0 0 2 0 16 11 0 1 2 10 0 12 16 0 0 11 10 21 10 12 2 0 16 11 0 10 2 10 0 21 0 0 16 11 3 0 0 12 0 1 16 11 0 10 2 10 0 12 0 16 0 11 0 0 1 12 2 0 16 11 0 10 2 10 0 12 0 0 0 11 0 0 0 12 2 0 16 11 0 0 1 0 0 12 16 0 0 11 0 0 0 12 0 0 16 11 10 12 2 11 10 12 0 16 0 11 0 10 10 12 2 0 16 16 0 0 2 16 0 0 0 0 0 11 0 0 3 12 0 11 12 16 0 16 16 16 0 0 16 0 0 21 0 0 0 0 2 0 12 16 0 0 0 0 0 0 0 0 0 11 0 0 1 0 2 0 12 16 16 16 16 16 16 16 16 16 16 11 12 13 11 12 14 11 12" + }, + { + "mapID": "82e6709231e6add4279097f5efe074f862eea1d8", + "mapName": "Kings-Crossing", + "mapWidth": 18, + "mapHeight": 18, + "mapData": "10 10 10 10 10 10 10 12 14 14 11 10 10 10 10 10 10 10 10 0 0 0 0 0 0 0 2 2 0 0 0 0 0 0 0 10 10 0 11 10 10 12 0 21 2 2 21 0 11 10 10 12 0 10 10 0 11 4 4 4 0 21 2 2 21 0 4 4 4 12 0 10 10 0 11 4 4 0 0 21 2 2 21 0 0 4 4 12 0 10 10 0 11 4 0 0 0 21 2 2 21 0 0 0 4 12 0 10 10 0 0 0 0 0 21 1 2 2 1 21 0 0 0 0 0 10 10 0 21 21 21 21 1 1 2 2 1 1 21 21 21 21 0 10 14 5 5 5 5 5 5 5 6 6 5 5 5 5 5 5 5 14 14 5 5 5 5 5 5 5 6 6 5 5 5 5 5 5 5 14 10 0 21 21 21 21 1 1 2 2 1 1 21 21 21 21 0 10 10 0 0 0 0 0 21 1 2 2 1 21 0 0 0 0 0 10 10 0 11 4 0 0 0 21 2 2 21 0 0 0 4 12 0 10 10 0 11 4 4 0 0 21 2 2 21 0 0 4 4 12 0 10 10 0 11 4 4 4 0 21 2 2 21 0 4 4 4 12 0 10 10 0 11 10 10 12 0 21 2 2 21 0 11 10 10 12 0 10 10 0 0 0 0 0 0 0 2 2 0 0 0 0 0 0 0 10 10 10 10 10 10 10 10 12 14 14 11 10 10 10 10 10 10 10" + }, + { + "mapID": "db8fb88e7a0c7bb133f792b5dd6b3ebbd9d6a15f", + "mapName": "Maze", + "mapWidth": 18, + "mapHeight": 18, + "mapData": "16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 0 0 0 0 0 0 0 0 0 0 16 0 0 0 0 0 16 16 0 16 16 16 16 0 16 16 16 16 16 0 16 16 16 0 16 16 0 16 0 0 0 0 0 0 20 0 0 0 0 0 16 0 16 16 0 16 16 16 16 16 16 16 0 16 16 16 16 0 16 0 16 16 0 0 20 0 0 0 0 0 0 0 0 0 16 0 16 0 16 16 0 16 0 16 16 16 16 16 16 16 16 0 16 0 16 20 16 16 0 16 0 0 0 0 20 0 0 0 16 0 16 0 16 0 16 16 0 16 16 16 16 16 0 16 16 0 16 0 16 0 16 0 16 16 20 0 0 16 0 0 0 16 16 0 16 0 16 0 16 0 16 16 0 16 0 16 0 16 0 16 16 20 0 0 0 0 16 0 16 16 0 16 0 16 0 16 16 16 16 16 16 16 16 0 16 0 16 16 0 16 20 16 0 0 0 0 0 16 0 0 0 20 0 0 16 16 0 16 0 16 16 16 16 16 0 16 0 16 16 16 16 0 16 16 0 16 0 0 0 0 0 0 0 16 0 0 0 0 16 0 16 16 0 16 16 0 16 16 16 16 16 16 16 16 16 0 16 0 16 16 0 0 0 0 0 0 0 0 20 0 0 0 0 0 0 0 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16" + }, + { + "mapID": "ac7c6f0fcaaf730804925aae280cce26f0da481e", + "mapName": "AsymmetricBomberman", + "mapWidth": 18, + "mapHeight": 18, + "mapData": "10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 1 1 1 20 1 20 1 20 1 20 1 20 1 20 1 1 10 10 1 1 20 10 20 10 20 10 20 10 20 10 20 10 20 1 10 10 1 20 1 20 1 20 1 20 1 20 1 20 1 20 1 20 10 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 10 10 1 20 1 20 1 20 1 20 1 20 1 20 1 20 1 20 10 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 10 10 1 20 1 20 1 20 1 20 1 20 1 20 1 20 1 20 10 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 10 10 1 20 1 20 1 20 1 20 1 20 1 20 1 20 1 20 10 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 10 10 1 20 1 20 1 20 1 20 1 20 1 20 1 20 1 20 10 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 10 10 1 20 1 20 1 20 1 20 1 20 1 20 1 20 1 20 10 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 10 10 1 20 1 20 1 20 1 20 1 20 1 20 1 20 1 1 10 10 1 1 20 10 20 10 20 10 20 10 20 10 20 10 1 1 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10" + }, + { + "mapID": "ff52df212fcd29f16db9d7aa11d305cad9063c35", + "mapName": "SymmetricBomberman", + "mapWidth": 18, + "mapHeight": 18, + "mapData": "10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 1 1 20 20 1 20 1 20 20 1 20 1 20 1 20 1 10 10 1 10 20 10 20 10 20 10 10 20 10 20 10 20 10 20 10 10 20 20 1 20 1 20 1 20 20 1 20 1 20 1 20 1 10 10 20 10 20 10 20 10 20 10 10 20 10 20 10 20 10 20 10 10 1 20 1 20 1 20 1 20 20 1 20 1 20 1 20 1 10 10 20 10 20 10 20 10 20 10 10 20 10 20 10 20 10 20 10 10 1 20 1 20 1 20 1 20 20 1 20 1 20 1 20 1 10 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 10 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 10 10 1 20 1 20 1 20 1 20 20 1 20 1 20 1 20 1 10 10 20 10 20 10 20 10 20 10 10 20 10 20 10 20 10 20 10 10 1 20 1 20 1 20 1 20 20 1 20 1 20 1 20 1 10 10 20 10 20 10 20 10 20 10 10 20 10 20 10 20 10 20 10 10 1 20 1 20 1 20 1 20 20 1 20 1 20 1 20 20 10 10 20 10 20 10 20 10 20 10 10 20 10 20 10 20 10 1 10 10 1 20 1 20 1 20 1 20 1 20 20 1 20 20 1 1 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10" + }, + { + "mapID": "8bf04771fc5eea669f8dda582fe8d8b159f15009", + "mapName": "SymmetricBombermanFullBoxed", + "mapWidth": 18, + "mapHeight": 18, + "mapData": "10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 1 1 20 20 20 20 20 20 20 20 20 20 20 20 1 1 10 10 1 10 20 10 20 10 20 10 10 20 10 20 10 20 10 1 10 10 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 10 10 20 10 20 10 20 10 20 10 10 20 10 20 10 20 10 20 10 10 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 10 10 20 10 20 10 20 10 20 10 10 20 10 20 10 20 10 20 10 10 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 10 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 10 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 10 10 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 10 10 20 10 20 10 20 10 20 10 10 20 10 20 10 20 10 20 10 10 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 10 10 20 10 20 10 20 10 20 10 10 20 10 20 10 20 10 20 10 10 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 10 10 1 10 20 10 20 10 20 10 10 20 10 20 10 20 10 1 10 10 1 1 20 20 20 20 20 20 20 20 20 20 20 20 1 1 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10" + }, + { + "mapID": "09f4fbab8fd30c11a585ade60258aadebb424c23", + "mapName": "HelloWorld", + "mapWidth": 18, + "mapHeight": 18, + "mapData": "10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 11 0 11 0 11 10 0 11 0 0 11 0 0 11 10 10 10 10 11 0 11 0 11 0 0 11 0 0 11 0 0 11 0 11 10 10 11 10 10 0 11 10 0 11 0 0 11 0 0 11 0 11 10 10 11 0 11 0 11 0 0 11 0 0 11 0 0 11 0 11 10 10 11 0 11 0 11 10 0 11 10 0 11 10 0 11 10 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 0 0 0 0 0 0 16 16 16 16 0 0 0 0 0 0 10 10 0 0 0 0 0 16 16 16 16 16 16 0 0 0 0 0 10 10 0 0 0 0 16 16 16 16 16 16 16 16 0 0 0 0 10 10 0 0 0 0 16 16 16 16 16 16 16 16 0 0 0 0 10 10 0 0 0 0 16 16 16 16 16 16 16 16 0 0 0 0 10 10 0 0 0 0 16 16 16 16 16 16 16 16 0 0 0 0 10 10 0 0 0 0 0 16 16 16 16 16 16 0 0 0 0 0 10 10 0 0 0 0 0 0 16 16 16 16 0 0 0 0 0 0 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10" } -] \ No newline at end of file +] diff --git a/src/main/resources/player/appSettings.json b/src/main/resources/player/appSettings.json index f7d371619fa1db8dd4701e6607908135293b820c..b09c56e399848e7f331f341a39652fb9e499b789 100644 --- a/src/main/resources/player/appSettings.json +++ b/src/main/resources/player/appSettings.json @@ -1,4 +1,4 @@ { - "sfxVolume": 100, + "sfxVolume": 16, "musicVolume": 0 } \ No newline at end of file diff --git a/src/main/resources/player/playerAccount.json b/src/main/resources/player/playerAccount.json index 60070b6ed6a4c8153907eaf7e737e2e997fb3377..2580dc191f7349bc8b8f8e5435a9deaa65147908 100644 --- a/src/main/resources/player/playerAccount.json +++ b/src/main/resources/player/playerAccount.json @@ -1,5 +1,5 @@ { - "playerName": "Player1", - "accountPassword": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8", + "playerName": "kaka", + "accountPassword": "", "accountType": "LOCAL" } \ No newline at end of file diff --git a/src/main/resources/sound/music/License Information.txt b/src/main/resources/sound/music/License Information.txt new file mode 100644 index 0000000000000000000000000000000000000000..66ec28dbbc7f54832532876017234828800cfac7 --- /dev/null +++ b/src/main/resources/sound/music/License Information.txt @@ -0,0 +1,44 @@ +-------------------- +License Information: +-------------------- +//////////////////// +-------------------- +Downloaded music: +-------------------- +-------------------- +Track: Only the Braves +Music by https://www.fiftysounds.com +-------------------- +Track: In This Place +Music by https://www.fiftysounds.com +-------------------- +Track: Giants +Music by https://www.fiftysounds.com +-------------------- +Track: The Awakening +Music by https://www.fiftysounds.com +-------------------- +Track: Introspective Demon +Music by https://www.fiftysounds.com +-------------------- +//////////////////// +-------------------- +Original music: +-------------------- +-------------------- +Track: Master_Szene_1 +Artist: Uwe Schuh +-------------------- +Track: Eclipse of the Lord - Original Soundtrack +Artist: Maximilian Scherbaum +-------------------- +Track: Tempest Overture - A BattleArena Medley +Artist: Maximilian Scherbaum +Samples: (licenses listed above) + - Only the Braves + - In This Place + - Giants + - The Awakening + - Introspective Demon + - Master_Szene_1 + - Eclipse of the Lord - Original Soundtrack \ No newline at end of file diff --git a/src/main/resources/sound/music/game/musicPlaceholder.mp3 b/src/main/resources/sound/music/game/Eclipse of the Lord - Original Soundtrack.mp3 similarity index 100% rename from src/main/resources/sound/music/game/musicPlaceholder.mp3 rename to src/main/resources/sound/music/game/Eclipse of the Lord - Original Soundtrack.mp3 diff --git a/src/main/resources/sound/music/game/Giants.mp3 b/src/main/resources/sound/music/game/Giants.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..b0b87b79ca42b9f51b6b22fc23aeedeaf8394779 Binary files /dev/null and b/src/main/resources/sound/music/game/Giants.mp3 differ diff --git a/src/main/resources/sound/music/game/In this Place.mp3 b/src/main/resources/sound/music/game/In this Place.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..fcd05060c6e0f1f289e850b5b1c7b291fdb03c6c Binary files /dev/null and b/src/main/resources/sound/music/game/In this Place.mp3 differ diff --git a/src/main/resources/sound/music/game/Introspective Demon.mp3 b/src/main/resources/sound/music/game/Introspective Demon.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..708c99d23bc337eeb70375ff3680d8af56ef693c Binary files /dev/null and b/src/main/resources/sound/music/game/Introspective Demon.mp3 differ diff --git a/src/main/resources/textures/images/background.png b/src/main/resources/sound/music/game/Master_Szene_1.wav similarity index 60% rename from src/main/resources/textures/images/background.png rename to src/main/resources/sound/music/game/Master_Szene_1.wav index cfecaea36ac9953b10720b8cee301e0501b75064..675edc4484de7603868e162eb7a451ee0fa56915 100644 Binary files a/src/main/resources/textures/images/background.png and b/src/main/resources/sound/music/game/Master_Szene_1.wav differ diff --git a/src/main/resources/sound/music/game/Only the Braves - FiftySounds.mp3 b/src/main/resources/sound/music/game/Only the Braves - FiftySounds.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..9756bea32b9335e7be46a54651a23bdb7d7922ad Binary files /dev/null and b/src/main/resources/sound/music/game/Only the Braves - FiftySounds.mp3 differ diff --git a/src/main/resources/sound/music/game/The Awakening.mp3 b/src/main/resources/sound/music/game/The Awakening.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..d718e86a8f4401d2e459e0780c4093c7473cfe78 Binary files /dev/null and b/src/main/resources/sound/music/game/The Awakening.mp3 differ diff --git a/src/main/resources/sound/music/cocBackgroundMusicTest.mp3 b/src/main/resources/sound/music/memes/cocBackgroundMusicTest.mp3 similarity index 100% rename from src/main/resources/sound/music/cocBackgroundMusicTest.mp3 rename to src/main/resources/sound/music/memes/cocBackgroundMusicTest.mp3 diff --git a/src/main/resources/sound/music/spongeBob.mp3 b/src/main/resources/sound/music/memes/spongeBob.mp3 similarity index 100% rename from src/main/resources/sound/music/spongeBob.mp3 rename to src/main/resources/sound/music/memes/spongeBob.mp3 diff --git a/src/main/resources/sound/music/stadiumRave.mp3 b/src/main/resources/sound/music/memes/stadiumRave.mp3 similarity index 100% rename from src/main/resources/sound/music/stadiumRave.mp3 rename to src/main/resources/sound/music/memes/stadiumRave.mp3 diff --git a/src/main/resources/sound/music/wii.mp3 b/src/main/resources/sound/music/memes/wii.mp3 similarity index 100% rename from src/main/resources/sound/music/wii.mp3 rename to src/main/resources/sound/music/memes/wii.mp3 diff --git a/src/main/resources/sound/music/menu/Tempest Overture - A BattleArena Medley.mp3 b/src/main/resources/sound/music/menu/Tempest Overture - A BattleArena Medley.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..ee40fcf09279d331776d07c50e20af5cdad28106 Binary files /dev/null and b/src/main/resources/sound/music/menu/Tempest Overture - A BattleArena Medley.mp3 differ diff --git a/src/main/resources/sound/music/constructionJazz.mp3 b/src/main/resources/sound/music/placeholder/constructionJazz.mp3 similarity index 100% rename from src/main/resources/sound/music/constructionJazz.mp3 rename to src/main/resources/sound/music/placeholder/constructionJazz.mp3 diff --git a/src/main/resources/sound/sfx/otSFX/attack/Sword_hit1.wav b/src/main/resources/sound/sfx/otSFX/attack/Sword_hit1.wav new file mode 100644 index 0000000000000000000000000000000000000000..8ed31a9c367d3a0dc74d7ac28d5373bdf4b4f420 Binary files /dev/null and b/src/main/resources/sound/sfx/otSFX/attack/Sword_hit1.wav differ diff --git a/src/main/resources/sound/sfx/otSFX/attack/Sword_swing.wav b/src/main/resources/sound/sfx/otSFX/attack/Sword_swing.wav new file mode 100644 index 0000000000000000000000000000000000000000..b1c6c91018821fa54644db465b380e99974d6e8a Binary files /dev/null and b/src/main/resources/sound/sfx/otSFX/attack/Sword_swing.wav differ diff --git a/src/main/resources/sound/sfx/otSFX/bomb/Bomb2.wav b/src/main/resources/sound/sfx/otSFX/bomb/Bomb2.wav new file mode 100644 index 0000000000000000000000000000000000000000..6056057b4e42ca6e9b87dfabafc009896ab0c83e Binary files /dev/null and b/src/main/resources/sound/sfx/otSFX/bomb/Bomb2.wav differ diff --git a/src/main/resources/sound/sfx/otSFX/bomb/BombSound.wav b/src/main/resources/sound/sfx/otSFX/bomb/BombSound.wav new file mode 100644 index 0000000000000000000000000000000000000000..b5e779c77634bad6a142fa1324639b763c313abf Binary files /dev/null and b/src/main/resources/sound/sfx/otSFX/bomb/BombSound.wav differ diff --git a/src/main/resources/sound/sfx/otSFX/bomb/Fuse.wav b/src/main/resources/sound/sfx/otSFX/bomb/Fuse.wav new file mode 100644 index 0000000000000000000000000000000000000000..31099639db4593beed4764193084bdf3fbc36aa0 Binary files /dev/null and b/src/main/resources/sound/sfx/otSFX/bomb/Fuse.wav differ diff --git a/src/main/resources/sound/sfx/otSFX/destruction/WoodDestruction.wav b/src/main/resources/sound/sfx/otSFX/destruction/WoodDestruction.wav new file mode 100644 index 0000000000000000000000000000000000000000..e51acbdb37fb2bea31b35251facd10643caa18e7 Binary files /dev/null and b/src/main/resources/sound/sfx/otSFX/destruction/WoodDestruction.wav differ diff --git a/src/main/resources/sound/sfx/otSFX/dieSounds/body-falling-to-ground.mp3 b/src/main/resources/sound/sfx/otSFX/dieSounds/body-falling-to-ground.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..701a73f47a8dc8013eabb1e7fc8a4a8d0a2b62f8 Binary files /dev/null and b/src/main/resources/sound/sfx/otSFX/dieSounds/body-falling-to-ground.mp3 differ diff --git a/src/main/resources/sound/sfx/otSFX/powerups/drop-coins.mp3 b/src/main/resources/sound/sfx/otSFX/powerups/drop-coins.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..f2d3de25f746a2effadbf80558cc66b9314e6d60 Binary files /dev/null and b/src/main/resources/sound/sfx/otSFX/powerups/drop-coins.mp3 differ diff --git a/src/main/resources/sound/sfx/otSFX/powerups/powerup.mp3 b/src/main/resources/sound/sfx/otSFX/powerups/powerup.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..eaa0ef201d75d1e3344a63dac598335861e5d524 Binary files /dev/null and b/src/main/resources/sound/sfx/otSFX/powerups/powerup.mp3 differ diff --git a/src/main/resources/styles/style.css b/src/main/resources/styles/style.css index 0389e5bbbcc594716ff89c2a3d73e0dfd7fc61a3..44d3c8fd1f2afc5807078d86285817fba447a187 100644 --- a/src/main/resources/styles/style.css +++ b/src/main/resources/styles/style.css @@ -1,6 +1,6 @@ * { -fx-dark-brown: #3c2014; - -fx-brown: #956233; + -fx-brown: #805e29; } #button { @@ -34,7 +34,7 @@ #mainMenu{ - -fx-background-image: url("../textures/images/background.png"); + -fx-background-image: url("../textures/images/background.jpg"); -fx-background-size: cover; } @@ -43,6 +43,11 @@ -fx-font-family: "Starship Shadow"; } +#gameScene { + -fx-background-image: url("../textures/images/game_scene_backgorund.png"); + -fx-background-size: cover; +} + .button { -fx-text-fill: -fx-brown; -fx-background-color: none; @@ -51,7 +56,7 @@ #btnLeft { -fx-skin: none; - -fx-text-fill: #7a7a7a; + -fx-text-fill: #404040; } .accordion { diff --git a/src/main/resources/textures/images/background.jpg b/src/main/resources/textures/images/background.jpg new file mode 100644 index 0000000000000000000000000000000000000000..0618af6c2edbd72fc986c19759f2a3c102dabcc5 Binary files /dev/null and b/src/main/resources/textures/images/background.jpg differ diff --git a/src/main/resources/sound/music/menu/musicPlaceholder.wav b/src/main/resources/textures/images/game_scene_backgorund.jpg similarity index 66% rename from src/main/resources/sound/music/menu/musicPlaceholder.wav rename to src/main/resources/textures/images/game_scene_backgorund.jpg index e10258b8b48d0253ca1a3141482ee600c96d58e9..4582a8a16813744f793a6f78424321548071ca01 100644 Binary files a/src/main/resources/sound/music/menu/musicPlaceholder.wav and b/src/main/resources/textures/images/game_scene_backgorund.jpg differ diff --git a/src/main/resources/textures/images/game_scene_backgorund.png b/src/main/resources/textures/images/game_scene_backgorund.png new file mode 100644 index 0000000000000000000000000000000000000000..f634cef655e4982edc226cf79c3f654ea9a76926 Binary files /dev/null and b/src/main/resources/textures/images/game_scene_backgorund.png differ diff --git a/src/main/resources/textures/map/grass_biom/building/StoneBriddleStone.png b/src/main/resources/textures/map/grass_biom/building/StoneBriddleStone.png new file mode 100644 index 0000000000000000000000000000000000000000..8ef990b6718bf4dc128f949940d5945cc93c6923 Binary files /dev/null and b/src/main/resources/textures/map/grass_biom/building/StoneBriddleStone.png differ diff --git a/src/main/resources/textures/map/grass_biom/ground/GrassPathCrossway.png b/src/main/resources/textures/map/grass_biom/ground/GrassPathCrossway.png new file mode 100644 index 0000000000000000000000000000000000000000..26a0f5db57b124df0ccddaf8ff959a1385ae560d Binary files /dev/null and b/src/main/resources/textures/map/grass_biom/ground/GrassPathCrossway.png differ diff --git a/src/main/resources/textures/map/grass_biom/ground/GrassPathHorizontal.png b/src/main/resources/textures/map/grass_biom/ground/GrassPathHorizontal.png new file mode 100644 index 0000000000000000000000000000000000000000..290b12fe15b6f291b0e5fe3ba230eb0c72b3b87b Binary files /dev/null and b/src/main/resources/textures/map/grass_biom/ground/GrassPathHorizontal.png differ diff --git a/src/main/resources/textures/map/grass_biom/ground/GrassStoneRemains.png b/src/main/resources/textures/map/grass_biom/ground/GrassStoneRemains.png new file mode 100644 index 0000000000000000000000000000000000000000..bec48a5e3e4aca6195c0b04dab7d550356191e97 Binary files /dev/null and b/src/main/resources/textures/map/grass_biom/ground/GrassStoneRemains.png differ diff --git a/src/main/resources/textures/map/grass_biom/objects/Crate.png b/src/main/resources/textures/map/grass_biom/objects/Crate.png new file mode 100644 index 0000000000000000000000000000000000000000..6badbcb1890d7c3ac1112726288eff2fdd750c79 Binary files /dev/null and b/src/main/resources/textures/map/grass_biom/objects/Crate.png differ diff --git a/src/main/resources/textures/player/high_res/highBorn.png b/src/main/resources/textures/player/high_res/highBorn.png new file mode 100644 index 0000000000000000000000000000000000000000..130cd5b07eb6e42474abef8e60cf2af8232a0f06 Binary files /dev/null and b/src/main/resources/textures/player/high_res/highBorn.png differ diff --git a/src/main/resources/textures/player/high_res/human.png b/src/main/resources/textures/player/high_res/human.png new file mode 100644 index 0000000000000000000000000000000000000000..ecd69bc6b099bd4b899155b7f0e9199e9a49fb02 Binary files /dev/null and b/src/main/resources/textures/player/high_res/human.png differ diff --git a/src/main/resources/textures/player/high_res/sentinel.png b/src/main/resources/textures/player/high_res/sentinel.png new file mode 100644 index 0000000000000000000000000000000000000000..ebcc6a9ffc8d66aa9b7bc5a5407787aef05ea62a Binary files /dev/null and b/src/main/resources/textures/player/high_res/sentinel.png differ diff --git a/src/main/resources/videos/BattleArenaIntro.mp4 b/src/main/resources/videos/BattleArenaIntro.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..41e9788a372bc80cdba0376f071226ec3227048c Binary files /dev/null and b/src/main/resources/videos/BattleArenaIntro.mp4 differ diff --git a/src/main/resources/videos/DigitalGlitch.mp4 b/src/main/resources/videos/DigitalGlitch.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..aded9600e1ab498f49c6d626e1205b7e34bc2f87 Binary files /dev/null and b/src/main/resources/videos/DigitalGlitch.mp4 differ diff --git a/src/main/resources/videos/EngineIntro.mp4 b/src/main/resources/videos/EngineIntro.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..844be12c35e5af667896086302dc12f6160defc1 Binary files /dev/null and b/src/main/resources/videos/EngineIntro.mp4 differ diff --git a/src/main/resources/videos/black.mp4 b/src/main/resources/videos/black.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..1e37430ad1ffd46d92f15466e795ac1102049667 Binary files /dev/null and b/src/main/resources/videos/black.mp4 differ diff --git a/src/main/resources/videos/catRave.mp4 b/src/main/resources/videos/catRave.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..5f5c8bdda380c4acc510e85e54692e63fa941f7e Binary files /dev/null and b/src/main/resources/videos/catRave.mp4 differ diff --git a/src/main/resources/videos/cpr.mp4 b/src/main/resources/videos/cpr.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..14dae5969f47dd64a2891c749b9bda379246da31 Binary files /dev/null and b/src/main/resources/videos/cpr.mp4 differ diff --git a/src/main/resources/videos/defense.mp4 b/src/main/resources/videos/defense.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..f2284e229990768da37acd6f594945ba48bccfa2 Binary files /dev/null and b/src/main/resources/videos/defense.mp4 differ diff --git a/src/main/resources/videos/denied.mp4 b/src/main/resources/videos/denied.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..897097e291b9ea326d3a8ab1671e4c05f88288d7 Binary files /dev/null and b/src/main/resources/videos/denied.mp4 differ diff --git a/src/main/resources/videos/email.mp4 b/src/main/resources/videos/email.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..a7f8ff018aa6822c6ed2e5315ff164ffc184f7f2 Binary files /dev/null and b/src/main/resources/videos/email.mp4 differ diff --git a/src/main/resources/videos/gender.mp4 b/src/main/resources/videos/gender.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..78d5dd209fd66aa77a3c0a7f93cfbce85440b305 Binary files /dev/null and b/src/main/resources/videos/gender.mp4 differ diff --git a/src/main/resources/videos/humping.mp4 b/src/main/resources/videos/humping.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..b5da1c503f13e7f24cfef6ff7092e3c0e45d5b58 Binary files /dev/null and b/src/main/resources/videos/humping.mp4 differ diff --git a/src/main/resources/videos/justTheTwoOfUs.mp4 b/src/main/resources/videos/justTheTwoOfUs.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..fb84e59fc4a0944075f234dcccdf7664bc1c5409 Binary files /dev/null and b/src/main/resources/videos/justTheTwoOfUs.mp4 differ diff --git a/src/main/resources/videos/minecraftCat3.mp4 b/src/main/resources/videos/minecraftCat3.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..4158689b7a52d2540f3b0a008b13c0880142f317 Binary files /dev/null and b/src/main/resources/videos/minecraftCat3.mp4 differ diff --git a/src/main/resources/videos/monke.mp4 b/src/main/resources/videos/monke.mp4 index 980756e7cd8fa4c3c00d5a246ad179b143c1fae1..5759b5af794cd74dd84a37d76d422473911db35c 100644 Binary files a/src/main/resources/videos/monke.mp4 and b/src/main/resources/videos/monke.mp4 differ diff --git a/src/main/resources/videos/singingCat.mp4 b/src/main/resources/videos/singingCat.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..6ae8a7c59523354b806bef85c92f57828e344c46 Binary files /dev/null and b/src/main/resources/videos/singingCat.mp4 differ diff --git a/src/main/resources/videos/slap.mp4 b/src/main/resources/videos/slap.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..bc300c857b72ebc2e7bf6cc3a7ae6a2a41d93033 Binary files /dev/null and b/src/main/resources/videos/slap.mp4 differ diff --git a/src/main/resources/videos/spinSlot.mp4 b/src/main/resources/videos/spinSlot.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..075d8374389bd8f9fd1072b636a6015fe927dca5 Binary files /dev/null and b/src/main/resources/videos/spinSlot.mp4 differ diff --git a/src/main/resources/videos/spoderman.mp4 b/src/main/resources/videos/spoderman.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..ea4e01d5c8ef5fe7a2ffc5d1bded4d8790a20dfe Binary files /dev/null and b/src/main/resources/videos/spoderman.mp4 differ diff --git a/src/main/resources/videos/steak.mp4 b/src/main/resources/videos/steak.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..e2281e0c9e0681b18db249e73f6a144ffa61361d Binary files /dev/null and b/src/main/resources/videos/steak.mp4 differ diff --git a/src/main/resources/videos/tutel.mp4 b/src/main/resources/videos/tutel.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..41b86a66a34d526ada9499cdba37107974066cd9 Binary files /dev/null and b/src/main/resources/videos/tutel.mp4 differ diff --git a/src/test/java/MusicPlayerTest.java b/src/test/java/MusicPlayerTest.java new file mode 100644 index 0000000000000000000000000000000000000000..b56177a78e498e6c0a299da7d9be5da207d9068c --- /dev/null +++ b/src/test/java/MusicPlayerTest.java @@ -0,0 +1,26 @@ +import de.hdm_stuttgart.battlearena.Controller.Enum.GameState; +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Persistence; +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.RuntimeInfo; +import de.hdm_stuttgart.battlearena.Model.Sound.MusicPlayer; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class MusicPlayerTest { + private static final Logger log = LogManager.getLogger(MusicPlayerTest.class); + + RuntimeInfo runtimeInfo; + MusicPlayer musicPlayer; + @BeforeEach + void setup(){ + musicPlayer = MusicPlayer.getInstance(); + runtimeInfo = RuntimeInfo.getInstance(); + } + + @Test + void startGameStateMonitoringTest(){ + runtimeInfo.setGameState(GameState.MENU); + musicPlayer.startGameStateMonitoring(); + } +} diff --git a/src/test/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/PersistenceTest.java b/src/test/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/PersistenceTest.java index 79b599da6c201b66ffe5d1c21293f44b9ee244e4..5b75327412c816a62ba58deac048f0ccde255afa 100644 --- a/src/test/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/PersistenceTest.java +++ b/src/test/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/PersistenceTest.java @@ -21,7 +21,7 @@ class PersistenceTest { OracleDB inst = new OracleDB(); - @Before + @BeforeEach public void setup() throws SQLException { persistenceSingleton = Persistence.getInstance(); persistenceSingleton.db = inst; @@ -42,7 +42,4 @@ class PersistenceTest { void loadPlayerStatistics() { } - - - } \ No newline at end of file diff --git a/src/test/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/Utilities/ParserTest.java b/src/test/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/Utilities/ParserTest.java index 6cbf6fc345bc7da7639d7b61c0299c9b89ac6930..6129c434546c7100137b64db95527ecc335dc65c 100644 --- a/src/test/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/Utilities/ParserTest.java +++ b/src/test/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/Utilities/ParserTest.java @@ -51,7 +51,7 @@ class ParserTest { @ParameterizedTest @ValueSource(strings = {"012345678901234567890123456789", - "de_dust", + "SE3", "Ziba-Tower"}) void mapNameValid(String test){ assertDoesNotThrow(() -> Parser.mapNameValid(test)); @@ -59,8 +59,8 @@ class ParserTest { @Test void mapNameInvalid() { - ParserException testMe = assertThrows(ParserException.class, () -> Parser.mapNameValid("lol")); - assertTrue(testMe.getMessage().contains("Map-Name too short! Min length is 4 characters.")); + ParserException testMe = assertThrows(ParserException.class, () -> Parser.mapNameValid("hi")); + assertTrue(testMe.getMessage().contains("Map-Name too short! Min length is 3 characters.")); testMe = assertThrows(ParserException.class, () -> Parser.mapNameValid("0123456789012345678901234567890")); assertTrue(testMe.getMessage().contains("Map-Name too long! Max length is 30 characters.")); @@ -140,7 +140,7 @@ class ParserTest { } @ParameterizedTest - @ValueSource(strings = {"12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12", + @ValueSource(strings = {"11 10 13 10 13 10 10 12 14 14 11 10 10 13 10 13 10 12 11 0 0 0 0 0 16 0 2 2 0 3 0 0 0 3 0 12 11 0 16 0 0 0 0 0 1 2 0 0 0 0 16 0 1 12 11 16 0 0 3 0 16 0 2 2 0 0 3 0 0 0 0 12 11 0 3 0 0 16 0 1 1 2 0 0 0 0 16 0 0 12 11 0 0 16 16 0 0 0 1 2 0 0 0 0 3 16 0 12 11 16 0 0 12 10 10 15 12 2 11 15 16 15 15 11 0 12 11 0 0 0 12 0 1 1 0 2 0 0 0 0 0 11 0 12 11 0 0 16 12 5 5 5 5 4 5 5 5 5 0 11 1 12 11 0 0 0 12 11 10 10 10 2 12 0 0 1 0 11 0 12 11 0 0 0 12 1 0 0 11 2 12 16 0 1 0 11 0 12 11 0 0 0 12 0 1 0 11 2 12 0 16 0 0 11 0 12 11 0 1 0 12 0 0 12 11 2 12 11 13 10 13 11 0 12 11 0 0 0 12 0 0 0 0 2 0 0 0 0 0 0 0 12 11 0 0 0 12 15 13 10 12 14 11 10 13 10 13 12 0 12 11 1 0 0 1 0 0 0 0 2 0 0 1 1 0 0 0 12 11 0 0 1 0 0 1 0 0 2 0 0 1 0 0 1 0 12 11 10 15 15 10 10 15 10 12 14 11 10 10 15 10 15 10 12", "12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12 12 1 1 1 1 1 1 1 5 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12", "12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12 12 1 1 1 1 1 1 1 8 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 12"}) void mapDataValid(String test){ diff --git a/src/test/java/de/hdm_stuttgart/battlearena/Model/Multiplayer/ClientTest.java b/src/test/java/de/hdm_stuttgart/battlearena/Model/Multiplayer/ClientTest.java new file mode 100644 index 0000000000000000000000000000000000000000..541d65a2b2f6e1420a866f31548043078b5f9bfb --- /dev/null +++ b/src/test/java/de/hdm_stuttgart/battlearena/Model/Multiplayer/ClientTest.java @@ -0,0 +1,18 @@ +package de.hdm_stuttgart.battlearena.Model.Multiplayer; + +import org.junit.jupiter.api.Test; + +import java.util.Arrays; + +import static org.junit.jupiter.api.Assertions.*; + +class ClientTest { + + @Test + void convertStringToArray() { + int[] array = {23}; //Array must be formatted like this for Server transfer + int[] result = Client.convertStringToArray("1234"); + assertEquals(Arrays.toString(array), Arrays.toString(result)); + + } +} \ No newline at end of file diff --git a/src/test/java/de/hdm_stuttgart/battlearena/Model/Multiplayer/ConnectionHandlerTest.java b/src/test/java/de/hdm_stuttgart/battlearena/Model/Multiplayer/ConnectionHandlerTest.java new file mode 100644 index 0000000000000000000000000000000000000000..fa4a0e2aee3c7a7338b65f7c61f830c171e7cb36 --- /dev/null +++ b/src/test/java/de/hdm_stuttgart/battlearena/Model/Multiplayer/ConnectionHandlerTest.java @@ -0,0 +1,143 @@ +package de.hdm_stuttgart.battlearena.Model.Multiplayer; + +import de.hdm_stuttgart.battlearena.Model.Entity.EntityClass; +import de.hdm_stuttgart.battlearena.Model.Entity.EntityDirection; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class ConnectionHandlerTest { + + ConnectionHandler handler = new ConnectionHandler(); + + @Test + void getPlayerID() { + assertEquals(0,handler.getPlayerID()); + } + + @Test + void getpX() { + assertEquals(0,handler.getpX()); + } + + @Test + void setpX() { + handler.setpX(1); + assertEquals(1,handler.getpX()); + } + + @Test + void getpY() { + assertEquals(0,handler.getpY()); + } + + @Test + void setpY() { + handler.setpY(1); + assertEquals(1,handler.getpY()); + } + + @Test + void getEnemyX() { + assertEquals(0,handler.getEnemyX()); + } + + @Test + void getEnemyY() { + assertEquals(0,handler.getEnemyY()); + } + + @Test + void getPlayerAttacking() { + assertEquals(true,ConnectionHandler.getPlayerAttacking()); + } + + @Test + void setPlayerAttacking() { + ConnectionHandler.setPlayerAttacking(false); + assertEquals(false,ConnectionHandler.getPlayerAttacking()); + ConnectionHandler.setPlayerAttacking(true); + } + + @Test + void getEnemyAttacking() { + assertEquals(false,ConnectionHandler.getEnemyAttacking()); + } + + @Test + void setEnemyAttacking() { + ConnectionHandler.setEnemyAttacking(true); + assertEquals(true,ConnectionHandler.getEnemyAttacking()); + ConnectionHandler.setEnemyAttacking(false); + } + + @Test + void getPlayerClass() { + assertEquals(EntityClass.HUMAN, ConnectionHandler.getPlayerClass()); + + } + + @Test + void setPlayerClass() { + ConnectionHandler.setPlayerClass(EntityClass.HIGH_BORN); + assertEquals(EntityClass.HIGH_BORN, ConnectionHandler.getPlayerClass()); + ConnectionHandler.setPlayerClass(EntityClass.HUMAN); + } + + @Test + void getEnemyClass() { + assertEquals(EntityClass.HUMAN, ConnectionHandler.getEnemyClass()); + } + + @Test + void setEnemyClass() { + ConnectionHandler.setEnemyClass(EntityClass.HIGH_BORN); + assertEquals(EntityClass.HIGH_BORN, ConnectionHandler.getEnemyClass()); + ConnectionHandler.setEnemyClass(EntityClass.HUMAN); + } + + @Test + void getPlayerWalkDirection() { + assertEquals(EntityDirection.DOWN, ConnectionHandler.getPlayerWalkDirection()); + } + + @Test + void setPlayerWalkDirection() { + ConnectionHandler.setPlayerWalkDirection(EntityDirection.UP); + assertEquals(EntityDirection.UP, ConnectionHandler.getPlayerWalkDirection()); + ConnectionHandler.setPlayerWalkDirection(EntityDirection.DOWN); + } + + @Test + void getEnemyWalkDirection() { + assertEquals(EntityDirection.DOWN, ConnectionHandler.getPlayerWalkDirection()); + } + + @Test + void setEnemyWalkDirection() { + ConnectionHandler.setEnemyWalkDirection(EntityDirection.UP); + assertEquals(EntityDirection.UP, ConnectionHandler.getEnemyWalkDirection()); + } + + @Test + void getPlayerHealth() { + assertEquals(10, ConnectionHandler.getPlayerHealth()); + } + + @Test + void setPlayerHealth() { + ConnectionHandler.setPlayerHealth(5); + assertEquals(5, ConnectionHandler.getPlayerHealth()); + } + + @Test + void getEnemyHealth() { + assertEquals(10, ConnectionHandler.getEnemyHealth()); + } + + @Test + void setEnemyHealth() { + ConnectionHandler.setEnemyHealth(5); + assertEquals(5, ConnectionHandler.getEnemyHealth()); + } +} \ No newline at end of file diff --git a/src/test/java/de/hdm_stuttgart/battlearena/Model/Multiplayer/ServerTest.java b/src/test/java/de/hdm_stuttgart/battlearena/Model/Multiplayer/ServerTest.java new file mode 100644 index 0000000000000000000000000000000000000000..9d0ad878e4c34c8518f470bd4b0193c96336bfb2 --- /dev/null +++ b/src/test/java/de/hdm_stuttgart/battlearena/Model/Multiplayer/ServerTest.java @@ -0,0 +1,43 @@ +package de.hdm_stuttgart.battlearena.Model.Multiplayer; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.junit.jupiter.api.Test; + +import java.io.IOException; +import java.net.ServerSocket; +import java.util.concurrent.TimeUnit; + +import static org.junit.jupiter.api.Assertions.*; + +class ServerTest { + + private static final Logger log = LogManager.getLogger(Server.class); + + private ServerSocket serverSocket; + private int port = 3333; + private boolean started = false; + + @Test + void startServerSocket() throws IOException { + Server server = new Server(); + server.start(port); //check if the serversocket of the server is started + assertTrue(server.isStarted()); + } + + @Test + void stopServer() throws IOException { + + Server server = new Server(); + server.startServer(); + + try{ + serverSocket.close(); + started = false; + }catch (NullPointerException e){ + //Throws a NullPointer Exception because not connection is active currently + log.info("No active connection to close!"); + } + assertFalse(started); + } +} \ No newline at end of file