mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2025-04-17 12:40:59 +02:00
Compare commits
No commits in common. "f4bf38bca1a87610a8c722486e1829b1203e1e8e" and "f6137b8b689ac882eb66aa2a6b71f7ff4d656e42" have entirely different histories.
f4bf38bca1
...
f6137b8b68
@ -280,11 +280,15 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
|
|||||||
//logik zum wechselnden erscheinen und verschwinden beim drücken von B //TODO süäter entfernen
|
//logik zum wechselnden erscheinen und verschwinden beim drücken von B //TODO süäter entfernen
|
||||||
private void handleB(boolean isPressed) {
|
private void handleB(boolean isPressed) {
|
||||||
if (isPressed) {
|
if (isPressed) {
|
||||||
Dialog tmp = new NoMoneyWarning(this);
|
Dialog tmp = new LooserPopUp(this);
|
||||||
tmp.open();
|
tmp.open();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes and attaches the necessary application states for the game.
|
* Initializes and attaches the necessary application states for the game.
|
||||||
*/
|
*/
|
||||||
|
@ -11,12 +11,10 @@ import pp.monopoly.client.gui.popups.EventCardPopup;
|
|||||||
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.LooserPopUp;
|
||||||
import pp.monopoly.client.gui.popups.Rent;
|
|
||||||
import pp.monopoly.client.gui.popups.TimeOut;
|
import pp.monopoly.client.gui.popups.TimeOut;
|
||||||
import pp.monopoly.client.gui.popups.WinnerPopUp;
|
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.message.server.NotificationMessage;
|
|
||||||
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;
|
||||||
@ -155,8 +153,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("rent")) {
|
|
||||||
new Rent(app, ( (NotificationMessage) event.message()).getRentOwner(), ( (NotificationMessage) event.message()).getRentAmount() ).open();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,120 +0,0 @@
|
|||||||
package pp.monopoly.client.gui.popups;
|
|
||||||
|
|
||||||
import com.jme3.material.Material;
|
|
||||||
import com.jme3.material.RenderState.BlendMode;
|
|
||||||
import com.jme3.math.ColorRGBA;
|
|
||||||
import com.jme3.math.Vector3f;
|
|
||||||
import com.jme3.scene.Geometry;
|
|
||||||
import com.jme3.scene.shape.Quad;
|
|
||||||
import com.simsilica.lemur.Button;
|
|
||||||
import com.simsilica.lemur.Container;
|
|
||||||
import com.simsilica.lemur.Label;
|
|
||||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
|
||||||
import com.simsilica.lemur.style.ElementId;
|
|
||||||
import pp.dialog.Dialog;
|
|
||||||
import pp.monopoly.client.MonopolyApp;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Bankrupt is a Warning-Popup which appears when the balance is negative at the end of a player´s turn
|
|
||||||
*/
|
|
||||||
public class AcceptTrade extends Dialog {
|
|
||||||
private final MonopolyApp app;
|
|
||||||
private final Geometry overlayBackground;
|
|
||||||
private final Container noMoneyWarningContainer;
|
|
||||||
private final Container backgroundContainer;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public AcceptTrade(MonopolyApp app) {
|
|
||||||
super(app.getDialogManager());
|
|
||||||
this.app = app;
|
|
||||||
|
|
||||||
|
|
||||||
// Halbtransparentes Overlay hinzufügen
|
|
||||||
overlayBackground = createOverlayBackground();
|
|
||||||
app.getGuiNode().attachChild(overlayBackground);
|
|
||||||
|
|
||||||
// Create the background container
|
|
||||||
backgroundContainer = new Container();
|
|
||||||
backgroundContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); // Darker background
|
|
||||||
app.getGuiNode().attachChild(backgroundContainer);
|
|
||||||
|
|
||||||
|
|
||||||
// Hauptcontainer für die Warnung
|
|
||||||
noMoneyWarningContainer = new Container();
|
|
||||||
noMoneyWarningContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f)));
|
|
||||||
noMoneyWarningContainer.setPreferredSize(new Vector3f(550,250,10));
|
|
||||||
|
|
||||||
float padding = 10; // Passt den backgroundContainer an die Größe des bankruptContainers an
|
|
||||||
backgroundContainer.setPreferredSize(noMoneyWarningContainer.getPreferredSize().addLocal(padding, padding, 0));
|
|
||||||
|
|
||||||
// Titel
|
|
||||||
Label gateFieldTitle = noMoneyWarningContainer.addChild(new Label("Handel angenommen!", new ElementId("warning-title")));
|
|
||||||
gateFieldTitle.setFontSize(48);
|
|
||||||
gateFieldTitle.setColor(ColorRGBA.Black);
|
|
||||||
|
|
||||||
// Text, der im Popup steht
|
|
||||||
Container textContainer = noMoneyWarningContainer.addChild(new Container());
|
|
||||||
textContainer.addChild(new Label("Du hast Spieler XXX einen Handel vorgeschlagen", new ElementId("label-Text")));
|
|
||||||
textContainer.addChild(new Label("", new ElementId("label-Text")));
|
|
||||||
textContainer.addChild(new Label("Der Handel wurde angenommen", new ElementId("label-Text")));
|
|
||||||
textContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
|
|
||||||
|
|
||||||
// Passt den textContainer an die Größe des bankruptContainers an
|
|
||||||
textContainer.setPreferredSize(noMoneyWarningContainer.getPreferredSize().addLocal(-250,-200,0));
|
|
||||||
|
|
||||||
// Beenden-Button
|
|
||||||
Button quitButton = noMoneyWarningContainer.addChild(new Button("Bestätigen", new ElementId("button")));
|
|
||||||
quitButton.setFontSize(32);
|
|
||||||
quitButton.addClickCommands(source -> close());
|
|
||||||
|
|
||||||
|
|
||||||
// Zentriere das Popup
|
|
||||||
noMoneyWarningContainer.setLocalTranslation(
|
|
||||||
(app.getCamera().getWidth() - noMoneyWarningContainer.getPreferredSize().x) / 2,
|
|
||||||
(app.getCamera().getHeight() + noMoneyWarningContainer.getPreferredSize().y) / 2,
|
|
||||||
8
|
|
||||||
);
|
|
||||||
|
|
||||||
// Zentriere das Popup
|
|
||||||
backgroundContainer.setLocalTranslation(
|
|
||||||
(app.getCamera().getWidth() - noMoneyWarningContainer.getPreferredSize().x - padding) / 2,
|
|
||||||
(app.getCamera().getHeight() + noMoneyWarningContainer.getPreferredSize().y+ padding) / 2,
|
|
||||||
7
|
|
||||||
);
|
|
||||||
|
|
||||||
app.getGuiNode().attachChild(noMoneyWarningContainer);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Erstellt einen halbtransparenten Hintergrund für das Menü.
|
|
||||||
*
|
|
||||||
* @return Geometrie des Overlays
|
|
||||||
*/
|
|
||||||
private Geometry createOverlayBackground() {
|
|
||||||
Quad quad = new Quad(app.getCamera().getWidth(), app.getCamera().getHeight());
|
|
||||||
Geometry overlay = new Geometry("Overlay", quad);
|
|
||||||
Material material = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
|
|
||||||
material.setColor("Color", new ColorRGBA(0, 0, 0, 0.5f)); // Halbtransparent
|
|
||||||
material.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
|
|
||||||
overlay.setMaterial(material);
|
|
||||||
overlay.setLocalTranslation(0, 0, 0);
|
|
||||||
return overlay;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Closes the menu and removes the GUI elements.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void close() {
|
|
||||||
app.getGuiNode().detachChild(noMoneyWarningContainer); // Entferne das Menü
|
|
||||||
app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand
|
|
||||||
app.getGuiNode().detachChild(overlayBackground); // Entferne das Overlay
|
|
||||||
super.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void escape() {
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,118 +0,0 @@
|
|||||||
package pp.monopoly.client.gui.popups;
|
|
||||||
|
|
||||||
import com.jme3.material.Material;
|
|
||||||
import com.jme3.material.RenderState.BlendMode;
|
|
||||||
import com.jme3.math.ColorRGBA;
|
|
||||||
import com.jme3.math.Vector3f;
|
|
||||||
import com.jme3.scene.Geometry;
|
|
||||||
import com.jme3.scene.shape.Quad;
|
|
||||||
import com.simsilica.lemur.Button;
|
|
||||||
import com.simsilica.lemur.Container;
|
|
||||||
import com.simsilica.lemur.Label;
|
|
||||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
|
||||||
import com.simsilica.lemur.style.ElementId;
|
|
||||||
import pp.dialog.Dialog;
|
|
||||||
import pp.monopoly.client.MonopolyApp;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Bankrupt is a Warning-Popup which appears when the balance is negative at the end of a player´s turn
|
|
||||||
*/
|
|
||||||
public class NoMoneyWarning extends Dialog {
|
|
||||||
private final MonopolyApp app;
|
|
||||||
private final Geometry overlayBackground;
|
|
||||||
private final Container noMoneyWarningContainer;
|
|
||||||
private final Container backgroundContainer;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public NoMoneyWarning(MonopolyApp app) {
|
|
||||||
super(app.getDialogManager());
|
|
||||||
this.app = app;
|
|
||||||
|
|
||||||
|
|
||||||
// Halbtransparentes Overlay hinzufügen
|
|
||||||
overlayBackground = createOverlayBackground();
|
|
||||||
app.getGuiNode().attachChild(overlayBackground);
|
|
||||||
|
|
||||||
// Create the background container
|
|
||||||
backgroundContainer = new Container();
|
|
||||||
backgroundContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); // Darker background
|
|
||||||
app.getGuiNode().attachChild(backgroundContainer);
|
|
||||||
|
|
||||||
|
|
||||||
// Hauptcontainer für die Warnung
|
|
||||||
noMoneyWarningContainer = new Container();
|
|
||||||
noMoneyWarningContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f)));
|
|
||||||
noMoneyWarningContainer.setPreferredSize(new Vector3f(550,250,10));
|
|
||||||
|
|
||||||
float padding = 10; // Passt den backgroundContainer an die Größe des bankruptContainers an
|
|
||||||
backgroundContainer.setPreferredSize(noMoneyWarningContainer.getPreferredSize().addLocal(padding, padding, 0));
|
|
||||||
|
|
||||||
// Titel
|
|
||||||
Label gateFieldTitle = noMoneyWarningContainer.addChild(new Label("Na, schon wieder Pleite?", new ElementId("warning-title")));
|
|
||||||
gateFieldTitle.setFontSize(38);
|
|
||||||
gateFieldTitle.setColor(ColorRGBA.Black);
|
|
||||||
|
|
||||||
// Text, der im Popup steht
|
|
||||||
Container textContainer = noMoneyWarningContainer.addChild(new Container());
|
|
||||||
textContainer.addChild(new Label("Du hast nicht genug Geld, um dieses Gebäude zu kaufen", new ElementId("label-Text")));
|
|
||||||
textContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
|
|
||||||
|
|
||||||
// Passt den textContainer an die Größe des bankruptContainers an
|
|
||||||
textContainer.setPreferredSize(noMoneyWarningContainer.getPreferredSize().addLocal(-250,-200,0));
|
|
||||||
|
|
||||||
// Beenden-Button
|
|
||||||
Button quitButton = noMoneyWarningContainer.addChild(new Button("Bestätigen", new ElementId("button")));
|
|
||||||
quitButton.setFontSize(32);
|
|
||||||
quitButton.addClickCommands(source -> close());
|
|
||||||
|
|
||||||
|
|
||||||
// Zentriere das Popup
|
|
||||||
noMoneyWarningContainer.setLocalTranslation(
|
|
||||||
(app.getCamera().getWidth() - noMoneyWarningContainer.getPreferredSize().x) / 2,
|
|
||||||
(app.getCamera().getHeight() + noMoneyWarningContainer.getPreferredSize().y) / 2,
|
|
||||||
8
|
|
||||||
);
|
|
||||||
|
|
||||||
// Zentriere das Popup
|
|
||||||
backgroundContainer.setLocalTranslation(
|
|
||||||
(app.getCamera().getWidth() - noMoneyWarningContainer.getPreferredSize().x - padding) / 2,
|
|
||||||
(app.getCamera().getHeight() + noMoneyWarningContainer.getPreferredSize().y+ padding) / 2,
|
|
||||||
7
|
|
||||||
);
|
|
||||||
|
|
||||||
app.getGuiNode().attachChild(noMoneyWarningContainer);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Erstellt einen halbtransparenten Hintergrund für das Menü.
|
|
||||||
*
|
|
||||||
* @return Geometrie des Overlays
|
|
||||||
*/
|
|
||||||
private Geometry createOverlayBackground() {
|
|
||||||
Quad quad = new Quad(app.getCamera().getWidth(), app.getCamera().getHeight());
|
|
||||||
Geometry overlay = new Geometry("Overlay", quad);
|
|
||||||
Material material = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
|
|
||||||
material.setColor("Color", new ColorRGBA(0, 0, 0, 0.5f)); // Halbtransparent
|
|
||||||
material.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
|
|
||||||
overlay.setMaterial(material);
|
|
||||||
overlay.setLocalTranslation(0, 0, 0);
|
|
||||||
return overlay;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Closes the menu and removes the GUI elements.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void close() {
|
|
||||||
app.getGuiNode().detachChild(noMoneyWarningContainer); // Entferne das Menü
|
|
||||||
app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand
|
|
||||||
app.getGuiNode().detachChild(overlayBackground); // Entferne das Overlay
|
|
||||||
super.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void escape() {
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
package pp.monopoly.client.gui.popups;
|
|
||||||
|
|
||||||
import com.jme3.material.Material;
|
|
||||||
import com.jme3.material.RenderState.BlendMode;
|
|
||||||
import com.jme3.math.ColorRGBA;
|
|
||||||
import com.jme3.math.Vector3f;
|
|
||||||
import com.jme3.scene.Geometry;
|
|
||||||
import com.jme3.scene.shape.Quad;
|
|
||||||
import com.simsilica.lemur.Button;
|
|
||||||
import com.simsilica.lemur.Container;
|
|
||||||
import com.simsilica.lemur.Label;
|
|
||||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
|
||||||
import com.simsilica.lemur.style.ElementId;
|
|
||||||
import pp.dialog.Dialog;
|
|
||||||
import pp.monopoly.client.MonopolyApp;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Bankrupt is a Warning-Popup which appears when the balance is negative at the end of a player´s turn
|
|
||||||
*/
|
|
||||||
public class RejectTrade extends Dialog {
|
|
||||||
private final MonopolyApp app;
|
|
||||||
private final Geometry overlayBackground;
|
|
||||||
private final Container noMoneyWarningContainer;
|
|
||||||
private final Container backgroundContainer;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public RejectTrade(MonopolyApp app) {
|
|
||||||
super(app.getDialogManager());
|
|
||||||
this.app = app;
|
|
||||||
|
|
||||||
|
|
||||||
// Halbtransparentes Overlay hinzufügen
|
|
||||||
overlayBackground = createOverlayBackground();
|
|
||||||
app.getGuiNode().attachChild(overlayBackground);
|
|
||||||
|
|
||||||
// Create the background container
|
|
||||||
backgroundContainer = new Container();
|
|
||||||
backgroundContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); // Darker background
|
|
||||||
app.getGuiNode().attachChild(backgroundContainer);
|
|
||||||
|
|
||||||
|
|
||||||
// Hauptcontainer für die Warnung
|
|
||||||
noMoneyWarningContainer = new Container();
|
|
||||||
noMoneyWarningContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f)));
|
|
||||||
noMoneyWarningContainer.setPreferredSize(new Vector3f(550,250,10));
|
|
||||||
|
|
||||||
float padding = 10; // Passt den backgroundContainer an die Größe des bankruptContainers an
|
|
||||||
backgroundContainer.setPreferredSize(noMoneyWarningContainer.getPreferredSize().addLocal(padding, padding, 0));
|
|
||||||
|
|
||||||
// Titel
|
|
||||||
Label gateFieldTitle = noMoneyWarningContainer.addChild(new Label("Handel abgelehnt!", new ElementId("warning-title")));
|
|
||||||
gateFieldTitle.setFontSize(48);
|
|
||||||
gateFieldTitle.setColor(ColorRGBA.Black);
|
|
||||||
|
|
||||||
// Text, der im Popup steht
|
|
||||||
Container textContainer = noMoneyWarningContainer.addChild(new Container());
|
|
||||||
textContainer.addChild(new Label("Du hast Spieler XXX einen Handel vorgeschlagen", new ElementId("label-Text")));
|
|
||||||
textContainer.addChild(new Label("", new ElementId("label-Text")));
|
|
||||||
textContainer.addChild(new Label("Der Handel wurde abgelehnt", new ElementId("label-Text")));
|
|
||||||
textContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
|
|
||||||
|
|
||||||
// Passt den textContainer an die Größe des bankruptContainers an
|
|
||||||
textContainer.setPreferredSize(noMoneyWarningContainer.getPreferredSize().addLocal(-250,-200,0));
|
|
||||||
|
|
||||||
// Beenden-Button
|
|
||||||
Button quitButton = noMoneyWarningContainer.addChild(new Button("Bestätigen", new ElementId("button")));
|
|
||||||
quitButton.setFontSize(32);
|
|
||||||
quitButton.addClickCommands(source -> close());
|
|
||||||
|
|
||||||
|
|
||||||
// Zentriere das Popup
|
|
||||||
noMoneyWarningContainer.setLocalTranslation(
|
|
||||||
(app.getCamera().getWidth() - noMoneyWarningContainer.getPreferredSize().x) / 2,
|
|
||||||
(app.getCamera().getHeight() + noMoneyWarningContainer.getPreferredSize().y) / 2,
|
|
||||||
8
|
|
||||||
);
|
|
||||||
|
|
||||||
// Zentriere das Popup
|
|
||||||
backgroundContainer.setLocalTranslation(
|
|
||||||
(app.getCamera().getWidth() - noMoneyWarningContainer.getPreferredSize().x - padding) / 2,
|
|
||||||
(app.getCamera().getHeight() + noMoneyWarningContainer.getPreferredSize().y+ padding) / 2,
|
|
||||||
7
|
|
||||||
);
|
|
||||||
|
|
||||||
app.getGuiNode().attachChild(noMoneyWarningContainer);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Erstellt einen halbtransparenten Hintergrund für das Menü.
|
|
||||||
*
|
|
||||||
* @return Geometrie des Overlays
|
|
||||||
*/
|
|
||||||
private Geometry createOverlayBackground() {
|
|
||||||
Quad quad = new Quad(app.getCamera().getWidth(), app.getCamera().getHeight());
|
|
||||||
Geometry overlay = new Geometry("Overlay", quad);
|
|
||||||
Material material = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
|
|
||||||
material.setColor("Color", new ColorRGBA(0, 0, 0, 0.5f)); // Halbtransparent
|
|
||||||
material.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
|
|
||||||
overlay.setMaterial(material);
|
|
||||||
overlay.setLocalTranslation(0, 0, 0);
|
|
||||||
return overlay;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Closes the menu and removes the GUI elements.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void close() {
|
|
||||||
app.getGuiNode().detachChild(noMoneyWarningContainer); // Entferne das Menü
|
|
||||||
app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand
|
|
||||||
app.getGuiNode().detachChild(overlayBackground); // Entferne das Overlay
|
|
||||||
super.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void escape() {
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
}
|
|
@ -13,7 +13,7 @@ import com.simsilica.lemur.component.QuadBackgroundComponent;
|
|||||||
import com.simsilica.lemur.style.ElementId;
|
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.notification.Sound;
|
import pp.monopoly.model.fields.BuildingProperty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rent is a popup that is triggered when a player enters a field that does not belong himself and is owned by another player
|
* Rent is a popup that is triggered when a player enters a field that does not belong himself and is owned by another player
|
||||||
@ -24,10 +24,17 @@ public class Rent extends Dialog {
|
|||||||
private final Container rentContainer;
|
private final Container rentContainer;
|
||||||
private final Container backgroundContainer;
|
private final Container backgroundContainer;
|
||||||
|
|
||||||
public Rent(MonopolyApp app, String playerName, int amount) {
|
|
||||||
|
private int index = 21; // TODO fixed for testing
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public Rent(MonopolyApp app) {
|
||||||
super(app.getDialogManager());
|
super(app.getDialogManager());
|
||||||
this.app = app;
|
this.app = app;
|
||||||
|
|
||||||
|
BuildingProperty field = (BuildingProperty) app.getGameLogic().getBoardManager().getFieldAtIndex(index);
|
||||||
|
|
||||||
// Halbtransparentes Overlay hinzufügen
|
// Halbtransparentes Overlay hinzufügen
|
||||||
overlayBackground = createOverlayBackground();
|
overlayBackground = createOverlayBackground();
|
||||||
app.getGuiNode().attachChild(overlayBackground);
|
app.getGuiNode().attachChild(overlayBackground);
|
||||||
@ -41,29 +48,26 @@ public class Rent extends Dialog {
|
|||||||
|
|
||||||
// Hauptcontainer für die Warnung
|
// Hauptcontainer für die Warnung
|
||||||
rentContainer = new Container();
|
rentContainer = new Container();
|
||||||
rentContainer.setBackground(new QuadBackgroundComponent(ColorRGBA.Gray));
|
rentContainer.setBackground(new QuadBackgroundComponent(field.getColor().getColor()));
|
||||||
rentContainer.setPreferredSize(new Vector3f(550,250,10));
|
rentContainer.setPreferredSize(new Vector3f(550,250,10));
|
||||||
|
|
||||||
float padding = 10; // Passt den backgroundContainer an die Größe des bankruptContainers an
|
float padding = 10; // Passt den backgroundContainer an die Größe des bankruptContainers an
|
||||||
backgroundContainer.setPreferredSize(rentContainer.getPreferredSize().addLocal(padding, padding, 0));
|
backgroundContainer.setPreferredSize(rentContainer.getPreferredSize().addLocal(padding, padding, 0));
|
||||||
|
|
||||||
// Titel
|
// Titel
|
||||||
Label gateFieldTitle = rentContainer.addChild(new Label( "Miete !", new ElementId("label-Bold")));
|
Label gateFieldTitle = rentContainer.addChild(new Label( "Miete fürs "+field.getName()+" !", new ElementId("label-Bold")));
|
||||||
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
|
||||||
Container textContainer = rentContainer.addChild(new Container());
|
Container textContainer = rentContainer.addChild(new Container());
|
||||||
textContainer.addChild(new Label("Du must Spieler "+ playerName + " "+ amount+" EUR Miete zahlen", new ElementId("label-Text")));
|
textContainer.addChild(new Label("Du bist auf das " + field.getName()+ " gekommen!", new ElementId("label-Text")));
|
||||||
|
textContainer.addChild(new Label("Du must Spieler XXX XXX EUR Miete zahlen", new ElementId("label-Text")));
|
||||||
textContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
|
textContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
|
||||||
textContainer.setPreferredSize(rentContainer.getPreferredSize().addLocal(-250,-200,0));
|
textContainer.setPreferredSize(rentContainer.getPreferredSize().addLocal(-250,-200,0));
|
||||||
|
|
||||||
// Beenden-Button
|
// Beenden-Button
|
||||||
Button quitButton = rentContainer.addChild(new Button("Überweisen", new ElementId("button")));
|
Button quitButton = rentContainer.addChild(new Button("Überweisen", new ElementId("button")));
|
||||||
quitButton.addClickCommands(s -> ifTopDialog(() -> {
|
|
||||||
app.getGameLogic().playSound(Sound.BUTTON);
|
|
||||||
close();
|
|
||||||
}));
|
|
||||||
quitButton.setFontSize(32);
|
quitButton.setFontSize(32);
|
||||||
quitButton.addClickCommands(source -> close());
|
quitButton.addClickCommands(source -> close());
|
||||||
|
|
||||||
@ -72,14 +76,14 @@ public class Rent extends Dialog {
|
|||||||
rentContainer.setLocalTranslation(
|
rentContainer.setLocalTranslation(
|
||||||
(app.getCamera().getWidth() - rentContainer.getPreferredSize().x) / 2,
|
(app.getCamera().getWidth() - rentContainer.getPreferredSize().x) / 2,
|
||||||
(app.getCamera().getHeight() + rentContainer.getPreferredSize().y) / 2,
|
(app.getCamera().getHeight() + rentContainer.getPreferredSize().y) / 2,
|
||||||
10
|
8
|
||||||
);
|
);
|
||||||
|
|
||||||
// Zentriere das Popup
|
// Zentriere das Popup
|
||||||
backgroundContainer.setLocalTranslation(
|
backgroundContainer.setLocalTranslation(
|
||||||
(app.getCamera().getWidth() - rentContainer.getPreferredSize().x - padding) / 2,
|
(app.getCamera().getWidth() - rentContainer.getPreferredSize().x - padding) / 2,
|
||||||
(app.getCamera().getHeight() + rentContainer.getPreferredSize().y+ padding) / 2,
|
(app.getCamera().getHeight() + rentContainer.getPreferredSize().y+ padding) / 2,
|
||||||
10
|
7
|
||||||
);
|
);
|
||||||
|
|
||||||
app.getGuiNode().attachChild(rentContainer);
|
app.getGuiNode().attachChild(rentContainer);
|
||||||
@ -97,7 +101,7 @@ public class Rent extends Dialog {
|
|||||||
material.setColor("Color", new ColorRGBA(0, 0, 0, 0.5f)); // Halbtransparent
|
material.setColor("Color", new ColorRGBA(0, 0, 0, 0.5f)); // Halbtransparent
|
||||||
material.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
|
material.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
|
||||||
overlay.setMaterial(material);
|
overlay.setMaterial(material);
|
||||||
overlay.setLocalTranslation(0, 0, 10);
|
overlay.setLocalTranslation(0, 0, 0);
|
||||||
return overlay;
|
return overlay;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,10 +110,10 @@ public class Rent extends Dialog {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
super.close();
|
|
||||||
app.getGuiNode().detachChild(rentContainer); // Entferne das Menü
|
app.getGuiNode().detachChild(rentContainer); // Entferne das Menü
|
||||||
app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand
|
app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand
|
||||||
app.getGuiNode().detachChild(overlayBackground); // Entferne das Overlay
|
app.getGuiNode().detachChild(overlayBackground); // Entferne das Overlay
|
||||||
|
super.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -14,7 +14,6 @@ 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;
|
||||||
import pp.monopoly.message.server.NotificationMessage;
|
|
||||||
import pp.monopoly.message.server.PlayerStatusUpdate;
|
import pp.monopoly.message.server.PlayerStatusUpdate;
|
||||||
import pp.monopoly.message.server.ServerInterpreter;
|
import pp.monopoly.message.server.ServerInterpreter;
|
||||||
import pp.monopoly.message.server.TimeOutWarning;
|
import pp.monopoly.message.server.TimeOutWarning;
|
||||||
@ -234,10 +233,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", msg));
|
notifyListeners(new PopUpEvent("Winner"));
|
||||||
playSound(Sound.WINNER);
|
playSound(Sound.WINNER);
|
||||||
} else {
|
} else {
|
||||||
notifyListeners(new PopUpEvent("Looser", msg));
|
notifyListeners(new PopUpEvent("Looser"));
|
||||||
playSound(Sound.LOSER);
|
playSound(Sound.LOSER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -288,7 +287,7 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(TimeOutWarning msg) {
|
public void received(TimeOutWarning msg) {
|
||||||
notifyListeners(new PopUpEvent("timeout", msg));
|
notifyListeners(new PopUpEvent("timeout"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -323,7 +322,7 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
|||||||
@Override
|
@Override
|
||||||
public void received(TradeRequest msg) {
|
public void received(TradeRequest msg) {
|
||||||
tradeHandler = msg.getTradeHandler();
|
tradeHandler = msg.getTradeHandler();
|
||||||
notifyListeners(new PopUpEvent("tradeRequest", msg));
|
notifyListeners(new PopUpEvent("tradeRequest"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -339,13 +338,6 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(BuyPropertyRequest msg) {
|
public void received(BuyPropertyRequest msg) {
|
||||||
notifyListeners(new PopUpEvent("Buy", msg));
|
notifyListeners(new PopUpEvent("Buy"));
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(NotificationMessage msg) {
|
|
||||||
if (msg.getKeyWord().equals("rent")) {
|
|
||||||
notifyListeners(new PopUpEvent("rent", msg));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ 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.NextPlayerTurn;
|
import pp.monopoly.message.server.NextPlayerTurn;
|
||||||
import pp.monopoly.message.server.NotificationMessage;
|
|
||||||
import pp.monopoly.message.server.PlayerStatusUpdate;
|
import pp.monopoly.message.server.PlayerStatusUpdate;
|
||||||
import pp.monopoly.model.FieldVisitor;
|
import pp.monopoly.model.FieldVisitor;
|
||||||
import pp.monopoly.model.Figure;
|
import pp.monopoly.model.Figure;
|
||||||
@ -305,10 +304,6 @@ public class Player implements FieldVisitor<Void>{
|
|||||||
int rent = field.calcRent();
|
int rent = field.calcRent();
|
||||||
field.getOwner().earnMoney(rent);
|
field.getOwner().earnMoney(rent);
|
||||||
pay(rent);
|
pay(rent);
|
||||||
NotificationMessage msg = new NotificationMessage("rent");
|
|
||||||
msg.setRentAmount(rent);
|
|
||||||
msg.setRentOwnerId(field.getOwner().getName());
|
|
||||||
getHandler().getLogic().send(this, msg);
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -322,13 +317,8 @@ public class Player implements FieldVisitor<Void>{
|
|||||||
if (field.getOwner().getNumProp(field) == 2) {
|
if (field.getOwner().getNumProp(field) == 2) {
|
||||||
factor = 10;
|
factor = 10;
|
||||||
}
|
}
|
||||||
int rent = rollResult.calcTotal()*factor;
|
field.getOwner().earnMoney(rollResult.calcTotal()*factor);
|
||||||
field.getOwner().earnMoney(rent);
|
pay(rollResult.calcTotal()*factor);
|
||||||
pay(rent);
|
|
||||||
NotificationMessage msg = new NotificationMessage("rent");
|
|
||||||
msg.setRentAmount(rent);
|
|
||||||
msg.setRentOwnerId(field.getOwner().getName());
|
|
||||||
getHandler().getLogic().send(this, msg);
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -342,10 +332,6 @@ public class Player implements FieldVisitor<Void>{
|
|||||||
|
|
||||||
field.getOwner().earnMoney(rent);
|
field.getOwner().earnMoney(rent);
|
||||||
pay(rent);
|
pay(rent);
|
||||||
NotificationMessage msg = new NotificationMessage("rent");
|
|
||||||
msg.setRentAmount(rent);
|
|
||||||
msg.setRentOwnerId(field.getOwner().getName());
|
|
||||||
getHandler().getLogic().send(this, msg);
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1,50 +0,0 @@
|
|||||||
package pp.monopoly.message.server;
|
|
||||||
|
|
||||||
import com.jme3.network.serializing.Serializable;
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
public class NotificationMessage extends ServerMessage{
|
|
||||||
|
|
||||||
private final String keyWord;
|
|
||||||
|
|
||||||
private int rentAmount;
|
|
||||||
private String rentOwner;
|
|
||||||
|
|
||||||
private NotificationMessage(){ keyWord = null;}
|
|
||||||
|
|
||||||
public NotificationMessage(String keyWord) {
|
|
||||||
this.keyWord = keyWord;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRentAmount() {
|
|
||||||
return rentAmount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRentAmount(int rentAmount) {
|
|
||||||
this.rentAmount = rentAmount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRentOwnerId(String rentOwnerId) {
|
|
||||||
this.rentOwner = rentOwnerId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRentOwner() {
|
|
||||||
return rentOwner;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getKeyWord() {
|
|
||||||
return keyWord;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void accept(ServerInterpreter interpreter) {
|
|
||||||
interpreter.received(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getInfoTextKey() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'getInfoTextKey'");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -96,11 +96,4 @@ public interface ServerInterpreter {
|
|||||||
* @param msg the NextPlayerTurn message received
|
* @param msg the NextPlayerTurn message received
|
||||||
*/
|
*/
|
||||||
void received(BuyPropertyRequest msg);
|
void received(BuyPropertyRequest msg);
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles a NextPlayerTurn message received from the server.
|
|
||||||
*
|
|
||||||
* @param msg the NextPlayerTurn message received
|
|
||||||
*/
|
|
||||||
void received(NotificationMessage msg);
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package pp.monopoly.notification;
|
package pp.monopoly.notification;
|
||||||
|
|
||||||
import pp.monopoly.message.server.ServerMessage;
|
public record PopUpEvent(String msg) implements GameEvent{
|
||||||
|
|
||||||
public record PopUpEvent(String msg, ServerMessage message) implements GameEvent{
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void notifyListener(GameEventListener listener) {
|
public void notifyListener(GameEventListener listener) {
|
||||||
|
@ -42,7 +42,6 @@ import pp.monopoly.message.server.DiceResult;
|
|||||||
import pp.monopoly.message.server.EventDrawCard;
|
import pp.monopoly.message.server.EventDrawCard;
|
||||||
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.NotificationMessage;
|
|
||||||
import pp.monopoly.message.server.PlayerStatusUpdate;
|
import pp.monopoly.message.server.PlayerStatusUpdate;
|
||||||
import pp.monopoly.message.server.ServerMessage;
|
import pp.monopoly.message.server.ServerMessage;
|
||||||
import pp.monopoly.message.server.TradeReply;
|
import pp.monopoly.message.server.TradeReply;
|
||||||
@ -171,7 +170,6 @@ public class MonopolyServer implements MessageListener<HostedConnection>, Connec
|
|||||||
Serializer.registerClass(TradeRequest.class);
|
Serializer.registerClass(TradeRequest.class);
|
||||||
Serializer.registerClass(TradeReply.class);
|
Serializer.registerClass(TradeReply.class);
|
||||||
Serializer.registerClass(TradeHandler.class);
|
Serializer.registerClass(TradeHandler.class);
|
||||||
Serializer.registerClass(NotificationMessage.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerListeners() {
|
private void registerListeners() {
|
||||||
|
Loading…
Reference in New Issue
Block a user