Aufgabe 13
added class Shell for the feature Airstrike added class ShellControl for the feature Airstrike added new Model Bomb to implement the feature Airstrike added README´S to the Models to show the free to use license edited class ShipMap for the feature Airstrike edited class ImpactEffectManager to improve the Fire and Water Particles edited class MapViewSynchronizer for the feature Airstrike edited class BattleState for the feature Airstrike edited class BattleshipApp for the feature Airstrike
This commit is contained in:
@@ -7,9 +7,11 @@
|
||||
|
||||
package pp.battleship.game.client;
|
||||
|
||||
import com.jme3.math.Vector3f;
|
||||
import pp.battleship.message.client.ShootMessage;
|
||||
import pp.battleship.message.server.EffectMessage;
|
||||
import pp.battleship.model.IntPoint;
|
||||
import pp.battleship.model.Shell;
|
||||
import pp.battleship.model.ShipMap;
|
||||
import pp.battleship.notification.Sound;
|
||||
|
||||
@@ -57,6 +59,7 @@ public void receivedEffect(EffectMessage msg) {
|
||||
myTurn = msg.isMyTurn();
|
||||
logic.setInfoText(msg.getInfoTextKey());
|
||||
affectedMap(msg).add(msg.getShot());
|
||||
affectedMap(msg).add(new Shell(new Vector3f(0, 10, 0), new Vector3f(msg.getShot().getY() + 0.5f, -0.4f, msg.getShot().getX() + 0.5f), 1f));
|
||||
if (destroyedOpponentShip(msg))
|
||||
logic.getOpponentMap().add(msg.getDestroyedShip());
|
||||
if (msg.isGameOver()) {
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package pp.battleship.model;
|
||||
|
||||
import com.jme3.math.Vector3f;
|
||||
import pp.util.FloatMath;
|
||||
|
||||
public class Shell implements Item {
|
||||
private Vector3f startPosition; // Startposition des Geschosses
|
||||
private Vector3f targetPosition; // Zielposition des Geschosses0
|
||||
private Vector3f currentPosition; // Aktuelle Position des Geschosses
|
||||
private float speed; // Geschwindigkeit des Geschosses
|
||||
|
||||
private float progress;
|
||||
|
||||
public Shell(Vector3f startPosition, Vector3f targetPosition, float speed) {
|
||||
this.startPosition = startPosition;
|
||||
this.targetPosition = targetPosition;
|
||||
this.currentPosition = new Vector3f(startPosition); // Initiale Position ist die Startposition
|
||||
this.speed = speed;
|
||||
}
|
||||
|
||||
// Methode, um die Position des Geschosses basierend auf der Zeit zu aktualisieren
|
||||
public void updatePosition(float deltaTime) {
|
||||
progress+=deltaTime*speed;
|
||||
|
||||
// Interpoliere die Position zwischen Start- und Zielposition basierend auf dem Fortschritt
|
||||
currentPosition.x = FloatMath.interpolateLinear(progress,startPosition.x,targetPosition.x);
|
||||
currentPosition.y = FloatMath.interpolateLinear(progress,startPosition.y,targetPosition.y);
|
||||
currentPosition.z = FloatMath.interpolateLinear(progress,startPosition.z,targetPosition.z);
|
||||
|
||||
//currentPosition.interpolateLocal(startPosition, targetPosition, progress);
|
||||
}
|
||||
|
||||
// Aktuelle Position des Geschosses
|
||||
public Vector3f getCurrentPosition() {
|
||||
return currentPosition;
|
||||
}
|
||||
|
||||
// Überprüfen, ob das Ziel erreicht ist
|
||||
public boolean isAtTarget() {
|
||||
return currentPosition.distance(targetPosition) < 0.0001f; // Toleranz für die Zielgenauigkeit
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public <T> T accept(Visitor<T> visitor) {
|
||||
return visitor.visit(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Accepts a visitor that does not return a value. This method is part of the
|
||||
* Visitor design pattern.
|
||||
*
|
||||
* @param visitor the visitor to accept
|
||||
*/
|
||||
@Override
|
||||
public void accept(VoidVisitor visitor) {
|
||||
visitor.visit(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -78,6 +78,14 @@ public void add(Battleship ship) {
|
||||
addItem(ship);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param shell
|
||||
*/
|
||||
public void add(Shell shell){
|
||||
addItem(shell);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a shot on the map, updates the state of the affected ship (if any),
|
||||
* and triggers an item addition event.
|
||||
|
||||
@@ -28,4 +28,6 @@ public interface Visitor<T> {
|
||||
* @return the result of visiting the Battleship element
|
||||
*/
|
||||
T visit(Battleship ship);
|
||||
|
||||
T visit(Shell shell);
|
||||
}
|
||||
|
||||
@@ -25,4 +25,6 @@ public interface VoidVisitor {
|
||||
* @param ship the Battleship element to visit
|
||||
*/
|
||||
void visit(Battleship ship);
|
||||
|
||||
void visit(Shell shell);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user