37 Commits

Author SHA1 Message Date
Filip Szepielewicz
f1d52c445b Tests bis T075 überarbeitet 2024-11-22 21:45:22 +01:00
Filip Szepielewicz
30e4298f88 Merge remote-tracking branch 'origin/Testhandbuch' into Testhandbuch 2024-11-17 20:38:30 +01:00
Filip Szepielewicz
7a9e84f49c Tests bis T071 erweitert 2024-11-17 20:06:47 +01:00
Filip Szepielewicz
7fce07ac19 Tests bis T070 erweitert 2024-11-17 20:00:05 +01:00
Johannes Schmelz
2496ad812a Merge branch 'main' into 'Testhandbuch'
# Conflicts:
#   Projekte/monopoly/model/src/test/java/pp/monopoly/Testhandbuch.java
2024-11-17 18:27:54 +00:00
Johannes Schmelz
2f6d6037de Merge branch 'logic' into 'main'
Serverseitige Logik

See merge request progproj/gruppen-ht24/Gruppe-02!6
2024-11-17 18:25:32 +00:00
Johannes Schmelz
1d69bcc814 refactor and bug fixes 2024-11-17 17:43:05 +01:00
Johannes Schmelz
62c363068b fixed bug with client server messages 2024-11-16 18:57:52 +01:00
Johannes Schmelz
d2e0b8187b implemented PlayerStates 2024-11-16 18:42:05 +01:00
Johannes Schmelz
628b98af9b recive logic for messages 2024-11-16 18:03:19 +01:00
Johannes Schmelz
627e3dbd7f added fine to FineField 2024-11-16 17:53:07 +01:00
Filip Szepielewicz
f4fb04d17e T001 - T037 überarbeitet 2024-11-15 19:46:26 +01:00
Filip Szepielewicz
1b4fee2853 T001 - T034 erster versuch 2024-11-15 08:42:56 +01:00
Filip Szepielewicz
b65f458302 T001 - T034 erster versuch 2024-11-15 08:42:11 +01:00
Johannes Schmelz
10b978debf fixed addPlayer 2024-11-15 04:27:32 +01:00
Johannes Schmelz
3bdfd6a78a TradeHandler logic 2024-11-15 03:19:48 +01:00
Johannes Schmelz
e59ab4a320 cleintmessages logic 2024-11-15 03:06:07 +01:00
Johannes Schmelz
7a2ad1d31a corrected server states 2024-11-14 23:50:18 +01:00
Johannes Schmelz
c5ad476eaf added rent payment logic
added player on field logic
2024-11-14 23:50:06 +01:00
Filip Szepielewicz
c792a8b3fb T001 - T034 erster versuch 2024-11-14 21:58:47 +01:00
Filip Szepielewicz
12978ff410 T001 - T034 erster versuch 2024-11-14 21:54:27 +01:00
Johannes Schmelz
232e3a117c corrected rent prices 2024-11-14 01:08:22 +01:00
Johannes Schmelz
3668382911 FineField in Player 2024-11-13 23:50:06 +01:00
Johannes Schmelz
fafa53ffb7 rent calculation 2024-11-13 23:49:37 +01:00
Johannes Schmelz
44673fd57e createBoard method 2024-11-13 23:30:04 +01:00
Johannes Schmelz
f7149f225c Interpreter fuer messages hinzugefuegt 2024-11-13 18:54:24 +01:00
Johannes Schmelz
6773e18d34 Message Klassen hinzugefuegt 2024-11-13 14:11:20 +01:00
Johannes Schmelz
19a9b06f3c Merge branch 'gui' into 'main'
First compileable version of Client

See merge request progproj/gruppen-ht24/Gruppe-02!4
2024-11-13 12:42:37 +00:00
Johannes Schmelz
7ee2273761 First compileable version of Client 2024-11-13 12:42:37 +00:00
Johannes Schmelz
2cc1a338ec added Figure to Player for visual representation 2024-11-12 22:36:02 +01:00
Johannes Schmelz
81731247c7 added Fields 2024-11-12 22:35:41 +01:00
Johannes Schmelz
65c85aacf0 started UC-gameplay-15 2024-11-12 22:34:46 +01:00
Johannes Schmelz
dca23151a8 added Visitors 2024-11-12 22:33:10 +01:00
Johannes Schmelz
25305760c5 added Player 2024-11-12 22:32:55 +01:00
Johannes Schmelz
29a56f42a8 Merge branch 'main' of https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02 2024-11-12 14:53:08 +01:00
Johannes Schmelz
3784348f91 init for monopoly 2024-11-12 14:53:04 +01:00
Johannes Schmelz
188ec03abd working version of battleship 2024-11-12 00:37:05 +01:00
260 changed files with 572909 additions and 407871 deletions

View File

