Compare commits
11 Commits
1ccdea0c87
...
1438ae5e4f
Author | SHA1 | Date | |
---|---|---|---|
|
1438ae5e4f | ||
|
01c351e64b | ||
|
b0c21dfcb8 | ||
|
f4cddbc87f | ||
|
cfce176c82 | ||
|
782b1a10c3 | ||
|
2d9cd0e4e1 | ||
|
908ba09e2a | ||
|
4a84ef4b3c | ||
|
f3353327dd | ||
|
316433f592 |
@ -7,12 +7,12 @@ import pp.monopoly.client.gui.popups.BuyCard;
|
|||||||
import pp.monopoly.client.gui.popups.EventCard;
|
import pp.monopoly.client.gui.popups.EventCard;
|
||||||
import pp.monopoly.client.gui.popups.FoodFieldCard;
|
import pp.monopoly.client.gui.popups.FoodFieldCard;
|
||||||
import pp.monopoly.client.gui.popups.GateFieldCard;
|
import pp.monopoly.client.gui.popups.GateFieldCard;
|
||||||
|
import pp.monopoly.client.gui.popups.LooserPopUp;
|
||||||
|
import pp.monopoly.client.gui.popups.WinnerPopUp;
|
||||||
import pp.monopoly.game.server.Player;
|
import pp.monopoly.game.server.Player;
|
||||||
import pp.monopoly.model.fields.BuildingProperty;
|
import pp.monopoly.model.fields.BuildingProperty;
|
||||||
import pp.monopoly.model.fields.FoodField;
|
import pp.monopoly.model.fields.FoodField;
|
||||||
import pp.monopoly.model.fields.GateField;
|
import pp.monopoly.model.fields.GateField;
|
||||||
import pp.monopoly.model.fields.PropertyField;
|
|
||||||
import pp.monopoly.notification.DiceRollEvent;
|
|
||||||
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;
|
||||||
@ -20,11 +20,12 @@ import pp.monopoly.notification.PopUpEvent;
|
|||||||
/**
|
/**
|
||||||
* TestWorld zeigt eine einfache Szene mit Spielfeld und Spielfiguren.
|
* TestWorld zeigt eine einfache Szene mit Spielfeld und Spielfiguren.
|
||||||
*/
|
*/
|
||||||
public class TestWorld {
|
public class TestWorld implements GameEventListener{
|
||||||
|
|
||||||
private final MonopolyApp app;
|
private final MonopolyApp app;
|
||||||
private final List<Player> players; // Liste der Spieler, bereits aus GameStart geladen
|
private final List<Player> players; // Liste der Spieler, bereits aus GameStart geladen
|
||||||
private CameraController cameraController;
|
private CameraController cameraController;
|
||||||
|
private Toolbar toolbar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Konstruktor für die TestWorld.
|
* Konstruktor für die TestWorld.
|
||||||
@ -35,6 +36,7 @@ public class TestWorld {
|
|||||||
public TestWorld(MonopolyApp app, List<Player> players) {
|
public TestWorld(MonopolyApp app, List<Player> players) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
this.players = players;
|
this.players = players;
|
||||||
|
app.getGameLogic().addListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -52,6 +54,8 @@ public class TestWorld {
|
|||||||
createBoard();
|
createBoard();
|
||||||
createPlayerFigures(); // Lädt Figuren aus der bereits vorhandenen Liste
|
createPlayerFigures(); // Lädt Figuren aus der bereits vorhandenen Liste
|
||||||
setupCamera();
|
setupCamera();
|
||||||
|
toolbar = new Toolbar(app);
|
||||||
|
toolbar.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -128,9 +132,8 @@ public class TestWorld {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void receivedEvent(PopUpEvent event) {
|
public void receivedEvent(PopUpEvent event) {
|
||||||
System.err.println("Trigger ?");
|
if(event.msg().equals("Buy")) {
|
||||||
// if (event.desc() == "BuyCard") {
|
int field = app.getGameLogic().getPlayerHandler().getPlayerById(app.getId()).getFieldID();
|
||||||
int field = app.getGameLogic().getPlayerHandler().getPlayers().get(0).getFieldID();
|
|
||||||
Object fieldObject = app.getGameLogic().getBoardManager().getFieldAtIndex(field);
|
Object fieldObject = app.getGameLogic().getBoardManager().getFieldAtIndex(field);
|
||||||
|
|
||||||
if (fieldObject instanceof BuildingProperty) {
|
if (fieldObject instanceof BuildingProperty) {
|
||||||
@ -140,8 +143,15 @@ public class TestWorld {
|
|||||||
} else if (fieldObject instanceof FoodField) {
|
} else if (fieldObject instanceof FoodField) {
|
||||||
new FoodFieldCard(app).open();
|
new FoodFieldCard(app).open();
|
||||||
}
|
}
|
||||||
|
} else if(event.msg().equals("Winner")) {
|
||||||
|
new WinnerPopUp(app).open();
|
||||||
|
} else if(event.msg().equals("Looser")) {
|
||||||
|
new LooserPopUp(app).open();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void receivedEvent(EventCardEvent event) {
|
||||||
|
new EventCard(app, event.description()).open();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,28 +156,9 @@ public class Toolbar extends Dialog implements GameEventListener {
|
|||||||
animatingDice = true;
|
animatingDice = true;
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
Thread diceAnimation = new Thread(() -> {
|
new Thread(() -> {
|
||||||
int[] currentFace = {1};
|
|
||||||
try {
|
try {
|
||||||
while (System.currentTimeMillis() - startTime < 2000) { // Animation läuft für 4 Sekunden
|
animateDice(startTime);
|
||||||
currentFace[0] = (currentFace[0] % 6) + 1;
|
|
||||||
|
|
||||||
String rotatingImage1 = diceToString(currentFace[0]);
|
|
||||||
String rotatingImage2 = diceToString((currentFace[0] % 6) + 1);
|
|
||||||
|
|
||||||
IconComponent newIcon1 = new IconComponent(rotatingImage1);
|
|
||||||
newIcon1.setIconSize(new Vector2f(100, 100));
|
|
||||||
app.enqueue(() -> imageLabel.setIcon(newIcon1));
|
|
||||||
|
|
||||||
IconComponent newIcon2 = new IconComponent(rotatingImage2);
|
|
||||||
newIcon2.setIconSize(new Vector2f(100, 100));
|
|
||||||
app.enqueue(() -> imageLabel2.setIcon(newIcon2));
|
|
||||||
|
|
||||||
// Warte 100 ms, bevor die Bilder wechseln
|
|
||||||
Thread.sleep(100);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Animation beenden
|
|
||||||
animatingDice = false;
|
animatingDice = false;
|
||||||
if (latestDiceRollEvent != null) {
|
if (latestDiceRollEvent != null) {
|
||||||
showFinalDiceResult(latestDiceRollEvent);
|
showFinalDiceResult(latestDiceRollEvent);
|
||||||
|
@ -15,7 +15,7 @@ import pp.dialog.Dialog;
|
|||||||
import pp.monopoly.client.MonopolyApp;
|
import pp.monopoly.client.MonopolyApp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bankrupt ist ein Overlay-Menü, welches aufgerufen werden kann, wenn man mit einem negativen Kontostand den Zug beenden möchte. // TODO welche menü-Klasse
|
* Bankrupt is a Warning-Popup, which appears, if the balance is negative at the end of a player´s turn // TODO welche menü-Klasse
|
||||||
*/
|
*/
|
||||||
public class Bankrupt extends Dialog {
|
public class Bankrupt extends Dialog {
|
||||||
private final MonopolyApp app;
|
private final MonopolyApp app;
|
||||||
@ -40,26 +40,26 @@ public class Bankrupt extends Dialog {
|
|||||||
app.getGuiNode().attachChild(backgroundContainer);
|
app.getGuiNode().attachChild(backgroundContainer);
|
||||||
|
|
||||||
|
|
||||||
// Hauptcontainer für die Gebäudekarte
|
// Hauptcontainer für die Warnung
|
||||||
bankruptContainer = new Container();
|
bankruptContainer = new Container();
|
||||||
bankruptContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f)));
|
bankruptContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f)));
|
||||||
bankruptContainer.setPreferredSize(new Vector3f(550,250,10));
|
bankruptContainer.setPreferredSize(new Vector3f(550,250,10));
|
||||||
|
|
||||||
float padding = 10; // Padding around the settingsContainer for the background
|
float padding = 10; // Passt den backgroundContainer an die Größe des bankruptContainers an
|
||||||
backgroundContainer.setPreferredSize(bankruptContainer.getPreferredSize().addLocal(padding, padding, 0));
|
backgroundContainer.setPreferredSize(bankruptContainer.getPreferredSize().addLocal(padding, padding, 0));
|
||||||
|
|
||||||
// Titel
|
// Titel
|
||||||
// Die Namen werden dynamisch dem BoardManager entnommen
|
|
||||||
Label gateFieldTitle = bankruptContainer.addChild(new Label("Vorsicht !", new ElementId("settings-title"))); //TODO Dicke Schrift
|
Label gateFieldTitle = bankruptContainer.addChild(new Label("Vorsicht !", new ElementId("settings-title"))); //TODO Dicke Schrift
|
||||||
gateFieldTitle.setFontSize(48);
|
gateFieldTitle.setFontSize(48);
|
||||||
gateFieldTitle.setColor(ColorRGBA.Black);
|
gateFieldTitle.setColor(ColorRGBA.Black);
|
||||||
|
|
||||||
// Text, der auf der Karte steht
|
// Text, der im Popup steht
|
||||||
// Die Preise werden dynamisch dem BoardManager entnommen
|
Container textContainer = bankruptContainer.addChild(new Container());
|
||||||
Container Container = bankruptContainer.addChild(new Container());
|
textContainer.addChild(new Label("Du hast noch einen negativen Kontostand. Wenn du jetzt deinen Zug beendest, gehst du Bankrott und verlierst das Spiel!", new ElementId("label-Text")));
|
||||||
Container.addChild(new Label("Du hast noch einen negativen Kontostand. Wenn du jetzt deinen Zug beendest, gehst du Bankrott und verlierst das Spiel!", new ElementId("label-Text")));
|
textContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
|
||||||
Container.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
|
|
||||||
Container.setPreferredSize(bankruptContainer.getPreferredSize().addLocal(-250,-200,0));
|
// Passt den textContainer an die Größe des bankruptContainers an
|
||||||
|
textContainer.setPreferredSize(bankruptContainer.getPreferredSize().addLocal(-250,-200,0));
|
||||||
|
|
||||||
// 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")));
|
||||||
@ -67,14 +67,14 @@ public class Bankrupt extends Dialog {
|
|||||||
quitButton.addClickCommands(source -> close());
|
quitButton.addClickCommands(source -> close());
|
||||||
|
|
||||||
|
|
||||||
// Zentriere das Menü
|
// Zentriere den Container
|
||||||
bankruptContainer.setLocalTranslation(
|
bankruptContainer.setLocalTranslation(
|
||||||
(app.getCamera().getWidth() - bankruptContainer.getPreferredSize().x) / 2,
|
(app.getCamera().getWidth() - bankruptContainer.getPreferredSize().x) / 2,
|
||||||
(app.getCamera().getHeight() + bankruptContainer.getPreferredSize().y) / 2,
|
(app.getCamera().getHeight() + bankruptContainer.getPreferredSize().y) / 2,
|
||||||
8
|
8
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Zentriere den Container
|
||||||
backgroundContainer.setLocalTranslation(
|
backgroundContainer.setLocalTranslation(
|
||||||
(app.getCamera().getWidth() - bankruptContainer.getPreferredSize().x - padding) / 2,
|
(app.getCamera().getWidth() - bankruptContainer.getPreferredSize().x - padding) / 2,
|
||||||
(app.getCamera().getHeight() + bankruptContainer.getPreferredSize().y+ padding) / 2,
|
(app.getCamera().getHeight() + bankruptContainer.getPreferredSize().y+ padding) / 2,
|
||||||
@ -101,7 +101,7 @@ public class Bankrupt extends Dialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Schließt das Menü und entfernt die GUI-Elemente.
|
* Closes the menu and removes the GUI elements.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
@ -115,5 +115,4 @@ public class Bankrupt extends Dialog {
|
|||||||
public void escape() {
|
public void escape() {
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -17,7 +17,7 @@ import pp.monopoly.notification.Sound;
|
|||||||
import static pp.monopoly.Resources.lookup;
|
import static pp.monopoly.Resources.lookup;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TimeOut ist ein Overlay-Menü, welches aufgerufen wird, wenn die Verbindung zum Server unterbrochen wurde.
|
* TimeOut is a warning popup that is triggered when the connection to the server is interrupted.
|
||||||
*/
|
*/
|
||||||
public class TimeOut extends Dialog {
|
public class TimeOut extends Dialog {
|
||||||
private final MonopolyApp app;
|
private final MonopolyApp app;
|
||||||
@ -43,26 +43,24 @@ public class TimeOut extends Dialog {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Hauptcontainer für die Gebäudekarte
|
// Hauptcontainer für die Warnung
|
||||||
timeOutContainer = new Container();
|
timeOutContainer = new Container();
|
||||||
timeOutContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f)));
|
timeOutContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f)));
|
||||||
timeOutContainer.setPreferredSize(new Vector3f(550,250,10));
|
timeOutContainer.setPreferredSize(new Vector3f(550,250,10));
|
||||||
|
|
||||||
float padding = 10; // Padding around the settingsContainer for the background
|
float padding = 10; // Passt den backgroundContainer an die Größe des bankruptContainers an
|
||||||
backgroundContainer.setPreferredSize(timeOutContainer.getPreferredSize().addLocal(padding, padding, 0));
|
backgroundContainer.setPreferredSize(timeOutContainer.getPreferredSize().addLocal(padding, padding, 0));
|
||||||
|
|
||||||
// Titel
|
// Titel
|
||||||
// Die Namen werden dynamisch dem BoardManager entnommen
|
|
||||||
Label gateFieldTitle = timeOutContainer.addChild(new Label("Vorsicht !", new ElementId("settings-title"))); //TODO dicke Schrift
|
Label gateFieldTitle = timeOutContainer.addChild(new Label("Vorsicht !", new ElementId("settings-title"))); //TODO dicke Schrift
|
||||||
gateFieldTitle.setFontSize(48);
|
gateFieldTitle.setFontSize(48);
|
||||||
gateFieldTitle.setColor(ColorRGBA.Black);
|
gateFieldTitle.setColor(ColorRGBA.Black);
|
||||||
|
|
||||||
// Text, der auf der Karte steht
|
// Text, der auf der Karte steht
|
||||||
// Die Preise werden dynamisch dem BoardManager entnommen
|
Container textContainer = timeOutContainer.addChild(new Container());
|
||||||
Container propertyValuesContainer = timeOutContainer.addChild(new Container());
|
textContainer.addChild(new Label("Du hast die Verbindung verloren und kannst nichts dagegen machen. Akzeptiere einfach, dass du verloren hast!", new ElementId("label-Text")));
|
||||||
propertyValuesContainer.addChild(new Label("Du hast die Verbindung verloren und kannst nichts dagegen machen. Akzeptiere einfach, dass du verloren hast!", new ElementId("label-Text")));
|
textContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
|
||||||
propertyValuesContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
|
textContainer.setPreferredSize(timeOutContainer.getPreferredSize().addLocal(-250,-200,0));
|
||||||
propertyValuesContainer.setPreferredSize(timeOutContainer.getPreferredSize().addLocal(-250,-200,0));
|
|
||||||
|
|
||||||
// Beenden-Button
|
// Beenden-Button
|
||||||
Button quitButton = timeOutContainer.addChild(new Button("Bestätigen", new ElementId("button")));
|
Button quitButton = timeOutContainer.addChild(new Button("Bestätigen", new ElementId("button")));
|
||||||
@ -70,14 +68,14 @@ public class TimeOut extends Dialog {
|
|||||||
quitButton.addClickCommands(source -> close());
|
quitButton.addClickCommands(source -> close());
|
||||||
|
|
||||||
|
|
||||||
// Zentriere das Menü
|
// Zentriere den Container
|
||||||
timeOutContainer.setLocalTranslation(
|
timeOutContainer.setLocalTranslation(
|
||||||
(app.getCamera().getWidth() - timeOutContainer.getPreferredSize().x) / 2,
|
(app.getCamera().getWidth() - timeOutContainer.getPreferredSize().x) / 2,
|
||||||
(app.getCamera().getHeight() + timeOutContainer.getPreferredSize().y) / 2,
|
(app.getCamera().getHeight() + timeOutContainer.getPreferredSize().y) / 2,
|
||||||
8
|
8
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Zentriere den Container
|
||||||
backgroundContainer.setLocalTranslation(
|
backgroundContainer.setLocalTranslation(
|
||||||
(app.getCamera().getWidth() - timeOutContainer.getPreferredSize().x - padding) / 2,
|
(app.getCamera().getWidth() - timeOutContainer.getPreferredSize().x - padding) / 2,
|
||||||
(app.getCamera().getHeight() + timeOutContainer.getPreferredSize().y+ padding) / 2,
|
(app.getCamera().getHeight() + timeOutContainer.getPreferredSize().y+ padding) / 2,
|
||||||
|
After Width: | Height: | Size: 6.7 MiB |
After Width: | Height: | Size: 518 KiB |
After Width: | Height: | Size: 24 MiB |
After Width: | Height: | Size: 31 MiB |
After Width: | Height: | Size: 15 MiB |
After Width: | Height: | Size: 18 MiB |
After Width: | Height: | Size: 556 KiB |
After Width: | Height: | Size: 66 KiB |
After Width: | Height: | Size: 200 KiB |
After Width: | Height: | Size: 143 B |
After Width: | Height: | Size: 146 B |
After Width: | Height: | Size: 153 B |
After Width: | Height: | Size: 147 B |
After Width: | Height: | Size: 187 B |
After Width: | Height: | Size: 177 B |
After Width: | Height: | Size: 165 B |
After Width: | Height: | Size: 147 B |
After Width: | Height: | Size: 150 B |
After Width: | Height: | Size: 202 B |
After Width: | Height: | Size: 41 KiB |
BIN
Projekte/monopoly/client/src/main/resources/models/OOP/OOP.j3o
Normal file
@ -226,12 +226,10 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
|||||||
@Override
|
@Override
|
||||||
public void received(GameOver msg) {
|
public void received(GameOver msg) {
|
||||||
if (msg.isWinner()) {
|
if (msg.isWinner()) {
|
||||||
|
notifyListeners(new PopUpEvent("Winner"));
|
||||||
//Winner popup
|
|
||||||
playSound(Sound.WINNER);
|
playSound(Sound.WINNER);
|
||||||
} else {
|
} else {
|
||||||
|
notifyListeners(new PopUpEvent("Looser"));
|
||||||
// Looser popup
|
|
||||||
playSound(Sound.LOSER);
|
playSound(Sound.LOSER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -333,6 +331,6 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(BuyPropertyRequest msg) {
|
public void received(BuyPropertyRequest msg) {
|
||||||
notifyListeners(new PopUpEvent());
|
notifyListeners(new PopUpEvent("Buy"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package pp.monopoly.notification;
|
package pp.monopoly.notification;
|
||||||
|
|
||||||
public record PopUpEvent() implements GameEvent{
|
public record PopUpEvent(String msg) implements GameEvent{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void notifyListener(GameEventListener listener) {
|
public void notifyListener(GameEventListener listener) {
|
||||||
|