Added mark rounding noise and hover button noise.

#story[1249]
This commit is contained in:
Kusal Ekanayake
2017-09-05 14:33:37 +12:00
parent 396098e009
commit 1619c95098
7 changed files with 35 additions and 11 deletions
+20 -3
View File
@@ -19,17 +19,23 @@ public class Sounds {
public static void stopMusic() {
if (musicPlayer != null) {
musicPlayer.stop();
}
}
public static void stopSoundEffects() {
if (soundEffect != null) {
soundEffect.stop();
}
}
public static void toggleMuteMusic() {
musicMuted = !musicMuted;
if (musicPlayer != null) {
musicPlayer.setMute(musicMuted);
}
}
public static void toggleMuteEffects() {
soundEffectsMuted = !soundEffectsMuted;
@@ -83,21 +89,32 @@ public class Sounds {
Media finishSound = new Media(Sounds.class.getClassLoader().getResource("sounds/Sms-notification.mp3").toString());
soundPlayer = new MediaPlayer(finishSound);
soundPlayer.play();
soundPlayer.setMute(soundEffectsMuted);
}
public static void playMarkRoundingSound() {
Media markRoundingSound = new Media(Sounds.class.getClassLoader().getResource("sounds/sms-tone.mp3").toString());
soundPlayer = new MediaPlayer(markRoundingSound);
soundPlayer.play();
}
public static void playCapGunSound() {
Media gunSound = new Media(Sounds.class.getClassLoader().getResource("sounds/Gunshot-sound.mp3").toString());
soundPlayer = new MediaPlayer(gunSound);
soundPlayer.play();
soundPlayer.setMute(soundEffectsMuted);
}
public static void playCrashSound() {
Media crashSound = new Media(Sounds.class.getClassLoader().getResource("sounds/Large-metal-door-slam.mp3").toString());
soundPlayer = new MediaPlayer(crashSound);
soundPlayer.play();
soundPlayer.setMute(soundEffectsMuted);
}
public static void playHoverSound() {
Media hoverSound = new Media(Sounds.class.getClassLoader().getResource("sounds/sound-over.wav").toString());
soundPlayer = new MediaPlayer(hoverSound);
soundPlayer.play();
}
}
@@ -164,7 +164,6 @@ public class GameClient {
// server = null;
// }
Sounds.stopSoundEffects();
Sounds.stopMusic();
Sounds.playMenuMusic();
FXMLLoader fxmlLoader = new FXMLLoader(
@@ -36,6 +36,7 @@ import seng302.model.mark.CompoundMark;
import seng302.model.mark.Corner;
import seng302.model.mark.Mark;
import seng302.utilities.GeoUtility;
import seng302.utilities.Sounds;
import seng302.visualiser.fxObjects.AnnotationBox;
import seng302.visualiser.fxObjects.BoatObject;
import seng302.visualiser.fxObjects.CourseBoundary;
@@ -785,12 +786,14 @@ public class GameView extends Pane {
private void updateMarkArrows (ClientYacht yacht, CompoundMark compoundMark, int legNumber) {
//Only show arrows for this and next leg.
if (compoundMark != null) {
Sounds.playMarkRoundingSound();
for (Mark mark : compoundMark.getMarks()) {
markerObjects.get(mark).showNextExitArrow();
}
}
CompoundMark nextMark = null;
if (legNumber < course.size() - 1) {
Sounds.playMarkRoundingSound();
nextMark = course.get(legNumber);
for (Mark mark : nextMark.getMarks()) {
markerObjects.get(mark).showNextEnterArrow();
@@ -11,6 +11,7 @@ import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TextField;
import javafx.scene.control.ToggleButton;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.GridPane;
import seng302.gameServer.GameState;
@@ -205,4 +206,8 @@ public class StartScreenController implements Initializable {
muteSoundsButton.setText("Mute Sounds");
}
}
public void playButtonHoverSound(MouseEvent mouseEvent) {
Sounds.playHoverSound();
}
}
Binary file not shown.
Binary file not shown.
@@ -25,8 +25,8 @@
<Font size="40.0" />
</font>
</Label>
<Button mnemonicParsing="false" onAction="#hostButtonPressed" prefHeight="25.0" prefWidth="175.0" text="Host" GridPane.columnSpan="2147483647" GridPane.halignment="CENTER" GridPane.rowIndex="2" />
<Button mnemonicParsing="false" onAction="#connectButtonPressed" prefHeight="25.0" prefWidth="147.0" text="Connect" GridPane.columnIndex="1" GridPane.rowIndex="4">
<Button mnemonicParsing="false" onAction="#hostButtonPressed" onMouseEntered="#playButtonHoverSound" prefHeight="25.0" prefWidth="175.0" text="Host" GridPane.columnSpan="2147483647" GridPane.halignment="CENTER" GridPane.rowIndex="2" />
<Button mnemonicParsing="false" onAction="#connectButtonPressed" onMouseEntered="#playButtonHoverSound" prefHeight="25.0" prefWidth="147.0" text="Connect" GridPane.columnIndex="1" GridPane.rowIndex="4">
<GridPane.margin>
<Insets left="5.0" right="5.0" />
</GridPane.margin>
@@ -58,12 +58,12 @@
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<ToggleButton fx:id="muteMusicButton" mnemonicParsing="false" onAction="#toggleMusic" prefWidth="130.0" text="Mute Music" GridPane.halignment="RIGHT">
<ToggleButton fx:id="muteMusicButton" mnemonicParsing="false" onAction="#toggleMusic" onMouseEntered="#playButtonHoverSound" prefWidth="130.0" text="Mute Music" GridPane.halignment="RIGHT">
<GridPane.margin>
<Insets left="5.0" right="5.0" />
</GridPane.margin>
</ToggleButton>
<ToggleButton fx:id="muteSoundsButton" mnemonicParsing="false" onAction="#toggleSounds" prefWidth="130.0" text="Mute Sounds" GridPane.columnIndex="1">
<ToggleButton fx:id="muteSoundsButton" mnemonicParsing="false" onAction="#toggleSounds" onMouseEntered="#playButtonHoverSound" prefWidth="130.0" text="Mute Sounds" GridPane.columnIndex="1">
<GridPane.margin>
<Insets left="5.0" right="5.0" />
</GridPane.margin>