mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2025-08-07 08:56:37 +02:00
task 13 + debug
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
#
|
||||
# Specifies the map used by the opponent in single mode.
|
||||
# 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.
|
||||
# The player must define their own map if this property is not set.
|
||||
|
@@ -249,8 +249,8 @@ public class BattleshipApp extends SimpleApplication implements BattleshipClient
|
||||
private void setupInput() {
|
||||
inputManager.deleteMapping(INPUT_MAPPING_EXIT);
|
||||
inputManager.setCursorVisible(false);
|
||||
inputManager.addMapping(CLICK, new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
|
||||
inputManager.addMapping(ESC, new KeyTrigger(KeyInput.KEY_ESCAPE));
|
||||
inputManager.addMapping(CLICK, new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
|
||||
inputManager.addListener(escapeListener, ESC);
|
||||
}
|
||||
|
||||
@@ -309,18 +309,14 @@ public class BattleshipApp extends SimpleApplication implements BattleshipClient
|
||||
*
|
||||
* @param isPressed Indicates whether the Escape key is pressed.
|
||||
*/
|
||||
|
||||
private void escape(boolean isPressed) {
|
||||
if (!isPressed) return;
|
||||
LOGGER.log(Level.INFO, "Escape key pressed"); // Debugging
|
||||
if (dialogManager.showsDialog()) {
|
||||
LOGGER.log(Level.INFO, "Closing current dialog");
|
||||
if (dialogManager.showsDialog())
|
||||
dialogManager.escape();
|
||||
} else {
|
||||
LOGGER.log(Level.INFO, "Opening menu");
|
||||
else
|
||||
new Menu(this).open();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link Draw} instance used for rendering graphical elements in the game.
|
||||
*
|
||||
|
@@ -67,7 +67,7 @@ public class GameSound extends AbstractAppState implements GameEventListener {
|
||||
|
||||
/**
|
||||
* Initializes the sound effects for the game.
|
||||
* Overrides {@link com.jme3.app.state.AbstractAppState#initialize(com.jme3.app.state.AppStateManager, com.jme3.app.Application)}
|
||||
* Overrides {@link AbstractAppState#initialize(AppStateManager, Application)}
|
||||
*
|
||||
* @param stateManager The state manager
|
||||
* @param app The application
|
||||
|
@@ -11,6 +11,7 @@ import com.simsilica.lemur.Button;
|
||||
import com.simsilica.lemur.Checkbox;
|
||||
import com.simsilica.lemur.Label;
|
||||
import com.simsilica.lemur.style.ElementId;
|
||||
|
||||
import pp.battleship.client.gui.GameMusic;
|
||||
import pp.battleship.client.gui.VolumeSlider;
|
||||
import pp.dialog.Dialog;
|
||||
@@ -92,7 +93,7 @@ class Menu extends Dialog {
|
||||
* Executes a file action.
|
||||
*
|
||||
* @param file the file to be processed
|
||||
* @throws java.io.IOException if an I/O error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
void run(File file) throws IOException;
|
||||
}
|
||||
|
@@ -13,7 +13,7 @@ import com.simsilica.lemur.Label;
|
||||
import com.simsilica.lemur.TextField;
|
||||
import com.simsilica.lemur.component.SpringGridLayout;
|
||||
|
||||
import pp.battleship.client.sever.BattleshipServer;
|
||||
import pp.battleship.server.BattleshipServer;
|
||||
import pp.dialog.Dialog;
|
||||
import pp.dialog.DialogBuilder;
|
||||
import pp.dialog.SimpleDialog;
|
||||
@@ -36,6 +36,7 @@ class NetworkDialog extends SimpleDialog {
|
||||
private final NetworkSupport network;
|
||||
private final TextField host = new TextField(LOCALHOST);
|
||||
private final TextField port = new TextField(DEFAULT_PORT);
|
||||
// private final Button serverButton = new Button(lookup("client.server-star"));
|
||||
private final Button serverButton = new Button(lookup("client.server-start"));
|
||||
private String hostname;
|
||||
private int portNumber;
|
||||
@@ -69,7 +70,7 @@ class NetworkDialog extends SimpleDialog {
|
||||
.setOkClose(false)
|
||||
.setNoClose(false)
|
||||
.build(this);
|
||||
|
||||
|
||||
//Add the button to start the sever
|
||||
addChild(serverButton).addClickCommands(s -> ifTopDialog(this::startServerInThread));
|
||||
}
|
||||
|
@@ -31,7 +31,7 @@ public class GameMusic extends AbstractAppState{
|
||||
return PREFERENCES.getBoolean(ENABLED_PREF, true);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Checks if sound is enabled in the preferences.
|
||||
*
|
||||
* @return float to which the volume is set
|
||||
@@ -95,7 +95,7 @@ public class GameMusic extends AbstractAppState{
|
||||
music.stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
super.setEnabled(enabled);
|
||||
LOGGER.log(Level.INFO, "Sound enabled: {0}", enabled); //NON-NLS
|
||||
PREFERENCES.putBoolean(ENABLED_PREF, enabled);
|
||||
|
@@ -8,10 +8,12 @@
|
||||
package pp.battleship.client.gui;
|
||||
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.Node;
|
||||
import com.jme3.scene.Spatial;
|
||||
import pp.battleship.model.Battleship;
|
||||
import pp.battleship.model.Shell;
|
||||
import pp.battleship.model.Shot;
|
||||
import pp.util.Position;
|
||||
|
||||
@@ -36,6 +38,7 @@ class MapViewSynchronizer extends ShipMapSynchronizer {
|
||||
|
||||
// The MapView associated with this synchronizer
|
||||
private final MapView view;
|
||||
private Shell shell;
|
||||
|
||||
/**
|
||||
* Constructs a new MapViewSynchronizer for the given MapView.
|
||||
@@ -122,4 +125,19 @@ class MapViewSynchronizer extends ShipMapSynchronizer {
|
||||
private Geometry shipLine(float x1, float y1, float x2, float y2, ColorRGBA color) {
|
||||
return view.getApp().getDraw().makeFatLine(x1, y1, x2, y2, SHIP_DEPTH, color, SHIP_LINE_WIDTH);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param deltaTime
|
||||
*/
|
||||
public void update(float deltaTime) {
|
||||
if (shell != null) {
|
||||
shell.updatePosition(deltaTime);
|
||||
drawShell(shell.getCurrentPosition());
|
||||
}
|
||||
}
|
||||
|
||||
private void drawShell(Vector3f position) {
|
||||
// Methode zum Zeichnen des Geschosses auf der 2D-Karte TODO
|
||||
}
|
||||
}
|
||||
|
@@ -4,7 +4,7 @@ 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
|
||||
* with the help of the Slider in the GUI
|
||||
*/
|
||||
public class VolumeSlider extends Slider {
|
||||
|
||||
@@ -31,5 +31,5 @@ public class VolumeSlider extends Slider {
|
||||
music.setVolume( (float) vol);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -1,4 +1,11 @@
|
||||
package pp.battleship.client.sever;
|
||||
////////////////////////////////////////
|
||||
// Programming project code
|
||||
// UniBw M, 2022, 2023, 2024
|
||||
// www.unibw.de/inf2
|
||||
// (c) Mark Minas (mark.minas@unibw.de)
|
||||
////////////////////////////////////////
|
||||
|
||||
package pp.battleship.server;
|
||||
|
||||
import com.jme3.network.ConnectionListener;
|
||||
import com.jme3.network.HostedConnection;
|
||||
@@ -169,4 +176,4 @@ public class BattleshipServer implements MessageListener<HostedConnection>, Conn
|
||||
else
|
||||
LOGGER.log(Level.ERROR, "there is no connection with id={0}", id); //NON-NLS
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,4 +1,11 @@
|
||||
package pp.battleship.client.sever;
|
||||
////////////////////////////////////////
|
||||
// Programming project code
|
||||
// UniBw M, 2022, 2023, 2024
|
||||
// www.unibw.de/inf2
|
||||
// (c) Mark Minas (mark.minas@unibw.de)
|
||||
////////////////////////////////////////
|
||||
|
||||
package pp.battleship.server;
|
||||
|
||||
import pp.battleship.message.client.ClientInterpreter;
|
||||
import pp.battleship.message.client.ClientMessage;
|
||||
@@ -7,4 +14,4 @@ record ReceivedMessage(ClientMessage message, int from) {
|
||||
void process(ClientInterpreter interpreter) {
|
||||
message.accept(interpreter, from);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user