dynamically allocate values

This commit is contained in:
Johannes Schmelz 2024-11-23 17:41:20 +01:00
parent 09b363f943
commit 885ab5bdc9
3 changed files with 36 additions and 22 deletions

View File

@ -21,6 +21,7 @@ import pp.monopoly.client.gui.popups.BuyCard;
import pp.monopoly.game.client.ClientGameLogic; import pp.monopoly.game.client.ClientGameLogic;
import pp.monopoly.game.client.MonopolyClient; import pp.monopoly.game.client.MonopolyClient;
import pp.monopoly.game.client.ServerConnection; import pp.monopoly.game.client.ServerConnection;
import pp.monopoly.model.fields.BoardManager;
import pp.monopoly.notification.GameEventListener; import pp.monopoly.notification.GameEventListener;
import pp.monopoly.notification.InfoTextEvent; import pp.monopoly.notification.InfoTextEvent;
import pp.monopoly.server.MonopolyServer; import pp.monopoly.server.MonopolyServer;
@ -41,10 +42,11 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
private boolean inputBlocked = false; private boolean inputBlocked = false;
private MonopolyServer monopolyServer; private MonopolyServer monopolyServer;
private NetworkSupport networkSupport; private NetworkSupport networkSupport;
private BoardManager boardManager = new BoardManager();
// TODO Temp später entfernen // TODO Temp später entfernen
private BuildingProperty buildingProperty; private BuildingPropertyCard buildingProperty;
private FoodField foodField; private FoodField foodField;
private GateField gateField; private GateField gateField;
private BuyCard buyCard; private BuyCard buyCard;
@ -85,6 +87,10 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
return logic; return logic;
} }
public BoardManager getBoardManager() {
return boardManager;
}
public NetworkSupport getNetworkSupport() { public NetworkSupport getNetworkSupport() {
return networkSupport; return networkSupport;
} }
@ -158,7 +164,7 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
} else { } else {
// Öffne das SettingsMenu // Öffne das SettingsMenu
System.out.println("Öffne BuyCardPopup..."); System.out.println("Öffne BuyCardPopup...");
buildingProperty = new BuildingProperty(this); buildingProperty = new BuildingPropertyCard(this);
buildingProperty.open(); buildingProperty.open();
setBuyCardPopupOpen(true); setBuyCardPopupOpen(true);
} }

View File

