Merge dev/client_beck

This commit is contained in:
Felix Koppe
2024-12-01 21:51:01 +01:00
18 changed files with 160 additions and 79 deletions

View File

@@ -18,8 +18,12 @@
import pp.mdga.client.board.PieceControl;
import pp.mdga.client.gui.CardControl;
import pp.mdga.client.view.GameView;
import pp.mdga.game.BonusCard;
import pp.mdga.game.Color;
import pp.mdga.game.Piece;
import pp.mdga.notification.SelectableCardsNotification;
import java.util.List;
public class InputSynchronizer {
@@ -112,6 +116,7 @@ else if(boardSelect != null) {
}
if(name.equals("Test") &&isPressed){
if(app.getView() instanceof GameView gameView){
app.getNotificationSynchronizer().addTestNotification(new SelectableCardsNotification(List.of(BonusCard.SHIELD)));
}
}
}

View File

@@ -66,7 +66,6 @@ private void handleLobby(Notification notification) {
//lobbyView.setReady(lobbyReadyNotification.getColor(), lobbyReadyNotification.isReady()):
} else if (notification instanceof GameNotification n) {
app.enter(MdgaState.GAME);
((GameView) app.getView()).setOwnColor(n.getOwnColor());
} else {
throw new RuntimeException("notification not expected: " + notification.toString());
}
@@ -77,8 +76,8 @@ private void handleGame(Notification notification) {
GuiHandler guiHandler = gameView.getGuiHandler();
BoardHandler boardHandler = gameView.getBoardHandler();
if (notification instanceof AcquireCardNotification) {
// Handle AcquireCardNotification
if (notification instanceof AcquireCardNotification n) {
guiHandler.addCard(n.getBonusCard());
} else if (notification instanceof ActivePlayerNotification n) {
gameView.getGuiHandler().setActivePlayer(n.getColor());
} else if (notification instanceof CeremonyNotification ceremonyNotification) {
@@ -146,11 +145,11 @@ private void handleGame(Notification notification) {
//TODO
} else if (notification instanceof RollDiceNotification n) {
if(n.getColor() == gameView.getOwnColor()){
//guiHandler.rollDice(n.getEyes(), n.isTurbo() ? n.getMultiplier() : -1);
guiHandler.rollDice(n.getEyes(), n.isTurbo() ? n.getMultiplier() : -1);
}
else {
//if (n.isTurbo()) guiHandler.showRolledDiceMult(n.getEyes(), n.getMultiplier(), n.getColor());
//else guiHandler.showRolledDice(n.getEyes(), n.getColor());
if (n.isTurbo()) guiHandler.showRolledDiceMult(n.getEyes(), n.getMultiplier(), n.getColor());
else guiHandler.showRolledDice(n.getEyes(), n.getColor());
}
} else if (notification instanceof SelectableCardsNotification n) {
guiHandler.setSelectableCards(n.getCards());
@@ -169,10 +168,10 @@ private void handleGame(Notification notification) {
boardHandler.outlineMove(n.getPieces(), n.getMoveIndexe(), n.getHomeMoves());
} else if (notification instanceof SelectableSwapNotification n) {
boardHandler.outlineSwap(n.getOwnPieces(), n.getEnemyPieces());
// } //else if (notification instanceof SelectableShieldNotification n) {
// boardHandler.outlineShield(n.getOwnPieces());
//} else if (notification instanceof TurboActiveNotification){
// guiHandler.turbo();
} else if (notification instanceof SelectableShieldNotification n) {
boardHandler.outlineShield(n.getPieces());
} else if (notification instanceof TurboActiveNotification){
guiHandler.turbo();
} else {
throw new RuntimeException("notification not expected: " + notification.toString());
}

View File

@@ -68,7 +68,6 @@ public void init() {
public void shutdown(){
clearSelectable();
isInitialised = false;
initMap();
rootNode.detachChild(rootNodeBoard);
}

View File

@@ -7,6 +7,7 @@
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.scene.Spatial;
import pp.mdga.client.MdgaApp;
public class SelectObjectOutliner {
@@ -19,14 +20,16 @@ public class SelectObjectOutliner {
private ViewPort outlineViewport = null;
// private OutlineFilter outlineFilter = null;
private OutlineProFilter outlineFilter = null;
private final MdgaApp app;
public SelectObjectOutliner(int width, FilterPostProcessor fpp, RenderManager renderManager, AssetManager assetManager, Camera cam) {
public SelectObjectOutliner(int width, FilterPostProcessor fpp, RenderManager renderManager, AssetManager assetManager, Camera cam, MdgaApp app) {
this.selected = false;
this.fpp = fpp;
this.renderManager = renderManager;
this.assetManager = assetManager;
this.cam = cam;
this.width = width;
this.app = app;
}
public void deselect(Spatial model) {
@@ -51,6 +54,7 @@ public void select(Spatial model, ColorRGBA color, int width) {
}
private void hideOutlineFilterEffect(Spatial model) {
// app.enqueue(() -> {
outlineFilter.setEnabled(false);
outlineFilter.getOutlinePreFilter().setEnabled(false);
fpp.removeFilter(outlineFilter);
@@ -58,9 +62,12 @@ private void hideOutlineFilterEffect(Spatial model) {
outlineViewport.clearProcessors();
renderManager.removePreView(outlineViewport);
outlineViewport = null;
// return null;
// });
}
private void showOutlineFilterEffect(Spatial model, int width, ColorRGBA color) {
// app.enqueue(() -> {
outlineViewport = renderManager.createPreView("outlineViewport", cam);
FilterPostProcessor outlineFpp = new FilterPostProcessor(assetManager);
@@ -70,11 +77,12 @@ private void showOutlineFilterEffect(Spatial model, int width, ColorRGBA color)
outlineViewport.attachScene(model);
outlineViewport.addProcessor(outlineFpp);
// outlineFilter = new OutlineFilter(outlinePreFilter);
outlineFilter = new OutlineProFilter(outlinePreFilter);
outlineFilter.setOutlineColor(color);
outlineFilter.setOutlineWidth(width);
fpp.addFilter(outlineFilter);
// return null;
// });
}
}

View File

@@ -18,17 +18,17 @@ public class OutlineControl extends AbstractControl {
public OutlineControl(MdgaApp app, FilterPostProcessor fpp){
this.app = app;
outlineOwn = new SelectObjectOutliner(THICKNESS_DEFAULT, fpp, app.getRenderManager(), app.getAssetManager(), app.getCamera());
outlineOwn = new SelectObjectOutliner(THICKNESS_DEFAULT, fpp, app.getRenderManager(), app.getAssetManager(), app.getCamera(), app);
}
public OutlineControl(MdgaApp app, FilterPostProcessor fpp, Camera cam){
this.app = app;
outlineOwn = new SelectObjectOutliner(THICKNESS_DEFAULT, fpp, app.getRenderManager(), app.getAssetManager(), cam);
outlineOwn = new SelectObjectOutliner(THICKNESS_DEFAULT, fpp, app.getRenderManager(), app.getAssetManager(), cam, app);
}
public OutlineControl(MdgaApp app, FilterPostProcessor fpp, Camera cam, int thickness){
this.app = app;
outlineOwn = new SelectObjectOutliner(thickness, fpp, app.getRenderManager(), app.getAssetManager(), cam);
outlineOwn = new SelectObjectOutliner(thickness, fpp, app.getRenderManager(), app.getAssetManager(), cam, app);
}
public void outline(ColorRGBA color){

View File

@@ -84,9 +84,6 @@ public Node getRoot() {
public void initSpatial(){
}
public void outline(){
super.outline(OUTLINE_COLOR);
}

View File

@@ -88,8 +88,6 @@ public void render(RenderManager rm) {
@Override
public void update( float tpf ) {
if (init && !cardBuffer.isEmpty()) {
for(Spatial spatial : cardBuffer){
root.attachChild(spatial);

View File

@@ -43,6 +43,7 @@ public void init() {
cardLayerCamera = createOverlayCam();
cardLayer = new CardLayer(fpp, cardLayerCamera, backTexture);
app.getStateManager().attach(cardLayer);
diceControl = new DiceControl(app.getAssetManager());
diceControl.create(new Vector3f(0, 0, 0), 1f, false);
}
@@ -50,6 +51,7 @@ public void init() {
public void shutdown() {
if (cardLayer != null) {
cardLayer.shutdown();
clearSelectableCards();
}
cardLayer = null;
}

View File

@@ -15,11 +15,11 @@ public class GuiHandler {
private final CardLayerHandler cardLayerHandler;
private final PlayerNameHandler playerNameHandler;
private final ActionTextHandler actionTextHandler;
private final Color ownColor;
private Color ownColor;
private FrameBuffer backFrameBuffer;
public GuiHandler(MdgaApp app, Node guiNode, Color ownColor) {
public GuiHandler(MdgaApp app, Node guiNode) {
this.app = app;
this.ownColor = ownColor;
@@ -33,8 +33,10 @@ public GuiHandler(MdgaApp app, Node guiNode, Color ownColor) {
actionTextHandler = new ActionTextHandler(guiNode, app.getAssetManager(), app.getContext().getSettings());
}
public void init() {
public void init(Color ownColor) {
cardLayerHandler.init();
playerNameHandler.show();
this.ownColor = ownColor;
app.getViewPort().setOutputFrameBuffer(backFrameBuffer);
}

View File

@@ -9,9 +9,18 @@
import pp.mdga.client.button.ButtonLeft;
import pp.mdga.client.button.ButtonRight;
import pp.mdga.client.gui.GuiHandler;
import pp.mdga.game.BonusCard;
import pp.mdga.game.Color;
import pp.mdga.notification.AcquireCardNotification;
import pp.mdga.notification.ActivePlayerNotification;
import pp.mdga.notification.DiceNowNotification;
import pp.mdga.notification.GameNotification;
import pp.mdga.notification.MovePieceNotification;
import pp.mdga.notification.PlayerInGameNotification;
import pp.mdga.notification.RollDiceNotification;
import pp.mdga.notification.SelectableCardsNotification;
import pp.mdga.notification.SelectableMoveNotification;
import pp.mdga.notification.ShieldActiveNotification;
import java.util.ArrayList;
import java.util.List;
@@ -43,26 +52,66 @@ public GameView(MdgaApp app) {
this.camera = new CameraHandler(app, fpp);
this.boardHandler = new BoardHandler(app, rootNode, fpp);
guiHandler = new GuiHandler(app, guiNode, ownColor);
guiHandler = new GuiHandler(app, guiNode);
}
@Override
public void onEnter() {
camera.init();
boardHandler.init();
guiHandler.init();
setOwnColor(Color.AIRFORCE);
guiHandler.init(ownColor);
app.getViewPort().addProcessor(fpp);
app.getAcousticHandler().playSound(MdgaSound.START);
//Test
List<UUID> uuid1 = new ArrayList<>();
UUID p1 = UUID.randomUUID();
UUID p2 = UUID.randomUUID();
uuid1.add(p1);
uuid1.add(p2);
uuid1.add(UUID.randomUUID());
uuid1.add(UUID.randomUUID());
List<UUID> uuid2 = new ArrayList<>();
UUID p1_2 = UUID.randomUUID();
UUID p2_2 = UUID.randomUUID();
uuid2.add(p1_2);
uuid2.add(p2_2);
uuid2.add(UUID.randomUUID());
uuid2.add(UUID.randomUUID());
app.getNotificationSynchronizer().addTestNotification(new PlayerInGameNotification(Color.AIRFORCE, uuid1, "Cedric"));
app.getNotificationSynchronizer().addTestNotification(new PlayerInGameNotification(Color.NAVY, uuid2, "Test"));
app.getNotificationSynchronizer().addTestNotification(new MovePieceNotification(p1, 0, true));
app.getNotificationSynchronizer().addTestNotification(new MovePieceNotification(p1_2, 30, true));
// app.getNotificationSynchronizer().addTestNotification(new SelectableMoveNotification(List.of(p1), List.of(4), List.of(false)));
app.getNotificationSynchronizer().addTestNotification(new AcquireCardNotification(BonusCard.SHIELD));
// app.getNotificationSynchronizer().addTestNotification(new SelectableCardsNotification(List.of(BonusCard.SHIELD)));
// app.getNotificationSynchronizer().addTestNotification(new ShieldActiveNotification(p1));
// app.getNotificationSynchronizer().addTestNotification(new ActivePlayerNotification(Color.NAVY));
// app.getNotificationSynchronizer().addTestNotification(new DiceNowNotification());
// app.getNotificationSynchronizer().addTestNotification(new RollDiceNotification(Color.AIRFORCE, 5, true, 2));
p1 = p1;
}
@Override
public void onLeave() {
camera.shutdown();
boardHandler.shutdown();
guiHandler.shutdown();
camera.shutdown();
confirmButton.hide();

View File

@@ -51,8 +51,8 @@ public void enter() {
}
public void leave() {
app.getRootNode().detachChild(rootNode);
app.getGuiNode().detachChild(guiNode);
onLeave();
settingsButton.hide();
@@ -60,7 +60,8 @@ public void leave() {
pressEscape();
}
onLeave();
app.getRootNode().detachChild(rootNode);
app.getGuiNode().detachChild(guiNode);
}
public void enterOverlay(Overlay overlay) {

View File

@@ -46,17 +46,21 @@ cir 5,4 0
cir 5,5 0
#Assets
jet -10,-1 45
ship 11,0 169
big_tent -9,-7 130
big_tent 7,-10 225
jet -12,0 45
jet -17,-2 55
small_tent -9,7 45
small_tent -10,5 60
small_tent -7,8 30
ship 11,0 169
small_tent 6,8 340
small_tent 8,7 320
big_tent -10,-9 130
big_tent 9,-10 225
radar 0,10 -20
small_tent 6,8 190
small_tent 8,7 160
tank -1,-10 135
tank 0,-18 180
tank 3,-18 180
tank -3,-18 180
#Yellow (CIR) wait Node
node_wait_yellow 4,5 0

View File

@@ -34,7 +34,7 @@ public void received(CeremonyMessage msg){
@Override
public void received(DieMessage msg){
logic.getGame().setDiceEyes(msg.getDiceEye());
logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes(), logic.getGame().getDiceEyes() * logic.getGame().getDiceModifier()));
// logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes(), logic.getGame().getDiceEyes() * logic.getGame().getDiceModifier()));
if(msg.getDiceEye() == 6){
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseDiced6();
logic.getGame().getGameStatistics().increaseDiced6();

View File

@@ -40,7 +40,7 @@ public void received(DiceNowMessage msg){
@Override
public void received(DieMessage msg){
logic.getGame().setDiceEyes(msg.getDiceEye());
logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes(), logic.getGame().getDiceEyes() * logic.getGame().getDiceModifier()));
// logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes(), logic.getGame().getDiceEyes() * logic.getGame().getDiceModifier()));
if(msg.getDiceEye() == 6){
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseDiced6();
logic.getGame().getGameStatistics().increaseDiced6();

View File

@@ -9,24 +9,13 @@
*/
public class AcquireCardNotification extends Notification{
private UUID cardId;
private BonusCard bonusCard;
/**
* Constructor.
* @param cardId The id of the card that was acquired.
*/
public AcquireCardNotification(BonusCard bonusCard, UUID cardId) {
public AcquireCardNotification(BonusCard bonusCard) {
this.bonusCard = bonusCard;
this.cardId = cardId;
}
/**
* Get the id of the card that was acquired.
* @return The id of the card that was acquired.
*/
public UUID getCardId() {
return cardId;
}
public BonusCard getBonusCard() {

View File

@@ -9,18 +9,26 @@ public class RollDiceNotification extends Notification{
private Color color;
private int eyes;
private int moveNumber;
private boolean turbo;
private int multiplier;
/**
* Constructor.
* @param color the color of the player that rolled the die.
* @param eyes the number of eyes that were rolled.
* @param moveNumber the number of the move that was made.
*/
public RollDiceNotification(Color color, int eyes, int moveNumber) {
public RollDiceNotification(Color color, int eyes) {
this.color = color;
this.eyes = eyes;
this.moveNumber = moveNumber;
this.turbo = false;
this.multiplier = -1;
}
public RollDiceNotification(Color color, int eyes, boolean turbo, int multiplier) {
this.color = color;
this.eyes = eyes;
this.turbo = turbo;
this.multiplier = multiplier;
}
/**
@@ -39,11 +47,11 @@ public int getEyes() {
return eyes;
}
/**
* Get the number of the move that was made.
* @return the number of the move that was made.
*/
public int getMoveNumber() {
return moveNumber;
public int getMultiplier() {
return multiplier;
}
public boolean isTurbo() {
return turbo;
}
}

View File

@@ -0,0 +1,16 @@
package pp.mdga.notification;
import java.util.List;
import java.util.UUID;
public class SelectableShieldNotification extends Notification{
private List<UUID> pieces;
public SelectableShieldNotification(List<UUID> pieces){
this.pieces = pieces;
}
public List<UUID> getPieces() {
return pieces;
}
}

View File

@@ -0,0 +1,4 @@
package pp.mdga.notification;
public class TurboActiveNotification extends Notification{
}