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 18984aff8b34492b1058b3a5f51c53c58d0a5dd0..1b09b4b3a4fdc1bba073bae2f79fcd78c4ece9e1 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Controller/GameSceneController.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/GameSceneController.java @@ -101,6 +101,8 @@ public class GameSceneController implements Initializable { } catch (InterruptedException e) { throw new RuntimeException(e); } + + runtimeInfo.setGameState(GameState.PLAYING); AnimationTimer gameLoop = new AnimationTimer() { 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..b167600f08a0087d6eb0f0f6a8995579e8c3e9b1 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Controller/MapSelectionController.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/MapSelectionController.java @@ -19,6 +19,9 @@ 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; @@ -31,6 +34,8 @@ public class MapSelectionController implements Initializable { private final ArrayList<MapData> coreMaps = Persistence.getInstance().getCoreMaps(); + private static Logger log = LogManager.getLogger(MapSelectionController.class); + @Override public void initialize(URL url, ResourceBundle resourceBundle) { ToggleGroup group = new ToggleGroup(); @@ -60,6 +65,7 @@ public class MapSelectionController implements Initializable { MusicPlayerSingleton.getInstance().getMediaPlayer().dispose(); parent.getScene().setRoot(FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/GameScene.fxml")))); } catch (IOException e) { + log.info(e.getCause()); throw new RuntimeException(); } } 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 index 63896675b7dee4da7d05b96ece8e73e06be7f60d..8305eac045969dfd58891918f53e2fcda6579103 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/MusicPlayer.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/MusicPlayer.java @@ -20,22 +20,20 @@ import java.util.ResourceBundle; import java.util.stream.Collectors; import java.util.stream.Stream; -public class MusicPlayer implements Initializable { +public class MusicPlayer { private static final Logger log = LogManager.getLogger(MusicPlayer.class); private MediaPlayer mediaPlayer; private RuntimeInfo runtimeInfo; - @Override - public void initialize(URL url, ResourceBundle resourceBundle) { - setVolume(runtimeInfo.getMusicVolume()); - } + + //Runtime - //Todo Make music play public void playGameMusic(MusicType musicType) throws IOException { Path pathTypeOfMusic = Paths.get(musicType.getPath()); List<Path> musicPaths = getFilePathsFromResources(pathTypeOfMusic); String randomPath = getRandomFilePath(musicPaths); String resource = convertPathToResourcePath(randomPath); + setVolume(runtimeInfo.getMusicVolume()); playMusicLoop(resource); } 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 index cef4794d3fd12b5669e86dab84e164a4e1ced3de..7c5e4f56252116cb31b616f8fe9fd813caa4cc41 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/SoundEffects.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Sound/SoundEffects.java @@ -18,23 +18,23 @@ import java.nio.file.Paths; import java.util.List; import java.util.ResourceBundle; -public class SoundEffects implements Initializable { +public class SoundEffects { private static final Logger log = LogManager.getLogger(SoundEffects.class); private int sfxVolume; private RuntimeInfo runtimeInfo; + GameSceneController gameSceneController; + - @Override - public void initialize(URL url, ResourceBundle resourceBundle) { - sfxVolume = runtimeInfo.getSfxVolume(); - } public void playSoundEffect() throws IOException, InterruptedException { - GameSceneController gameSceneController = new GameSceneController(); + + MusicPlayer musicPlayer = new MusicPlayer(); InputHandler inputhandler = InputHandler.getInstance(); - TileManager tileManager = gameSceneController.getTileManager(); - IEntity player = gameSceneController.getPlayer(); + TileManager tileManager = gameSceneController.getTileManager();// TODO Find out why tileManager is null + log.info(tileManager); + /*IEntity player = gameSceneController.getPlayer(); ITile[] tileSet = tileManager.getTileSet(); int[][] map = tileManager.getTileMap(); int playerPosX; @@ -54,6 +54,7 @@ public class SoundEffects implements Initializable { String resource = musicPlayer.convertPathToResourcePath(randomPath); Thread sfxLoop = new Thread(() -> { AudioClip effect = new AudioClip(resource); + effect.setVolume(runtimeInfo.getSfxVolume()); effect.setVolume((double) sfxVolume / 100); //TODO Replace with own Method effect.play(); }); @@ -63,7 +64,7 @@ public class SoundEffects implements Initializable { sfxPaths.clear(); } } - + */ }