Skip to content
Snippets Groups Projects
Commit 9b6b929c authored by Gehrung Jonas's avatar Gehrung Jonas
Browse files

UPDATE: soundeffects

parent fde38fce
No related branches found
No related tags found
3 merge requests!74V1,!73Initial commit,!71Merge DataBase into Development
...@@ -101,6 +101,8 @@ public class GameSceneController implements Initializable { ...@@ -101,6 +101,8 @@ public class GameSceneController implements Initializable {
} catch (InterruptedException e) { } catch (InterruptedException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
runtimeInfo.setGameState(GameState.PLAYING); runtimeInfo.setGameState(GameState.PLAYING);
AnimationTimer gameLoop = new AnimationTimer() { AnimationTimer gameLoop = new AnimationTimer() {
......
...@@ -19,6 +19,9 @@ import java.util.ArrayList; ...@@ -19,6 +19,9 @@ import java.util.ArrayList;
import java.util.Objects; import java.util.Objects;
import java.util.ResourceBundle; import java.util.ResourceBundle;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
public class MapSelectionController implements Initializable { public class MapSelectionController implements Initializable {
@FXML @FXML
private VBox boxBox, parent; private VBox boxBox, parent;
...@@ -31,6 +34,8 @@ public class MapSelectionController implements Initializable { ...@@ -31,6 +34,8 @@ public class MapSelectionController implements Initializable {
private final ArrayList<MapData> coreMaps = Persistence.getInstance().getCoreMaps(); private final ArrayList<MapData> coreMaps = Persistence.getInstance().getCoreMaps();
private static Logger log = LogManager.getLogger(MapSelectionController.class);
@Override @Override
public void initialize(URL url, ResourceBundle resourceBundle) { public void initialize(URL url, ResourceBundle resourceBundle) {
ToggleGroup group = new ToggleGroup(); ToggleGroup group = new ToggleGroup();
...@@ -60,6 +65,7 @@ public class MapSelectionController implements Initializable { ...@@ -60,6 +65,7 @@ public class MapSelectionController implements Initializable {
MusicPlayerSingleton.getInstance().getMediaPlayer().dispose(); MusicPlayerSingleton.getInstance().getMediaPlayer().dispose();
parent.getScene().setRoot(FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/GameScene.fxml")))); parent.getScene().setRoot(FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/GameScene.fxml"))));
} catch (IOException e) { } catch (IOException e) {
log.info(e.getCause());
throw new RuntimeException(); throw new RuntimeException();
} }
} }
......
...@@ -20,22 +20,20 @@ import java.util.ResourceBundle; ...@@ -20,22 +20,20 @@ import java.util.ResourceBundle;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
public class MusicPlayer implements Initializable { public class MusicPlayer {
private static final Logger log = LogManager.getLogger(MusicPlayer.class); private static final Logger log = LogManager.getLogger(MusicPlayer.class);
private MediaPlayer mediaPlayer; private MediaPlayer mediaPlayer;
private RuntimeInfo runtimeInfo; private RuntimeInfo runtimeInfo;
@Override
public void initialize(URL url, ResourceBundle resourceBundle) { //Runtime
setVolume(runtimeInfo.getMusicVolume());
}
//Todo Make music play
public void playGameMusic(MusicType musicType) throws IOException { public void playGameMusic(MusicType musicType) throws IOException {
Path pathTypeOfMusic = Paths.get(musicType.getPath()); Path pathTypeOfMusic = Paths.get(musicType.getPath());
List<Path> musicPaths = getFilePathsFromResources(pathTypeOfMusic); List<Path> musicPaths = getFilePathsFromResources(pathTypeOfMusic);
String randomPath = getRandomFilePath(musicPaths); String randomPath = getRandomFilePath(musicPaths);
String resource = convertPathToResourcePath(randomPath); String resource = convertPathToResourcePath(randomPath);
setVolume(runtimeInfo.getMusicVolume());
playMusicLoop(resource); playMusicLoop(resource);
} }
......
...@@ -18,23 +18,23 @@ import java.nio.file.Paths; ...@@ -18,23 +18,23 @@ import java.nio.file.Paths;
import java.util.List; import java.util.List;
import java.util.ResourceBundle; import java.util.ResourceBundle;
public class SoundEffects implements Initializable { public class SoundEffects {
private static final Logger log = LogManager.getLogger(SoundEffects.class); private static final Logger log = LogManager.getLogger(SoundEffects.class);
private int sfxVolume; private int sfxVolume;
private RuntimeInfo runtimeInfo; private RuntimeInfo runtimeInfo;
GameSceneController gameSceneController;
@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
sfxVolume = runtimeInfo.getSfxVolume();
}
public void playSoundEffect() throws IOException, InterruptedException { public void playSoundEffect() throws IOException, InterruptedException {
GameSceneController gameSceneController = new GameSceneController();
MusicPlayer musicPlayer = new MusicPlayer(); MusicPlayer musicPlayer = new MusicPlayer();
InputHandler inputhandler = InputHandler.getInstance(); InputHandler inputhandler = InputHandler.getInstance();
TileManager tileManager = gameSceneController.getTileManager(); TileManager tileManager = gameSceneController.getTileManager();// TODO Find out why tileManager is null
IEntity player = gameSceneController.getPlayer(); log.info(tileManager);
/*IEntity player = gameSceneController.getPlayer();
ITile[] tileSet = tileManager.getTileSet(); ITile[] tileSet = tileManager.getTileSet();
int[][] map = tileManager.getTileMap(); int[][] map = tileManager.getTileMap();
int playerPosX; int playerPosX;
...@@ -54,6 +54,7 @@ public class SoundEffects implements Initializable { ...@@ -54,6 +54,7 @@ public class SoundEffects implements Initializable {
String resource = musicPlayer.convertPathToResourcePath(randomPath); String resource = musicPlayer.convertPathToResourcePath(randomPath);
Thread sfxLoop = new Thread(() -> { Thread sfxLoop = new Thread(() -> {
AudioClip effect = new AudioClip(resource); AudioClip effect = new AudioClip(resource);
effect.setVolume(runtimeInfo.getSfxVolume());
effect.setVolume((double) sfxVolume / 100); //TODO Replace with own Method effect.setVolume((double) sfxVolume / 100); //TODO Replace with own Method
effect.play(); effect.play();
}); });
...@@ -63,7 +64,7 @@ public class SoundEffects implements Initializable { ...@@ -63,7 +64,7 @@ public class SoundEffects implements Initializable {
sfxPaths.clear(); sfxPaths.clear();
} }
} }
*/
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment