Compare commits
32 Commits
0a34751825
...
demo
Author | SHA1 | Date | |
---|---|---|---|
|
eb54fb1d14 | ||
|
40c550cc4d | ||
|
18300987a4 | ||
|
df4a81cbf2 | ||
|
c635df9369 | ||
|
c6ad605021 | ||
|
1e20a2ac6e | ||
|
36a9a7addf | ||
|
e1190cd4a2 | ||
|
34ecd2277b | ||
|
5959f36a21 | ||
|
1db2d9ebac | ||
|
54bac50a7e | ||
|
274ed2b25d | ||
|
371fa83319 | ||
|
c1faf91188 | ||
|
617d707df8 | ||
|
d18cea435c | ||
|
1543f0dcea | ||
|
ae181e4eff | ||
|
fa96324c15 | ||
|
9f559fe0d7 | ||
|
cf6ee535b8 | ||
|
be89bf1a27 | ||
|
6f2027c2fb | ||
|
6e99f17787 | ||
|
b7e2e3213a | ||
|
3ea6452d6d | ||
|
fd3c141967 | ||
|
b3d2dfed08 | ||
|
5306208107 | ||
|
2a7cbeed89 |
@@ -9,32 +9,29 @@ import com.jme3.effect.shapes.EmitterSphereShape;
|
||||
import com.jme3.light.AmbientLight;
|
||||
import com.jme3.light.DirectionalLight;
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.material.RenderState.FaceCullMode;
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.FastMath;
|
||||
import com.jme3.math.Quaternion;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.renderer.Camera;
|
||||
import com.jme3.renderer.queue.RenderQueue;
|
||||
import com.jme3.renderer.queue.RenderQueue.ShadowMode;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.Node;
|
||||
import com.jme3.scene.Spatial;
|
||||
import com.jme3.scene.shape.Box;
|
||||
import com.jme3.scene.shape.Cylinder;
|
||||
import com.jme3.shadow.DirectionalLightShadowRenderer;
|
||||
import com.jme3.shadow.EdgeFilteringMode;
|
||||
import com.jme3.texture.Texture;
|
||||
import com.jme3.util.SkyFactory;
|
||||
import com.jme3.util.TangentBinormalGenerator;
|
||||
|
||||
import pp.monopoly.client.gui.BobTheBuilder;
|
||||
import pp.monopoly.client.gui.CameraController;
|
||||
import pp.monopoly.client.gui.CameraInputHandler;
|
||||
import pp.monopoly.client.gui.Toolbar;
|
||||
import pp.monopoly.model.Board;
|
||||
import pp.monopoly.client.gui.FigureControl;
|
||||
|
||||
import static java.lang.Math.divideExact;
|
||||
import static pp.util.FloatMath.TWO_PI;
|
||||
import static pp.util.FloatMath.cos;
|
||||
import static pp.util.FloatMath.sin;
|
||||
import static pp.util.FloatMath.sqrt;
|
||||
|
||||
/**
|
||||
* Manages the rendering and visual aspects of the sea and sky in the Battleship game.
|
||||
@@ -46,6 +43,7 @@ public class BoardAppState extends MonopolyAppState {
|
||||
* The path to the unshaded texture material.
|
||||
*/
|
||||
private static final String UNSHADED = "Common/MatDefs/Misc/Unshaded.j3md"; //NON-NLS
|
||||
private static final String LIGHTING = "Common/MatDefs/Light/Lighting.j3md";
|
||||
|
||||
/**
|
||||
* The path to the sea texture material.
|
||||
@@ -70,9 +68,12 @@ public class BoardAppState extends MonopolyAppState {
|
||||
/**
|
||||
* The pop-up manager for displaying messages and notifications.
|
||||
*/
|
||||
private PopUpManager popUpManager;;
|
||||
private PopUpManager popUpManager;
|
||||
|
||||
private CameraController cameraController;
|
||||
|
||||
private CameraInputHandler cameraInputHandler;
|
||||
|
||||
private Vector3f currentTarget = new Vector3f(-10f,0,-10f);
|
||||
|
||||
/**
|
||||
* Initializes the state by setting up the sky, lights, and other visual components.
|
||||
@@ -84,14 +85,19 @@ public class BoardAppState extends MonopolyAppState {
|
||||
@Override
|
||||
public void initialize(AppStateManager stateManager, Application application) {
|
||||
super.initialize(stateManager, application);
|
||||
|
||||
// Initialisiere den CameraController zuerst
|
||||
cameraController = new CameraController(getApp().getCamera(), getApp());
|
||||
|
||||
// Danach den CameraInputHandler mit dem initialisierten CameraController
|
||||
cameraInputHandler = new CameraInputHandler(cameraController, getApp().getInputManager());
|
||||
|
||||
popUpManager = new PopUpManager(getApp());
|
||||
viewNode.attachChild(sceneNode);
|
||||
|
||||
//TODO remove this only for camera testing
|
||||
adjustCamera();
|
||||
|
||||
setupLights();
|
||||
setupSky();
|
||||
// setupSky();
|
||||
getApp().getViewPort().setBackgroundColor(new com.jme3.math.ColorRGBA(0.5f, 0.7f, 1.0f, 1.0f));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,30 +120,6 @@ public class BoardAppState extends MonopolyAppState {
|
||||
}
|
||||
getApp().getRootNode().attachChild(viewNode);
|
||||
}
|
||||
//TODO remove this only for camera testing
|
||||
private static final float ABOVE_SEA_LEVEL = 10f;
|
||||
private static final float INCLINATION = 2.5f;
|
||||
private float cameraAngle;
|
||||
|
||||
/**
|
||||
* Adjusts the camera position and orientation to create a circular motion around
|
||||
* the center of the map. This provides a dynamic view of the sea and surrounding environment.
|
||||
*/
|
||||
private void adjustCamera() {
|
||||
final Board board = getGameLogic().getBoard();
|
||||
final float mx = 0.5f * board.getWidth();
|
||||
final float my = 0.5f * board.getHeight();
|
||||
final float radius = 2f * sqrt(mx * mx + my + my);
|
||||
final float cos = radius * cos(cameraAngle);
|
||||
final float sin = radius * sin(cameraAngle);
|
||||
final float x = mx - cos;
|
||||
final float y = my - sin;
|
||||
final Camera camera = getApp().getCamera();
|
||||
camera.setLocation(new Vector3f(0,10,0));
|
||||
camera.lookAt(new Vector3f(getCurrentTarget()),
|
||||
Vector3f.UNIT_Y);
|
||||
camera.update();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -154,18 +136,7 @@ public class BoardAppState extends MonopolyAppState {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the state each frame, moving the camera to simulate it circling around the map.
|
||||
*
|
||||
* @param tpf the time per frame (seconds)
|
||||
*/
|
||||
@Override
|
||||
public void update(float tpf) {
|
||||
super.update(tpf);
|
||||
//TODO remove this only for camera testing
|
||||
cameraAngle += TWO_PI * 0.05f * tpf;
|
||||
// adjustCamera();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets up the lighting for the scene, including directional and ambient lights.
|
||||
@@ -184,7 +155,8 @@ public class BoardAppState extends MonopolyAppState {
|
||||
viewNode.addLight(sun);
|
||||
shRend.setLight(sun);
|
||||
|
||||
final AmbientLight ambientLight = new AmbientLight(new ColorRGBA(1f, 1f, 1f, 1f));
|
||||
final AmbientLight ambientLight = new AmbientLight();
|
||||
// ambientLight.setColor(ColorRGBA.White.mult(0.f)); // brightness
|
||||
viewNode.addLight(ambientLight);
|
||||
}
|
||||
|
||||
@@ -194,17 +166,79 @@ public class BoardAppState extends MonopolyAppState {
|
||||
*/
|
||||
private void setupSky() {
|
||||
final AssetManager assetManager = getApp().getAssetManager();
|
||||
final Texture west = assetManager.loadTexture("Pictures/Backdrop/west.jpg"); //NON-NLS
|
||||
final Texture east = assetManager.loadTexture("Pictures/Backdrop/ost.jpg"); //NON-NLS
|
||||
final Texture north = assetManager.loadTexture("Pictures/Backdrop/nord.jpg"); //NON-NLS
|
||||
final Texture south = assetManager.loadTexture("Pictures/Backdrop/sued.jpg"); //NON-NLS
|
||||
final Texture up = assetManager.loadTexture("Pictures/Backdrop/sued.jpg"); //NON-NLS
|
||||
final Texture down = assetManager.loadTexture("Pictures/Backdrop/sued.jpg"); //NON-NLS
|
||||
final Spatial sky = SkyFactory.createSky(assetManager, west, east, north, south, up, down);
|
||||
// sky.rotate(0, PI, 0);
|
||||
viewNode.attachChild(sky);
|
||||
|
||||
// Create a cylinder for the sky
|
||||
float radius = 500f; // Adjust radius as needed
|
||||
float height = 200f; // Height of the cylinder
|
||||
int radialSamples = 64; // Number of radial segments for smoothness
|
||||
int axisSamples = 2; // No vertical divisions (flat vertical surface)
|
||||
|
||||
Cylinder skyCylinder = new Cylinder(axisSamples, radialSamples, radius, height, true);
|
||||
|
||||
// Create a geometry for the cylinder
|
||||
Geometry skyGeometry = new Geometry("CylinderSky", skyCylinder);
|
||||
|
||||
// Load the cylindrical texture
|
||||
Texture cylinderTexture = assetManager.loadTexture("Textures/CylinderMap.jpg");
|
||||
|
||||
// Create a material and apply the texture
|
||||
Material skyMaterial = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
skyMaterial.setTexture("ColorMap", cylinderTexture);
|
||||
skyMaterial.getAdditionalRenderState().setFaceCullMode(FaceCullMode.Off); // Render inside of the cylinder
|
||||
|
||||
// Assign material to the geometry
|
||||
skyGeometry.setMaterial(skyMaterial);
|
||||
skyGeometry.rotate(-FastMath.HALF_PI, 0, 0); // Rotate 90° along the Y-axis
|
||||
|
||||
// Position and attach the cylinder to the scene
|
||||
skyGeometry.setQueueBucket(RenderQueue.Bucket.Sky); // Ensure it's rendered in the background
|
||||
skyGeometry.setCullHint(Spatial.CullHint.Never); // Always render the sky
|
||||
|
||||
viewNode.attachChild(skyGeometry);
|
||||
|
||||
addCylinderCaps();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds top and bottom caps to the cylinder sky.
|
||||
*/
|
||||
private void addCylinderCaps() {
|
||||
final AssetManager assetManager = getApp().getAssetManager();
|
||||
|
||||
float radius = 500f; // Match the cylinder's radius
|
||||
float height = 225f; // Match the cylinder's height
|
||||
int radialSamples = 64; // Match the cylinder's radial samples
|
||||
|
||||
// Bottom Cap
|
||||
Cylinder bottomCap = new Cylinder(2, radialSamples, radius, 0.01f, true, false); // Thin bottom cap
|
||||
Geometry bottomGeometry = new Geometry("BottomCap", bottomCap);
|
||||
bottomGeometry.setLocalTranslation(0, -height / 2, 0); // Position at the bottom
|
||||
bottomGeometry.rotate(FastMath.HALF_PI, 0, 0); // Rotate to make it horizontal
|
||||
Material bottomMaterial = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
bottomMaterial.setTexture("ColorMap", assetManager.loadTexture("Textures/grass.jpg")); // Bottom texture
|
||||
bottomMaterial.getAdditionalRenderState().setFaceCullMode(FaceCullMode.Off); // Render both sides
|
||||
bottomGeometry.setMaterial(bottomMaterial);
|
||||
bottomGeometry.setQueueBucket(RenderQueue.Bucket.Sky);
|
||||
bottomGeometry.setCullHint(Spatial.CullHint.Never);
|
||||
|
||||
// Top Cap
|
||||
Cylinder topCap = new Cylinder(2, radialSamples, radius, 0.01f, true, false); // Thin top cap
|
||||
Geometry topGeometry = new Geometry("TopCap", topCap);
|
||||
topGeometry.setLocalTranslation(0, height / 2, 0); // Position at the top
|
||||
topGeometry.rotate(FastMath.HALF_PI, 0, 0); // Rotate to make it horizontal
|
||||
Material topMaterial = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
topMaterial.setTexture("ColorMap", assetManager.loadTexture("Textures/Top.png")); // Top texture
|
||||
topMaterial.getAdditionalRenderState().setFaceCullMode(FaceCullMode.Off); // Render both sides
|
||||
topGeometry.setMaterial(topMaterial);
|
||||
topGeometry.setQueueBucket(RenderQueue.Bucket.Sky);
|
||||
topGeometry.setCullHint(Spatial.CullHint.Never);
|
||||
|
||||
// Attach caps to the view node
|
||||
viewNode.attachChild(bottomGeometry);
|
||||
viewNode.attachChild(topGeometry);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets up the sea surface in the scene. This includes creating the sea mesh,
|
||||
* applying textures, and enabling shadows.
|
||||
@@ -221,7 +255,16 @@ public class BoardAppState extends MonopolyAppState {
|
||||
seaGeo.setLocalRotation(rotation);
|
||||
final Material seaMat = new Material(getApp().getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
|
||||
Texture texture = getApp().getAssetManager().loadTexture("Pictures/board2.png");
|
||||
texture.setMagFilter(Texture.MagFilter.Bilinear);
|
||||
texture.setMinFilter(Texture.MinFilter.Trilinear);
|
||||
seaMat.setTexture("DiffuseMap", texture);
|
||||
|
||||
// Add specular highlights
|
||||
// seaMat.setBoolean("UseMaterialColors", true);
|
||||
seaMat.setColor("Diffuse", ColorRGBA.White);
|
||||
seaMat.setColor("Specular", ColorRGBA.White);
|
||||
// seaMat.setFloat("Shininess", 16f);
|
||||
|
||||
seaGeo.setMaterial(seaMat);
|
||||
seaGeo.setShadowMode(ShadowMode.CastAndReceive);
|
||||
TangentBinormalGenerator.generate(seaGeo);
|
||||
@@ -230,30 +273,49 @@ public class BoardAppState extends MonopolyAppState {
|
||||
sceneNode.attachChild(seaGeo);
|
||||
|
||||
// Schneefall hinzufügen
|
||||
addSnowEffect(sceneNode);
|
||||
// addSnowEffect(sceneNode);
|
||||
}
|
||||
|
||||
private Node createCardDeck() {
|
||||
Node cardDeck = new Node("cardDeck");
|
||||
Spatial card = getApp().getAssetManager().loadModel("models/Kartendecks/Ereigniskarten_Deck.j3o");
|
||||
card.setLocalTranslation(5.5f, 0, 2.7f);
|
||||
card.setLocalScale(4.1f);
|
||||
card.setLocalRotation(new Quaternion().fromAngleAxis(FastMath.QUARTER_PI, Vector3f.UNIT_Y));
|
||||
|
||||
Spatial card2 = getApp().getAssetManager().loadModel("models/Kartendecks/Gemeinschaftskarten_Deck.j3o");
|
||||
card2.setLocalTranslation(-1.4f, 0, -3.8f);
|
||||
card2.setLocalScale(4.1f);
|
||||
card2.setLocalRotation(new Quaternion().fromAngleAxis(FastMath.QUARTER_PI , Vector3f.UNIT_Y));
|
||||
|
||||
cardDeck.attachChild(card);
|
||||
cardDeck.attachChild(card2);
|
||||
|
||||
// Ereigniskarten
|
||||
Vector3f basePosition1 = new Vector3f(3.1f, 0.4f, 3.8f); // Basisposition für Ereigniskarten
|
||||
float baseRotation1 = -60; // Basisrotation in Grad
|
||||
for (int i = 0; i < 6; i++) {
|
||||
Box box = new Box(1.2f, 0.05f, 1.8f); // Sehr flaches Rechteck
|
||||
Geometry flatCard = new Geometry("Ereigniskarten_" + i, box);
|
||||
Material mat = new Material(getApp().getAssetManager(), UNSHADED);
|
||||
mat.setTexture("ColorMap", getApp().getAssetManager().loadTexture("Textures/Ereigniskarten.png"));
|
||||
flatCard.setMaterial(mat);
|
||||
|
||||
// Position und Rotation für die Karte
|
||||
flatCard.setLocalTranslation(basePosition1.x, basePosition1.y - (i * 0.08f), basePosition1.z);
|
||||
flatCard.setLocalRotation(new Quaternion().fromAngleAxis(FastMath.DEG_TO_RAD * (baseRotation1 - (i * 5)), Vector3f.UNIT_Y));
|
||||
|
||||
cardDeck.attachChild(flatCard);
|
||||
}
|
||||
|
||||
// Gemeinschaftskarten
|
||||
Vector3f basePosition2 = new Vector3f(-3.3f, 0.4f, -3.8f); // Basisposition für Gemeinschaftskarten
|
||||
float baseRotation2 = -220; // Basisrotation in Grad
|
||||
for (int i = 0; i < 6; i++) {
|
||||
Box box = new Box(1.2f, 0.04f, 1.8f); // Sehr flaches Rechteck
|
||||
Geometry flatCard = new Geometry("Gemeinschaftskarten_" + i, box);
|
||||
Material mat = new Material(getApp().getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
mat.setTexture("ColorMap", getApp().getAssetManager().loadTexture("Textures/Gemeinschaftskarten.png"));
|
||||
flatCard.setMaterial(mat);
|
||||
|
||||
// Position und Rotation für die Karte
|
||||
flatCard.setLocalTranslation(basePosition2.x, basePosition2.y - (i * 0.08f), basePosition2.z);
|
||||
flatCard.setLocalRotation(new Quaternion().fromAngleAxis(FastMath.DEG_TO_RAD * (baseRotation2 - (i * 5)), Vector3f.UNIT_Y));
|
||||
|
||||
cardDeck.attachChild(flatCard);
|
||||
}
|
||||
|
||||
return cardDeck;
|
||||
}
|
||||
|
||||
public Vector3f getCurrentTarget(){
|
||||
return currentTarget;
|
||||
}
|
||||
|
||||
private void addSnowEffect(Node parentNode) {
|
||||
// ParticleEmitter für Schnee
|
||||
ParticleEmitter snowEmitter = new ParticleEmitter("Snow", ParticleMesh.Type.Triangle, 5000);
|
||||
@@ -282,4 +344,11 @@ public class BoardAppState extends MonopolyAppState {
|
||||
// Emitter zur Szene hinzufügen
|
||||
parentNode.attachChild(snowEmitter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(float tpf) {
|
||||
super.update(tpf);
|
||||
cameraController.update(tpf);
|
||||
}
|
||||
|
||||
}
|
@@ -292,7 +292,9 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
|
||||
final StatsAppState stats = new StatsAppState(guiNode, normalFont);
|
||||
stateManager.attach(stats);
|
||||
}
|
||||
flyCam.setEnabled(true);
|
||||
flyCam.setEnabled(false);
|
||||
flyCam.setMoveSpeed(4f); // Setzt die Bewegungsgeschwindigkeit der Kamera (Standardwert ist 1f)
|
||||
|
||||
stateManager.detach(stateManager.getState(StatsAppState.class));
|
||||
stateManager.detach(stateManager.getState(DebugKeysAppState.class));
|
||||
|
||||
|
@@ -56,7 +56,7 @@ public class PopUpManager implements GameEventListener {
|
||||
}
|
||||
});
|
||||
}
|
||||
}, 6000);
|
||||
}, 8000);
|
||||
} else if (event.msg().equals("Winner")) {
|
||||
new WinnerPopUp(app).open();
|
||||
} else if (event.msg().equals("Looser")) {
|
||||
|
@@ -3,64 +3,106 @@ package pp.monopoly.client.gui;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.renderer.Camera;
|
||||
|
||||
/**
|
||||
* Controls the movement of the camera within the scene.
|
||||
*/
|
||||
public class CameraController {
|
||||
import pp.monopoly.client.MonopolyApp; // Import MonopolyApp
|
||||
import pp.monopoly.game.server.PlayerHandler;
|
||||
import pp.monopoly.notification.GameEventListener;
|
||||
import pp.monopoly.notification.UpdatePlayerView;
|
||||
|
||||
public class CameraController implements GameEventListener{
|
||||
|
||||
public enum CameraMode {
|
||||
FOCUS_CURRENT_PLAYER,
|
||||
FOCUS_SELF,
|
||||
FREECAM
|
||||
}
|
||||
|
||||
private final Camera camera;
|
||||
private final float height = 25; // Height of the camera above the game board
|
||||
private CameraMode currentMode;
|
||||
|
||||
/**
|
||||
* Constructor for the CameraController.
|
||||
*
|
||||
* @param camera The camera to be controlled
|
||||
*/
|
||||
public CameraController(Camera camera) {
|
||||
private PlayerHandler playerHandler; // Reference to PlayerHandler for player data
|
||||
private final MonopolyApp app; // Reference to MonopolyApp for self ID
|
||||
|
||||
public CameraController(Camera camera, MonopolyApp app) {
|
||||
this.camera = camera;
|
||||
setPosition(0);
|
||||
camera.lookAt(Vector3f.ZERO, Vector3f.UNIT_Y);
|
||||
this.playerHandler = app.getGameLogic().getPlayerHandler();
|
||||
this.app = app;
|
||||
app.getGameLogic().addListener(this);
|
||||
setMode(CameraMode.FOCUS_SELF); // Initialize the camera mode
|
||||
}
|
||||
|
||||
public void setMode(CameraMode mode) {
|
||||
this.currentMode = mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the camera's position and orientation.
|
||||
*
|
||||
* @param tpf Time per frame
|
||||
*/
|
||||
public void update(float tpf) {
|
||||
camera.lookAt(Vector3f.ZERO, Vector3f.UNIT_Y);
|
||||
|
||||
switch (currentMode) {
|
||||
case FOCUS_CURRENT_PLAYER:
|
||||
updatePosition();
|
||||
break;
|
||||
case FOCUS_SELF:
|
||||
updatePosition();
|
||||
break;
|
||||
|
||||
case FREECAM:
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the camera's position based on the field ID.
|
||||
*
|
||||
* @param fieldID The ID of the field to which the camera should move
|
||||
*/
|
||||
public void setPosition(int fieldID) {
|
||||
camera.setLocation(fieldIdToVector(fieldID));
|
||||
public void updatePosition() {
|
||||
Vector3f newPosition = getPos();
|
||||
camera.setLocation(newPosition);
|
||||
|
||||
camera.lookAt(app.getGameLogic().getBoard().getFigure(app.getId()).getPos(), Vector3f.UNIT_Y);
|
||||
camera.update();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the camera's position using specific coordinates.
|
||||
*
|
||||
* @param x The X-coordinate of the new camera position
|
||||
* @param y The Y-coordinate of the new camera position
|
||||
*/
|
||||
public void setPosition(float x, float y) {
|
||||
camera.setLocation(new Vector3f(x, height, y));
|
||||
private Vector3f getPos() {
|
||||
Vector3f pos = new Vector3f();
|
||||
switch (currentMode) {
|
||||
case FOCUS_CURRENT_PLAYER:
|
||||
pos = app.getGameLogic().getBoard().getFigure(playerHandler.getPlayerById(0).getId()).getPos();
|
||||
|
||||
case FOCUS_SELF:
|
||||
pos = app.getGameLogic().getBoard().getFigure(app.getId()).getPos();
|
||||
|
||||
case FREECAM:
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Vector3f offset = getOffset();
|
||||
pos = new Vector3f(pos.getX() + offset.getX(), pos.getY() + offset.getY(), pos.getZ() + offset.getZ());
|
||||
|
||||
return pos;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps a field ID to its corresponding position in the game world.
|
||||
*
|
||||
* @param fieldID The ID of the field
|
||||
* @return The position of the field as a {@link Vector3f}
|
||||
* @throws IllegalArgumentException If the field ID is invalid
|
||||
*/
|
||||
private Vector3f fieldIdToVector(int fieldID) {
|
||||
if (fieldID <= 10) return new Vector3f(30, height, 0);
|
||||
if (fieldID <= 20) return new Vector3f(0, height, 30);
|
||||
if (fieldID <= 30) return new Vector3f(-30, height, 0);
|
||||
if (fieldID <= 40) return new Vector3f(0, height, -30);
|
||||
else throw new IllegalArgumentException();
|
||||
private Vector3f getOffset() {
|
||||
Vector3f offset = new Vector3f();
|
||||
|
||||
int fieldId = playerHandler.getPlayerById( (currentMode == CameraMode.FOCUS_SELF ? app.getId() : playerHandler.getPlayerAtIndex(0).getId()) ).getFieldID();
|
||||
// System.out.println();
|
||||
if(fieldId < 10) {
|
||||
offset = new Vector3f(0, 10, -15);
|
||||
} else if(fieldId < 20) {
|
||||
offset = new Vector3f(15 , 10, 0);
|
||||
} else if(fieldId < 30) {
|
||||
offset = new Vector3f(0, 10, 15 );
|
||||
} else {
|
||||
offset = new Vector3f(-15, 10, 0);
|
||||
}
|
||||
|
||||
return offset;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receivedEvent(UpdatePlayerView event) {
|
||||
playerHandler = app.getGameLogic().getPlayerHandler();
|
||||
}
|
||||
}
|
||||
|
@@ -1,60 +1,31 @@
|
||||
//package pp.monopoly.client.gui;
|
||||
//
|
||||
//import com.jme3.input.InputManager;
|
||||
//import com.jme3.input.KeyInput;
|
||||
//import com.jme3.input.controls.ActionListener;
|
||||
//import com.jme3.input.controls.KeyTrigger;
|
||||
//
|
||||
///**
|
||||
// * Handhabt die Eingaben für die Kamera.
|
||||
// */
|
||||
//public class CameraInputHandler {
|
||||
//
|
||||
// private CameraController cameraController; // Kamera-Controller
|
||||
//
|
||||
// /**
|
||||
// * Konstruktor für den CameraInputHandler.
|
||||
// *
|
||||
// * @param cameraController Der Kamera-Controller, der gesteuert werden soll.
|
||||
// * @param inputManager Der InputManager, um Eingaben zu registrieren.
|
||||
// */
|
||||
// public CameraInputHandler(CameraController cameraController, InputManager inputManager) {
|
||||
// if (cameraController == null || inputManager == null) {
|
||||
// throw new IllegalArgumentException("CameraController und InputManager dürfen nicht null sein");
|
||||
// }
|
||||
// this.cameraController = cameraController;
|
||||
//
|
||||
// // Mappings für Kamerasteuerung
|
||||
// inputManager.addMapping("FocusCurrentPlayer", new KeyTrigger(KeyInput.KEY_1)); // Modus 1
|
||||
// inputManager.addMapping("FocusSelf", new KeyTrigger(KeyInput.KEY_2)); // Modus 2
|
||||
// inputManager.addMapping("FreeCam", new KeyTrigger(KeyInput.KEY_3)); // Modus 3
|
||||
//
|
||||
// // Listener für die Kameramodi
|
||||
// inputManager.addListener(actionListener, "FocusCurrentPlayer", "FocusSelf", "FreeCam");
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * ActionListener für die Kamerasteuerung.
|
||||
// */
|
||||
// private final ActionListener actionListener = (name, isPressed, tpf) -> {
|
||||
// if (!isPressed) return;
|
||||
//
|
||||
// // Umschalten der Kamera-Modi basierend auf der Eingabe
|
||||
// switch (name) {
|
||||
// case "FocusCurrentPlayer" -> {
|
||||
// cameraController.setMode(CameraController.CameraMode.FOCUS_CURRENT_PLAYER);
|
||||
// System.out.println("Kameramodus: Fokus auf aktuellen Spieler");
|
||||
// }
|
||||
// case "FocusSelf" -> {
|
||||
// cameraController.setMode(CameraController.CameraMode.FOCUS_SELF);
|
||||
// System.out.println("Kameramodus: Fokus auf eigene Figur");
|
||||
// }
|
||||
// case "FreeCam" -> {
|
||||
// cameraController.setMode(CameraController.CameraMode.FREECAM);
|
||||
// System.out.println("Kameramodus: Freie Kamera");
|
||||
// }
|
||||
// default -> System.err.println("Unbekannter Kameramodus: " + name);
|
||||
// }
|
||||
// };
|
||||
//}
|
||||
//
|
||||
package pp.monopoly.client.gui;
|
||||
|
||||
import com.jme3.input.InputManager;
|
||||
import com.jme3.input.KeyInput;
|
||||
import com.jme3.input.controls.ActionListener;
|
||||
import com.jme3.input.controls.KeyTrigger;
|
||||
|
||||
public class CameraInputHandler {
|
||||
private CameraController cameraController;
|
||||
|
||||
public CameraInputHandler(CameraController cameraController, InputManager inputManager) {
|
||||
this.cameraController = cameraController;
|
||||
|
||||
// Tasten für die verschiedenen Kameramodi registrieren
|
||||
inputManager.addMapping("FocusCurrentPlayer", new KeyTrigger(KeyInput.KEY_1));
|
||||
inputManager.addMapping("FocusSelf", new KeyTrigger(KeyInput.KEY_2));
|
||||
inputManager.addMapping("FreeCam", new KeyTrigger(KeyInput.KEY_3));
|
||||
|
||||
inputManager.addListener(actionListener, "FocusCurrentPlayer", "FocusSelf", "FreeCam");
|
||||
}
|
||||
|
||||
private final ActionListener actionListener = (name, isPressed, tpf) -> {
|
||||
if (!isPressed) return;
|
||||
|
||||
switch (name) {
|
||||
case "FocusCurrentPlayer" -> cameraController.setMode(CameraController.CameraMode.FOCUS_CURRENT_PLAYER);
|
||||
case "FocusSelf" -> cameraController.setMode(CameraController.CameraMode.FOCUS_SELF);
|
||||
case "FreeCam" -> cameraController.setMode(CameraController.CameraMode.FREECAM);
|
||||
}
|
||||
};
|
||||
}
|
@@ -101,6 +101,7 @@ public class Toolbar extends Dialog implements GameEventListener {
|
||||
setupBorders(container);
|
||||
setupSpacer(container);
|
||||
setupPlayerInfoSection(container);
|
||||
setupSpacer(container);
|
||||
setupDiceSection(container);
|
||||
setupActionMenu(container);
|
||||
|
||||
@@ -195,16 +196,6 @@ public class Toolbar extends Dialog implements GameEventListener {
|
||||
menuContainer.setBackground(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the color of the current player.
|
||||
*
|
||||
* @return The color of the current player.
|
||||
*/
|
||||
private ColorRGBA getCurrentPlayerColor() {
|
||||
Player currentPlayer = playerHandler.getPlayerById(app.getId());
|
||||
return Player.getColor(currentPlayer.getId()).getColor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the dice display section of the toolbar interface.
|
||||
*
|
||||
@@ -282,15 +273,15 @@ public class Toolbar extends Dialog implements GameEventListener {
|
||||
* Handles the dice roll event.
|
||||
*/
|
||||
private void handleDiceRoll() {
|
||||
ifTopDialog(() -> {
|
||||
if (!canRollDice) return;
|
||||
canRollDice = false;
|
||||
if (endTurnButton != null) endTurnButton.setEnabled(true);
|
||||
startDiceAnimation();
|
||||
app.getGameLogic().send(new RollDice());
|
||||
app.getGameLogic().playSound(Sound.BUTTON);
|
||||
});
|
||||
}
|
||||
ifTopDialog(() -> {
|
||||
if (!canRollDice) return;
|
||||
canRollDice = false;
|
||||
if (endTurnButton != null) endTurnButton.setEnabled(true);
|
||||
startDiceAnimation();
|
||||
app.getGameLogic().send(new RollDice());
|
||||
app.getGameLogic().playSound(Sound.BUTTON);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private Button createTradeButton() {
|
||||
@@ -307,6 +298,7 @@ public class Toolbar extends Dialog implements GameEventListener {
|
||||
|
||||
tradeButton.addClickCommands(s -> ifTopDialog(() -> {
|
||||
new ChoosePartner(app).open();
|
||||
|
||||
}));
|
||||
|
||||
return tradeButton;
|
||||
@@ -352,18 +344,6 @@ public class Toolbar extends Dialog implements GameEventListener {
|
||||
return endTurnButton;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a background with the specified color.
|
||||
*
|
||||
* @param color The color of the background.
|
||||
* @return The background component.
|
||||
*/
|
||||
private QuadBackgroundComponent createButtonBackground(ColorRGBA color) {
|
||||
QuadBackgroundComponent background = new QuadBackgroundComponent(color);
|
||||
Texture gradient = app.getAssetManager().loadTexture("Textures/gradient.png");
|
||||
if (gradient != null) background.setTexture(gradient);
|
||||
return background;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the end turn event.
|
||||
|
@@ -92,7 +92,7 @@ public class AcceptTrade extends Dialog implements PopupDialog {
|
||||
|
||||
// Message
|
||||
Container textContainer = noMoneyWarningContainer.addChild(new Container());
|
||||
textContainer.addChild(new Label("Du hast Spieler " + msg.getTradeHandler().getReceiver().getName() + " einen Handel vorgeschlagen.", new ElementId("label-Text")));
|
||||
textContainer.addChild(new Label("Du hast " + msg.getTradeHandler().getReceiver().getName() + " einen Handel vorgeschlagen.", new ElementId("label-Text")));
|
||||
textContainer.addChild(new Label("", new ElementId("label-Text")));
|
||||
textContainer.addChild(new Label("Der Handel wurde angenommen.", new ElementId("label-Text")));
|
||||
textContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
|
||||
|
@@ -73,7 +73,7 @@ public class Bankrupt extends Dialog implements PopupDialog {
|
||||
private void createBankruptContainer() {
|
||||
bankruptContainer = new Container();
|
||||
bankruptContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f)));
|
||||
bankruptContainer.setPreferredSize(new Vector3f(550, 250, 10));
|
||||
bankruptContainer.setPreferredSize(new Vector3f(550, 350, 10));
|
||||
|
||||
// Title
|
||||
Label title = bankruptContainer.addChild(new Label("Vorsicht!", new ElementId("warning-title")));
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package pp.monopoly.client.gui.popups;
|
||||
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.simsilica.lemur.Button;
|
||||
import com.simsilica.lemur.Container;
|
||||
import com.simsilica.lemur.Label;
|
||||
@@ -41,6 +42,8 @@ public class BuildingPropertyCard extends Dialog implements PopupDialog {
|
||||
buildingPropertyContainer = new Container();
|
||||
buildingPropertyContainer.setBackground(new QuadBackgroundComponent(field.getColor().getColor()));
|
||||
addContentToContainer(buildingPropertyContainer, field);
|
||||
buildingPropertyContainer.setPreferredSize(new Vector3f(360,460,1));
|
||||
System.out.println(buildingPropertyContainer.getPreferredSize());
|
||||
|
||||
// Create the background container
|
||||
backgroundContainer = new Container();
|
||||
@@ -50,6 +53,9 @@ public class BuildingPropertyCard extends Dialog implements PopupDialog {
|
||||
float padding = 10f;
|
||||
backgroundContainer.setPreferredSize(buildingPropertyContainer.getPreferredSize().addLocal(padding, padding, 0));
|
||||
|
||||
|
||||
System.out.println(backgroundContainer.getPreferredSize());
|
||||
|
||||
// Position the containers
|
||||
centerContainers(padding);
|
||||
}
|
||||
@@ -64,11 +70,12 @@ public class BuildingPropertyCard extends Dialog implements PopupDialog {
|
||||
// Title
|
||||
Label title = container.addChild(new Label(field.getName(), new ElementId("label-Bold")));
|
||||
title.setBackground(new QuadBackgroundComponent(field.getColor().getColor()));
|
||||
title.setFontSize(48);
|
||||
title.setFontSize(38);
|
||||
|
||||
// Property details
|
||||
Container propertyValuesContainer = container.addChild(new Container());
|
||||
propertyValuesContainer.addChild(new Label("Grundstückswert: " + field.getPrice() + " EUR", new ElementId("label-Text")));
|
||||
propertyValuesContainer.addChild(new Label("", new ElementId("label-Text")));
|
||||
propertyValuesContainer.addChild(new Label("Miete allein: " + field.getAllRent().get(0) + " EUR", new ElementId("label-Text")));
|
||||
propertyValuesContainer.addChild(new Label("- mit 1 Haus: " + field.getAllRent().get(1) + " EUR", new ElementId("label-Text")));
|
||||
propertyValuesContainer.addChild(new Label("- mit 2 Häusern: " + field.getAllRent().get(2) + " EUR", new ElementId("label-Text")));
|
||||
@@ -76,6 +83,7 @@ public class BuildingPropertyCard extends Dialog implements PopupDialog {
|
||||
propertyValuesContainer.addChild(new Label("- mit 4 Häusern: " + field.getAllRent().get(4) + " EUR", new ElementId("label-Text")));
|
||||
propertyValuesContainer.addChild(new Label("- mit 1 Hotel: " + field.getAllRent().get(5) + " EUR", new ElementId("label-Text")));
|
||||
propertyValuesContainer.addChild(new Label("1 Haus kostet: " + field.getHousePrice() + " EUR", new ElementId("label-Text")));
|
||||
propertyValuesContainer.addChild(new Label("", new ElementId("label-Text")));
|
||||
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)));
|
||||
|
||||
|
@@ -7,7 +7,6 @@ import com.simsilica.lemur.Button;
|
||||
import com.simsilica.lemur.Container;
|
||||
import com.simsilica.lemur.Label;
|
||||
import com.simsilica.lemur.Selector;
|
||||
import com.simsilica.lemur.TextField;
|
||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
||||
import com.simsilica.lemur.component.SpringGridLayout;
|
||||
import com.simsilica.lemur.core.VersionedList;
|
||||
|
@@ -79,7 +79,7 @@ public class ConfirmTrade extends Dialog implements PopupDialog {
|
||||
|
||||
// Trade details
|
||||
Container propertyValuesContainer = confirmTradeContainer.addChild(new Container());
|
||||
propertyValuesContainer.addChild(new Label("„Spieler " + tradeHandler.getSender().getName() + " möchte:", new ElementId("label-Text")));
|
||||
propertyValuesContainer.addChild(new Label( tradeHandler.getSender().getName() + " möchte:", new ElementId("label-Text")));
|
||||
propertyValuesContainer.addChild(new Label("", new ElementId("label-Text")));
|
||||
propertyValuesContainer.addChild(new Label("- " + offeredProperties, new ElementId("label-Text")));
|
||||
propertyValuesContainer.addChild(new Label("- " + tradeHandler.getOfferedAmount() + " EUR", new ElementId("label-Text")));
|
||||
|
@@ -3,6 +3,7 @@ package pp.monopoly.client.gui.popups;
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.material.RenderState.BlendMode;
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.shape.Quad;
|
||||
import com.simsilica.lemur.Button;
|
||||
@@ -72,6 +73,7 @@ public class FoodFieldCard extends Dialog implements PopupDialog {
|
||||
private void createBackgroundContainer() {
|
||||
backgroundContainer = new Container();
|
||||
backgroundContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); // Light gray background
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,6 +84,7 @@ public class FoodFieldCard extends Dialog implements PopupDialog {
|
||||
private void createFoodFieldContainer(FoodField field) {
|
||||
foodFieldContainer = new Container();
|
||||
foodFieldContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.1f, 0.1f, 0.1f, 0.9f)));
|
||||
foodFieldContainer.setPreferredSize(new Vector3f(360,445,1));
|
||||
|
||||
// Title
|
||||
Label title = foodFieldContainer.addChild(new Label(field.getName(), new ElementId("label-Bold")));
|
||||
@@ -92,8 +95,12 @@ public class FoodFieldCard extends Dialog implements PopupDialog {
|
||||
Container propertyValuesContainer = foodFieldContainer.addChild(new Container());
|
||||
propertyValuesContainer.addChild(new Label("„Preis: " + field.getPrice() + " EUR", new ElementId("label-Text")));
|
||||
propertyValuesContainer.addChild(new Label("", new ElementId("label-Text"))); // Empty line
|
||||
propertyValuesContainer.addChild(new Label("„Miete: 40x Würfel-Augen, wenn Besitzer eines Restaurants.", new ElementId("label-Text")));
|
||||
propertyValuesContainer.addChild(new Label("„Miete: 100x Würfel-Augen, wenn Besitzer beider Restaurants.", new ElementId("label-Text")));
|
||||
propertyValuesContainer.addChild(new Label("„Miete: 40x Würfel-Augen,", new ElementId("label-Text")));
|
||||
propertyValuesContainer.addChild(new Label("„wenn Besitzer eines ", new ElementId("label-Text")));
|
||||
propertyValuesContainer.addChild(new Label("„Restaurants.", new ElementId("label-Text")));
|
||||
propertyValuesContainer.addChild(new Label("„Miete: 100x Würfel-Augen, ", new ElementId("label-Text")));
|
||||
propertyValuesContainer.addChild(new Label("„wenn Besitzer eines ", new ElementId("label-Text")));
|
||||
propertyValuesContainer.addChild(new Label("„Restaurants.", new ElementId("label-Text")));
|
||||
propertyValuesContainer.addChild(new Label("", new ElementId("label-Text"))); // Empty line
|
||||
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)));
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package pp.monopoly.client.gui.popups;
|
||||
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.simsilica.lemur.Button;
|
||||
import com.simsilica.lemur.Container;
|
||||
import com.simsilica.lemur.Label;
|
||||
@@ -61,6 +62,8 @@ public class GateFieldCard extends Dialog implements PopupDialog {
|
||||
*/
|
||||
private void createGateFieldContainer(GateField field) {
|
||||
gateFieldContainer = new Container();
|
||||
//TODO: Set the size of the container to the size of the screen @Simon
|
||||
gateFieldContainer.setPreferredSize(new Vector3f(360,460,1));
|
||||
gateFieldContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f)));
|
||||
|
||||
// Title
|
||||
@@ -73,9 +76,12 @@ public class GateFieldCard extends Dialog implements PopupDialog {
|
||||
propertyValuesContainer.addChild(new Label("„Preis: " + field.getPrice() + " EUR", new ElementId("label-Text")));
|
||||
propertyValuesContainer.addChild(new Label("", new ElementId("label-Text"))); // Empty line
|
||||
propertyValuesContainer.addChild(new Label("Miete: 250 EUR", new ElementId("label-Text")));
|
||||
propertyValuesContainer.addChild(new Label("Wenn man 2 Bahnhöfe besitzt: 500 EUR", new ElementId("label-Text")));
|
||||
propertyValuesContainer.addChild(new Label("Wenn man 3 Bahnhöfe besitzt: 1000 EUR", new ElementId("label-Text")));
|
||||
propertyValuesContainer.addChild(new Label("Wenn man 4 Bahnhöfe besitzt: 2000 EUR", new ElementId("label-Text")));
|
||||
propertyValuesContainer.addChild(new Label("Wenn man 2 Tore", new ElementId("label-Text")));
|
||||
propertyValuesContainer.addChild(new Label("besitzt: 500 EUR", new ElementId("label-Text")));
|
||||
propertyValuesContainer.addChild(new Label("Wenn man 3 Tore", new ElementId("label-Text")));
|
||||
propertyValuesContainer.addChild(new Label("besitzt: 1000 EUR", new ElementId("label-Text")));
|
||||
propertyValuesContainer.addChild(new Label("Wenn man 4 Tore", new ElementId("label-Text")));
|
||||
propertyValuesContainer.addChild(new Label("besitzt: 2000 EUR", new ElementId("label-Text")));
|
||||
propertyValuesContainer.addChild(new Label("", new ElementId("label-Text"))); // Empty line
|
||||
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)));
|
||||
|
@@ -138,4 +138,4 @@ public class Gulag extends Dialog implements PopupDialog {
|
||||
public void escape() {
|
||||
close();
|
||||
}
|
||||
}
|
||||
}
|
@@ -96,7 +96,7 @@ public class RejectTrade extends Dialog implements PopupDialog {
|
||||
|
||||
// Rejection message
|
||||
Container textContainer = container.addChild(new Container());
|
||||
textContainer.addChild(new Label("Du hast Spieler " + msg.getTradeHandler().getReceiver().getName()
|
||||
textContainer.addChild(new Label("Du hast " + msg.getTradeHandler().getReceiver().getName()
|
||||
+ " einen Handel vorgeschlagen.", new ElementId("label-Text")));
|
||||
textContainer.addChild(new Label("", new ElementId("label-Text")));
|
||||
textContainer.addChild(new Label("Der Handel wurde abgelehnt.", new ElementId("label-Text")));
|
||||
|
@@ -7,7 +7,6 @@ import com.simsilica.lemur.Button;
|
||||
import com.simsilica.lemur.Container;
|
||||
import com.simsilica.lemur.Label;
|
||||
import com.simsilica.lemur.Selector;
|
||||
import com.simsilica.lemur.TextField;
|
||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
||||
import com.simsilica.lemur.component.SpringGridLayout;
|
||||
import com.simsilica.lemur.core.VersionedList;
|
||||
|
@@ -7,7 +7,6 @@ import com.simsilica.lemur.Button;
|
||||
import com.simsilica.lemur.Container;
|
||||
import com.simsilica.lemur.Label;
|
||||
import com.simsilica.lemur.Selector;
|
||||
import com.simsilica.lemur.TextField;
|
||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
||||
import com.simsilica.lemur.component.SpringGridLayout;
|
||||
import com.simsilica.lemur.core.VersionedList;
|
||||
|
@@ -7,7 +7,6 @@ import com.simsilica.lemur.Button;
|
||||
import com.simsilica.lemur.Container;
|
||||
import com.simsilica.lemur.Label;
|
||||
import com.simsilica.lemur.Selector;
|
||||
import com.simsilica.lemur.TextField;
|
||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
||||
import com.simsilica.lemur.component.SpringGridLayout;
|
||||
import com.simsilica.lemur.core.VersionedList;
|
||||
|
After Width: | Height: | Size: 121 KiB |
After Width: | Height: | Size: 114 KiB |
After Width: | Height: | Size: 304 KiB |
After Width: | Height: | Size: 473 KiB |
After Width: | Height: | Size: 94 KiB |
After Width: | Height: | Size: 136 KiB |
After Width: | Height: | Size: 136 KiB |
BIN
Projekte/monopoly/client/src/main/resources/Textures/Bot.jpg
Normal file
After Width: | Height: | Size: 707 KiB |
Before Width: | Height: | Size: 18 MiB After Width: | Height: | Size: 14 MiB |
After Width: | Height: | Size: 215 KiB |
After Width: | Height: | Size: 60 KiB |
BIN
Projekte/monopoly/client/src/main/resources/Textures/Top.png
Normal file
After Width: | Height: | Size: 478 KiB |
BIN
Projekte/monopoly/client/src/main/resources/Textures/grass.jpg
Normal file
After Width: | Height: | Size: 3.2 MiB |
Before Width: | Height: | Size: 518 KiB |
Before Width: | Height: | Size: 55 KiB |
Before Width: | Height: | Size: 552 KiB |
Before Width: | Height: | Size: 100 KiB |
Before Width: | Height: | Size: 24 MiB |
After Width: | Height: | Size: 215 KiB |
After Width: | Height: | Size: 60 KiB |
Before Width: | Height: | Size: 66 KiB |
Before Width: | Height: | Size: 200 KiB |
Before Width: | Height: | Size: 6.7 MiB |
Before Width: | Height: | Size: 31 MiB |
Before Width: | Height: | Size: 209 KiB |
Before Width: | Height: | Size: 41 KiB |
@@ -327,6 +327,11 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
||||
|
||||
board.add(new Hotel(property.getId()));
|
||||
} else {
|
||||
|
||||
for(int i = 0; i < 4; i++) {
|
||||
board.remove(board.getHouse(msg.getId(), i+1));
|
||||
}
|
||||
|
||||
board.add(new House( property.getHouses(), property.getId()));
|
||||
}
|
||||
} else {
|
||||
|
@@ -492,7 +492,8 @@ public class Player implements FieldVisitor<Void>{
|
||||
}
|
||||
return total;
|
||||
}
|
||||
// private static int c = 0;
|
||||
private static int c = 0;
|
||||
private static int[] rolls = {4,4, 1,2, 2,3};
|
||||
|
||||
/**
|
||||
* Inner class for dice functionality in the game.
|
||||
@@ -507,8 +508,20 @@ public class Player implements FieldVisitor<Void>{
|
||||
* @return the result of a dice roll (1 to 6)
|
||||
*/
|
||||
private static int rollDice() {
|
||||
return random.nextInt(6) + 1;
|
||||
// return random.nextInt(6) + 1;
|
||||
// c++;
|
||||
if(c >= rolls.length) return random.nextInt(6) + 1;
|
||||
System.out.println();
|
||||
System.out.println();
|
||||
System.out.println();
|
||||
System.out.println();
|
||||
System.out.println("DICEEEEEEEEEEEEEEEEEEEEE");
|
||||
System.out.println();
|
||||
System.out.println();
|
||||
System.out.println();
|
||||
System.out.println();
|
||||
System.out.println();
|
||||
return rolls[c++];
|
||||
// return (c%2 == 0)? 3: 2;
|
||||
// if(c < 7) {
|
||||
// return 3;
|
||||
|
@@ -120,7 +120,7 @@ public class PlayerHandler {
|
||||
* @param index the index of the queue
|
||||
* @return the Player at the required index
|
||||
*/
|
||||
Player getPlayerAtIndex(int index) {
|
||||
public Player getPlayerAtIndex(int index) {
|
||||
return players.get(index);
|
||||
}
|
||||
|
||||
@@ -165,10 +165,11 @@ public class PlayerHandler {
|
||||
* Shuffles the players and sets their state to WaitForNextTurn, the first one will be active
|
||||
*/
|
||||
void randomOrder() {
|
||||
Collections.shuffle(players);
|
||||
for (Player player : players) {
|
||||
player.finishTurn();
|
||||
}
|
||||
// Collections.shuffle(players);
|
||||
// for (Player player : players) {
|
||||
// player.finishTurn();
|
||||
// }
|
||||
nextPlayer();
|
||||
players.get(0).setActive();
|
||||
}
|
||||
|
||||
|
@@ -229,6 +229,8 @@ public class ServerGameLogic implements ClientInterpreter {
|
||||
for (Player p : playerHandler.getPlayers()) {
|
||||
send(p, new GameStart(playerHandler));
|
||||
}
|
||||
|
||||
|
||||
playerHandler.randomOrder();
|
||||
send(playerHandler.getPlayerAtIndex(0), new NextPlayerTurn());
|
||||
}
|
||||
@@ -472,7 +474,7 @@ public class ServerGameLogic implements ClientInterpreter {
|
||||
|
||||
// Define properties to assign
|
||||
Set<Integer> p1Properties = Set.of(1, 3, 6, 8); // Gym, Sportplatz, Studium+, PhysikHörsaal
|
||||
Set<Integer> p2Properties = Set.of(21, 23, 24, 9); // Red set + Audimax
|
||||
Set<Integer> p2Properties = Set.of(21, 23, 24, 9, 11); // Red set + Audimax + Spießtor
|
||||
|
||||
// Assign properties via AlterProperty
|
||||
assignProperties(p1, p1Properties);
|
||||
@@ -483,13 +485,15 @@ public class ServerGameLogic implements ClientInterpreter {
|
||||
|
||||
// Player 2 builds houses on the Red set
|
||||
// buildHouses(p2, Set.of(21, 23, 24));
|
||||
// buildHouses(p2, Set.of(23, 24));
|
||||
// // buildHouses(p2, Set.of( 24));
|
||||
|
||||
// Set player balances
|
||||
p1.setAccountBalance(12325);
|
||||
p2.setAccountBalance(26750);
|
||||
|
||||
// Add Get Out of Jail cards
|
||||
p1.addJailCard();
|
||||
p2.addJailCard();
|
||||
|
||||
// Set player positions
|
||||
p1.setPosition(6); // Near Studium+
|
||||
@@ -514,6 +518,8 @@ public class ServerGameLogic implements ClientInterpreter {
|
||||
field.setOwner(player);
|
||||
player.addProperty(propertyId);
|
||||
}
|
||||
|
||||
updateAllPlayers();
|
||||
LOGGER.log(Level.DEBUG, "Properties assigned to player {0}: {1}", player.getName(), properties);
|
||||
}
|
||||
|
||||
@@ -532,6 +538,8 @@ public class ServerGameLogic implements ClientInterpreter {
|
||||
if (boardManager.canBuild(field) && player.getAccountBalance() >= field.getHousePrice()) {
|
||||
field.build();
|
||||
player.pay(field.getHousePrice());
|
||||
updateAllPlayers();
|
||||
sendAll( new BuildInfo(field.getId(), true));
|
||||
LOGGER.log(Level.DEBUG, "House built on property {0} for player {1}.", field.getName(), player.getName());
|
||||
}
|
||||
}
|
||||
|
@@ -147,6 +147,10 @@ public class Board {
|
||||
return getHotels().filter(hotel -> hotel.getFieldID() == fieldId).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
public Figure getFigure(int playerId) {
|
||||
return getFigures().filter(figure -> figure.getId() == playerId).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a stream of all hotels currently on the map.
|
||||
*
|
||||
|
@@ -17,25 +17,26 @@ public class DeckHelper{
|
||||
|
||||
public DeckHelper() {
|
||||
cards = new LinkedList<Card>();
|
||||
cards.add(new Card("Dein Jodel eines Schneepenis mit Unterhodenbeleuchtung geht viral. Ziehe 1000 EUR ein", "jodel-eispenis"));
|
||||
cards.add(new Card("Auf deiner Stube wurde Schimmel gefunden. Gehe ins Gulak. Begib dich direkt dorthin. Gehe nicht über Monatsgehalt. Ziehe nicht 2000 EUR ein.", "schimmel-gulak"));
|
||||
cards.add(new Card("Malkmus läd zum Pubquiz ein. Rücke vor bis zum 20er.", "pubquiz"));
|
||||
cards.add(new Card("Du wurdest mit einem Dienst KFZ geblitzt. Zahle 800 EUR", "dienst-kfz-blitzer"));
|
||||
cards.add(new Card("Die erste Spoparty steht bevor. Ziehe vor zum 23er.", "spoparty"));
|
||||
cards.add(new Card("Deine IGF-Daten sind verschwunden. Statte Padubrin einen Besuch ab und gib ihm einen Jägermeister aus. Zahle 250 EUR", "IGF-Padubrin"));
|
||||
cards.add(new Card("Du kommst aus dem Gulak frei!", "gulak-frei-1"));
|
||||
cards.add(new Card("Du kommst aus dem Gulak frei!", "gulak-frei-2"));
|
||||
cards.add(new Card("Du hast den Dienstführerschein bestanden. Ziehe vor bis Teststrecke.", "dienstfuehrerschein"));
|
||||
cards.add(new Card("Malkmus läd zum Pubquiz ein. Rücke vor bis zum 20er.", "pubquiz"));
|
||||
cards.add(new Card("Deine IGF-Daten sind verschwunden. Statte Padubrin einen Besuch ab und gib ihm einen Jägermeister aus. Zahle 250 EUR", "IGF-Padubrin"));
|
||||
cards.add(new Card("Du hast heute die Spendierhosen an und gibst eine Runde in der Unibar. Zahle jedem Spieler 400 EUR", "spendierhosen-unibar"));
|
||||
cards.add(new Card("Du musstest einen Rückstuferantrag stellen. Setze eine Runde aus.", "rueckstuferantrag"));
|
||||
cards.add(new Card("Du warst in der Prüfungsphase krank. Gehe 3 Felder zurück.", "pruefungsphase-krank"));
|
||||
cards.add(new Card("Ziehe vor bis zum nächsten Monatsgehalt.", "naechstes-monatsgehalt"));
|
||||
cards.add(new Card("Du hast ein Antreten verschlafen. Zahle 500 EUR", "antreten-verschlafen-1"));
|
||||
cards.add(new Card("Du hast den Maibock organisiert. Du erhältst 3000 EUR", "maibock-organisiert"));
|
||||
cards.add(new Card("Der Spieß macht eine unangekündigte Inventur. Zahle für jedes Haus 400 EUR und für jedes Hotel 2800 EUR", "inventur-haeuser-hotels"));
|
||||
cards.add(new Card("Es gab keine Mozzarella-Bällchen mehr für Thoma. Rücke vor bis aufs Gym.", "dienstsport-gym"));
|
||||
cards.add(new Card("Auf deiner Stube wurde Schimmel gefunden. Gehe ins Gulak. Begib dich direkt dorthin. Gehe nicht über Monatsgehalt. Ziehe nicht 2000 EUR ein.", "schimmel-gulak"));
|
||||
cards.add(new Card("Deine Stube ist nach einer Partynacht nicht mehr bewohnbar. Du ziehst ins Gulak. Begib dich direkt dorthin. Gehe nicht über Monatsgehalt. Ziehe nicht 2000 EUR ein.", "partynacht-gulak"));
|
||||
cards.add(new Card("Das Jahresabschlussantreten steht an. Ziehe vor bis Schwimmhalle.", "jahresabschlussantreten"));
|
||||
cards.add(new Card("Du wurdest beim Verkaufen von Versicherungen erwischt. Zahle 4000 EUR", "verkaufen-versicherungen"));
|
||||
cards.add(new Card("Du musstest einen Rückstuferantrag stellen. Setze eine Runde aus.", "rueckstuferantrag"));
|
||||
cards.add(new Card("Auf einer Hausfeier bist du betrunken auf der Treppe gestürzt und dabei auf einen Kameraden gefallen. Zahle 800 EUR und gehe zurück zum SanZ.", "hausfeier-sturz"));
|
||||
cards.add(new Card("Beförderung. Beim nächsten Monatsgehalt ziehst du 3000 EUR ein", "befoerderung"));
|
||||
cards.add(new Card("Du entscheidest dich für eine Dienstreise nach Lourd. Zahle 1000 EUR und setze eine Runde aus.", "dienstreise-lourd"));
|
||||
@@ -48,9 +49,8 @@ public class DeckHelper{
|
||||
cards.add(new Card("Du wurdest zur VP gewählt und schmeißt eine Einstandsparty. Zahle 800 EUR", "vp-einstandsparty"));
|
||||
cards.add(new Card("Du hast eine Party veranstaltet und dick Gewinn gemacht. Ziehe 1500 EUR ein", "party-gewinn"));
|
||||
cards.add(new Card("Zur falschen Zeit am falschen Ort. Du musst einen Bergmarsch planen und setzt eine Runde aus.", "bergmarsch"));
|
||||
cards.add(new Card("Dein Jodel eines Schneepenis mit Unterhodenbeleuchtung geht viral. Ziehe 1000 EUR ein", "jodel-eispenis"));
|
||||
|
||||
shuffle();
|
||||
// shuffle();
|
||||
}
|
||||
|
||||
public void visit(Card card, Player player) {
|
||||
|