@@ -9,6 +9,7 @@ dependencies {
implementation project(":battleship:model") implementation project(":battleship:model")
implementation libs.jme3.desktop implementation libs.jme3.desktop
implementation libs.jme3.effects
runtimeOnly libs.jme3.awt.dialogs runtimeOnly libs.jme3.awt.dialogs
runtimeOnly libs.jme3.plugins runtimeOnly libs.jme3.plugins

View File

@@ -9,7 +9,7 @@
# #
# Specifies the map used by the opponent in single mode. # Specifies the map used by the opponent in single mode.
# Single mode is activated if this property is set. # Single mode is activated if this property is set.
map.opponent=maps/map2.json #map.opponent=maps/map2.json
# #
# Specifies the map used by the player in single mode. # Specifies the map used by the player in single mode.
# The player must define their own map if this property is not set. # The player must define their own map if this property is not set.

View File

@@ -1,66 +0,0 @@
{
"width": 10,
"height": 10,
"ships": [
{
"length": 4,
"x": 15,
"y": 5,
"rot": "DOWN"
},
{
"length": 3,
"x": 0,
"y": 9,
"rot": "DOWN"
},
{
"length": 3,
"x": 2,
"y": 6,
"rot": "RIGHT"
},
{
"length": 2,
"x": 4,
"y": 8,
"rot": "RIGHT"
},
{
"length": 2,
"x": 2,
"y": 4,
"rot": "DOWN"
},
{
"length": 2,
"x": 2,
"y": 1,
"rot": "DOWN"
},
{
"length": 1,
"x": 6,
"y": 2,
"rot": "RIGHT"
},
{
"length": 1,
"x": 8,
"y": 2,
"rot": "RIGHT"
},
{
"length": 1,
"x": 6,
"y": 0,
"rot": "RIGHT"
},
{
"length": 1,
"x": 8,
"y": 0,
"rot": "RIGHT"
}
]
}

View File

@@ -1,66 +0,0 @@
{
"width": 10,
"height": 10,
"ships": [
{
"length": 4,
"x": 0,
"y": 5,
"rot": "DOWN"
},
{
"length": 3,
"x": 0,
"y": 9,
"rot": "DOWN"
},
{
"length": 3,
"x": 2,
"y": 6,
"rot": "RIGHT"
},
{
"length": 2,
"x": 0,
"y": 8,
"rot": "RIGHT"
},
{
"length": 2,
"x": 2,
"y": 4,
"rot": "DOWN"
},
{
"length": 2,
"x": 2,
"y": 1,
"rot": "DOWN"
},
{
"length": 1,
"x": 6,
"y": 2,
"rot": "RIGHT"
},
{
"length": 1,
"x": 8,
"y": 2,
"rot": "RIGHT"
},
{
"length": 1,
"x": 6,
"y": 0,
"rot": "RIGHT"
},
{
"length": 1,
"x": 8,
"y": 0,
"rot": "RIGHT"
}
]
}

View File

@@ -1,66 +0,0 @@
{
"width": 10,
"height": 10,
"ships": [
{
"length": 4,
"x": 0,
"y": 5,
"rot": "DOWN"
},
{
"length": 3,
"x": 0,
"y": 9,
"rot": "DOWN"
},
{
"length": 3,
"x": 0,
"y": 6,
"rot": "RIGHT"
},
{
"length": 2,
"x": 4,
"y": 8,
"rot": "RIGHT"
},
{
"length": 2,
"x": 2,
"y": 4,
"rot": "DOWN"
},
{
"length": 2,
"x": 2,
"y": 1,
"rot": "DOWN"
},
{
"length": 1,
"x": 6,
"y": 2,
"rot": "RIGHT"
},
{
"length": 1,
"x": 8,
"y": 2,
"rot": "RIGHT"
},
{
"length": 1,
"x": 6,
"y": 0,
"rot": "RIGHT"
},
{
"length": 1,
"x": 8,
"y": 0,
"rot": "RIGHT"
}
]
}

View File

@@ -1,60 +0,0 @@
{
"width": 10,
"height": 10,
"ships": [
{
"length": 3,
"x": 0,
"y": 9,
"rot": "DOWN"
},
{
"length": 3,
"x": 2,
"y": 6,
"rot": "RIGHT"
},
{
"length": 2,
"x": 4,
"y": 8,
"rot": "RIGHT"
},
{
"length": 2,
"x": 2,
"y": 4,
"rot": "DOWN"
},
{
"length": 2,
"x": 2,
"y": 1,
"rot": "DOWN"
},
{
"length": 1,
"x": 6,
"y": 2,
"rot": "RIGHT"
},
{
"length": 1,
"x": 8,
"y": 2,
"rot": "RIGHT"
},
{
"length": 1,
"x": 6,
"y": 0,
"rot": "RIGHT"
},
{
"length": 1,
"x": 8,
"y": 0,
"rot": "RIGHT"
}
]
}

View File

@@ -1,66 +0,0 @@
{
"width": 10,
"height": 10,
"ships": [
{
"length": 4,
"x": 0,
"y": 9,
"rot": "RIGHT"
},
{
"length": 3,
"x": 4,
"y": 9,
"rot": "RIGHT"
},
{
"length": 3,
"x": 7,
"y": 9,
"rot": "RIGHT"
},
{
"length": 2,
"x": 0,
"y": 8,
"rot": "RIGHT"
},
{
"length": 2,
"x": 2,
"y": 8,
"rot": "RIGHT"
},
{
"length": 2,
"x": 4,
"y": 8,
"rot": "RIGHT"
},
{
"length": 1,
"x": 6,
"y": 8,
"rot": "RIGHT"
},
{
"length": 1,
"x": 7,
"y": 8,
"rot": "RIGHT"
},
{
"length": 1,
"x": 8,
"y": 8,
"rot": "RIGHT"
},
{
"length": 1,
"x": 9,
"y": 8,
"rot": "RIGHT"
}
]
}

View File

@@ -1,66 +0,0 @@
{
"width": 10,
"height": 10,
"ships": [
{
"length": 4,
"x": 0,
"y": 9,
"rot": "RIGHT"
},
{
"length": 3,
"x": 0,
"y": 8,
"rot": "RIGHT"
},
{
"length": 3,
"x": 0,
"y": 7,
"rot": "RIGHT"
},
{
"length": 2,
"x": 0,
"y": 6,
"rot": "RIGHT"
},
{
"length": 2,
"x": 0,
"y": 5,
"rot": "RIGHT"
},
{
"length": 2,
"x": 0,
"y": 4,
"rot": "RIGHT"
},
{
"length": 1,
"x": 0,
"y": 3,
"rot": "RIGHT"
},
{
"length": 1,
"x": 0,
"y": 2,
"rot": "RIGHT"
},
{
"length": 1,
"x": 0,
"y": 1,
"rot": "RIGHT"
},
{
"length": 1,
"x": 0,
"y": 0,
"rot": "RIGHT"
}
]
}

View File

@@ -22,6 +22,7 @@ import com.simsilica.lemur.GuiGlobals;
import com.simsilica.lemur.style.BaseStyles; import com.simsilica.lemur.style.BaseStyles;
import pp.battleship.client.gui.BattleAppState; import pp.battleship.client.gui.BattleAppState;
import pp.battleship.client.gui.EditorAppState; import pp.battleship.client.gui.EditorAppState;
import pp.battleship.client.gui.GameMusic;
import pp.battleship.client.gui.SeaAppState; import pp.battleship.client.gui.SeaAppState;
import pp.battleship.game.client.BattleshipClient; import pp.battleship.game.client.BattleshipClient;
import pp.battleship.game.client.ClientGameLogic; import pp.battleship.game.client.ClientGameLogic;
@@ -282,15 +283,14 @@ public class BattleshipApp extends SimpleApplication implements BattleshipClient
} }
/** /**
* Attaches the music state and sets its initial enabled state. * Attaches the background music state and sets its initial enabled state.
*/ */
private void attachGameMusic() { private void attachGameMusic() {
final GameMusic gameMusic = new GameMusic(); final GameMusic gameSound = new GameMusic();
gameMusic.setEnabled(GameMusic.enabledInPreferences()); gameSound.setEnabled(GameMusic.enabledInPreferences());
stateManager.attach(gameMusic); stateManager.attach(gameSound);
} }
/** /**
* Updates the application state every frame. * Updates the application state every frame.
* This method is called once per frame during the game loop. * This method is called once per frame during the game loop.

View File

@@ -80,7 +80,6 @@ public class GameSound extends AbstractAppState implements GameEventListener {
splashSound = loadSound(app, "Sound/Effects/splash.wav"); //NON-NLS splashSound = loadSound(app, "Sound/Effects/splash.wav"); //NON-NLS
explosionSound = loadSound(app, "Sound/Effects/explosion.wav"); //NON-NLS explosionSound = loadSound(app, "Sound/Effects/explosion.wav"); //NON-NLS
shellFlyingSound = loadSound(app, "Sound/Effects/shell_flying.wav"); shellFlyingSound = loadSound(app, "Sound/Effects/shell_flying.wav");
} }
/** /**
@@ -148,7 +147,6 @@ public class GameSound extends AbstractAppState implements GameEventListener {
case SPLASH -> splash(); case SPLASH -> splash();
case DESTROYED_SHIP -> shipDestroyed(); case DESTROYED_SHIP -> shipDestroyed();
case SHELL_FLYING -> shellFly(); case SHELL_FLYING -> shellFly();
} }
} }
} }

View File

@@ -7,22 +7,21 @@
package pp.battleship.client; package pp.battleship.client;
import com.simsilica.lemur.Button;
import com.simsilica.lemur.Checkbox;
import com.simsilica.lemur.Label;
import com.simsilica.lemur.style.ElementId;
import pp.dialog.Dialog;
import pp.dialog.StateCheckboxModel;
import pp.dialog.TextInputDialog;
import pp.battleship.client.GameMusic;
import pp.battleship.client.VolumeSlider;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.prefs.Preferences; import java.util.prefs.Preferences;
import com.simsilica.lemur.Button;
import com.simsilica.lemur.Checkbox;
import com.simsilica.lemur.Label;
import com.simsilica.lemur.style.ElementId;
import static pp.battleship.Resources.lookup; import static pp.battleship.Resources.lookup;
import pp.battleship.client.gui.GameMusic;
import pp.battleship.client.gui.VolumeSlider;
import pp.dialog.Dialog;
import pp.dialog.StateCheckboxModel;
import pp.dialog.TextInputDialog;
import static pp.util.PreferencesUtils.getPreferences; import static pp.util.PreferencesUtils.getPreferences;
/** /**
@@ -39,7 +38,7 @@ class Menu extends Dialog {
private final VolumeSlider slider; private final VolumeSlider slider;
/** /**
* Constructs the Menu dialog for the Battleship application. * Constructs the Menu dialog for the Battleship application.+
* *
* @param app the BattleshipApp instance * @param app the BattleshipApp instance
*/ */
@@ -54,14 +53,11 @@ class Menu extends Dialog {
addChild(slider); addChild(slider);
addChild(loadButton) addChild(loadButton).addClickCommands(s -> ifTopDialog(this::loadDialog));
.addClickCommands(s -> ifTopDialog(this::loadDialog)); addChild(saveButton).addClickCommands(s -> ifTopDialog(this::saveDialog));
addChild(saveButton) addChild(new Button(lookup("menu.return-to-game"))).addClickCommands(s -> ifTopDialog(this::close));
.addClickCommands(s -> ifTopDialog(this::saveDialog)); addChild(new Button(lookup("menu.quit"))).addClickCommands(s -> ifTopDialog(app::closeApp));
addChild(new Button(lookup("menu.return-to-game")))
.addClickCommands(s -> ifTopDialog(this::close));
addChild(new Button(lookup("menu.quit")))
.addClickCommands(s -> ifTopDialog(app::closeApp));
update(); update();
} }
@@ -74,6 +70,11 @@ class Menu extends Dialog {
saveButton.setEnabled(app.getGameLogic().maySaveMap()); saveButton.setEnabled(app.getGameLogic().maySaveMap());
} }
@Override
public void update(float delta) {
slider.update();
}
/** /**
* As an escape action, this method closes the menu if it is the top dialog. * As an escape action, this method closes the menu if it is the top dialog.
*/ */
@@ -149,13 +150,4 @@ class Menu extends Dialog {
private void saveDialog() { private void saveDialog() {
fileDialog(app.getGameLogic()::saveMap, lookup("menu.map.save")); fileDialog(app.getGameLogic()::saveMap, lookup("menu.map.save"));
} }
/**
* Updates the position of the volume control slider.
*/
@Override
public void update(float delta) {
slider.update();
}
} }

