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
2 Commits
9120e4d53c
...
4095d9e79d
Author | SHA1 | Date | |
---|---|---|---|
|
4095d9e79d | ||
|
547a4c2353 |
@ -61,4 +61,9 @@ public class ChoosePartner extends Dialog {
|
|||||||
|
|
||||||
app.getGuiNode().attachChild(background);
|
app.getGuiNode().attachChild(background);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void escape() {
|
||||||
|
new SettingsMenu(app).open();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,11 +27,10 @@ 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 final int positionsPerSide = 10; // Anzahl der Positionen pro Seite
|
private String diceOneImage = "Pictures/dice/one.png";
|
||||||
private final Random random = new Random(); // Zufallsgenerator für den Würfelwurf
|
private String diceTwoImage = "Pictures/dice/two.png";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Konstruktor für die Toolbar.
|
* Konstruktor für die Toolbar.
|
||||||
@ -94,12 +93,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("Pictures/dice/one.png"); // Icon mit Textur erstellen
|
IconComponent icon = new IconComponent(diceOneImage); // 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("Pictures/dice/two.png"); // Icon mit Textur erstellen
|
IconComponent icon2 = new IconComponent(diceTwoImage); // 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);
|
||||||
|
|
||||||
@ -132,7 +131,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(() -> {
|
||||||
rollDice();
|
//TODO dice roll logic
|
||||||
app.getGameLogic().playSound(Sound.BUTTON);
|
app.getGameLogic().playSound(Sound.BUTTON);
|
||||||
}));
|
}));
|
||||||
diceContainer.addChild(diceButton);
|
diceContainer.addChild(diceButton);
|
||||||
@ -142,9 +141,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(new Button("Handeln"));
|
menuContainer.addChild(addTradeMenuButton());
|
||||||
menuContainer.addChild(new Button("Grundstücke"));
|
menuContainer.addChild(addPropertyMenuButton());
|
||||||
menuContainer.addChild(new Button("Zug beenden"));
|
menuContainer.addChild(addEndTurnButton());
|
||||||
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
|
||||||
@ -155,107 +154,35 @@ public class Toolbar extends Dialog {
|
|||||||
updatePositionDisplay(); // Initialisiere die Anzeige mit der Startposition
|
updatePositionDisplay(); // Initialisiere die Anzeige mit der Startposition
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private Button addTradeMenuButton() {
|
||||||
* Initialisiert die Buttons in der Toolbar.
|
Button tradebutton = new Button("Handeln");
|
||||||
*/
|
tradebutton.setPreferredSize(new Vector3f(150, 50, 0)); // Größe des Buttons
|
||||||
private void initializeButtons() {
|
tradebutton.addClickCommands(s -> ifTopDialog( () -> {
|
||||||
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);
|
|
||||||
}));
|
}));
|
||||||
toolbarContainer.addChild(diceButton);
|
return tradebutton;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addPropertyMenuButton() {
|
private Button addEndTurnButton() {
|
||||||
Button diceButton = new Button("Zug beenden");
|
Button endTurnButton = new Button("Grundstücke");
|
||||||
diceButton.setPreferredSize(new Vector3f(150, 50, 0)); // Größe des Buttons
|
endTurnButton.setPreferredSize(new Vector3f(150, 50, 0)); // Größe des Buttons
|
||||||
diceButton.addClickCommands(s -> ifTopDialog(() -> {
|
endTurnButton.addClickCommands(s -> ifTopDialog(() -> {
|
||||||
rollDice();
|
|
||||||
app.getGameLogic().playSound(Sound.BUTTON);
|
app.getGameLogic().playSound(Sound.BUTTON);
|
||||||
|
//TODO open property dialog
|
||||||
}));
|
}));
|
||||||
toolbarContainer.addChild(diceButton);
|
return endTurnButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private Button addPropertyMenuButton() {
|
||||||
* Simuliert einen Würfelwurf und bewegt die Figur entsprechend.
|
Button propertyMenuButton = new Button("Zug beenden");
|
||||||
*/
|
propertyMenuButton.setPreferredSize(new Vector3f(150, 50, 0)); // Größe des Buttons
|
||||||
private void rollDice() {
|
propertyMenuButton.addClickCommands(s -> ifTopDialog(() -> {
|
||||||
int diceRoll = random.nextInt(6) + 1; // Zahl zwischen 1 und 6
|
app.getGameLogic().playSound(Sound.BUTTON);
|
||||||
System.out.println("Gewürfelt: " + diceRoll);
|
//TODO send end turn
|
||||||
}
|
}));
|
||||||
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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,22 +34,18 @@ 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
|
||||||
app.getGuiNode().attachChild(backgroundContainer);
|
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 settingsTitle = buyCardContainer.addChild(new Label( field.getName(), new ElementId("settings-title")));
|
Label title = buyCardContainer.addChild(new Label( field.getName(), new ElementId("label-Bold")));
|
||||||
settingsTitle.setFontSize(48);
|
title.setBackground(new QuadBackgroundComponent(field.getColor().getColor()));
|
||||||
|
title.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
|
||||||
@ -70,9 +66,17 @@ 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));
|
||||||
@ -94,22 +98,6 @@ 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.
|
||||||
*/
|
*/
|
||||||
@ -117,7 +105,6 @@ 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user