mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2025-05-22 17:50:13 +02:00
Compare commits
No commits in common. "85e0c68a36c9345abbce1bb66b3e4d2eb6ebc0ab" and "b702e3a14de8c4a38fbe3358f5ff5651f83a9b51" have entirely different histories.
85e0c68a36
...
b702e3a14d
@ -1,7 +1,5 @@
|
|||||||
package pp.monopoly.client.gui;
|
package pp.monopoly.client.gui;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
|
||||||
@ -12,14 +10,7 @@ import com.jme3.renderer.ViewPort;
|
|||||||
import com.jme3.scene.control.AbstractControl;
|
import com.jme3.scene.control.AbstractControl;
|
||||||
|
|
||||||
import pp.monopoly.client.MonopolyApp;
|
import pp.monopoly.client.MonopolyApp;
|
||||||
import pp.monopoly.client.gui.popups.BuildingPropertyCard;
|
import pp.monopoly.client.gui.popups.*;
|
||||||
import pp.monopoly.client.gui.popups.ConfirmTrade;
|
|
||||||
import pp.monopoly.client.gui.popups.EventCardPopup;
|
|
||||||
import pp.monopoly.client.gui.popups.FoodFieldCard;
|
|
||||||
import pp.monopoly.client.gui.popups.GateFieldCard;
|
|
||||||
import pp.monopoly.client.gui.popups.LooserPopUp;
|
|
||||||
import pp.monopoly.client.gui.popups.TimeOut;
|
|
||||||
import pp.monopoly.client.gui.popups.WinnerPopUp;
|
|
||||||
import pp.monopoly.game.server.Player;
|
import pp.monopoly.game.server.Player;
|
||||||
import pp.monopoly.game.server.PlayerHandler;
|
import pp.monopoly.game.server.PlayerHandler;
|
||||||
import pp.monopoly.model.fields.BuildingProperty;
|
import pp.monopoly.model.fields.BuildingProperty;
|
||||||
@ -28,6 +19,7 @@ import pp.monopoly.model.fields.GateField;
|
|||||||
import pp.monopoly.notification.EventCardEvent;
|
import pp.monopoly.notification.EventCardEvent;
|
||||||
import pp.monopoly.notification.GameEventListener;
|
import pp.monopoly.notification.GameEventListener;
|
||||||
import pp.monopoly.notification.PopUpEvent;
|
import pp.monopoly.notification.PopUpEvent;
|
||||||
|
import pp.monopoly.notification.Sound;
|
||||||
import pp.monopoly.notification.UpdatePlayerView;
|
import pp.monopoly.notification.UpdatePlayerView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -48,9 +40,9 @@ public class TestWorld implements GameEventListener {
|
|||||||
*/
|
*/
|
||||||
public TestWorld(MonopolyApp app) {
|
public TestWorld(MonopolyApp app) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
this.playerHandler = app.getGameLogic().getPlayerHandler();
|
this.playerHandler = app.getGameLogic().getPlayerHandler(); // Hole den PlayerHandler
|
||||||
app.getGameLogic().addListener(this);
|
app.getGameLogic().addListener(this);
|
||||||
cameraController = new CameraController(app.getCamera());
|
cameraController = new CameraController(app.getCamera()); // Übergebe PlayerHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -94,7 +86,7 @@ public class TestWorld implements GameEventListener {
|
|||||||
geom.setLocalTranslation(0, -0.1f, 0);
|
geom.setLocalTranslation(0, -0.1f, 0);
|
||||||
|
|
||||||
com.jme3.math.Quaternion rotation = new com.jme3.math.Quaternion();
|
com.jme3.math.Quaternion rotation = new com.jme3.math.Quaternion();
|
||||||
rotation.fromAngleAxis(FastMath.HALF_PI, com.jme3.math.Vector3f.UNIT_Y);
|
rotation.fromAngleAxis(com.jme3.math.FastMath.HALF_PI, com.jme3.math.Vector3f.UNIT_Y);
|
||||||
geom.setLocalRotation(rotation);
|
geom.setLocalRotation(rotation);
|
||||||
|
|
||||||
app.getRootNode().attachChild(geom);
|
app.getRootNode().attachChild(geom);
|
||||||
@ -117,8 +109,7 @@ public class TestWorld implements GameEventListener {
|
|||||||
);
|
);
|
||||||
model.setLocalScale(0.5f);
|
model.setLocalScale(0.5f);
|
||||||
|
|
||||||
int playerIndexOnField = calculatePlayerIndexOnField(player.getFieldID(), player.getId());
|
Vector3f startPosition = calculateFieldPosition(player.getFieldID(), i);
|
||||||
Vector3f startPosition = calculateFieldPosition(player.getFieldID(), playerIndexOnField);
|
|
||||||
model.setLocalTranslation(startPosition);
|
model.setLocalTranslation(startPosition);
|
||||||
|
|
||||||
model.setName("PlayerFigure_" + player.getId());
|
model.setName("PlayerFigure_" + player.getId());
|
||||||
@ -187,49 +178,72 @@ public class TestWorld implements GameEventListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void movePlayerFigure(Player player) {
|
private void movePlayerFigure(Player player) {
|
||||||
int playerIndexOnField = calculatePlayerIndexOnField(player.getFieldID(), player.getId());
|
int fieldID = player.getFieldID();
|
||||||
|
int playerIndex = playerHandler.getPlayers().indexOf(player); // Spielerindex holen
|
||||||
|
Vector3f targetPosition = calculateFieldPosition(fieldID, playerIndex);
|
||||||
|
|
||||||
String figureName = "PlayerFigure_" + player.getId();
|
String figureName = "PlayerFigure_" + player.getId();
|
||||||
com.jme3.scene.Spatial figure = app.getRootNode().getChild(figureName);
|
com.jme3.scene.Spatial figure = app.getRootNode().getChild(figureName);
|
||||||
|
|
||||||
if (figure != null) {
|
if (figure != null) {
|
||||||
// Berechne das aktuelle Feld basierend auf der Position der Figur
|
Vector3f startPosition = figure.getLocalTranslation();
|
||||||
int startFieldID = getFieldIDFromPosition(figure.getLocalTranslation());
|
Vector3f cornerPosition = calculateCornerPosition(startPosition, targetPosition); // Berechne Eckpunkt
|
||||||
int targetFieldID = player.getFieldID();
|
float animationDuration = 3.0f; // Gesamtdauer der Animation
|
||||||
|
float[] elapsedTime = {0.0f}; // Verstrichene Zeit
|
||||||
|
|
||||||
// Bewege die Figur nur, wenn das Ziel-Feld unterschiedlich ist
|
|
||||||
if (startFieldID != targetFieldID) {
|
|
||||||
// Verzögerung vor Start der Animation (z.B. 3 Sekunden)
|
|
||||||
Timer timer = new Timer();
|
Timer timer = new Timer();
|
||||||
timer.schedule(new TimerTask() {
|
timer.schedule(new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// Berechne den Pfad basierend auf den Feld-IDs
|
app.enqueue(() -> {
|
||||||
List<Vector3f> pathPoints = calculatePath(startFieldID, targetFieldID, playerIndexOnField);
|
app.getRootNode().addControl(new AbstractControl() {
|
||||||
|
@Override
|
||||||
|
protected void controlUpdate(float tpf) {
|
||||||
|
elapsedTime[0] += tpf;
|
||||||
|
float progress = Math.min(elapsedTime[0] / animationDuration, 1.0f);
|
||||||
|
|
||||||
// Starte die Animation entlang des Pfads
|
Vector3f interpolatedPosition;
|
||||||
animateMovementAlongPath(figure, pathPoints);
|
if (progress < 0.5f) {
|
||||||
}
|
// Erste Hälfte der Animation: Bewegung zur Ecke
|
||||||
}, 3000); // Verzögerung von 3000ms (3 Sekunden)
|
float localProgress = progress / 0.5f; // Normiere auf [0, 1]
|
||||||
|
interpolatedPosition = new Vector3f(
|
||||||
|
FastMath.interpolateLinear(localProgress, startPosition.x, cornerPosition.x),
|
||||||
|
FastMath.interpolateLinear(localProgress, startPosition.y, cornerPosition.y),
|
||||||
|
FastMath.interpolateLinear(localProgress, startPosition.z, cornerPosition.z)
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Figur für Spieler " + player.getId() + " bleibt auf dem gleichen Feld.");
|
// Zweite Hälfte der Animation: Bewegung vom Eckpunkt zum Ziel
|
||||||
|
float localProgress = (progress - 0.5f) / 0.5f; // Normiere auf [0, 1]
|
||||||
|
interpolatedPosition = new Vector3f(
|
||||||
|
FastMath.interpolateLinear(localProgress, cornerPosition.x, targetPosition.x),
|
||||||
|
FastMath.interpolateLinear(localProgress, cornerPosition.y, targetPosition.y),
|
||||||
|
FastMath.interpolateLinear(localProgress, cornerPosition.z, targetPosition.z)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
figure.setLocalTranslation(interpolatedPosition);
|
||||||
|
|
||||||
|
// Animation beenden, wenn sie fertig ist
|
||||||
|
if (progress >= 1.0f) {
|
||||||
|
this.setEnabled(false);
|
||||||
|
app.getRootNode().removeControl(this);
|
||||||
|
System.out.println("Spieler " + player.getId() + " hat das Ziel erreicht: " + targetPosition);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void controlRender(RenderManager rm, ViewPort vp) {
|
||||||
|
// Keine spezielle Renderlogik notwendig
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, (long) 2000); // Verzögerung in Millisekunden
|
||||||
} else {
|
} else {
|
||||||
System.err.println("Figur für Spieler " + player.getId() + " nicht gefunden.");
|
System.err.println("Figur für Spieler " + player.getId() + " nicht gefunden.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getFieldIDFromPosition(Vector3f position) {
|
|
||||||
for (int fieldID = 0; fieldID < 40; fieldID++) {
|
|
||||||
Vector3f fieldPosition = calculateFieldPosition(fieldID, 0);
|
|
||||||
if (fieldPosition.distance(position) < 0.5f) { // Toleranz für Positionserkennung
|
|
||||||
return fieldID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new IllegalArgumentException("Position entspricht keinem gültigen Feld: " + position);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Berechnet den Eckpunkt basierend auf Start- und Zielposition.
|
* Berechnet den Eckpunkt basierend auf Start- und Zielposition.
|
||||||
*
|
*
|
||||||
@ -238,116 +252,24 @@ public class TestWorld implements GameEventListener {
|
|||||||
* @return Die Position der Ecke, die passiert werden muss.
|
* @return Die Position der Ecke, die passiert werden muss.
|
||||||
*/
|
*/
|
||||||
private Vector3f calculateCornerPosition(Vector3f startPosition, Vector3f targetPosition) {
|
private Vector3f calculateCornerPosition(Vector3f startPosition, Vector3f targetPosition) {
|
||||||
// Ziel: Immer entlang der Spielfeldkante navigieren
|
if (Math.abs(startPosition.x - targetPosition.x) > Math.abs(startPosition.z - targetPosition.z)) {
|
||||||
float deltaX = targetPosition.x - startPosition.x;
|
// Bewegung entlang der X-Achse zuerst, dann Z-Achse
|
||||||
float deltaZ = targetPosition.z - startPosition.z;
|
|
||||||
|
|
||||||
// Überprüfen, ob Bewegung entlang X oder Z-Koordinate zuerst erfolgen soll
|
|
||||||
if (deltaX != 0 && deltaZ != 0) {
|
|
||||||
if (Math.abs(deltaX) > Math.abs(deltaZ)) {
|
|
||||||
// Bewegung entlang X zuerst
|
|
||||||
return new Vector3f(targetPosition.x, 0, startPosition.z);
|
return new Vector3f(targetPosition.x, 0, startPosition.z);
|
||||||
} else {
|
} else {
|
||||||
// Bewegung entlang Z zuerst
|
// Bewegung entlang der Z-Achse zuerst, dann X-Achse
|
||||||
return new Vector3f(startPosition.x, 0, targetPosition.z);
|
return new Vector3f(startPosition.x, 0, targetPosition.z);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// Bewegung ist bereits entlang einer Achse (keine Ecke erforderlich)
|
|
||||||
return targetPosition;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<Vector3f> calculatePath(int startFieldID, int targetFieldID, int playerIndex) {
|
|
||||||
List<Vector3f> pathPoints = new ArrayList<>();
|
|
||||||
|
|
||||||
// Bewegung im Uhrzeigersinn
|
|
||||||
if (startFieldID < targetFieldID) {
|
|
||||||
for (int i = startFieldID; i <= targetFieldID; i++) {
|
|
||||||
// Füge Ecken hinzu, falls sie überschritten werden
|
|
||||||
if (i == 10 || i == 20 || i == 30 || i == 0) {
|
|
||||||
pathPoints.add(calculateFieldPosition(i, playerIndex));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Bewegung über das Ende des Spielfelds hinaus (z.B. von 39 zu 5)
|
|
||||||
for (int i = startFieldID; i < 40; i++) {
|
|
||||||
if (i == 10 || i == 20 || i == 30 || i == 0) {
|
|
||||||
pathPoints.add(calculateFieldPosition(i, playerIndex));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int i = 0; i <= targetFieldID; i++) {
|
|
||||||
if (i == 10 || i == 20 || i == 30 || i == 0) {
|
|
||||||
pathPoints.add(calculateFieldPosition(i, playerIndex));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Füge das Ziel hinzu
|
|
||||||
pathPoints.add(calculateFieldPosition(targetFieldID, playerIndex));
|
|
||||||
|
|
||||||
return pathPoints;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private int calculatePlayerIndexOnField(int fieldID, int playerID) {
|
|
||||||
List<Player> playersOnField = playerHandler.getPlayers().stream()
|
|
||||||
.filter(p -> p.getFieldID() == fieldID)
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
for (int i = 0; i < playersOnField.size(); i++) {
|
|
||||||
if (playersOnField.get(i).getId() == playerID) {
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void animateMovementAlongPath(com.jme3.scene.Spatial figure, List<Vector3f> pathPoints) {
|
|
||||||
float animationDurationPerSegment = 2.5f; // Langsamere Animation (2.5 Sekunden pro Segment)
|
|
||||||
int[] currentSegment = {0};
|
|
||||||
|
|
||||||
app.enqueue(() -> {
|
|
||||||
figure.addControl(new AbstractControl() {
|
|
||||||
private float elapsedTime = 0.0f;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void controlUpdate(float tpf) {
|
|
||||||
if (currentSegment[0] >= pathPoints.size() - 1) {
|
|
||||||
this.setEnabled(false); // Animation abgeschlossen
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
elapsedTime += tpf;
|
|
||||||
float progress = Math.min(elapsedTime / animationDurationPerSegment, 1.0f);
|
|
||||||
|
|
||||||
Vector3f start = pathPoints.get(currentSegment[0]);
|
|
||||||
Vector3f end = pathPoints.get(currentSegment[0] + 1);
|
|
||||||
|
|
||||||
Vector3f interpolatedPosition = start.interpolateLocal(end, progress);
|
|
||||||
figure.setLocalTranslation(interpolatedPosition);
|
|
||||||
|
|
||||||
if (progress >= 1.0f) {
|
|
||||||
elapsedTime = 0.0f;
|
|
||||||
currentSegment[0]++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void controlRender(RenderManager rm, ViewPort vp) {
|
|
||||||
// Nicht benötigt
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void receivedEvent(PopUpEvent event) {
|
public void receivedEvent(PopUpEvent event) {
|
||||||
if (event.msg().equals("Buy")) {
|
if (event.msg().equals("Buy")) {
|
||||||
|
// Erstelle einen Timer, um den Delay umzusetzen
|
||||||
Timer timer = new Timer();
|
Timer timer = new Timer();
|
||||||
timer.schedule(new TimerTask() {
|
timer.schedule(new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
// GUI-Operationen im jMonkey-Thread ausführen
|
||||||
app.enqueue(() -> {
|
app.enqueue(() -> {
|
||||||
int field = app.getGameLogic().getPlayerHandler().getPlayerById(app.getId()).getFieldID();
|
int field = app.getGameLogic().getPlayerHandler().getPlayerById(app.getId()).getFieldID();
|
||||||
Object fieldObject = app.getGameLogic().getBoardManager().getFieldAtIndex(field);
|
Object fieldObject = app.getGameLogic().getBoardManager().getFieldAtIndex(field);
|
||||||
@ -361,7 +283,7 @@ public class TestWorld implements GameEventListener {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, 2500);
|
}, 2500); // Verzögerung in Millisekunden
|
||||||
} else if (event.msg().equals("Winner")) {
|
} else if (event.msg().equals("Winner")) {
|
||||||
new WinnerPopUp(app).open();
|
new WinnerPopUp(app).open();
|
||||||
} else if (event.msg().equals("Looser")) {
|
} else if (event.msg().equals("Looser")) {
|
||||||
@ -370,10 +292,6 @@ public class TestWorld implements GameEventListener {
|
|||||||
new TimeOut(app).open();
|
new TimeOut(app).open();
|
||||||
} else if(event.msg().equals("tradeRequest")) {
|
} else if(event.msg().equals("tradeRequest")) {
|
||||||
new ConfirmTrade(app).open();
|
new ConfirmTrade(app).open();
|
||||||
} else if (event.msg().equals("goingToJail")) {
|
|
||||||
new Gulag(app).open();
|
|
||||||
} else if (event.msg().equals("NoMoneyWarning")) {
|
|
||||||
new NoMoneyWarning(app).open();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -383,14 +301,20 @@ public class TestWorld implements GameEventListener {
|
|||||||
timer.schedule(new TimerTask() {
|
timer.schedule(new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
app.enqueue(() -> new EventCardPopup(app, event.description()).open());
|
app.enqueue(() -> {
|
||||||
|
app.getGameLogic().playSound(Sound.EVENT_CARD);
|
||||||
|
new EventCardPopup(app, event.description()).open();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}, 2500);
|
}, 2500); // 5 Sekunden Verzögerung für Event-Popups
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void receivedEvent(UpdatePlayerView event) {
|
public void receivedEvent(UpdatePlayerView event) {
|
||||||
this.playerHandler = app.getGameLogic().getPlayerHandler();
|
this.playerHandler = app.getGameLogic().getPlayerHandler();
|
||||||
|
|
||||||
|
// Aktualisiere die Position aller Spielerfiguren
|
||||||
for (Player player : playerHandler.getPlayers()) {
|
for (Player player : playerHandler.getPlayers()) {
|
||||||
movePlayerFigure(player);
|
movePlayerFigure(player);
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,6 @@ import com.simsilica.lemur.style.ElementId;
|
|||||||
|
|
||||||
import pp.dialog.Dialog;
|
import pp.dialog.Dialog;
|
||||||
import pp.monopoly.client.MonopolyApp;
|
import pp.monopoly.client.MonopolyApp;
|
||||||
import pp.monopoly.client.gui.popups.Bankrupt;
|
|
||||||
import pp.monopoly.game.server.Player;
|
import pp.monopoly.game.server.Player;
|
||||||
import pp.monopoly.game.server.PlayerHandler;
|
import pp.monopoly.game.server.PlayerHandler;
|
||||||
import pp.monopoly.message.client.EndTurn;
|
import pp.monopoly.message.client.EndTurn;
|
||||||
@ -186,12 +185,8 @@ public class Toolbar extends Dialog implements GameEventListener {
|
|||||||
endTurnButton.setPreferredSize(new Vector3f(150, 50, 0));
|
endTurnButton.setPreferredSize(new Vector3f(150, 50, 0));
|
||||||
endTurnButton.addClickCommands(s -> ifTopDialog(() -> {
|
endTurnButton.addClickCommands(s -> ifTopDialog(() -> {
|
||||||
app.getGameLogic().playSound(Sound.BUTTON);
|
app.getGameLogic().playSound(Sound.BUTTON);
|
||||||
if (app.getGameLogic().getPlayerHandler().getPlayerById(app.getId()).getAccountBalance() < 0) {
|
|
||||||
new Bankrupt(app).open();
|
|
||||||
} else {
|
|
||||||
app.getGameLogic().send(new EndTurn());
|
app.getGameLogic().send(new EndTurn());
|
||||||
receivedEvent(new ButtonStatusEvent(false));
|
receivedEvent(new ButtonStatusEvent(false));
|
||||||
}
|
|
||||||
}));
|
}));
|
||||||
return endTurnButton;
|
return endTurnButton;
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ public class Bankrupt extends Dialog {
|
|||||||
// Beenden-Button
|
// Beenden-Button
|
||||||
Button quitButton = bankruptContainer.addChild(new Button("Bestätigen", new ElementId("button")));
|
Button quitButton = bankruptContainer.addChild(new Button("Bestätigen", new ElementId("button")));
|
||||||
quitButton.setFontSize(32);
|
quitButton.setFontSize(32);
|
||||||
quitButton.addClickCommands(source -> ifTopDialog(this::close));
|
quitButton.addClickCommands(source -> close());
|
||||||
|
|
||||||
|
|
||||||
// Zentriere das Popup
|
// Zentriere das Popup
|
||||||
|
@ -68,14 +68,14 @@ public class EventCardPopup extends Dialog {
|
|||||||
eventCardContainer.setLocalTranslation(
|
eventCardContainer.setLocalTranslation(
|
||||||
(app.getCamera().getWidth() - eventCardContainer.getPreferredSize().x) / 2,
|
(app.getCamera().getWidth() - eventCardContainer.getPreferredSize().x) / 2,
|
||||||
(app.getCamera().getHeight() + eventCardContainer.getPreferredSize().y) / 2,
|
(app.getCamera().getHeight() + eventCardContainer.getPreferredSize().y) / 2,
|
||||||
10
|
8
|
||||||
);
|
);
|
||||||
|
|
||||||
// Zentriere das Popup
|
// Zentriere das Popup
|
||||||
backgroundContainer.setLocalTranslation(
|
backgroundContainer.setLocalTranslation(
|
||||||
(app.getCamera().getWidth() - eventCardContainer.getPreferredSize().x - padding) / 2,
|
(app.getCamera().getWidth() - eventCardContainer.getPreferredSize().x - padding) / 2,
|
||||||
(app.getCamera().getHeight() + eventCardContainer.getPreferredSize().y+ padding) / 2,
|
(app.getCamera().getHeight() + eventCardContainer.getPreferredSize().y+ padding) / 2,
|
||||||
9
|
7
|
||||||
);
|
);
|
||||||
|
|
||||||
app.getGuiNode().attachChild(eventCardContainer);
|
app.getGuiNode().attachChild(eventCardContainer);
|
||||||
|
@ -261,8 +261,10 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
|||||||
@Override
|
@Override
|
||||||
public void received(JailEvent msg) {
|
public void received(JailEvent msg) {
|
||||||
if (msg.isGoingToJail()) {
|
if (msg.isGoingToJail()) {
|
||||||
|
|
||||||
playSound(Sound.GULAG);
|
playSound(Sound.GULAG);
|
||||||
notifyListeners(new PopUpEvent("goingToJail", msg));
|
} else {
|
||||||
|
System.out.println("NO MORE JAIL");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -343,10 +345,6 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
|||||||
public void received(NotificationMessage msg) {
|
public void received(NotificationMessage msg) {
|
||||||
if (msg.getKeyWord().equals("rent")) {
|
if (msg.getKeyWord().equals("rent")) {
|
||||||
notifyListeners(new PopUpEvent("rent", msg));
|
notifyListeners(new PopUpEvent("rent", msg));
|
||||||
} else if (msg.getKeyWord().equals("jailpay")) {
|
|
||||||
notifyListeners(new PopUpEvent(msg.getKeyWord(), msg));
|
|
||||||
} else if(msg.getKeyWord().equals("NoMoneyWarning")) {
|
|
||||||
notifyListeners(new PopUpEvent("NoMoneyWarning", msg));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -332,7 +332,6 @@ public class Player implements FieldVisitor<Void>{
|
|||||||
public Void visit(BuildingProperty field) {
|
public Void visit(BuildingProperty field) {
|
||||||
if(field.getOwner() == null) {
|
if(field.getOwner() == null) {
|
||||||
if (field.getPrice() <= accountBalance) getHandler().getLogic().send(this, new BuyPropertyRequest());
|
if (field.getPrice() <= accountBalance) getHandler().getLogic().send(this, new BuyPropertyRequest());
|
||||||
else getHandler().getLogic().send(this, new NotificationMessage("NoMoneyWarning"));
|
|
||||||
} else if (field.getOwner() != this){
|
} else if (field.getOwner() != this){
|
||||||
int rent = field.calcRent();
|
int rent = field.calcRent();
|
||||||
field.getOwner().earnMoney(rent);
|
field.getOwner().earnMoney(rent);
|
||||||
@ -495,7 +494,6 @@ public class Player implements FieldVisitor<Void>{
|
|||||||
*/
|
*/
|
||||||
private static int rollDice() {
|
private static int rollDice() {
|
||||||
return random.nextInt(6) + 1;
|
return random.nextInt(6) + 1;
|
||||||
// return 3;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -614,7 +612,6 @@ public class Player implements FieldVisitor<Void>{
|
|||||||
remainingAttempts--;
|
remainingAttempts--;
|
||||||
if (remainingAttempts <= 0) {
|
if (remainingAttempts <= 0) {
|
||||||
handler.getLogic().send(Player.this, new NotificationMessage("jailpay"));
|
handler.getLogic().send(Player.this, new NotificationMessage("jailpay"));
|
||||||
if(getOutOfJailCard == 0) payBail();
|
|
||||||
} else {
|
} else {
|
||||||
handler.getLogic().send(Player.this, new NotificationMessage("jailtryagain"));
|
handler.getLogic().send(Player.this, new NotificationMessage("jailtryagain"));
|
||||||
}
|
}
|
||||||
@ -625,15 +622,23 @@ public class Player implements FieldVisitor<Void>{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void payBail() {
|
public void payBail() {
|
||||||
|
if (accountBalance >= 500) {
|
||||||
pay(500);
|
pay(500);
|
||||||
|
handler.getLogic().send(Player.this, new NotificationMessage(""));
|
||||||
state = new ActiveState();
|
state = new ActiveState();
|
||||||
|
} else {
|
||||||
|
handler.getLogic().send(Player.this, new NotificationMessage(""));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void useJailCard() {
|
public void useJailCard() {
|
||||||
if (getOutOfJailCard > 0) {
|
if (getOutOfJailCard > 0) {
|
||||||
removeJailCard();
|
removeJailCard();
|
||||||
|
handler.getLogic().send(Player.this, new NotificationMessage(""));
|
||||||
state = new ActiveState();
|
state = new ActiveState();
|
||||||
|
} else {
|
||||||
|
handler.getLogic().send(Player.this, new NotificationMessage(""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,13 +14,11 @@ import pp.monopoly.message.client.AlterProperty;
|
|||||||
import pp.monopoly.message.client.BuyPropertyResponse;
|
import pp.monopoly.message.client.BuyPropertyResponse;
|
||||||
import pp.monopoly.message.client.ClientInterpreter;
|
import pp.monopoly.message.client.ClientInterpreter;
|
||||||
import pp.monopoly.message.client.EndTurn;
|
import pp.monopoly.message.client.EndTurn;
|
||||||
import pp.monopoly.message.client.NotificationAnswer;
|
|
||||||
import pp.monopoly.message.client.PlayerReady;
|
import pp.monopoly.message.client.PlayerReady;
|
||||||
import pp.monopoly.message.client.RollDice;
|
import pp.monopoly.message.client.RollDice;
|
||||||
import pp.monopoly.message.client.TradeOffer;
|
import pp.monopoly.message.client.TradeOffer;
|
||||||
import pp.monopoly.message.client.TradeResponse;
|
import pp.monopoly.message.client.TradeResponse;
|
||||||
import pp.monopoly.message.client.ViewAssetsRequest;
|
import pp.monopoly.message.client.ViewAssetsRequest;
|
||||||
import pp.monopoly.message.server.GameOver;
|
|
||||||
import pp.monopoly.message.server.GameStart;
|
import pp.monopoly.message.server.GameStart;
|
||||||
import pp.monopoly.message.server.NextPlayerTurn;
|
import pp.monopoly.message.server.NextPlayerTurn;
|
||||||
import pp.monopoly.message.server.PlayerStatusUpdate;
|
import pp.monopoly.message.server.PlayerStatusUpdate;
|
||||||
@ -183,14 +181,8 @@ public class ServerGameLogic implements ClientInterpreter {
|
|||||||
send(next, new NextPlayerTurn());
|
send(next, new NextPlayerTurn());
|
||||||
send(next, new PlayerStatusUpdate(playerHandler));
|
send(next, new PlayerStatusUpdate(playerHandler));
|
||||||
send(player, new PlayerStatusUpdate(playerHandler));
|
send(player, new PlayerStatusUpdate(playerHandler));
|
||||||
} else {
|
|
||||||
send(player, new GameOver(false));
|
|
||||||
playerHandler.removePlayer(player);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(playerHandler.getPlayers().size() == 1) {
|
|
||||||
send(playerHandler.getPlayerAtIndex(0), new GameOver(true));
|
|
||||||
}
|
|
||||||
updateAllPlayers();
|
updateAllPlayers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -408,18 +400,5 @@ public class ServerGameLogic implements ClientInterpreter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateAllPlayers();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(NotificationAnswer msg, int from) {
|
|
||||||
if(msg.getKeyword().equals("UseJailCard")) {
|
|
||||||
playerHandler.getPlayerById(from).useJailCard();
|
|
||||||
} else if (msg.getKeyword().equals("PayJail")) {
|
|
||||||
playerHandler.getPlayerById(from).payBail();
|
|
||||||
}
|
|
||||||
|
|
||||||
updateAllPlayers();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,12 +74,4 @@ public interface ClientInterpreter {
|
|||||||
* @param from the connection ID from which the message was received
|
* @param from the connection ID from which the message was received
|
||||||
*/
|
*/
|
||||||
void received(AlterProperty msg, int from);
|
void received(AlterProperty msg, int from);
|
||||||
|
|
||||||
/**
|
|
||||||
* Processes a received NotificationAnswer.
|
|
||||||
*
|
|
||||||
* @param msg the NotificationAnswer to be processed
|
|
||||||
* @param from the connection ID from which the message was received
|
|
||||||
*/
|
|
||||||
void received(NotificationAnswer msg, int from);
|
|
||||||
}
|
}
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
package pp.monopoly.message.client;
|
|
||||||
|
|
||||||
import com.jme3.network.serializing.Serializable;
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
public class NotificationAnswer extends ClientMessage{
|
|
||||||
|
|
||||||
private String keyword;
|
|
||||||
|
|
||||||
private NotificationAnswer() {}
|
|
||||||
|
|
||||||
public NotificationAnswer(String keyword) {
|
|
||||||
this.keyword = keyword;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getKeyword() {
|
|
||||||
return keyword;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void accept(ClientInterpreter interpreter, int from) {
|
|
||||||
interpreter.received(this, from);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -47,7 +47,7 @@ public class DeckHelper{
|
|||||||
cards.add(new Card("Du wurdest zur VP gewählt und schmeißt eine Einstandsparty. Zahle 800 EUR", "vp-einstandsparty"));
|
cards.add(new Card("Du wurdest zur VP gewählt und schmeißt eine Einstandsparty. Zahle 800 EUR", "vp-einstandsparty"));
|
||||||
cards.add(new Card("Du hast eine Party veranstaltet und dick Gewinn gemacht. Ziehe 1500 EUR ein", "party-gewinn"));
|
cards.add(new Card("Du hast eine Party veranstaltet und dick Gewinn gemacht. Ziehe 1500 EUR ein", "party-gewinn"));
|
||||||
cards.add(new Card("Zur falschen Zeit am falschen Ort. Du musst einen Bergmarsch planen und setzt eine Runde aus.", "bergmarsch"));
|
cards.add(new Card("Zur falschen Zeit am falschen Ort. Du musst einen Bergmarsch planen und setzt eine Runde aus.", "bergmarsch"));
|
||||||
cards.add(new Card("Dein Jodel eines Schneepenis mit Unterhodenbeleuchtung geht viral. Ziehe 1000 EUR ein", "jodel-eispenis"));
|
cards.add(new Card("Dein Jodel eines Eispenis mit Unterhodenbeleuchtung geht viral. Ziehe 1000 EUR ein", "jodel-eispenis"));
|
||||||
|
|
||||||
shuffle();
|
shuffle();
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,6 @@ import pp.monopoly.message.client.ViewAssetsRequest;
|
|||||||
import pp.monopoly.message.server.BuyPropertyRequest;
|
import pp.monopoly.message.server.BuyPropertyRequest;
|
||||||
import pp.monopoly.message.server.DiceResult;
|
import pp.monopoly.message.server.DiceResult;
|
||||||
import pp.monopoly.message.server.EventDrawCard;
|
import pp.monopoly.message.server.EventDrawCard;
|
||||||
import pp.monopoly.message.server.GameOver;
|
|
||||||
import pp.monopoly.message.server.GameStart;
|
import pp.monopoly.message.server.GameStart;
|
||||||
import pp.monopoly.message.server.JailEvent;
|
import pp.monopoly.message.server.JailEvent;
|
||||||
import pp.monopoly.message.server.NextPlayerTurn;
|
import pp.monopoly.message.server.NextPlayerTurn;
|
||||||
@ -177,7 +176,6 @@ public class MonopolyServer implements MessageListener<HostedConnection>, Connec
|
|||||||
Serializer.registerClass(NotificationMessage.class);
|
Serializer.registerClass(NotificationMessage.class);
|
||||||
Serializer.registerClass(JailEvent.class);
|
Serializer.registerClass(JailEvent.class);
|
||||||
Serializer.registerClass(AlterProperty.class);
|
Serializer.registerClass(AlterProperty.class);
|
||||||
Serializer.registerClass(GameOver.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerListeners() {
|
private void registerListeners() {
|
||||||
|
Loading…
Reference in New Issue
Block a user