@ -10,22 +10,30 @@ import com.simsilica.lemur.Container;
import com.simsilica.lemur.Label; import com.simsilica.lemur.Label;
import com.simsilica.lemur.component.QuadBackgroundComponent; 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.model.fields.BuildingProperty;
/** /**
* TODO Kommentare fixen
* SettingsMenu ist ein Overlay-Menü, das durch ESC aufgerufen werden kann. * SettingsMenu ist ein Overlay-Menü, das durch ESC aufgerufen werden kann.
*/ */
public class BuildingProperty extends Dialog { public class BuildingPropertyCard extends Dialog {
private final MonopolyApp app; private final MonopolyApp app;
private final Geometry overlayBackground; private final Geometry overlayBackground;
private final Container settingsContainer; private final Container settingsContainer;
private final Container backgroundContainer; private final Container backgroundContainer;
private int index = 23;
public BuildingProperty(MonopolyApp app) { public BuildingPropertyCard(MonopolyApp app) {
super(app.getDialogManager()); super(app.getDialogManager());
this.app = app; this.app = app;
// Titel
//Generate the corresponfing field
BuildingProperty field = (BuildingProperty) app.getBoardManager().getFieldAtIndex(index);
// Halbtransparentes Overlay hinzufügen // Halbtransparentes Overlay hinzufügen
overlayBackground = createOverlayBackground(); overlayBackground = createOverlayBackground();
app.getGuiNode().attachChild(overlayBackground); app.getGuiNode().attachChild(overlayBackground);
@ -38,30 +46,27 @@ public class BuildingProperty extends Dialog {
// Hauptcontainer für das Menü // Hauptcontainer für das Menü
settingsContainer = new Container(); settingsContainer = new Container();
//settingsContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(170 / 255f, 223 / 255f, 246 / 255f, 1))); // hell //settingsContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(170 / 255f, 223 / 255f, 246 / 255f, 1))); // hell
settingsContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(2 / 255f, 112 / 255f, 191 / 255f, 1))); //dunkel settingsContainer.setBackground(new QuadBackgroundComponent(field.getColor().getColor())); //dunkel
// Titel
Label settingsTitle = settingsContainer.addChild(new Label("Gebäude Arsch", new ElementId("settings-title"))); //TODO Dynamische Gebäudezahl einfügen
Label settingsTitle = settingsContainer.addChild(new Label( field.getName(), new ElementId("settings-title")));
settingsTitle.setFontSize(48); settingsTitle.setFontSize(48);
int i = 0;
int a = 10;
int b = -45;
// Effekt-Sound: Slider und Checkbox // Effekt-Sound: Slider und Checkbox
Container propertyValuesContainer = settingsContainer.addChild(new Container()); Container propertyValuesContainer = settingsContainer.addChild(new Container());
propertyValuesContainer.addChild(new Label("„Grundstückswert:" + i, new ElementId("label-Text")));//TODO Variable hier einsetzen propertyValuesContainer.addChild(new Label("„Grundstückswert: " + field.getPrice() + " EUR", new ElementId("label-Text")));
propertyValuesContainer.addChild(new Label("„Miete allein:" + a, new ElementId("label-Text")));//TODO Variable hier einsetzen propertyValuesContainer.addChild(new Label("„Miete allein: " + field.getAllRent().get(0)+ " EUR", new ElementId("label-Text")));
propertyValuesContainer.addChild(new Label("„-mit 1 Haus:" + a, new ElementId("label-Text")));//TODO Variable hier einsetzen propertyValuesContainer.addChild(new Label("„-mit 1 Haus: " + field.getAllRent().get(1) + " EUR", new ElementId("label-Text")));
propertyValuesContainer.addChild(new Label("„-mit 2 Häuser:" + a, new ElementId("label-Text")));//TODO Variable hier einsetzen propertyValuesContainer.addChild(new Label("„-mit 2 Häuser: " + field.getAllRent().get(2) + " EUR", new ElementId("label-Text")));
propertyValuesContainer.addChild(new Label("„-mit 3 Häuser:" + a, new ElementId("label-Text")));//TODO Variable hier einsetzen propertyValuesContainer.addChild(new Label("„-mit 3 Häuser: " + field.getAllRent().get(3) + " EUR", new ElementId("label-Text")));
propertyValuesContainer.addChild(new Label("„-mit 4 Häuser:" + a, new ElementId("label-Text")));//TODO Variable hier einsetzen propertyValuesContainer.addChild(new Label("„-mit 4 Häuser: " + field.getAllRent().get(4) + " EUR", new ElementId("label-Text")));
propertyValuesContainer.addChild(new Label("„-mit 1 Hotel:" + a, new ElementId("label-Text")));//TODO Variable hier einsetzen propertyValuesContainer.addChild(new Label("„-mit 1 Hotel: " + field.getAllRent().get(5) + " EUR", new ElementId("label-Text")));
propertyValuesContainer.addChild(new Label("„-1 Haus kostet:" + a, new ElementId("label-Text")));//TODO Variable hier einsetzen propertyValuesContainer.addChild(new Label("„-1 Haus kostet: " + field.getHousePrice()+ " EUR", new ElementId("label-Text")));
propertyValuesContainer.addChild(new Label("„Hypothek:" + b, new ElementId("label-Text")));//TODO Variable hier einsetzen propertyValuesContainer.addChild(new Label("„Hypothek: " + field.getHypo() + " EUR", new ElementId("label-Text")));
propertyValuesContainer.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)));
// Beenden-Button // Beenden-Button
@ -121,5 +126,8 @@ public class BuildingProperty extends Dialog {
System.out.println("SettingsMenu geschlossen."); // Debugging-Ausgabe System.out.println("SettingsMenu geschlossen."); // Debugging-Ausgabe
} }
public void setIndex(int index) {
this.index = index;
}
} }

View File

@ -5,7 +5,7 @@ import com.jme3.math.ColorRGBA;
/** /**
* Enum representing eight distinct colors for properties in the game. * Enum representing eight distinct colors for properties in the game.
*/ */
enum FieldColor { public enum FieldColor {
BROWN(new ColorRGBA(148 / 255f, 86 / 255f, 57 / 255f, 1)), BROWN(new ColorRGBA(148 / 255f, 86 / 255f, 57 / 255f, 1)),
GREEN(new ColorRGBA(30 / 255f, 179 / 255f, 90 / 255f, 1)), GREEN(new ColorRGBA(30 / 255f, 179 / 255f, 90 / 255f, 1)),
YELLOW(new ColorRGBA(252 / 255f, 241 / 255f, 1 / 255f, 1)), YELLOW(new ColorRGBA(252 / 255f, 241 / 255f, 1 / 255f, 1)),