mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2025-08-01 06:17:40 +02:00
trigger rent popup
This commit is contained in:
@@ -11,10 +11,12 @@ 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.Rent;
|
||||
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.PlayerHandler;
|
||||
import pp.monopoly.message.server.NotificationMessage;
|
||||
import pp.monopoly.model.fields.BuildingProperty;
|
||||
import pp.monopoly.model.fields.FoodField;
|
||||
import pp.monopoly.model.fields.GateField;
|
||||
@@ -153,6 +155,8 @@ public class TestWorld implements GameEventListener{
|
||||
new TimeOut(app).open();
|
||||
} else if (event.msg().equals("tradeRequest")) {
|
||||
new ConfirmTrade(app).open();
|
||||
} else if(event.msg().equals("rent")) {
|
||||
new Rent(app, ( (NotificationMessage) event.message()).getRentOwner(), ( (NotificationMessage) event.message()).getRentAmount() ).open();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -13,7 +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.model.fields.BuildingProperty;
|
||||
import pp.monopoly.notification.Sound;
|
||||
|
||||
/**
|
||||
* 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,17 +24,10 @@ public class Rent extends Dialog {
|
||||
private final Container rentContainer;
|
||||
private final Container backgroundContainer;
|
||||
|
||||
|
||||
private int index = 21; // TODO fixed for testing
|
||||
|
||||
|
||||
|
||||
public Rent(MonopolyApp app) {
|
||||
public Rent(MonopolyApp app, String playerName, int amount) {
|
||||
super(app.getDialogManager());
|
||||
this.app = app;
|
||||
|
||||
BuildingProperty field = (BuildingProperty) app.getGameLogic().getBoardManager().getFieldAtIndex(index);
|
||||
|
||||
// Halbtransparentes Overlay hinzufügen
|
||||
overlayBackground = createOverlayBackground();
|
||||
app.getGuiNode().attachChild(overlayBackground);
|
||||
@@ -48,26 +41,29 @@ public class Rent extends Dialog {
|
||||
|
||||
// Hauptcontainer für die Warnung
|
||||
rentContainer = new Container();
|
||||
rentContainer.setBackground(new QuadBackgroundComponent(field.getColor().getColor()));
|
||||
rentContainer.setBackground(new QuadBackgroundComponent(ColorRGBA.Gray));
|
||||
rentContainer.setPreferredSize(new Vector3f(550,250,10));
|
||||
|
||||
float padding = 10; // Passt den backgroundContainer an die Größe des bankruptContainers an
|
||||
backgroundContainer.setPreferredSize(rentContainer.getPreferredSize().addLocal(padding, padding, 0));
|
||||
|
||||
// Titel
|
||||
Label gateFieldTitle = rentContainer.addChild(new Label( "Miete fürs "+field.getName()+" !", new ElementId("label-Bold")));
|
||||
Label gateFieldTitle = rentContainer.addChild(new Label( "Miete !", new ElementId("label-Bold")));
|
||||
gateFieldTitle.setFontSize(48);
|
||||
gateFieldTitle.setColor(ColorRGBA.Black);
|
||||
|
||||
// Text, der auf der Karte steht
|
||||
Container textContainer = rentContainer.addChild(new Container());
|
||||
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.addChild(new Label("Du must Spieler "+ playerName + " "+ amount+" EUR Miete zahlen", new ElementId("label-Text")));
|
||||
textContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
|
||||
textContainer.setPreferredSize(rentContainer.getPreferredSize().addLocal(-250,-200,0));
|
||||
|
||||
// Beenden-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.addClickCommands(source -> close());
|
||||
|
||||
@@ -76,14 +72,14 @@ public class Rent extends Dialog {
|
||||
rentContainer.setLocalTranslation(
|
||||
(app.getCamera().getWidth() - rentContainer.getPreferredSize().x) / 2,
|
||||
(app.getCamera().getHeight() + rentContainer.getPreferredSize().y) / 2,
|
||||
8
|
||||
10
|
||||
);
|
||||
|
||||
// Zentriere das Popup
|
||||
backgroundContainer.setLocalTranslation(
|
||||
(app.getCamera().getWidth() - rentContainer.getPreferredSize().x - padding) / 2,
|
||||
(app.getCamera().getHeight() + rentContainer.getPreferredSize().y+ padding) / 2,
|
||||
7
|
||||
10
|
||||
);
|
||||
|
||||
app.getGuiNode().attachChild(rentContainer);
|
||||
@@ -101,7 +97,7 @@ public class Rent extends Dialog {
|
||||
material.setColor("Color", new ColorRGBA(0, 0, 0, 0.5f)); // Halbtransparent
|
||||
material.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
|
||||
overlay.setMaterial(material);
|
||||
overlay.setLocalTranslation(0, 0, 0);
|
||||
overlay.setLocalTranslation(0, 0, 10);
|
||||
return overlay;
|
||||
}
|
||||
|
||||
@@ -110,10 +106,10 @@ public class Rent extends Dialog {
|
||||
*/
|
||||
@Override
|
||||
public void close() {
|
||||
super.close();
|
||||
app.getGuiNode().detachChild(rentContainer); // Entferne das Menü
|
||||
app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand
|
||||
app.getGuiNode().detachChild(overlayBackground); // Entferne das Overlay
|
||||
super.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user