mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2025-01-18 20:36:17 +01:00
Figurenbewegung
This commit is contained in:
parent
c4955e0b57
commit
b819e1ca9b
@ -120,7 +120,7 @@ public class BoardAppState extends MonopolyAppState {
|
||||
final float x = mx - cos;
|
||||
final float y = my - sin;
|
||||
final Camera camera = getApp().getCamera();
|
||||
camera.setLocation(new Vector3f(0,40,0));
|
||||
camera.setLocation(new Vector3f(-30,25,-30));
|
||||
camera.lookAt(new Vector3f(0,0, 0),
|
||||
Vector3f.UNIT_Y);
|
||||
camera.update();
|
||||
|
@ -36,14 +36,15 @@ public class BobTheBuilder extends GameBoardSynchronizer {
|
||||
@Override
|
||||
public Spatial visit(Figure figure) {
|
||||
final Node node = new Node(FIGURE);
|
||||
node.attachChild(createFigure(figure));
|
||||
Spatial spatial = createFigure(figure);
|
||||
node.attachChild(spatial);
|
||||
|
||||
// Setze die Position basierend auf der Feld-ID
|
||||
node.setLocalTranslation(figure.getPos());
|
||||
|
||||
// Setze die Rotation basierend auf der Feld-ID
|
||||
node.setLocalRotation(figure.getRot().toQuaternion());
|
||||
node.addControl(new FigureControl(figure));
|
||||
node.addControl(new FigureControl(spatial, figure, app));
|
||||
return node;
|
||||
}
|
||||
|
||||
@ -138,9 +139,4 @@ public class BobTheBuilder extends GameBoardSynchronizer {
|
||||
material.setColor(COLOR, color);
|
||||
return material;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receivedEvent(UpdatePlayerView event) {
|
||||
//TODO player move animation
|
||||
}
|
||||
}
|
||||
|
@ -2,17 +2,26 @@ package pp.monopoly.client.gui;
|
||||
|
||||
import com.jme3.renderer.RenderManager;
|
||||
import com.jme3.renderer.ViewPort;
|
||||
import com.jme3.scene.Spatial;
|
||||
import com.jme3.scene.control.AbstractControl;
|
||||
|
||||
import pp.monopoly.client.MonopolyApp;
|
||||
import pp.monopoly.model.Figure;
|
||||
import pp.monopoly.notification.GameEventListener;
|
||||
import pp.monopoly.notification.UpdatePlayerView;
|
||||
|
||||
public class FigureControl extends AbstractControl {
|
||||
public class FigureControl extends AbstractControl implements GameEventListener{
|
||||
|
||||
private final Figure figure;
|
||||
private final Spatial spatial;
|
||||
private final MonopolyApp app;
|
||||
|
||||
public FigureControl(Figure figure) {
|
||||
public FigureControl(Spatial spatial, Figure figure, MonopolyApp app) {
|
||||
super();
|
||||
this.figure = figure;
|
||||
this.app = app;
|
||||
this.spatial = spatial;
|
||||
app.getGameLogic().addListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -24,5 +33,15 @@ public class FigureControl extends AbstractControl {
|
||||
protected void controlRender(RenderManager rm, ViewPort vp) {
|
||||
// No rendering required
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receivedEvent(UpdatePlayerView event) {
|
||||
int newPos = app.getGameLogic().getPlayerHandler().getPlayerById(figure.getId()).getFieldID();
|
||||
|
||||
figure.moveTo(newPos);
|
||||
|
||||
//TODO hier einzelne Punkte der Animation ablkaufen mit figure.setLocalTransLation und jeweils Rotation anpassen
|
||||
|
||||
spatial.setLocalTranslation(figure.getPos());
|
||||
}
|
||||
}
|
||||
|
@ -236,7 +236,7 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
||||
playerHandler = msg.getPlayerHandler();
|
||||
setState(new WaitForTurnState(this));
|
||||
for (Player player : playerHandler.getPlayers()) {
|
||||
board.add(new Figure(Vector3f.ZERO, Rotation.NORTH, player.getFigure()));
|
||||
board.add(new Figure(Vector3f.ZERO, Rotation.NORTH, player.getFigure(), player.getId()));
|
||||
}
|
||||
notifyListeners(new ButtonStatusEvent(false));
|
||||
notifyListeners(new UpdatePlayerView());
|
||||
|
@ -7,6 +7,8 @@ import com.jme3.network.serializing.Serializable;
|
||||
|
||||
@Serializable
|
||||
public class Figure implements Item{
|
||||
|
||||
private final int id;
|
||||
private final String type;
|
||||
private Vector3f position;
|
||||
private Rotation rot; // The rotation of the Figure
|
||||
@ -16,7 +18,7 @@ public class Figure implements Item{
|
||||
* at position (0, 0), with a default rotation of NORTH.
|
||||
*/
|
||||
private Figure() {
|
||||
this(null, Rotation.NORTH, "");
|
||||
this(null, Rotation.NORTH, "", 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -27,10 +29,19 @@ public class Figure implements Item{
|
||||
* @param z the z-coordinate of the Figure's initial position
|
||||
* @param rot the rotation of the Figure
|
||||
*/
|
||||
public Figure(Vector3f position, Rotation rot, String type) {
|
||||
public Figure(Vector3f position, Rotation rot, String type, int id) {
|
||||
this.position = calculateFieldPosition(0);
|
||||
this.rot = rot;
|
||||
this.type = type;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the id corresponding to the players id
|
||||
* @return the id of the figure
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -92,46 +103,44 @@ public class Figure implements Item{
|
||||
float baseZ = 0.0f;
|
||||
|
||||
switch (fieldID) {
|
||||
case 0: baseX = -9.1f; baseZ = -9.1f; break;
|
||||
case 1: baseX = -6.5f; baseZ = -9.1f; break;
|
||||
case 2: baseX = -4.9f; baseZ = -9.1f; break;
|
||||
case 3: baseX = -3.3f; baseZ = -9.1f; break;
|
||||
case 4: baseX = -1.6f; baseZ = -9.1f; break;
|
||||
case 5: baseX = 0.0f; baseZ = -9.1f; break;
|
||||
case 6: baseX = 1.6f; baseZ = -9.1f; break;
|
||||
case 7: baseX = 3.3f; baseZ = -9.1f; break;
|
||||
case 8: baseX = 4.9f; baseZ = -9.1f; break;
|
||||
case 9: baseX = 6.5f; baseZ = -9.1f; break;
|
||||
case 10: baseX = 9.1f; baseZ = -9.1f; break;
|
||||
case 11: baseX = 9.1f; baseZ = -6.5f; break;
|
||||
case 12: baseX = 9.1f; baseZ = -4.9f; break;
|
||||
case 13: baseX = 9.1f; baseZ = -3.3f; break;
|
||||
case 14: baseX = 9.1f; baseZ = -1.6f; break;
|
||||
case 15: baseX = 9.1f; baseZ = 0.0f; break;
|
||||
case 16: baseX = 9.1f; baseZ = 1.6f; break;
|
||||
case 17: baseX = 9.1f; baseZ = 3.3f; break;
|
||||
case 18: baseX = 9.1f; baseZ = 4.9f; break;
|
||||
case 19: baseX = 9.1f; baseZ = 6.5f; break;
|
||||
case 20: baseX = 9.1f; baseZ = 9.1f; break;
|
||||
case 21: baseX = 6.5f; baseZ = 9.1f; break;
|
||||
case 22: baseX = 4.9f; baseZ = 9.1f; break;
|
||||
case 23: baseX = 3.3f; baseZ = 9.1f; break;
|
||||
case 24: baseX = 1.6f; baseZ = 9.1f; break;
|
||||
case 25: baseX = 0.0f; baseZ = 9.1f; break;
|
||||
case 26: baseX = -1.6f; baseZ = 9.1f; break;
|
||||
case 27: baseX = -3.3f; baseZ = 9.1f; break;
|
||||
case 28: baseX = -4.9f; baseZ = 9.1f; break;
|
||||
case 29: baseX = -6.5f; baseZ = 9.1f; break;
|
||||
case 30: baseX = -9.1f; baseZ = 9.1f; break;
|
||||
case 31: baseX = -9.1f; baseZ = 6.5f; break;
|
||||
case 32: baseX = -9.1f; baseZ = 4.9f; break;
|
||||
case 33: baseX = -9.1f; baseZ = 3.3f; break;
|
||||
case 34: baseX = -9.1f; baseZ = 1.6f; break;
|
||||
case 35: baseX = -9.1f; baseZ = 0.0f; break;
|
||||
case 36: baseX = -9.1f; baseZ = -1.6f; break;
|
||||
case 37: baseX = -9.1f; baseZ = -3.3f; break;
|
||||
case 38: baseX = -9.1f; baseZ = -4.9f; break;
|
||||
case 39: baseX = -9.1f; baseZ = -6.5f; break;
|
||||
case 0: baseX = -5.0f; baseZ = -5.0f; break;
|
||||
case 1: baseX = -3.5f; baseZ = -5.0f; break;
|
||||
case 2: baseX = -2.5f; baseZ = -5.0f; break;
|
||||
case 3: baseX = -1.5f; baseZ = -5.0f; break;
|
||||
case 4: baseX = -0.5f; baseZ = -5.0f; break;
|
||||
case 5: baseX = 0.5f; baseZ = -5.0f; break;
|
||||
case 6: baseX = 1.5f; baseZ = -5.0f; break;
|
||||
case 7: baseX = 2.5f; baseZ = -5.0f; break;
|
||||
case 8: baseX = 3.5f; baseZ = -5.0f; break;
|
||||
case 9: baseX = 5.0f; baseZ = -5.0f; break;
|
||||
case 10: baseX = 5.0f; baseZ = -3.5f; break;
|
||||
case 11: baseX = 5.0f; baseZ = -2.5f; break;
|
||||
case 12: baseX = 5.0f; baseZ = -1.5f; break;
|
||||
case 13: baseX = 5.0f; baseZ = -0.5f; break;
|
||||
case 14: baseX = 5.0f; baseZ = 0.5f; break;
|
||||
case 15: baseX = 5.0f; baseZ = 1.5f; break;
|
||||
case 16: baseX = 5.0f; baseZ = 2.5f; break;
|
||||
case 17: baseX = 5.0f; baseZ = 3.5f; break;
|
||||
case 18: baseX = 5.0f; baseZ = 5.0f; break;
|
||||
case 19: baseX = 3.5f; baseZ = 5.0f; break;
|
||||
case 20: baseX = 2.5f; baseZ = 5.0f; break;
|
||||
case 21: baseX = 1.5f; baseZ = 5.0f; break;
|
||||
case 22: baseX = 0.5f; baseZ = 5.0f; break;
|
||||
case 23: baseX = -0.5f; baseZ = 5.0f; break;
|
||||
case 24: baseX = -1.5f; baseZ = 5.0f; break;
|
||||
case 25: baseX = -2.5f; baseZ = 5.0f; break;
|
||||
case 26: baseX = -3.5f; baseZ = 5.0f; break;
|
||||
case 27: baseX = -5.0f; baseZ = 5.0f; break;
|
||||
case 28: baseX = -5.0f; baseZ = 3.5f; break;
|
||||
case 29: baseX = -5.0f; baseZ = 2.5f; break;
|
||||
case 30: baseX = -5.0f; baseZ = 1.5f; break;
|
||||
case 31: baseX = -5.0f; baseZ = 0.5f; break;
|
||||
case 32: baseX = -5.0f; baseZ = -0.5f; break;
|
||||
case 33: baseX = -5.0f; baseZ = -1.5f; break;
|
||||
case 34: baseX = -5.0f; baseZ = -2.5f; break;
|
||||
case 35: baseX = -5.0f; baseZ = -3.5f; break;
|
||||
case 36: baseX = -5.0f; baseZ = -4.5f; break;
|
||||
case 37: baseX = -5.0f; baseZ = -5.0f; break;
|
||||
default: throw new IllegalArgumentException("Ungültige Feld-ID: " + fieldID);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user