Merge remote-tracking branch 'origin/gui' into gui
@ -288,13 +288,13 @@ public class LobbyMenu extends Dialog {
|
||||
app.getGameLogic().playSound(Sound.BUTTON);
|
||||
switch (selected) {
|
||||
case "[0]":
|
||||
figure = "Laptop";
|
||||
figure = "Computer";
|
||||
break;
|
||||
case "[1]":
|
||||
figure = "Flugzeug";
|
||||
break;
|
||||
case "[2]":
|
||||
figure = "Jägermeister";
|
||||
figure = "Jaegermeister";
|
||||
break;
|
||||
case "[3]":
|
||||
figure = "Katze";
|
||||
@ -303,7 +303,7 @@ public class LobbyMenu extends Dialog {
|
||||
figure = "OOP";
|
||||
break;
|
||||
case "[5]":
|
||||
figure = "Handyholster";
|
||||
figure = "Holster";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -5,11 +5,16 @@ import java.util.List;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import com.jme3.light.AmbientLight;
|
||||
import com.jme3.light.DirectionalLight;
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.FastMath;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.renderer.RenderManager;
|
||||
import com.jme3.renderer.ViewPort;
|
||||
import com.jme3.scene.control.AbstractControl;
|
||||
import com.jme3.texture.Texture;
|
||||
|
||||
import pp.monopoly.client.MonopolyApp;
|
||||
import pp.monopoly.client.gui.popups.AcceptTrade;
|
||||
@ -47,6 +52,7 @@ public class TestWorld implements GameEventListener {
|
||||
private PlayerHandler playerHandler;
|
||||
private CameraController cameraController;
|
||||
private Toolbar toolbar;
|
||||
private List<String> existingHouses = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Konstruktor für die TestWorld.
|
||||
@ -74,6 +80,7 @@ public class TestWorld implements GameEventListener {
|
||||
//Füge Inhalte ein
|
||||
setSkyColor();
|
||||
createBoard();
|
||||
addLighting();
|
||||
createPlayerFigures();
|
||||
toolbar = new Toolbar(app);
|
||||
toolbar.open();
|
||||
@ -94,9 +101,9 @@ public class TestWorld implements GameEventListener {
|
||||
com.jme3.scene.shape.Box box = new com.jme3.scene.shape.Box(10, 0.1f, 10);
|
||||
com.jme3.scene.Geometry geom = new com.jme3.scene.Geometry("Board", box);
|
||||
|
||||
com.jme3.material.Material mat = new com.jme3.material.Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
com.jme3.texture.Texture texture = app.getAssetManager().loadTexture("Pictures/board2.png");
|
||||
mat.setTexture("ColorMap", texture);
|
||||
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
|
||||
Texture texture = app.getAssetManager().loadTexture("Pictures/board2.png");
|
||||
mat.setTexture("DiffuseMap", texture);
|
||||
geom.setMaterial(mat);
|
||||
|
||||
geom.setLocalTranslation(0, -0.1f, 0);
|
||||
@ -106,33 +113,49 @@ public class TestWorld implements GameEventListener {
|
||||
geom.setLocalRotation(rotation);
|
||||
|
||||
app.getRootNode().attachChild(geom);
|
||||
|
||||
System.out.println("Spielbrett erfolgreich erstellt, gedreht und hinzugefügt.");
|
||||
} catch (Exception e) {
|
||||
System.err.println("Fehler beim Erstellen des Spielfelds: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void addLighting() {
|
||||
// Direktionales Licht
|
||||
DirectionalLight sun = new DirectionalLight();
|
||||
sun.setColor(ColorRGBA.White);
|
||||
sun.setDirection(new Vector3f(-0.5f, -0.7f, -1.0f).normalizeLocal());
|
||||
app.getRootNode().addLight(sun);
|
||||
|
||||
// Umgebungslicht
|
||||
AmbientLight ambient = new AmbientLight();
|
||||
ambient.setColor(new ColorRGBA(0.6f, 0.6f, 0.6f, 1.0f));
|
||||
app.getRootNode().addLight(ambient);
|
||||
}
|
||||
|
||||
/**
|
||||
* Erstellt die Spielfiguren basierend auf der bereits bekannten Spielerliste.
|
||||
*/
|
||||
private void createPlayerFigures() {
|
||||
for (int i = 0; i < playerHandler.getPlayers().size(); i++) {
|
||||
Player player = playerHandler.getPlayers().get(i);
|
||||
for (Player player : playerHandler.getPlayers()) {
|
||||
try {
|
||||
// Lade das Modell
|
||||
com.jme3.scene.Spatial model = app.getAssetManager().loadModel(
|
||||
"models/" + player.getFigure().getType() + "/" + player.getFigure().getType() + ".j3o"
|
||||
);
|
||||
"models/" + "Spielfiguren/" + player.getFigure().getType() + "/" + player.getFigure().getType() + ".j3o");
|
||||
|
||||
// Setze das Material mit silberner Farbe
|
||||
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
|
||||
//mat.setColor("Diffuse", new com.jme3.math.ColorRGBA(0.45f, 0.45f, 0.45f, 1.0f)); // Silberne Farbe
|
||||
//mat.setColor("Specular", new com.jme3.math.ColorRGBA(0.6f, 0.6f, 0.6f, 1.0f)); // Glanzlicht
|
||||
//mat.setFloat("Shininess", 64f); // Höhere Werte machen das Material glänzender
|
||||
//model.setMaterial(mat);
|
||||
|
||||
// Skaliere und positioniere das Modell
|
||||
model.setLocalScale(0.5f);
|
||||
|
||||
int playerIndexOnField = calculatePlayerIndexOnField(player.getFieldID(), player.getId());
|
||||
Vector3f startPosition = calculateFieldPosition(player.getFieldID(), playerIndexOnField);
|
||||
Vector3f startPosition = calculateFieldPosition(player.getFieldID(), player.getId());
|
||||
model.setLocalTranslation(startPosition);
|
||||
|
||||
model.setName("PlayerFigure_" + player.getId());
|
||||
app.getRootNode().attachChild(model);
|
||||
|
||||
System.out.println("Figur für Spieler " + player.getId() + " erstellt bei " + startPosition);
|
||||
// Füge das Modell zur Szene hinzu
|
||||
app.getRootNode().attachChild(model);
|
||||
} catch (Exception e) {
|
||||
System.err.println("Fehler beim Laden des Modells für Spieler " + player.getId() + ": " + e.getMessage());
|
||||
}
|
||||
@ -395,6 +418,105 @@ public class TestWorld implements GameEventListener {
|
||||
}
|
||||
}
|
||||
|
||||
private Vector3f calculateBuildingPosition(int fieldID) {
|
||||
float baseX = 0.0f;
|
||||
float baseZ = 0.0f;
|
||||
|
||||
switch (fieldID) {
|
||||
case 0: baseX = -8.4f; baseZ = -7.7f; break;
|
||||
case 1: baseX = -6.3f; baseZ = -7.7f; break;
|
||||
case 2: baseX = -4.7f; baseZ = -7.7f; break;
|
||||
case 3: baseX = -3.1f; baseZ = -7.7f; break;
|
||||
case 4: baseX = -1.4f; baseZ = -7.7f; break;
|
||||
case 5: baseX = 0.2f; baseZ = -7.7f; break;
|
||||
case 6: baseX = 1.8f; baseZ = -7.7f; break;
|
||||
case 7: baseX = 3.5f; baseZ = -7.7f; break;
|
||||
case 8: baseX = 5.1f; baseZ = -7.7f; break;
|
||||
case 9: baseX = 6.7f; baseZ = -7.7f; break;
|
||||
case 10: baseX = 8.2f; baseZ = -7.7f; break;
|
||||
case 11: baseX = 8.2f; baseZ = -6.5f; break; //passt
|
||||
case 12: baseX = 8.2f; baseZ = -4.9f; break; //passt
|
||||
case 13: baseX = 8.2f; baseZ = -3.3f; break; //passt
|
||||
case 14: baseX = 8.2f; baseZ = -1.6f; break; //passt
|
||||
case 15: baseX = 8.2f; baseZ = 0.0f; break; //passt
|
||||
case 16: baseX = 8.2f; baseZ = 1.6f; break; //passt
|
||||
case 17: baseX = 8.2f; baseZ = 3.3f; break; //passt
|
||||
case 18: baseX = 8.2f; baseZ = 4.9f; break; //passt
|
||||
case 19: baseX = 8.2f; baseZ = 6.5f; break; //passt
|
||||
case 20: baseX = 8.2f; baseZ = 7.7f; break;
|
||||
case 21: baseX = 6.5f; baseZ = 7.7f; break;
|
||||
case 22: baseX = 4.9f; baseZ = 7.7f; break;
|
||||
case 23: baseX = 3.3f; baseZ = 7.7f; break;
|
||||
case 24: baseX = 1.6f; baseZ = 7.7f; break;
|
||||
case 25: baseX = 0.0f; baseZ = 7.7f; break;
|
||||
case 26: baseX = -1.6f; baseZ = 7.7f; break;
|
||||
case 27: baseX = -3.3f; baseZ = 7.7f; break;
|
||||
case 28: baseX = -4.9f; baseZ = 7.7f; break;
|
||||
case 29: baseX = -6.5f; baseZ = 7.7f; break;
|
||||
case 30: baseX = -7.2f; baseZ = 7.7f; break;
|
||||
case 31: baseX = -7.2f; baseZ = 6.5f; break;
|
||||
case 32: baseX = -7.2f; baseZ = 4.9f; break;
|
||||
case 33: baseX = -7.2f; baseZ = 3.3f; break;
|
||||
case 34: baseX = -7.2f; baseZ = 1.6f; break;
|
||||
case 35: baseX = -7.2f; baseZ = 0.0f; break;
|
||||
case 36: baseX = -7.2f; baseZ = -1.6f; break;
|
||||
case 37: baseX = -7.2f; baseZ = -3.3f; break;
|
||||
case 38: baseX = -7.2f; baseZ = -4.9f; break;
|
||||
case 39: baseX = -7.2f; baseZ = -6.5f; break;
|
||||
default: throw new IllegalArgumentException("Ungültige Feld-ID: " + fieldID);
|
||||
}
|
||||
|
||||
return new Vector3f(baseX, 0, baseZ);
|
||||
}
|
||||
|
||||
private void updateHousesOnBoard() {
|
||||
app.enqueue(() -> {
|
||||
List<BuildingProperty> propertiesWithBuildings = app.getGameLogic().getBoardManager().getPropertiesWithBuildings();
|
||||
|
||||
for (BuildingProperty property : propertiesWithBuildings) {
|
||||
int houseCount = property.getHouses();
|
||||
int hotelCount = property.getHotel();
|
||||
|
||||
String uniqueIdentifier = "Building_" + property.getId() + "_" + (hotelCount > 0 ? "Hotel" : houseCount);
|
||||
|
||||
if (existingHouses.contains(uniqueIdentifier)) continue;
|
||||
|
||||
try {
|
||||
String modelPath = hotelCount > 0
|
||||
? "models/Hotel/Hotel.j3o"
|
||||
: "models/Haus/" + houseCount + "Haus.j3o";
|
||||
|
||||
com.jme3.scene.Spatial buildingModel = app.getAssetManager().loadModel(modelPath);
|
||||
|
||||
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
|
||||
|
||||
buildingModel.setMaterial(mat);
|
||||
|
||||
buildingModel.setLocalScale(0.5f);
|
||||
Vector3f position = calculateBuildingPosition(property.getId()).add(0, 0.5f, 0);
|
||||
buildingModel.setLocalTranslation(position);
|
||||
|
||||
com.jme3.math.Quaternion rotation = new com.jme3.math.Quaternion();
|
||||
if (property.getId() >= 1 && property.getId() <= 10) {
|
||||
rotation.fromAngleAxis(FastMath.HALF_PI, Vector3f.UNIT_Y);
|
||||
} else if (property.getId() >= 21 && property.getId() <= 30) {
|
||||
rotation.fromAngleAxis(3 * FastMath.HALF_PI, Vector3f.UNIT_Y);
|
||||
} else if (property.getId() >= 31 && property.getId() <= 39) {
|
||||
rotation.fromAngleAxis(FastMath.PI, Vector3f.UNIT_Y);
|
||||
}
|
||||
|
||||
buildingModel.setLocalRotation(rotation);
|
||||
buildingModel.setName(uniqueIdentifier);
|
||||
app.getRootNode().attachChild(buildingModel);
|
||||
existingHouses.add(uniqueIdentifier);
|
||||
|
||||
} catch (Exception e) {
|
||||
System.err.println("Fehler beim Hinzufügen eines Gebäudes: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receivedEvent(EventCardEvent event) {
|
||||
Timer timer = new Timer();
|
||||
@ -412,5 +534,6 @@ public class TestWorld implements GameEventListener {
|
||||
for (Player player : playerHandler.getPlayers()) {
|
||||
movePlayerFigure(player);
|
||||
}
|
||||
updateHousesOnBoard();
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 518 KiB |
Before Width: | Height: | Size: 15 MiB |
Before Width: | Height: | Size: 556 KiB |
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 66 KiB |
Before Width: | Height: | Size: 200 KiB After Width: | Height: | Size: 200 KiB |
Before Width: | Height: | Size: 143 B |
Before Width: | Height: | Size: 146 B |
Before Width: | Height: | Size: 153 B |
Before Width: | Height: | Size: 147 B |
Before Width: | Height: | Size: 187 B |
Before Width: | Height: | Size: 177 B |
Before Width: | Height: | Size: 165 B |
Before Width: | Height: | Size: 147 B |
Before Width: | Height: | Size: 150 B |
Before Width: | Height: | Size: 202 B |
Before Width: | Height: | Size: 6.7 MiB After Width: | Height: | Size: 6.7 MiB |
Before Width: | Height: | Size: 31 MiB After Width: | Height: | Size: 31 MiB |
Before Width: | Height: | Size: 18 MiB After Width: | Height: | Size: 18 MiB |
After Width: | Height: | Size: 5.7 MiB |
After Width: | Height: | Size: 589 B |
After Width: | Height: | Size: 1.3 MiB |
After Width: | Height: | Size: 35 KiB |
After Width: | Height: | Size: 6.3 KiB |
After Width: | Height: | Size: 9.6 KiB |
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 41 KiB |
@ -3,7 +3,6 @@ package pp.monopoly.model.fields;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.stream.Collector;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
@ -181,4 +180,16 @@ public class BoardManager {
|
||||
.allMatch(bp -> bp.getHouses() <= currentHouses);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt eine Liste von BuildingProperty-Feldern zurück, auf denen Häuser oder Hotels stehen.
|
||||
* @return Liste von BuildingProperty-Feldern mit Gebäuden
|
||||
*/
|
||||
public List<BuildingProperty> getPropertiesWithBuildings() {
|
||||
return board.stream()
|
||||
.filter(f -> f instanceof BuildingProperty)
|
||||
.map(f -> (BuildingProperty) f)
|
||||
.filter(bp -> bp.getHouses() > 0 || bp.getHotel() > 0)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import pp.monopoly.game.server.Player;
|
||||
@Serializable
|
||||
public class BuildingProperty extends PropertyField {
|
||||
|
||||
private int houses = 2;
|
||||
private int houses;
|
||||
private final int housePrice;
|
||||
private final FieldColor color;
|
||||
private final int rentFactor1 = 5;
|
||||
|