mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2025-04-12 04:21:08 +02:00
Compare commits
10 Commits
e93791e6e8
...
737576e0ca
Author | SHA1 | Date | |
---|---|---|---|
|
737576e0ca | ||
|
db7a99dc59 | ||
|
4b48229329 | ||
|
1a41b548c4 | ||
|
1503e18585 | ||
|
ec42cc2c07 | ||
|
af79e39492 | ||
|
08c1854885 | ||
|
ff39402d82 | ||
|
4e375131d1 |
@ -131,6 +131,39 @@ public class TestWorld implements GameEventListener {
|
||||
app.getRootNode().addLight(ambient);
|
||||
}
|
||||
|
||||
private com.jme3.math.Quaternion calculateRotationForField(int fieldID) {
|
||||
com.jme3.math.Quaternion rotation = new com.jme3.math.Quaternion();
|
||||
|
||||
// Berechne die Rotation basierend auf der Feld-ID
|
||||
if (fieldID >= 0 && fieldID <= 9) {
|
||||
// Untere Seite (0-9)
|
||||
rotation.fromAngleAxis(0, Vector3f.UNIT_Y); // Richtung: nach oben
|
||||
} else if (fieldID >= 10 && fieldID <= 19) {
|
||||
// Rechte Seite (10-19)
|
||||
rotation.fromAngleAxis(FastMath.HALF_PI, Vector3f.UNIT_Y); // Richtung: nach links
|
||||
} else if (fieldID >= 20 && fieldID <= 29) {
|
||||
// Obere Seite (20-29)
|
||||
rotation.fromAngleAxis(FastMath.PI, Vector3f.UNIT_Y); // Richtung: nach unten
|
||||
} else if (fieldID >= 30 && fieldID <= 39) {
|
||||
// Linke Seite (30-39)
|
||||
rotation.fromAngleAxis(3 * FastMath.HALF_PI, Vector3f.UNIT_Y); // Richtung: nach rechts
|
||||
}
|
||||
|
||||
// Korrigiere die Richtung für die Quadranten 10–19 und 30–39 (gegenüberliegende Richtung)
|
||||
if ((fieldID >= 10 && fieldID <= 19) || (fieldID >= 30 && fieldID <= 39)) {
|
||||
com.jme3.math.Quaternion oppositeDirection = new com.jme3.math.Quaternion();
|
||||
oppositeDirection.fromAngleAxis(FastMath.PI, Vector3f.UNIT_Y); // 180° drehen
|
||||
rotation = rotation.multLocal(oppositeDirection);
|
||||
}
|
||||
|
||||
// Füge zusätzliche 90° nach links hinzu
|
||||
com.jme3.math.Quaternion leftTurn = new com.jme3.math.Quaternion();
|
||||
leftTurn.fromAngleAxis(FastMath.HALF_PI, Vector3f.UNIT_Y); // 90° nach links
|
||||
rotation = rotation.multLocal(leftTurn);
|
||||
|
||||
return rotation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Erstellt die Spielfiguren basierend auf der bereits bekannten Spielerliste.
|
||||
*/
|
||||
@ -141,17 +174,14 @@ public class TestWorld implements GameEventListener {
|
||||
com.jme3.scene.Spatial model = app.getAssetManager().loadModel(
|
||||
"models/" + "Spielfiguren/" + player.getFigure().getType() + "/" + player.getFigure().getType() + ".j3o");
|
||||
|
||||
// Setze das Material mit silberner Farbe
|
||||
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
|
||||
//mat.setColor("Diffuse", new com.jme3.math.ColorRGBA(0.45f, 0.45f, 0.45f, 1.0f)); // Silberne Farbe
|
||||
//mat.setColor("Specular", new com.jme3.math.ColorRGBA(0.6f, 0.6f, 0.6f, 1.0f)); // Glanzlicht
|
||||
//mat.setFloat("Shininess", 64f); // Höhere Werte machen das Material glänzender
|
||||
//model.setMaterial(mat);
|
||||
|
||||
// Skaliere und positioniere das Modell
|
||||
model.setLocalScale(0.5f);
|
||||
Vector3f startPosition = calculateFieldPosition(player.getFieldID(), player.getId());
|
||||
model.setLocalTranslation(startPosition);
|
||||
|
||||
// Setze die Rotation basierend auf der Feld-ID
|
||||
model.setLocalRotation(calculateRotationForField(player.getFieldID()));
|
||||
|
||||
model.setName("PlayerFigure_" + player.getId());
|
||||
|
||||
// Füge das Modell zur Szene hinzu
|
||||
@ -223,27 +253,21 @@ public class TestWorld implements GameEventListener {
|
||||
com.jme3.scene.Spatial figure = app.getRootNode().getChild(figureName);
|
||||
|
||||
if (figure != null) {
|
||||
// Berechne das aktuelle Feld basierend auf der Position der Figur
|
||||
int startFieldID = getFieldIDFromPosition(figure.getLocalTranslation());
|
||||
int targetFieldID = player.getFieldID();
|
||||
// Füge einen Delay hinzu (z.B. 3 Sekunden)
|
||||
Timer timer = new Timer();
|
||||
timer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
app.enqueue(() -> {
|
||||
// Setze die Position
|
||||
Vector3f targetPosition = calculateFieldPosition(player.getFieldID(), player.getId());
|
||||
figure.setLocalTranslation(targetPosition);
|
||||
|
||||
// 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.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
// Berechne den Pfad basierend auf den Feld-IDs
|
||||
List<Vector3f> pathPoints = calculatePath(startFieldID, targetFieldID, playerIndexOnField);
|
||||
|
||||
// Starte die Animation entlang des Pfads
|
||||
animateMovementAlongPath(figure, pathPoints);
|
||||
}
|
||||
}, 3000); // Verzögerung von 3000ms (3 Sekunden)
|
||||
} else {
|
||||
System.out.println("Figur für Spieler " + player.getId() + " bleibt auf dem gleichen Feld.");
|
||||
}
|
||||
// Aktualisiere die Rotation basierend auf der Feld-ID
|
||||
figure.setLocalRotation(calculateRotationForField(player.getFieldID()));
|
||||
});
|
||||
}
|
||||
}, 3000); // 3000 Millisekunden Delay
|
||||
} else {
|
||||
System.err.println("Figur für Spieler " + player.getId() + " nicht gefunden.");
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ public class TradeMenu extends Dialog {
|
||||
.getBoardManager()
|
||||
.getPropertyFields(app.getGameLogic()
|
||||
.getPlayerHandler()
|
||||
.getPlayerById(isLeft ? tradeHandler.getReceiver().getId() : tradeHandler.getSender().getId())
|
||||
.getPlayerById(isLeft ? tradeHandler.getSender().getId() : tradeHandler.getReceiver().getId())
|
||||
.getProperties());
|
||||
}
|
||||
|
||||
|
@ -67,19 +67,19 @@ public class BuildingPropertyCard extends Dialog {
|
||||
// Beenden-Button
|
||||
Button quitButton = buildingPropertyContainer.addChild(new Button("Beenden", new ElementId("button")));
|
||||
quitButton.setFontSize(32);
|
||||
quitButton.addClickCommands(s -> ifTopDialog(() -> {
|
||||
quitButton.addClickCommands(s -> {
|
||||
System.err.println("Button does something?");
|
||||
app.getGameLogic().playSound(Sound.BUTTON);
|
||||
close();
|
||||
}));
|
||||
});
|
||||
// Kaufen-Button
|
||||
Button buyButton = buildingPropertyContainer.addChild(new Button("Kaufen", new ElementId("button")));
|
||||
buyButton.setFontSize(32);
|
||||
buyButton.addClickCommands(s -> ifTopDialog( () -> {
|
||||
buyButton.addClickCommands(s -> {
|
||||
app.getGameLogic().playSound(Sound.BUTTON);
|
||||
close();
|
||||
app.getGameLogic().send(new BuyPropertyResponse());
|
||||
}));
|
||||
});
|
||||
|
||||
// Zentriere das Popup
|
||||
buildingPropertyContainer.setLocalTranslation(
|
||||
|
@ -13,6 +13,7 @@ import com.simsilica.lemur.component.QuadBackgroundComponent;
|
||||
import com.simsilica.lemur.style.ElementId;
|
||||
import pp.dialog.Dialog;
|
||||
import pp.monopoly.client.MonopolyApp;
|
||||
import pp.monopoly.notification.Sound;
|
||||
|
||||
/**
|
||||
* EventCardPopup is a popup which appears when a certain EventCard is triggered by entering a EventCardField
|
||||
@ -62,7 +63,10 @@ public class EventCardPopup extends Dialog {
|
||||
// Beenden-Button
|
||||
Button quitButton = eventCardContainer.addChild(new Button("Jawohl", new ElementId("button")));
|
||||
quitButton.setFontSize(32);
|
||||
quitButton.addClickCommands(source -> close());
|
||||
quitButton.addClickCommands(source -> {
|
||||
app.getGameLogic().playSound(Sound.BUTTON);
|
||||
close();
|
||||
});
|
||||
|
||||
// Zentriere das Popup
|
||||
eventCardContainer.setLocalTranslation(
|
||||
|
@ -77,18 +77,18 @@ public class FoodFieldCard extends Dialog {
|
||||
// Beenden-Button
|
||||
Button quitButton = foodFieldContainer.addChild(new Button("Beenden", new ElementId("button")));
|
||||
quitButton.setFontSize(32);
|
||||
quitButton.addClickCommands(s -> ifTopDialog(() -> {
|
||||
quitButton.addClickCommands(s -> {
|
||||
app.getGameLogic().playSound(Sound.BUTTON);
|
||||
close();
|
||||
}));
|
||||
});
|
||||
// Kaufen-Button
|
||||
Button buyButton = foodFieldContainer.addChild(new Button("Kaufen", new ElementId("button")));
|
||||
buyButton.setFontSize(32);
|
||||
buyButton.addClickCommands(s -> ifTopDialog( () -> {
|
||||
buyButton.addClickCommands(s -> {
|
||||
app.getGameLogic().playSound(Sound.BUTTON);
|
||||
app.getGameLogic().send(new BuyPropertyResponse());
|
||||
close();
|
||||
}));
|
||||
});
|
||||
|
||||
// Zentriere das Popup
|
||||
foodFieldContainer.setLocalTranslation(
|
||||
|
@ -69,18 +69,18 @@ public class GateFieldCard extends Dialog {
|
||||
// Beenden-Button
|
||||
Button quitButton = gateFieldContainer.addChild(new Button("Beenden", new ElementId("button")));
|
||||
quitButton.setFontSize(32);
|
||||
quitButton.addClickCommands(s -> ifTopDialog(() -> {
|
||||
quitButton.addClickCommands(s -> {
|
||||
app.getGameLogic().playSound(Sound.BUTTON);
|
||||
close();
|
||||
}));
|
||||
});
|
||||
// Kaufen-Button
|
||||
Button buyButton = gateFieldContainer.addChild(new Button("Kaufen", new ElementId("button")));
|
||||
buyButton.setFontSize(32);
|
||||
buyButton.addClickCommands(s -> ifTopDialog(() -> {
|
||||
buyButton.addClickCommands(s -> {
|
||||
app.getGameLogic().playSound(Sound.BUTTON);
|
||||
app.getGameLogic().send(new BuyPropertyResponse());
|
||||
close();
|
||||
}));
|
||||
});
|
||||
|
||||
// Zentriere das Popup
|
||||
gateFieldContainer.setLocalTranslation(
|
||||
|
@ -208,7 +208,9 @@ public class ServerGameLogic implements ClientInterpreter {
|
||||
}
|
||||
|
||||
if (player != null) {
|
||||
player.setName(msg.getName());
|
||||
String name = msg.getName();
|
||||
String truc = name.length() > 15 ? name.substring(0, 15) : name;
|
||||
player.setName(truc);
|
||||
player.setFigure(new Figure(1, -10, -10, Rotation.LEFT, msg.getFigure()));
|
||||
//TODO add figure to the map
|
||||
playerHandler.setPlayerReady(player, true);
|
||||
@ -298,7 +300,7 @@ public class ServerGameLogic implements ClientInterpreter {
|
||||
receiver.addJailCard();
|
||||
}
|
||||
|
||||
for (int i = 0; i < tradeHandler.getRequestedAmount(); i++) {
|
||||
for (int i = 0; i < tradeHandler.getRequestedJailCards(); i++) {
|
||||
sender.addJailCard();
|
||||
receiver.removeJailCard();
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ public class DeckHelper{
|
||||
}
|
||||
|
||||
private void jahresabschlussantreten(Player player) {
|
||||
player.setPositionWithMoney(17);
|
||||
player.setPositionWithMoney(16);
|
||||
}
|
||||
|
||||
private void verkaufenVersicherungen(Player player) {
|
||||
|
Loading…
Reference in New Issue
Block a user