mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2025-01-18 22:56:15 +01:00
update view
This commit is contained in:
parent
44d64c4e0f
commit
f0eeff3493
@ -71,11 +71,9 @@ public class GameAppState extends MonopolyAppState {
|
||||
* Creates the opponent's map view and adds a grid overlay to it.
|
||||
*/
|
||||
private void initializeGuiComponents() {
|
||||
// Abrufen der Spielerliste aus der ClientGameLogic
|
||||
List<Player> players = getApp().getGameLogic().getPlayerHandler().getPlayers();
|
||||
|
||||
// Initialisiere TestWorld mit Spielern
|
||||
testWorld = new TestWorld(getApp(), players);
|
||||
testWorld = new TestWorld(getApp());
|
||||
testWorld.initializeScene();
|
||||
}
|
||||
|
||||
@ -109,7 +107,7 @@ public class GameAppState extends MonopolyAppState {
|
||||
|
||||
@Override
|
||||
public void update(float tpf) {
|
||||
testWorld.update(tpf);
|
||||
// testWorld.update(tpf);
|
||||
super.update(tpf);
|
||||
}
|
||||
}
|
||||
|
@ -337,6 +337,7 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
|
||||
super.simpleUpdate(tpf);
|
||||
dialogManager.update(tpf);
|
||||
logic.update(tpf);
|
||||
stateManager.update(tpf);
|
||||
|
||||
//TODO testing replace later
|
||||
if (testWorld != null) {
|
||||
|
@ -1,6 +1,5 @@
|
||||
package pp.monopoly.client.gui;
|
||||
|
||||
import com.jme3.math.FastMath;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.renderer.Camera;
|
||||
|
||||
@ -9,11 +8,7 @@ import com.jme3.renderer.Camera;
|
||||
*/
|
||||
public class CameraController {
|
||||
private final Camera camera;
|
||||
private final Vector3f center; // Fokuspunkt der Kamera
|
||||
private final float radius; // Radius der Kreisbewegung
|
||||
private final float height; // Höhe der Kamera über dem Spielfeld
|
||||
private final float speed; // Geschwindigkeit der Kamerabewegung
|
||||
private float angle; // Aktueller Winkel in der Kreisbewegung
|
||||
private final float height = 25; // Höhe der Kamera über dem Spielfeld // Aktueller Winkel in der Kreisbewegung
|
||||
|
||||
/**
|
||||
* Konstruktor für den CameraController.
|
||||
@ -24,13 +19,10 @@ public class CameraController {
|
||||
* @param height Die Höhe der Kamera über dem Fokuspunkt
|
||||
* @param speed Die Geschwindigkeit der Kamerabewegung
|
||||
*/
|
||||
public CameraController(Camera camera, Vector3f center, float radius, float height, float speed) {
|
||||
public CameraController(Camera camera) {
|
||||
this.camera = camera;
|
||||
this.center = center;
|
||||
this.radius = radius;
|
||||
this.height = height;
|
||||
this.speed = speed;
|
||||
this.angle = 0; // Starte bei Winkel 0
|
||||
setPosition(0);
|
||||
camera.lookAt(Vector3f.ZERO, Vector3f.UNIT_Y);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -39,7 +31,7 @@ public class CameraController {
|
||||
* @param tpf Zeit pro Frame
|
||||
*/
|
||||
public void update(float tpf) {
|
||||
camera.lookAt(center, Vector3f.UNIT_Y);
|
||||
camera.lookAt(Vector3f.ZERO, Vector3f.UNIT_Y);
|
||||
}
|
||||
|
||||
public void setPosition(int fieldID) {
|
||||
|
@ -2,6 +2,8 @@ package pp.monopoly.client.gui;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.jme3.math.Vector3f;
|
||||
|
||||
import pp.monopoly.client.MonopolyApp;
|
||||
import pp.monopoly.client.gui.popups.BuyCard;
|
||||
import pp.monopoly.client.gui.popups.EventCardPopup;
|
||||
@ -11,12 +13,14 @@ import pp.monopoly.client.gui.popups.LooserPopUp;
|
||||
import pp.monopoly.client.gui.popups.TimeOut;
|
||||
import pp.monopoly.client.gui.popups.WinnerPopUp;
|
||||
import pp.monopoly.game.server.Player;
|
||||
import pp.monopoly.game.server.PlayerHandler;
|
||||
import pp.monopoly.model.fields.BuildingProperty;
|
||||
import pp.monopoly.model.fields.FoodField;
|
||||
import pp.monopoly.model.fields.GateField;
|
||||
import pp.monopoly.notification.EventCardEvent;
|
||||
import pp.monopoly.notification.GameEventListener;
|
||||
import pp.monopoly.notification.PopUpEvent;
|
||||
import pp.monopoly.notification.UpdatePlayerView;
|
||||
|
||||
/**
|
||||
* TestWorld zeigt eine einfache Szene mit Spielfeld und Spielfiguren.
|
||||
@ -24,7 +28,7 @@ import pp.monopoly.notification.PopUpEvent;
|
||||
public class TestWorld implements GameEventListener{
|
||||
|
||||
private final MonopolyApp app;
|
||||
private final List<Player> players; // Liste der Spieler, bereits aus GameStart geladen
|
||||
private PlayerHandler playerHandler; // Liste der Spieler, bereits aus GameStart geladen
|
||||
private CameraController cameraController;
|
||||
private Toolbar toolbar;
|
||||
|
||||
@ -34,10 +38,11 @@ public class TestWorld implements GameEventListener{
|
||||
* @param app Die Hauptanwendung
|
||||
* @param players Die Liste der Spieler mit ihren Figuren
|
||||
*/
|
||||
public TestWorld(MonopolyApp app, List<Player> players) {
|
||||
public TestWorld(MonopolyApp app) {
|
||||
this.app = app;
|
||||
this.players = players;
|
||||
this.playerHandler = app.getGameLogic().getPlayerHandler();
|
||||
app.getGameLogic().addListener(this);
|
||||
cameraController = new CameraController(app.getCamera());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -54,7 +59,6 @@ public class TestWorld implements GameEventListener{
|
||||
setSkyColor();
|
||||
createBoard();
|
||||
createPlayerFigures(); // Lädt Figuren aus der bereits vorhandenen Liste
|
||||
setupCamera();
|
||||
toolbar = new Toolbar(app);
|
||||
toolbar.open();
|
||||
}
|
||||
@ -95,8 +99,8 @@ public class TestWorld implements GameEventListener{
|
||||
* Erstellt die Spielfiguren basierend auf der bereits bekannten Spielerliste.
|
||||
*/
|
||||
private void createPlayerFigures() {
|
||||
for (int i = 0; i < players.size(); i++) {
|
||||
Player player = players.get(i);
|
||||
for (int i = 0; i < playerHandler.getPlayers().size(); i++) {
|
||||
Player player = playerHandler.getPlayers().get(i);
|
||||
try {
|
||||
// Lade das 3D-Modell der Spielfigur
|
||||
com.jme3.scene.Spatial model = app.getAssetManager().loadModel("Models/" + player.getFigure().getType() + "/" + player.getFigure().getType() + ".j3o");
|
||||
@ -116,15 +120,6 @@ public class TestWorld implements GameEventListener{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Richtet die Kamera auf das Spielfeld aus.
|
||||
*/
|
||||
private void setupCamera() {
|
||||
app.getCamera().setLocation(new com.jme3.math.Vector3f(0, 20, 20)); // Über dem Spielfeld
|
||||
app.getCamera().lookAt(new com.jme3.math.Vector3f(0, 0, 0), com.jme3.math.Vector3f.UNIT_Y); // Fokus auf Spielfeldmitte
|
||||
System.out.println("Kamera eingerichtet.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Wird bei jedem Frame aufgerufen, um die Szene zu aktualisieren.
|
||||
*
|
||||
@ -162,4 +157,11 @@ public class TestWorld implements GameEventListener{
|
||||
public void receivedEvent(EventCardEvent event) {
|
||||
new EventCardPopup(app, event.description()).open();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receivedEvent(UpdatePlayerView event) {
|
||||
this.playerHandler = app.getGameLogic().getPlayerHandler();
|
||||
cameraController.setPosition(playerHandler.getPlayerById(app.getId()).getFieldID());
|
||||
cameraController.update(0);
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ public class Toolbar extends Dialog implements GameEventListener {
|
||||
|
||||
// Spielerfarbe abrufen
|
||||
Player currentPlayer = playerHandler.getPlayerById(app.getId());
|
||||
ColorRGBA playerColor = convertPlayerColor(currentPlayer.getColor());
|
||||
ColorRGBA playerColor = currentPlayer.getColor().getColor();
|
||||
|
||||
// Füge einen farbigen Balken hinzu
|
||||
Container playerColorBar = new Container();
|
||||
@ -87,18 +87,6 @@ public class Toolbar extends Dialog implements GameEventListener {
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
private ColorRGBA convertPlayerColor(PlayerColor color) {
|
||||
switch (color) {
|
||||
case CYAN: return new ColorRGBA(0f, 1f, 1f, 1f); // Cyan
|
||||
case YELLOW: return ColorRGBA.Yellow;
|
||||
case RED: return ColorRGBA.Red;
|
||||
case PINK: return new ColorRGBA(1f, 0.75f, 0.8f, 1f); // Pink
|
||||
case GREEN: return ColorRGBA.Green;
|
||||
case PURPLE: return new ColorRGBA(0.5f, 0f, 0.5f, 1f); // Purple
|
||||
default: return ColorRGBA.Gray; // Fallback
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Container createDiceSection() {
|
||||
@ -249,7 +237,7 @@ public class Toolbar extends Dialog implements GameEventListener {
|
||||
|
||||
@Override
|
||||
public void receivedEvent(UpdatePlayerView event) {
|
||||
|
||||
playerHandler = app.getGameLogic().getPlayerHandler();
|
||||
System.out.println("Update Player View");
|
||||
accountContainer.clearChildren();
|
||||
overviewContainer.clearChildren();
|
||||
@ -270,7 +258,7 @@ public class Toolbar extends Dialog implements GameEventListener {
|
||||
for (Player player : playerHandler.getPlayers()) {
|
||||
if (player.getId() != app.getId()) {
|
||||
// Spielerfarbe abrufen
|
||||
ColorRGBA playerColor = convertPlayerColor(player.getColor());
|
||||
ColorRGBA playerColor = (player.getColor().getColor());
|
||||
|
||||
// Label für den Spieler erstellen
|
||||
Label playerLabel = new Label(
|
||||
|
Loading…
Reference in New Issue
Block a user