Add sounds

This commit is contained in:
Felix Koppe
2024-11-30 12:37:18 +01:00
parent 36d31e99e9
commit 8c8bd4db0d
14 changed files with 66 additions and 24 deletions

View File

@@ -1,5 +1,6 @@
package pp.mdga.client;
import pp.mdga.client.acoustic.MdgaSound;
import pp.mdga.client.view.CeremonyView;
import pp.mdga.client.view.GameView;
import pp.mdga.client.view.LobbyView;
@@ -71,17 +72,21 @@ public void selectCard(BonusCard card) {
public void confirm() {
LOGGER.log(Level.INFO, "confirm");
GameView gameView = (GameView) app.getView();
if(a != null && b != null) {
//swap
gameView.getBoardHandler().clearSelectable();
} else if (a != null) {
//piece
gameView.getBoardHandler().clearSelectable();
} else if (card != null){
//card
gameView.getGuiHandler().clearSelectableCards();
} else {
throw new RuntimeException("nothing to confirm");
}
GameView gameView = (GameView) app.getView();
gameView.noConfirm();
}
@@ -120,6 +125,7 @@ public void setJoin(String ip, int port) {
public void leave() {
LOGGER.log(Level.INFO, "leave");
app.getAcousticHandler().playSound(MdgaSound.LEAVE);
enter(MdgaState.MAIN);
}
@@ -151,9 +157,9 @@ public void enter(MdgaState state) {
if (state == MdgaState.LOBBY) {
LobbyView lobbyView = (LobbyView) app.getView();
//app.getNotificationSynchronizer().addTestNotification(new TskSelectNotification(Color.CYBER, "blablabupp", false));
//app.getNotificationSynchronizer().addTestNotification(new TskSelectNotification(Color.ARMY, "Spieler 2", false));
lobbyView.setReady(Color.ARMY, true);
app.getNotificationSynchronizer().addTestNotification(new TskSelectNotification(Color.CYBER, "blablabupp", false));
app.getNotificationSynchronizer().addTestNotification(new TskSelectNotification(Color.ARMY, "Spieler 2", false));
lobbyView.setReady(Color.ARMY, false);
}
}
}

View File

@@ -86,10 +86,30 @@ public void playSound(MdgaSound sound) {
assets.add(new SoundAssetDelayVolume(SoundAsset.UI_CLICK, 0.8f, 0.0f));
break;
case START:
assets.add(new SoundAssetDelayVolume(SoundAsset.START, 0.8f, 0.2f));
assets.add(new SoundAssetDelayVolume(SoundAsset.START, 0.8f, 0.5f));
break;
case THROW:
assets.add(new SoundAssetDelayVolume(SoundAsset.LAUGHT, 1.0f, 0.2f));
break;
case POWERUP:
assets.add(new SoundAssetDelayVolume(SoundAsset.POWERUP, 1.0f, 0.2f));
break;
case SELF_READY:
assets.add(new SoundAssetDelayVolume(SoundAsset.ROBOT_READY, 1.0f, 0.0f));
break;
case OTHER_READY:
assets.add(new SoundAssetDelayVolume(SoundAsset.UNIT_READY, 1.0f, 0.0f));
break;
case OTHER_CONNECTED:
assets.add(new SoundAssetDelayVolume(SoundAsset.CONNECTED, 1.0f, 0.0f));
break;
case NOT_READY:
assets.add(new SoundAssetDelayVolume(SoundAsset.UI_SOUND, 1.0f, 0.0f));
break;
case LEAVE:
assets.add(new SoundAssetDelayVolume(SoundAsset.UI_SOUND2, 0.6f, 0.0f));
break;
default:
break;
}

View File

@@ -24,4 +24,11 @@ public enum MdgaSound {
WRONG_INPUT,
UI_CLICK,
START,
THROW,
POWERUP,
SELF_READY,
OTHER_READY,
OTHER_CONNECTED,
NOT_READY,
LEAVE,
}

View File

@@ -19,9 +19,16 @@ enum SoundAsset {
VICTORY("LevelUp2.wav"),
LOST("GameOver.wav"),
BUTTON_PRESS("menu_button.ogg"),
ERROR("error_sound.ogg"),
ERROR("buzzer.wav"),
UI_SOUND("ui_sound.ogg"),
UI_SOUND2("ui_swoosch.wav"),
UI_CLICK("uiclick.ogg"),
START("gamestart.ogg");
START("gamestart.ogg"),
LAUGHT("laughter.wav"),
POWERUP("powerup.wav"),
ROBOT_READY("robotReady.wav"),
UNIT_READY("unitReady.wav"),
CONNECTED("connected.wav");
private final String path;

View File

@@ -10,6 +10,7 @@
import com.jme3.texture.Texture;
import com.jme3.util.SkyFactory;
import pp.mdga.client.MdgaApp;
import pp.mdga.client.acoustic.MdgaSound;
import pp.mdga.client.button.ButtonLeft;
import pp.mdga.client.button.ButtonRight;
import pp.mdga.client.button.LobbyButton;
@@ -140,19 +141,21 @@ public void setTaken(Color color, boolean isTaken, boolean isSelf, String name)
}
public void setReady(Color color, boolean isReady) {
switch (color) {
case CYBER:
cyberButton.setReady(isReady);
break;
case AIRFORCE:
airforceButton.setReady(isReady);
break;
case ARMY:
armyButton.setReady(isReady);
break;
case NAVY:
navyButton.setReady(isReady);
break;
LobbyButton button = switch (color) {
case CYBER -> cyberButton;
case AIRFORCE -> airforceButton;
case ARMY -> armyButton;
case NAVY -> navyButton;
};
button.setReady(isReady);
if(button.getTaken() != LobbyButton.Taken.SELF) {
app.getAcousticHandler().playSound(MdgaSound.OTHER_READY);
}
if(!isReady) {
app.getAcousticHandler().playSound(MdgaSound.NOT_READY);
}
}
@@ -189,11 +192,10 @@ private void toggleTsk(Color color) {
private void ready() {
app.getModelSyncronizer().setReady();
//TODO: playSound
app.getAcousticHandler().playSound(MdgaSound.SELF_READY);
}
private void leaveLobby() {
app.getModelSyncronizer().leave();
//TODO: playSound
}
}

View File

@@ -17,7 +17,7 @@ public class TskSelectNotification extends Notification{
* @param name the name of the player that is in the game.
* @param self true if it was the local player selecting the tsk, false otherwise
*/
TskSelectNotification(Color color, String name, boolean self) {
public TskSelectNotification(Color color, String name, boolean self) {
this.color = color;
this.name = name;
this.self = self;