mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2025-08-07 03:06:29 +02:00
fixing shell
This commit is contained in:
@@ -7,6 +7,10 @@
|
||||
|
||||
package pp.battleship.client;
|
||||
|
||||
import java.lang.System.Logger;
|
||||
import java.lang.System.Logger.Level;
|
||||
import java.util.prefs.Preferences;
|
||||
|
||||
import com.jme3.app.Application;
|
||||
import com.jme3.app.state.AbstractAppState;
|
||||
import com.jme3.app.state.AppStateManager;
|
||||
@@ -14,13 +18,9 @@ import com.jme3.asset.AssetLoadException;
|
||||
import com.jme3.asset.AssetNotFoundException;
|
||||
import com.jme3.audio.AudioData;
|
||||
import com.jme3.audio.AudioNode;
|
||||
|
||||
import pp.battleship.notification.GameEventListener;
|
||||
import pp.battleship.notification.SoundEvent;
|
||||
|
||||
import java.lang.System.Logger;
|
||||
import java.lang.System.Logger.Level;
|
||||
import java.util.prefs.Preferences;
|
||||
|
||||
import static pp.util.PreferencesUtils.getPreferences;
|
||||
|
||||
/**
|
||||
@@ -34,7 +34,6 @@ public class GameSound extends AbstractAppState implements GameEventListener {
|
||||
private AudioNode splashSound;
|
||||
private AudioNode shipDestroyedSound;
|
||||
private AudioNode explosionSound;
|
||||
private AudioNode shellFlyingSound;
|
||||
|
||||
/**
|
||||
* Checks if sound is enabled in the preferences.
|
||||
@@ -79,7 +78,6 @@ public class GameSound extends AbstractAppState implements GameEventListener {
|
||||
shipDestroyedSound = loadSound(app, "Sound/Effects/sunken.wav"); //NON-NLS
|
||||
splashSound = loadSound(app, "Sound/Effects/splash.wav"); //NON-NLS
|
||||
explosionSound = loadSound(app, "Sound/Effects/explosion.wav"); //NON-NLS
|
||||
shellFlyingSound = loadSound(app, "Sound/Effects/shell_flying.wav");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -125,20 +123,6 @@ public class GameSound extends AbstractAppState implements GameEventListener {
|
||||
if (isEnabled() && shipDestroyedSound != null)
|
||||
shipDestroyedSound.playInstance();
|
||||
}
|
||||
/**
|
||||
* Plays the shell flying sound effect.
|
||||
*/
|
||||
public void shellFly() {
|
||||
if (isEnabled() && shellFlyingSound != null) {S
|
||||
shellFlyingSound.playInstance();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles a recieved {@code SoundEvent} and plays the according sound.
|
||||
*
|
||||
* @param event the Sound event to be processed
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void receivedEvent(SoundEvent event) {
|
||||
|
@@ -7,19 +7,19 @@
|
||||
|
||||
package pp.battleship.client.gui;
|
||||
|
||||
import java.lang.System.Logger;
|
||||
import java.lang.System.Logger.Level;
|
||||
|
||||
import com.jme3.input.controls.ActionListener;
|
||||
import com.jme3.math.Vector2f;
|
||||
import com.jme3.scene.Node;
|
||||
import com.jme3.system.AppSettings;
|
||||
import com.simsilica.lemur.Button;
|
||||
import com.simsilica.lemur.Container;
|
||||
import pp.battleship.client.BattleshipAppState;
|
||||
|
||||
import java.lang.System.Logger;
|
||||
import java.lang.System.Logger.Level;
|
||||
|
||||
import static pp.battleship.Resources.lookup;
|
||||
import static pp.battleship.client.BattleshipApp.CLICK;
|
||||
import pp.battleship.client.BattleshipAppState;
|
||||
|
||||
/**
|
||||
* EditorState manages the editor mode in the Battleship game,
|
||||
|
@@ -7,19 +7,20 @@
|
||||
|
||||
package pp.battleship.client.gui;
|
||||
|
||||
import com.jme3.material.Material;
|
||||
import static com.jme3.material.Materials.UNSHADED;
|
||||
import com.jme3.material.RenderState;
|
||||
import com.jme3.material.RenderState.BlendMode;
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.Node;
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.material.RenderState;
|
||||
import com.jme3.material.RenderState.BlendMode;
|
||||
import com.jme3.scene.Spatial;
|
||||
import com.jme3.scene.shape.Sphere;
|
||||
|
||||
import com.jme3.scene.Spatial;
|
||||
import pp.battleship.model.Battleship;
|
||||
import pp.battleship.model.Shell;
|
||||
import pp.battleship.model.Shot;
|
||||
import pp.util.Position;
|
||||
import static com.jme3.material.Materials.UNSHADED;
|
||||
|
||||
/**
|
||||
* Synchronizes the visual representation of the ship map with the game model.
|
||||
@@ -148,6 +149,6 @@ class MapViewSynchronizer extends ShipMapSynchronizer {
|
||||
ellipse.setMaterial(mat);
|
||||
ellipse.addControl(new Shell2DControl(view, shell));
|
||||
return ellipse;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -232,7 +232,7 @@ public class ParticleEffectFactory {
|
||||
ParticleEmitter smokeEmitter = new ParticleEmitter("SmokeEmitter", Type.Triangle, 300);
|
||||
smokeEmitter.setGravity(0, 0, 0);
|
||||
smokeEmitter.getParticleInfluencer().setVelocityVariation(1);
|
||||
smokeEmitter.setLocalTranslation(0, 2f, 0);
|
||||
smokeEmitter.setLocalTranslation(0, 2f, 0); //___________________
|
||||
smokeEmitter.setLowLife(1);
|
||||
smokeEmitter.setHighLife(1);
|
||||
smokeEmitter.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 0, 0));
|
||||
@@ -243,7 +243,7 @@ public class ParticleEffectFactory {
|
||||
|
||||
return smokeEmitter;
|
||||
}
|
||||
public ParticleEmitter createWaterSplash() {
|
||||
public ParticleEmitter createWaterSplash() { //wird durch explosions animation ersetzt
|
||||
// Create a new particle emitter for the splash effect
|
||||
ParticleEmitter waterSplash = new ParticleEmitter("WaterSplash", Type.Triangle, 30);
|
||||
|
||||
|
@@ -26,9 +26,9 @@ import com.jme3.scene.shape.Cylinder;
|
||||
import pp.battleship.client.BattleshipApp;
|
||||
import pp.battleship.model.Battleship;
|
||||
import pp.battleship.model.Rotation;
|
||||
import pp.battleship.model.Shell;
|
||||
import pp.battleship.model.ShipMap;
|
||||
import pp.battleship.model.Shot;
|
||||
import pp.battleship.model.Shell;
|
||||
import static pp.util.FloatMath.HALF_PI;
|
||||
import static pp.util.FloatMath.PI;
|
||||
|
||||
@@ -52,6 +52,7 @@ class SeaSynchronizer extends ShipMapSynchronizer {
|
||||
private static final ColorRGBA BOX_COLOR = ColorRGBA.Gray;
|
||||
private static final ColorRGBA SPLASH_COLOR = new ColorRGBA(0f, 0f, 1f, 0.4f);
|
||||
private static final ColorRGBA HIT_COLOR = new ColorRGBA(1f, 0f, 0f, 0.4f);
|
||||
private static final String LIGHTING = "Common/MatDefs/Light/Lighting.j3md";
|
||||
|
||||
private final ShipMap map;
|
||||
private final BattleshipApp app;
|
||||
|
@@ -4,8 +4,8 @@ import com.jme3.math.Vector3f;
|
||||
import com.jme3.renderer.RenderManager;
|
||||
import com.jme3.renderer.ViewPort;
|
||||
import com.jme3.scene.control.AbstractControl;
|
||||
import pp.battleship.model.Shell;
|
||||
|
||||
import pp.battleship.model.Shell;
|
||||
import static pp.util.FloatMath.PI;
|
||||
|
||||
/**
|
||||
|
@@ -1,4 +1,4 @@
|
||||
///////////////////////////////////////
|
||||
////////////////////////////////////////
|
||||
// Programming project code
|
||||
// UniBw M, 2022, 2023, 2024
|
||||
// www.unibw.de/inf2
|
||||
@@ -28,6 +28,7 @@ import pp.battleship.BattleshipConfig;
|
||||
import pp.battleship.game.server.Player;
|
||||
import pp.battleship.game.server.ServerGameLogic;
|
||||
import pp.battleship.game.server.ServerSender;
|
||||
import pp.battleship.message.client.AnimationFinishedMessage;
|
||||
import pp.battleship.message.client.ClientMessage;
|
||||
import pp.battleship.message.client.MapMessage;
|
||||
import pp.battleship.message.client.ShootMessage;
|
||||
@@ -64,7 +65,7 @@ public class BattleshipSelfhostServer implements MessageListener<HostedConnectio
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the server.
|
||||
* Starts the Battleships server.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
new BattleshipSelfhostServer().run();
|
||||
@@ -119,12 +120,14 @@ public class BattleshipSelfhostServer implements MessageListener<HostedConnectio
|
||||
Serializer.registerClass(Battleship.class);
|
||||
Serializer.registerClass(IntPoint.class);
|
||||
Serializer.registerClass(Shot.class);
|
||||
Serializer.registerClass(AnimationFinishedMessage.class);
|
||||
}
|
||||
|
||||
private void registerListeners() {
|
||||
myServer.addMessageListener(this, MapMessage.class);
|
||||
myServer.addMessageListener(this, ShootMessage.class);
|
||||
myServer.addConnectionListener(this);
|
||||
myServer.addMessageListener(this, AnimationFinishedMessage.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -177,4 +180,4 @@ public class BattleshipSelfhostServer implements MessageListener<HostedConnectio
|
||||
else
|
||||
LOGGER.log(Level.ERROR, "there is no connection with id={0}", id); //NON-NLS
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,4 +1,3 @@
|
||||
|
||||
////////////////////////////////////////
|
||||
// Programming project code
|
||||
// UniBw M, 2022, 2023, 2024
|
||||
@@ -15,4 +14,4 @@ record ReceivedMessageSelfhost(ClientMessage message, int from) {
|
||||
void process(ClientInterpreter interpreter) {
|
||||
message.accept(interpreter, from);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user