added TODOÃ's for presentation

This commit is contained in:
Cedric Beck
2024-10-12 17:45:30 +02:00
parent bb1e3858bb
commit 67b99317d2
10 changed files with 13 additions and 3 deletions

View File

@@ -20,6 +20,7 @@
* EffectHandler manages the creation and manipulation of particle effects in the Battleship application. * EffectHandler manages the creation and manipulation of particle effects in the Battleship application.
*/ */
public class EffectHandler { public class EffectHandler {
//TODO: Ex. 12 EffectHandler
private final BattleshipApp app; private final BattleshipApp app;
private final Map<Battleship, List<ParticleEmitter>> effects; private final Map<Battleship, List<ParticleEmitter>> effects;

View File

@@ -14,6 +14,7 @@
* An application state that plays sounds. * An application state that plays sounds.
*/ */
public class GameMusic extends AbstractAppState { public class GameMusic extends AbstractAppState {
//TODO: Ex. 10 GameMusic
private static final Preferences PREFERENCES = getPreferences(GameMusic.class); private static final Preferences PREFERENCES = getPreferences(GameMusic.class);
private static final String ENABLED_PREF = "enabled"; private static final String ENABLED_PREF = "enabled";
private static final String VOLUME_PREF = "volume"; private static final String VOLUME_PREF = "volume";

View File

@@ -48,7 +48,7 @@ public Menu(BattleshipApp app) {
addChild(new Label(lookup("battleship.name"), new ElementId("header"))); //NON-NLS addChild(new Label(lookup("battleship.name"), new ElementId("header"))); //NON-NLS
addChild(new Checkbox(lookup("menu.sound-enabled"), addChild(new Checkbox(lookup("menu.sound-enabled"),
new StateCheckboxModel(app, GameSound.class))); new StateCheckboxModel(app, GameSound.class)));
//TODO: Ex. 10 VolumeSlider
addChild(new Checkbox(lookup("menu.music-enabled"), new StateCheckboxModel(app, GameMusic.class))); addChild(new Checkbox(lookup("menu.music-enabled"), new StateCheckboxModel(app, GameMusic.class)));
addChild(volumeSlider); addChild(volumeSlider);

View File

@@ -61,6 +61,7 @@ class NetworkDialog extends SimpleDialog {
input.addChild(host, 1); input.addChild(host, 1);
input.addChild(new Label(lookup("port.number") + ": ")); input.addChild(new Label(lookup("port.number") + ": "));
input.addChild(port, 1); input.addChild(port, 1);
//TODO: Ex. 11 ClientHost Checkbox
clientHostCheckbox = new Checkbox("Host Server"); clientHostCheckbox = new Checkbox("Host Server");
input.addChild(clientHostCheckbox); input.addChild(clientHostCheckbox);
DialogBuilder.simple(app.getDialogManager()) DialogBuilder.simple(app.getDialogManager())

View File

@@ -126,6 +126,7 @@ public Spatial visit(Battleship ship) {
*/ */
@Override @Override
public Spatial visit(Shell shell) { public Spatial visit(Shell shell) {
//TODO: Ex. 13 2D Shell
final ColorRGBA color = ColorRGBA.Black; final ColorRGBA color = ColorRGBA.Black;
Geometry ellipse = new Geometry("ellipse", new Sphere(50, 50, MapView.FIELD_SIZE / 2 * 0.8f)); Geometry ellipse = new Geometry("ellipse", new Sphere(50, 50, MapView.FIELD_SIZE / 2 * 0.8f));
Material mat = new Material(view.getApp().getAssetManager(), UNSHADED); //NON-NLS Material mat = new Material(view.getApp().getAssetManager(), UNSHADED); //NON-NLS

View File

@@ -92,7 +92,7 @@ private Spatial handleMiss(Shot shot) {
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");
//TODO: Ex. 12 Hit
shipNode.getControl(ShipControl.class).hit(shot); shipNode.getControl(ShipControl.class).hit(shot);
if (ship.isDestroyed()) { if (ship.isDestroyed()) {
shipNode.getControl(ShipControl.class).destroyed(); shipNode.getControl(ShipControl.class).destroyed();
@@ -149,6 +149,7 @@ public Spatial visit(Battleship ship) {
final float x = 0.5f * (ship.getMinY() + ship.getMaxY() + 1f); final float x = 0.5f * (ship.getMinY() + ship.getMaxY() + 1f);
final float z = 0.5f * (ship.getMinX() + ship.getMaxX() + 1f); final float z = 0.5f * (ship.getMinX() + ship.getMaxX() + 1f);
node.setLocalTranslation(x, 0f, z); node.setLocalTranslation(x, 0f, z);
//TODO: Ex. 12 ShipControl
node.addControl(new ShipControl(ship, node, app.getEffectHandler())); node.addControl(new ShipControl(ship, node, app.getEffectHandler()));
return node; return node;
} }
@@ -162,6 +163,7 @@ public Spatial visit(Battleship ship) {
*/ */
@Override @Override
public Spatial visit(Shell shell) { public Spatial visit(Shell shell) {
//TODO: Ex. 13 3D Shell
final Spatial model = app.getAssetManager().loadModel("Models/Shell/shell.j3o"); final Spatial model = app.getAssetManager().loadModel("Models/Shell/shell.j3o");
model.setLocalScale(.05f); model.setLocalScale(.05f);
model.setShadowMode(ShadowMode.CastAndReceive); model.setShadowMode(ShadowMode.CastAndReceive);

View File

@@ -57,9 +57,10 @@ public void receivedEffect(EffectMessage msg) {
myTurn = msg.isMyTurn(); myTurn = msg.isMyTurn();
logic.setInfoText(msg.getInfoTextKey()); logic.setInfoText(msg.getInfoTextKey());
//TODO: Ex. 13 add shell -> ItemAddedEvent
Shell shell = new Shell(msg.getShot()); Shell shell = new Shell(msg.getShot());
affectedMap(msg).add(shell); affectedMap(msg).add(shell);
//TODO: Ex. 13 Shell sound -> GameSound
logic.playSound(Sound.SHELL_FLYING); logic.playSound(Sound.SHELL_FLYING);
logic.setState(new ShootingState(logic, shell, myTurn, msg)); logic.setState(new ShootingState(logic, shell, myTurn, msg));
} }

View File

@@ -26,6 +26,7 @@ public class ShootingState extends ClientState {
* @param msg the effect message associated with the shooting action * @param msg the effect message associated with the shooting action
*/ */
public ShootingState(ClientGameLogic logic, Shell shell, boolean myTurn, EffectMessage msg) { public ShootingState(ClientGameLogic logic, Shell shell, boolean myTurn, EffectMessage msg) {
//TODO: Ex. 13 ShootingState
super(logic); super(logic);
this.msg = msg; this.msg = msg;
this.myTurn = myTurn; this.myTurn = myTurn;

View File

@@ -221,6 +221,7 @@ private boolean checkMap(List<Battleship> ships) {
*/ */
@Override @Override
public void received(ShootMessage msg, int from) { public void received(ShootMessage msg, int from) {
//TODO: Ex. 13 Server State
if (state != ServerState.BATTLE) if (state != ServerState.BATTLE)
LOGGER.log(Level.ERROR, "shoot not allowed in {0}", state); //NON-NLS LOGGER.log(Level.ERROR, "shoot not allowed in {0}", state); //NON-NLS
else{ else{

View File

@@ -9,6 +9,7 @@
* a Bezier curve. * a Bezier curve.
*/ */
public class Shell implements Item { public class Shell implements Item {
//TODO: Ex. 13 Shell
/** /**
* Initial position of the shell * Initial position of the shell
*/ */