fixed bug when playing rocket audio to not produce an AudioRender error

This commit is contained in:
Fleischer Hanno hanno.fleischer@unibw.de
2024-10-13 11:53:24 +02:00
parent 9e591e37c3
commit f8e97266d5
3 changed files with 9 additions and 16 deletions

View File

@@ -1,6 +1,5 @@
package pp.battleship.game.client;
import pp.battleship.message.client.AnimationEndMessage;
import pp.battleship.message.server.EffectMessage;
import pp.battleship.message.server.SwitchBattleState;
import pp.battleship.model.IntPoint;
@@ -9,7 +8,7 @@
import pp.battleship.notification.Music;
import pp.battleship.notification.Sound;
public class AnimatonState extends ClientState {
public class AnimationState extends ClientState {
private boolean myTurn;
/**
@@ -19,15 +18,15 @@ public class AnimatonState extends ClientState {
* @param myTurn a boolean containing if it is the clients turn
* @param position the position a shell should be created
*/
public AnimatonState(ClientGameLogic logic, boolean myTurn, IntPoint position) {
public AnimationState(ClientGameLogic logic, boolean myTurn, IntPoint position) {
super(logic);
logic.playMusic(Music.BATTLE_THEME);
logic.playSound(Sound.ROCKET_FIRED);
this.myTurn = myTurn;
if(myTurn) {
logic.getOpponentMap().add(new Shell(position));
}else {
logic.getOwnMap().add(new Shell(position));
logic.playSound(Sound.ROCKET_FIRED);
}
}

View File

@@ -9,13 +9,8 @@
import pp.battleship.message.client.ShootMessage;
import pp.battleship.message.server.AnimationStartMessage;
import pp.battleship.message.server.EffectMessage;
import pp.battleship.model.IntPoint;
import pp.battleship.model.ShipMap;
import pp.battleship.notification.Music;
import pp.battleship.notification.Sound;
import java.lang.System.Logger.Level;
/**
* Represents the state of the client where players take turns to attack each other's ships.
@@ -55,6 +50,6 @@ else if (logic.getOpponentMap().isValid(pos))
@Override
public void receivedAnimationStart(AnimationStartMessage msg){
logic.setState(new AnimatonState(logic, msg.isMyTurn(), msg.getPosition()));
logic.setState(new AnimationState(logic, msg.isMyTurn(), msg.getPosition()));
}
}