Compare commits

..

No commits in common. "4095d9e79d3e43d22abeaa71fc4e8b46a47a4909" and "9120e4d53cbd0f85a1bbfc0df27b78c232c15dd4" have entirely different histories.

3 changed files with 129 additions and 48 deletions

View File

@ -61,9 +61,4 @@ public class ChoosePartner extends Dialog {
app.getGuiNode().attachChild(background); app.getGuiNode().attachChild(background);
} }
@Override
public void escape() {
new SettingsMenu(app).open();
}
} }

View File

@ -27,10 +27,11 @@ public class Toolbar extends Dialog {
private final MonopolyApp app; private final MonopolyApp app;
private final Container toolbarContainer; private final Container toolbarContainer;
private final BitmapText positionText; // Anzeige für die aktuelle Position private final BitmapText positionText; // Anzeige für die aktuelle Position
private final float boardLimit = 0.95f; // Grenzen des Bretts
private final float stepSize = 0.18f; // Schrittgröße pro Bewegung
private int currentPosition = 0; // Aktuelle Position auf dem Spielfeld private int currentPosition = 0; // Aktuelle Position auf dem Spielfeld
private String diceOneImage = "Pictures/dice/one.png"; private final int positionsPerSide = 10; // Anzahl der Positionen pro Seite
private String diceTwoImage = "Pictures/dice/two.png"; private final Random random = new Random(); // Zufallsgenerator für den Würfelwurf
/** /**
* Konstruktor für die Toolbar. * Konstruktor für die Toolbar.
@ -93,12 +94,12 @@ public class Toolbar extends Dialog {
leftContainer.setPreferredSize(new Vector3f(100, 150, 0)); // Adjust size as needed leftContainer.setPreferredSize(new Vector3f(100, 150, 0)); // Adjust size as needed
Label imageLabel = new Label(""); Label imageLabel = new Label("");
IconComponent icon = new IconComponent(diceOneImage); // Icon mit Textur erstellen IconComponent icon = new IconComponent("Pictures/dice/one.png"); // Icon mit Textur erstellen
icon.setIconSize(new Vector2f(100,100)); // Skalierung des Bildes icon.setIconSize(new Vector2f(100,100)); // Skalierung des Bildes
imageLabel.setIcon(icon); imageLabel.setIcon(icon);
Label imageLabel2 = new Label(""); Label imageLabel2 = new Label("");
IconComponent icon2 = new IconComponent(diceTwoImage); // Icon mit Textur erstellen IconComponent icon2 = new IconComponent("Pictures/dice/two.png"); // Icon mit Textur erstellen
icon2.setIconSize(new Vector2f(100,100)); // Skalierung des Bildes icon2.setIconSize(new Vector2f(100,100)); // Skalierung des Bildes
imageLabel2.setIcon(icon2); imageLabel2.setIcon(icon2);
@ -131,7 +132,7 @@ public class Toolbar extends Dialog {
Button diceButton = new Button("Würfeln"); Button diceButton = new Button("Würfeln");
diceButton.setPreferredSize(new Vector3f(200, 50, 0)); // Full width for Würfeln button diceButton.setPreferredSize(new Vector3f(200, 50, 0)); // Full width for Würfeln button
diceButton.addClickCommands(s -> ifTopDialog(() -> { diceButton.addClickCommands(s -> ifTopDialog(() -> {
//TODO dice roll logic rollDice();
app.getGameLogic().playSound(Sound.BUTTON); app.getGameLogic().playSound(Sound.BUTTON);
})); }));
diceContainer.addChild(diceButton); diceContainer.addChild(diceButton);
@ -141,9 +142,9 @@ public class Toolbar extends Dialog {
// Menü-Container: Ein Nested-Container für Handeln, Grundstücke und Zug beenden // Menü-Container: Ein Nested-Container für Handeln, Grundstücke und Zug beenden
Container menuContainer = toolbarContainer.addChild(new Container()); Container menuContainer = toolbarContainer.addChild(new Container());
menuContainer.addChild(addTradeMenuButton()); menuContainer.addChild(new Button("Handeln"));
menuContainer.addChild(addPropertyMenuButton()); menuContainer.addChild(new Button("Grundstücke"));
menuContainer.addChild(addEndTurnButton()); menuContainer.addChild(new Button("Zug beenden"));
menuContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f))); menuContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
// Füge die Toolbar zur GUI hinzu // Füge die Toolbar zur GUI hinzu
@ -154,35 +155,107 @@ public class Toolbar extends Dialog {
updatePositionDisplay(); // Initialisiere die Anzeige mit der Startposition updatePositionDisplay(); // Initialisiere die Anzeige mit der Startposition
} }
private Button addTradeMenuButton() { /**
Button tradebutton = new Button("Handeln"); * Initialisiert die Buttons in der Toolbar.
tradebutton.setPreferredSize(new Vector3f(150, 50, 0)); // Größe des Buttons */
tradebutton.addClickCommands(s -> ifTopDialog( () -> { private void initializeButtons() {
addTradeMenuButton(); // Bewegung nach vorne
addEndTurnButton(); // Bewegung nach hinten
addDiceRollButton(); // Würfel-Button
}
/**
* Fügt einen Button mit einer Bewegung hinzu.
*
* @param label Der Text des Buttons
* @param step Schrittweite (+1 für vorwärts, -1 für rückwärts)
*/
/*private void addButton(String label, int step) {
Button button = new Button(label);
button.setPreferredSize(new Vector3f(150, 50, 0)); // Größe der Buttons
button.addClickCommands(source -> moveCube(step));
toolbarContainer.addChild(button);
}*/
/**
* Fügt den Würfel-Button hinzu, der die Figur entsprechend der gewürfelten Zahl bewegt.
*/
private Button addDiceRollButton() {
Button diceButton = new Button("Würfeln");
diceButton.setPreferredSize(new Vector3f(50, 20, 0));
diceButton.addClickCommands(s -> ifTopDialog(() -> {
rollDice();
app.getGameLogic().playSound(Sound.BUTTON);
}));
toolbarContainer.addChild(diceButton);
return diceButton;
}
private void addTradeMenuButton() {
Button diceButton = new Button("Handeln");
diceButton.setPreferredSize(new Vector3f(150, 50, 0)); // Größe des Buttons
diceButton.addClickCommands(s -> {
rollDice();
app.getGameLogic().playSound(Sound.BUTTON); app.getGameLogic().playSound(Sound.BUTTON);
this.close(); this.close();
System.out.println("test");
new ChoosePartner(app).open(); new ChoosePartner(app).open();
});
toolbarContainer.addChild(diceButton);
}// TODO Funktion der Buttons Überarbeiten und prüfen
private void addEndTurnButton() {
Button diceButton = new Button("Grundstücke");
diceButton.setPreferredSize(new Vector3f(150, 50, 0)); // Größe des Buttons
diceButton.addClickCommands(s -> ifTopDialog(() -> {
rollDice();
app.getGameLogic().playSound(Sound.BUTTON);
})); }));
return tradebutton; toolbarContainer.addChild(diceButton);
} }
private Button addEndTurnButton() { private void addPropertyMenuButton() {
Button endTurnButton = new Button("Grundstücke"); Button diceButton = new Button("Zug beenden");
endTurnButton.setPreferredSize(new Vector3f(150, 50, 0)); // Größe des Buttons diceButton.setPreferredSize(new Vector3f(150, 50, 0)); // Größe des Buttons
endTurnButton.addClickCommands(s -> ifTopDialog(() -> { diceButton.addClickCommands(s -> ifTopDialog(() -> {
rollDice();
app.getGameLogic().playSound(Sound.BUTTON); app.getGameLogic().playSound(Sound.BUTTON);
//TODO open property dialog
})); }));
return endTurnButton; toolbarContainer.addChild(diceButton);
} }
private Button addPropertyMenuButton() { /**
Button propertyMenuButton = new Button("Zug beenden"); * Simuliert einen Würfelwurf und bewegt die Figur entsprechend.
propertyMenuButton.setPreferredSize(new Vector3f(150, 50, 0)); // Größe des Buttons */
propertyMenuButton.addClickCommands(s -> ifTopDialog(() -> { private void rollDice() {
app.getGameLogic().playSound(Sound.BUTTON); int diceRoll = random.nextInt(6) + 1; // Zahl zwischen 1 und 6
//TODO send end turn System.out.println("Gewürfelt: " + diceRoll);
})); }
return propertyMenuButton;
/**
* Berechnet die neue Position des Würfels basierend auf der aktuellen Brettseite und Position.
*
* @param position Aktuelle Position auf dem Spielfeld
* @return Die berechnete Position als Vector3f
*/
private Vector3f calculatePosition(int position) {
int side = position / positionsPerSide; // Seite des Bretts (0 = unten, 1 = rechts, 2 = oben, 3 = links)
int offset = position % positionsPerSide; // Position auf der aktuellen Seite
switch (side) {
case 0: // Unten (positive x-Achse)
return new Vector3f(-boardLimit + offset * stepSize, 0.1f, -boardLimit + 0.05f);
case 1: // Rechts (positive z-Achse)
return new Vector3f(boardLimit - 0.05f, 0.1f, -boardLimit + offset * stepSize);
case 2: // Oben (negative x-Achse)
return new Vector3f(boardLimit - offset * stepSize, 0.1f, boardLimit - 0.05f);
case 3: // Links (negative z-Achse)
return new Vector3f(-boardLimit + 0.05f, 0.1f, boardLimit - offset * stepSize);
default:
throw new IllegalArgumentException("Ungültige Position: " + position);
}
} }
/** /**

View File

@ -15,13 +15,13 @@ import pp.monopoly.client.MonopolyApp;
import pp.monopoly.client.gui.SettingsMenu; import pp.monopoly.client.gui.SettingsMenu;
import pp.monopoly.model.fields.BoardManager; import pp.monopoly.model.fields.BoardManager;
import pp.monopoly.model.fields.BuildingProperty; import pp.monopoly.model.fields.BuildingProperty;
import pp.monopoly.notification.Sound;
/** /**
* SettingsMenu ist ein Overlay-Menü, das durch ESC aufgerufen werden kann. * SettingsMenu ist ein Overlay-Menü, das durch ESC aufgerufen werden kann.
*/ */
public class BuyCard extends Dialog { public class BuyCard extends Dialog {
private final MonopolyApp app; private final MonopolyApp app;
private final Geometry overlayBackground;
private final Container buyCardContainer; private final Container buyCardContainer;
private final Container backgroundContainer; private final Container backgroundContainer;
@ -34,18 +34,22 @@ public class BuyCard extends Dialog {
//Generate the corresponfing field //Generate the corresponfing field
BuildingProperty field = (BuildingProperty) new BoardManager().getFieldAtIndex(index); BuildingProperty field = (BuildingProperty) new BoardManager().getFieldAtIndex(index);
// Halbtransparentes Overlay hinzufügen
overlayBackground = createOverlayBackground();
app.getGuiNode().attachChild(overlayBackground);
// Create the background container // Create the background container
backgroundContainer = new Container(); backgroundContainer = new Container();
backgroundContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); // Darker background backgroundContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); // Darker background
attachChild(backgroundContainer); app.getGuiNode().attachChild(backgroundContainer);
// Hauptcontainer für die Gebäudekarte // Hauptcontainer für die Gebäudekarte
buyCardContainer = new Container(); buyCardContainer = new Container();
buyCardContainer.setBackground(new QuadBackgroundComponent(field.getColor().getColor()));
Label title = buyCardContainer.addChild(new Label( field.getName(), new ElementId("label-Bold")));
title.setBackground(new QuadBackgroundComponent(field.getColor().getColor())); Label settingsTitle = buyCardContainer.addChild(new Label( field.getName(), new ElementId("settings-title")));
title.setFontSize(48); settingsTitle.setFontSize(48);
// Text, der auf der Karte steht // Text, der auf der Karte steht
// Die Preise werden dynamisch dem BoardManager entnommen // Die Preise werden dynamisch dem BoardManager entnommen
@ -66,17 +70,9 @@ public class BuyCard extends Dialog {
// Beenden-Button // Beenden-Button
Button quitButton = buyCardContainer.addChild(new Button("Beenden", new ElementId("button"))); Button quitButton = buyCardContainer.addChild(new Button("Beenden", new ElementId("button")));
quitButton.setFontSize(32); quitButton.setFontSize(32);
quitButton.addClickCommands(s -> ifTopDialog(() -> {
app.getGameLogic().playSound(Sound.BUTTON);
close();
}));
// Kaufen-Button // Kaufen-Button
Button buyButton = buyCardContainer.addChild(new Button("Kaufen", new ElementId("button"))); Button buyButton = buyCardContainer.addChild(new Button("Kaufen", new ElementId("button")));
buyButton.setFontSize(32); buyButton.setFontSize(32);
buyButton.addClickCommands(s -> ifTopDialog( () -> {
app.getGameLogic().playSound(Sound.BUTTON);
//TODO send buy property request
}));
float padding = 10; // Padding around the settingsContainer for the background float padding = 10; // Padding around the settingsContainer for the background
backgroundContainer.setPreferredSize(buyCardContainer.getPreferredSize().addLocal(padding, padding, 0)); backgroundContainer.setPreferredSize(buyCardContainer.getPreferredSize().addLocal(padding, padding, 0));
@ -98,6 +94,22 @@ public class BuyCard extends Dialog {
app.getGuiNode().attachChild(buyCardContainer); app.getGuiNode().attachChild(buyCardContainer);
} }
/**
* 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;
}
/** /**
* Schließt das Menü und entfernt die GUI-Elemente. * Schließt das Menü und entfernt die GUI-Elemente.
*/ */
@ -105,6 +117,7 @@ public class BuyCard extends Dialog {
public void close() { public void close() {
app.getGuiNode().detachChild(buyCardContainer); // Entferne das Menü app.getGuiNode().detachChild(buyCardContainer); // Entferne das Menü
app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand app.getGuiNode().detachChild(backgroundContainer); //Entfernt Rand
app.getGuiNode().detachChild(overlayBackground); // Entferne das Overlay
super.close(); super.close();
} }