View File

@@ -12,6 +12,7 @@ import com.simsilica.lemur.Container;
import com.simsilica.lemur.Label; import com.simsilica.lemur.Label;
import com.simsilica.lemur.TextField; import com.simsilica.lemur.TextField;
import com.simsilica.lemur.component.SpringGridLayout; import com.simsilica.lemur.component.SpringGridLayout;
import pp.battleship.server.BattleshipServer; import pp.battleship.server.BattleshipServer;
import pp.dialog.Dialog; import pp.dialog.Dialog;
import pp.dialog.DialogBuilder; import pp.dialog.DialogBuilder;

View File

@@ -1,4 +1,4 @@
package pp.battleship.client; package pp.battleship.client.gui;
import static pp.util.PreferencesUtils.getPreferences; import static pp.util.PreferencesUtils.getPreferences;
@@ -14,6 +14,9 @@ import com.jme3.asset.AssetNotFoundException;
import com.jme3.audio.AudioData; import com.jme3.audio.AudioData;
import com.jme3.audio.AudioNode; import com.jme3.audio.AudioNode;
/**
* Handles the background music beeing played. Is able to start and stop the music. Set the Volume of the Audio.
*/
public class GameMusic extends AbstractAppState{ public class GameMusic extends AbstractAppState{
private static final Logger LOGGER = System.getLogger(GameMusic.class.getName()); private static final Logger LOGGER = System.getLogger(GameMusic.class.getName());
private static final Preferences PREFERENCES = getPreferences(GameMusic.class); private static final Preferences PREFERENCES = getPreferences(GameMusic.class);
@@ -34,7 +37,7 @@ public class GameMusic extends AbstractAppState{
/** /**
* Checks if sound is enabled in the preferences. * Checks if sound is enabled in the preferences.
* *
* * @return float to which the volume is set
*/ */
public static float volumeInPreferences() { public static float volumeInPreferences() {
return PREFERENCES.getFloat(VOLUME_PREF, 0.5f); return PREFERENCES.getFloat(VOLUME_PREF, 0.5f);
@@ -50,7 +53,7 @@ public class GameMusic extends AbstractAppState{
@Override @Override
public void initialize(AppStateManager stateManager, Application app) { public void initialize(AppStateManager stateManager, Application app) {
super.initialize(stateManager, app); super.initialize(stateManager, app);
music = loadSound(app, "Sound/DasBootMenu.ogg"); music = loadSound(app, "Sound/background.ogg");
setVolume(volumeInPreferences()); setVolume(volumeInPreferences());
music.setLooping(true); music.setLooping(true);
if (isEnabled() && music != null) { if (isEnabled() && music != null) {
@@ -87,11 +90,15 @@ public class GameMusic extends AbstractAppState{
@Override @Override
public void setEnabled(boolean enabled) { public void setEnabled(boolean enabled) {
if (isEnabled() == enabled) return; if (isEnabled() == enabled) return;
else if(!isEnabled() && enabled) {
if (music != null) music.play(); if (music != null) {
} else if (isEnabled() && !enabled) { if (enabled) {
if (music != null) music.stop(); music.play();
} else {
music.stop();
} }
}
super.setEnabled(enabled); super.setEnabled(enabled);
LOGGER.log(Level.INFO, "Sound enabled: {0}", enabled); //NON-NLS LOGGER.log(Level.INFO, "Sound enabled: {0}", enabled); //NON-NLS
PREFERENCES.putBoolean(ENABLED_PREF, enabled); PREFERENCES.putBoolean(ENABLED_PREF, enabled);
@@ -104,6 +111,10 @@ public class GameMusic extends AbstractAppState{
setEnabled(!isEnabled()); setEnabled(!isEnabled());
} }
/**
* Sets the volume of music
* @param vol the volume to which the music should be set
*/
public void setVolume(float vol){ public void setVolume(float vol){
music.setVolume(vol); music.setVolume(vol);
PREFERENCES.putFloat(VOLUME_PREF, vol); PREFERENCES.putFloat(VOLUME_PREF, vol);

View File

@@ -15,10 +15,12 @@ import com.jme3.scene.Geometry;
import com.jme3.scene.Node; import com.jme3.scene.Node;
import com.jme3.scene.Spatial; import com.jme3.scene.Spatial;
import com.jme3.scene.shape.Sphere; import com.jme3.scene.shape.Sphere;
import pp.battleship.model.Battleship; import pp.battleship.model.Battleship;
import pp.battleship.model.Shell; import pp.battleship.model.Shell;
import pp.battleship.model.Shot; import pp.battleship.model.Shot;
import pp.util.Position; import pp.util.Position;
import static com.jme3.material.Materials.UNSHADED; import static com.jme3.material.Materials.UNSHADED;
@@ -149,5 +151,4 @@ class MapViewSynchronizer extends ShipMapSynchronizer {
ellipse.addControl(new Shell2DControl(view, shell)); ellipse.addControl(new Shell2DControl(view, shell));
return ellipse; return ellipse;
} }
} }

View File

@@ -7,10 +7,13 @@ import com.jme3.material.Material;
import com.jme3.math.ColorRGBA; import com.jme3.math.ColorRGBA;
import com.jme3.math.FastMath; import com.jme3.math.FastMath;
import com.jme3.math.Vector3f; import com.jme3.math.Vector3f;
import pp.battleship.client.BattleshipApp; import pp.battleship.client.BattleshipApp;
public class ParticleCreator { /**
* Factory class responsible for creating particle effects used in the game.
* This centralizes the creation of various types of particle emitters.
*/
public class ParticleEffectFactory {
private static final int COUNT_FACTOR = 1; private static final int COUNT_FACTOR = 1;
private static final float COUNT_FACTOR_F = 1f; private static final float COUNT_FACTOR_F = 1f;
private static final boolean POINT_SPRITE = true; private static final boolean POINT_SPRITE = true;
@@ -18,7 +21,7 @@ public class ParticleCreator {
private final BattleshipApp app; private final BattleshipApp app;
ParticleCreator(BattleshipApp app) { ParticleEffectFactory(BattleshipApp app) {
this.app = app; this.app = app;
} }
@@ -27,8 +30,7 @@ public class ParticleCreator {
* *
* @return a configured flame particle emitter * @return a configured flame particle emitter
*/ */
ParticleEmitter createFlame() {
ParticleEmitter createFlame(){
ParticleEmitter flame = new ParticleEmitter("Flame", EMITTER_TYPE, 32 * COUNT_FACTOR); ParticleEmitter flame = new ParticleEmitter("Flame", EMITTER_TYPE, 32 * COUNT_FACTOR);
flame.setSelectRandomImage(true); flame.setSelectRandomImage(true);
flame.setStartColor(new ColorRGBA(1f, 0.4f, 0.05f, (1f / COUNT_FACTOR_F))); flame.setStartColor(new ColorRGBA(1f, 0.4f, 0.05f, (1f / COUNT_FACTOR_F)));
@@ -123,9 +125,9 @@ public class ParticleCreator {
spark.setFacingVelocity(true); spark.setFacingVelocity(true);
spark.setParticlesPerSec(0); spark.setParticlesPerSec(0);
spark.setGravity(0, 5, 0); spark.setGravity(0, 5, 0);
spark.setLowLife(0.5f); spark.setLowLife(1.1f);
spark.setHighLife(1.5f); spark.setHighLife(1.5f);
spark.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 8, 0)); // y20 spark.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 20, 0));
spark.getParticleInfluencer().setVelocityVariation(1); spark.getParticleInfluencer().setVelocityVariation(1);
spark.setImagesX(1); spark.setImagesX(1);
spark.setImagesY(1); spark.setImagesY(1);
@@ -280,5 +282,4 @@ public class ParticleCreator {
return waterSplash; return waterSplash;
} }
} }

View File

@@ -37,9 +37,9 @@ import static pp.util.FloatMath.PI;
class SeaSynchronizer extends ShipMapSynchronizer { class SeaSynchronizer extends ShipMapSynchronizer {
private static final String UNSHADED = "Common/MatDefs/Misc/Unshaded.j3md"; //NON-NLS private static final String UNSHADED = "Common/MatDefs/Misc/Unshaded.j3md"; //NON-NLS
private static final String KING_GEORGE_V_MODEL = "Models/KingGeorgeV/KingGeorgeV.j3o"; //NON-NLS private static final String KING_GEORGE_V_MODEL = "Models/KingGeorgeV/KingGeorgeV.j3o"; //NON-NLS
private static final String SMALL_SHIP_MODEL = "Models/SmallShip/SmallShip.j3o"; //NON-NLS private static final String BOAT_SMALL_MODEL = "Models/BoatSmall/12219_boat_v2_L2.j3o"; //NON-NLS
private static final String U_BOAT_MODEL = "Models/WWII_ship_German_Type_II_U-boat_v2/WW2Uboat.j3o"; //NON-NLS private static final String CV_MODEL = "Models/CV/CV.j3o"; //NON-NLS
private static final String TUG_BOAT_MODEL = "Models/TugBoat/TugBoat.j3o"; //NON-NLS private static final String BATTLE_MODEL = "Models/Battle/Battle.j3o"; //NON-NLS
private static final String LIGHTING = "Common/MatDefs/Light/Lighting.j3md"; private static final String LIGHTING = "Common/MatDefs/Light/Lighting.j3md";
private static final String COLOR = "Color"; //NON-NLS private static final String COLOR = "Color"; //NON-NLS
private static final String SHIP = "ship"; //NON-NLS private static final String SHIP = "ship"; //NON-NLS
@@ -50,8 +50,7 @@ class SeaSynchronizer extends ShipMapSynchronizer {
private final ShipMap map; private final ShipMap map;
private final BattleshipApp app; private final BattleshipApp app;
private final ParticleCreator particlecreator; private final ParticleEffectFactory particleFactory;
/** /**
* Constructs a {@code SeaSynchronizer} object with the specified application, root node, and ship map. * Constructs a {@code SeaSynchronizer} object with the specified application, root node, and ship map.
@@ -64,7 +63,7 @@ class SeaSynchronizer extends ShipMapSynchronizer {
super(app.getGameLogic().getOwnMap(), root); super(app.getGameLogic().getOwnMap(), root);
this.app = app; this.app = app;
this.map = map; this.map = map;
this.particlecreator = new ParticleCreator(app); this.particleFactory = new ParticleEffectFactory(app);
addExisting(); addExisting();
} }
@@ -91,7 +90,7 @@ class SeaSynchronizer extends ShipMapSynchronizer {
Node shotNode = new Node("ShotNode"); Node shotNode = new Node("ShotNode");
Geometry shotCylinder = createCylinder(shot); Geometry shotCylinder = createCylinder(shot);
shotNode.attachChild(shotCylinder); shotNode.attachChild(shotCylinder);
ParticleEmitter waterSplash = particlecreator.createWaterSplash(); ParticleEmitter waterSplash = particleFactory.createWaterSplash();
waterSplash.setLocalTranslation(shot.getY() + 0.5f, 0f, shot.getX() + 0.5f); waterSplash.setLocalTranslation(shot.getY() + 0.5f, 0f, shot.getX() + 0.5f);
shotNode.attachChild(waterSplash); shotNode.attachChild(waterSplash);
waterSplash.emitAllParticles(); waterSplash.emitAllParticles();
@@ -104,46 +103,45 @@ class SeaSynchronizer extends ShipMapSynchronizer {
* @param ship the ship to be sunk * @param ship the ship to be sunk
*/ */
private void sinkAndRemoveShip(Battleship ship) { private void sinkAndRemoveShip(Battleship ship) {
Battleship dasIstGelebteTeamarbeit = ship; Battleship wilkeningklaunichtmeinencode = ship;
final Node shipNode = (Node) getSpatial(dasIstGelebteTeamarbeit); final Node shipNode = (Node) getSpatial(wilkeningklaunichtmeinencode);
if (shipNode == null) return; if (shipNode == null) return;
// Add sinking control to animate the sinking // Add sinking control to animate the sinking
shipNode.addControl(new SinkControl(shipNode)); shipNode.addControl(new SinkingControl(shipNode));
// Add particle effects // Add particle effects
ParticleEmitter bubbles = particlecreator.createWaterSplash(); ParticleEmitter bubbles = particleFactory.createWaterSplash();
bubbles.setLocalTranslation(shipNode.getLocalTranslation()); bubbles.setLocalTranslation(shipNode.getLocalTranslation());
shipNode.attachChild(bubbles); shipNode.attachChild(bubbles);
bubbles.emitAllParticles(); bubbles.emitAllParticles();
} }
/** /**
* Handles a hit by attaching its representation to the node that * Handles a hit by attaching its representation to the node that
* contains the ship model as a child so that it moves with the ship. * contains the ship model as a child so that it moves with the ship.
* *
* @param shot a hit * @param shot a hit
* @return always null to prevent the representation from being attached * @return always null to prevent the representation from being attached to the items node as well
* to the items node as well
*/ */
private Spatial handleHit(Shot shot) { private Spatial handleHit(Shot shot) {
final Battleship ship = requireNonNull(map.findShipAt(shot), "Missing ship"); final Battleship ship = requireNonNull(map.findShipAt(shot), "Missing ship");
final Node shipNode = requireNonNull((Node) getSpatial(ship), "Missing ship node"); final Node shipNode = requireNonNull((Node) getSpatial(ship), "Missing ship node");
// Create a new node specifically for the hit effects // Create a new node specifically for the hit effects
Node hitEffectNode = new Node("HitEffectNode"); Node hitEffectNode = new Node("HitEffectNode");
// Create particle effects // Create particle effects
ParticleEmitter flame = particlecreator.createFlame(); ParticleEmitter flame = particleFactory.createFlame();
ParticleEmitter flash = particlecreator.createFlash(); ParticleEmitter flash = particleFactory.createFlash();
ParticleEmitter spark = particlecreator.createSpark(); ParticleEmitter spark = particleFactory.createSpark();
ParticleEmitter roundSpark = particlecreator.createRoundSpark(); ParticleEmitter roundSpark = particleFactory.createRoundSpark();
ParticleEmitter smokeTrail = particlecreator.createSmokeTrail(); ParticleEmitter smokeTrail = particleFactory.createSmokeTrail();
ParticleEmitter debris = particlecreator.createDebris(); ParticleEmitter debris = particleFactory.createDebris();
ParticleEmitter shockwave = particlecreator.createShockwave(); ParticleEmitter shockwave = particleFactory.createShockwave();
ParticleEmitter movingSmoke = particlecreator.createMovingSmokeEmitter(); ParticleEmitter movingSmoke = particleFactory.createMovingSmokeEmitter();
// Attach all effects to the hitEffectNode // Attach all effects to the hitEffectNode
hitEffectNode.attachChild(flame); hitEffectNode.attachChild(flame);
@@ -231,18 +229,12 @@ class SeaSynchronizer extends ShipMapSynchronizer {
*/ */
private Spatial createShip(Battleship ship) { private Spatial createShip(Battleship ship) {
switch (ship.getLength()) { switch (ship.getLength()) {
case 4: case 4: return createBattleship(ship);
return createBattleship(ship); case 3: return createCV(ship);
case 3: case 2: return createBattle(ship);
return createLargeship(ship); case 1: return createSmallship(ship);
case 2: default: return createBox(ship);
return createMediumship(ship);
case 1:
return createSmallship(ship);
default:
return createBox(ship);
} }
} }
/** /**
@@ -292,13 +284,20 @@ class SeaSynchronizer extends ShipMapSynchronizer {
model.rotate(-HALF_PI, calculateRotationAngle(ship.getRot()), 0f); model.rotate(-HALF_PI, calculateRotationAngle(ship.getRot()), 0f);
model.scale(1.48f); model.scale(1.48f);
// model.scale(0.0007f);
model.setShadowMode(ShadowMode.CastAndReceive); model.setShadowMode(ShadowMode.CastAndReceive);
return model; return model;
} }
/**
* Creates a detailed 3D model to represent a small tug boat.
*
* @param ship the battleship to be represented
* @return the spatial representing a small tug boat
*/
private Spatial createSmallship(Battleship ship) { private Spatial createSmallship(Battleship ship) {
final Spatial model = app.getAssetManager().loadModel(SMALL_SHIP_MODEL); final Spatial model = app.getAssetManager().loadModel(BOAT_SMALL_MODEL);
model.rotate(-HALF_PI, calculateRotationAngle(ship.getRot()), 0f); model.rotate(-HALF_PI, calculateRotationAngle(ship.getRot()), 0f);
model.scale(0.0005f); model.scale(0.0005f);
@@ -307,21 +306,35 @@ class SeaSynchronizer extends ShipMapSynchronizer {
return model; return model;
} }
private Spatial createMediumship(Battleship ship) { /**
final Spatial model = app.getAssetManager().loadModel(U_BOAT_MODEL); * Creates a detailed 3D model to represent a "German WWII UBoat".
*
* @param ship the battleship to be represented
* @return the spatial representing the "German WWII UBoat"
*/
private Spatial createCV(Battleship ship) {
final Spatial model = app.getAssetManager().loadModel(CV_MODEL);
model.rotate(-HALF_PI, calculateRotationAngle(ship.getRot()), 0f); model.rotate(0f, calculateRotationAngle(ship.getRot()), 0f);
model.scale(0.27f); model.move(0f, 0.25f, 0f);
model.scale(0.85f);
model.setShadowMode(ShadowMode.CastAndReceive); model.setShadowMode(ShadowMode.CastAndReceive);
return model; return model;
} }
private Spatial createLargeship(Battleship ship) { /**
final Spatial model = app.getAssetManager().loadModel(TUG_BOAT_MODEL); * Creates a detailed 3D model to represent a battleship.
*
* @param ship the battleship to be represented
* @return the spatial representing a battleship
*/
private Spatial createBattle(Battleship ship) {
final Spatial model = app.getAssetManager().loadModel(BATTLE_MODEL);
model.rotate(-HALF_PI, calculateRotationAngle(ship.getRot()), 0f); model.rotate(-HALF_PI, calculateRotationAngle(ship.getRot()), 0f);
model.scale(0.0004f); model.move(0f, -0.06f, 0f);
model.scale(0.27f);
model.setShadowMode(ShadowMode.CastAndReceive); model.setShadowMode(ShadowMode.CastAndReceive);
return model; return model;

View File

@@ -42,6 +42,14 @@ public class Shell2DControl extends AbstractControl {
spatial.setLocalTranslation(viewPos.getX() + MapView.FIELD_SIZE / 2, viewPos.getY() + MapView.FIELD_SIZE / 2, 0); spatial.setLocalTranslation(viewPos.getX() + MapView.FIELD_SIZE / 2, viewPos.getY() + MapView.FIELD_SIZE / 2, 0);
} }
/**
* This method is called during the rendering phase, but it does not perform any
* operations in this implementation as the control only influences the spatial's
* transformation, not its rendering process.
*
* @param rm the RenderManager rendering the controlled Spatial (not null)
* @param vp the ViewPort being rendered (not null)
*/
@Override @Override
protected void controlRender(RenderManager rm, ViewPort vp) { protected void controlRender(RenderManager rm, ViewPort vp) {
// No rendering-specific behavior required for this control // No rendering-specific behavior required for this control

View File

@@ -43,6 +43,14 @@ public class ShellControl extends AbstractControl {
spatial.rotate(PI/2,0,0); spatial.rotate(PI/2,0,0);
} }
/**
* This method is called during the rendering phase, but it does not perform any
* operations in this implementation as the control only influences the spatial's
* transformation, not its rendering process.
*
* @param rm the RenderManager rendering the controlled Spatial (not null)
* @param vp the ViewPort being rendered (not null)
*/
@Override @Override
protected void controlRender(RenderManager rm, ViewPort vp) { protected void controlRender(RenderManager rm, ViewPort vp) {
// No rendering-specific behavior required for this control // No rendering-specific behavior required for this control

View File

@@ -10,7 +10,7 @@ import com.jme3.scene.Node;
* Control that handles the sinking effect for destroyed ships. * Control that handles the sinking effect for destroyed ships.
* It will gradually move the ship downwards and then remove it from the scene. * It will gradually move the ship downwards and then remove it from the scene.
*/ */
class SinkControl extends AbstractControl { class SinkingControl extends AbstractControl {
private static final float SINK_DURATION = 5f; // Duration of the sinking animation private static final float SINK_DURATION = 5f; // Duration of the sinking animation
private static final float SINK_SPEED = 0.1f; // Speed at which the ship sinks private static final float SINK_SPEED = 0.1f; // Speed at which the ship sinks
private float elapsedTime = 0; private float elapsedTime = 0;
@@ -21,7 +21,7 @@ class SinkControl extends AbstractControl {
* Constructs a {@code SinkingControl} object with the shipNode to be to be sunk * Constructs a {@code SinkingControl} object with the shipNode to be to be sunk
* @param shipNode the node to handeld * @param shipNode the node to handeld
*/ */
public SinkControl(Node shipNode) { public SinkingControl(Node shipNode) {
this.shipNode = shipNode; this.shipNode = shipNode;
} }
@@ -46,9 +46,16 @@ class SinkControl extends AbstractControl {
} }
} }
/**
* This method is called during the rendering phase, but it does not perform any
* operations in this implementation as the control only influences the spatial's
* transformation, not its rendering process.
*
* @param rm the RenderManager rendering the controlled Spatial (not null)
* @param vp the ViewPort being rendered (not null)
*/
@Override @Override
protected void controlRender(RenderManager rm, ViewPort vp) { protected void controlRender(RenderManager rm, ViewPort vp) {
// No rendering-related code needed // No rendering-related code needed
} }
} }

View File

@@ -1,13 +1,20 @@
package pp.battleship.client; package pp.battleship.client.gui;
import com.simsilica.lemur.Slider; import com.simsilica.lemur.Slider;
/**
* The VolumeSlider class represents the Volume Slider in the Menu.
* It extends the Slider class and provides functionalities for setting the music volume,
* with the help of the Slider in the GUI
*/
public class VolumeSlider extends Slider { public class VolumeSlider extends Slider {
private final GameMusic music; private final GameMusic music;
private double vol; private double vol;
/**
* Constructs the Volume Slider for the Menu dialog
* @param music the music instance
*/
public VolumeSlider(GameMusic music) { public VolumeSlider(GameMusic music) {
super(); super();
this.music = music; this.music = music;
@@ -15,10 +22,14 @@ public class VolumeSlider extends Slider {
getModel().setPercent(vol); getModel().setPercent(vol);
} }
/**
* when triggered it updates the volume to the value set with the slider
*/
public void update() { public void update() {
if (vol != getModel().getPercent()) { if (vol != getModel().getPercent()) {
vol = getModel().getPercent(); vol = getModel().getPercent();
music.setVolume( (float) vol); music.setVolume( (float) vol);
} }
} }
} }

View File

@@ -18,8 +18,8 @@ import pp.battleship.BattleshipConfig;
import pp.battleship.game.server.Player; import pp.battleship.game.server.Player;
import pp.battleship.game.server.ServerGameLogic; import pp.battleship.game.server.ServerGameLogic;
import pp.battleship.game.server.ServerSender; import pp.battleship.game.server.ServerSender;
import pp.battleship.message.client.ClientMessage;
import pp.battleship.message.client.AnimationFinishedMessage; import pp.battleship.message.client.AnimationFinishedMessage;
import pp.battleship.message.client.ClientMessage;
import pp.battleship.message.client.MapMessage; import pp.battleship.message.client.MapMessage;
import pp.battleship.message.client.ShootMessage; import pp.battleship.message.client.ShootMessage;
import pp.battleship.message.server.EffectMessage; import pp.battleship.message.server.EffectMessage;
@@ -180,4 +180,3 @@ public class BattleshipServer implements MessageListener<HostedConnection>, Conn
LOGGER.log(Level.ERROR, "there is no connection with id={0}", id); //NON-NLS LOGGER.log(Level.ERROR, "there is no connection with id={0}", id); //NON-NLS
} }
} }

View File

@@ -15,4 +15,3 @@ record ReceivedMessage(ClientMessage message, int from) {
message.accept(interpreter, from); message.accept(interpreter, from);
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 670 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

View File

@@ -42,9 +42,15 @@ public class ModelExporter extends SimpleApplication {
@Override @Override
public void simpleInitApp() { public void simpleInitApp() {
export("Models/KingGeorgeV/King_George_V.obj", "KingGeorgeV.j3o"); //NON-NLS export("Models/KingGeorgeV/King_George_V.obj", "KingGeorgeV.j3o"); //NON-NLS
export("Models/SmallShip/12219_boat_v2_L2.obj", "SmallShip.j3o"); //NON-NLS export("Models/BoatSmall/12219_boat_v2_L2.obj", "BoatSmall.j3o"); //NON-NLS
export("Models/WWII_ship_German_Type_II_U-boat_v2/14084_WWII_Ship_German_Type_II_U-boat_v2_L1.obj", "WW2Uboat.j3o"); //NON-NLS export("Models/Battle/14084_WWII_Ship_German_Type_II_U-boat_v2_L1.obj", "Battle.j3o"); //NON-NLS
export("Models/TugBoat/12218_tugboat_v1_L2.obj", "TugBoat.j3o"); //NON-NLS export("Models/CV/essex_scb-125_generic.obj", "CV.j3o"); //NON-NLS
export("Models/Figures/Würfel_blau.obj", "Würfel_blau.j30");
export("Models/Figures/Würfel_gelb.obj", "Würfel_gelb.j30");
export("Models/Figures/Würfel_grün.obj", "Würfel_grün.j30");
export("Models/Figures/Würfel_rosa.obj", "Würfel_rosa.j30");
export("Models/Figures/Würfel_rot.obj", "Würfel_rot.j30");
export("Models/Figures/Würfel_schwarz.obj", "Würfel_schwarz.j30");
stop(); stop();
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Some files were not shown because too many files have changed in this diff Show More