added improved pieces model; added functionality to notifications + todos

This commit is contained in:
Cedric Beck
2024-11-28 02:08:51 +01:00
parent 304acf17a3
commit 7da388af37
15 changed files with 27012 additions and 158 deletions

View File

@@ -3,11 +3,11 @@
public enum Asset {
bigTent,
cardStack,
cir,
heer,
cir("Models/lcir/cir_newOrigin.obj"),
heer("Models/heer/heer_newOrigin.obj"),
jet,
lw,
marine,
lw("Models/lw/lw_newOrigin.obj"),
marine("Models/marine/marine_newOrigin.obj"),
node_home_blue("Models/node_home/node_home.j3o", "Models/node_home/node_home_blue_diff.png"),
node_wait_blue("Models/node_home/node_home.j3o", "Models/node_home/node_home_blue_diff.png"),
node_home_black("Models/node_home/node_home.j3o", "Models/node_home/node_home_black_diff.png"),
@@ -54,6 +54,13 @@ public enum Asset {
this.size = 1f;
}
Asset(String modelPath) {
String folderFileName = "./" + root + name() + "/" + name();
this.modelPath = modelPath;
this.diffPath = folderFileName + "_diff.png";;
this.size = 1f;
}
Asset(float size) {
String folderFileName = "./" + root + name() + "/" + name();
this.modelPath = folderFileName + ".j3o";

View File

@@ -95,7 +95,9 @@ else if(boardSelect != null) {
}
if(name.equals("Test") &&isPressed){
if(app.getView() instanceof GameView gameView){
gameView.getGuiHandler().swap();
gameView.getGuiHandler().showDice();
gameView.getGuiHandler().hideDice();
gameView.getGuiHandler().showDice();
}
}
}

View File

@@ -1,9 +1,5 @@
package pp.mdga.client;
import pp.mdga.notification.Notification;
import pp.mdga.notification.PieceInGameNotification;
import pp.mdga.notification.PlayerInGameNotification;
public enum MdgaState {
NONE,
MAIN,

View File

@@ -1,5 +1,7 @@
package pp.mdga.client;
import pp.mdga.client.board.BoardHandler;
import pp.mdga.client.gui.GuiHandler;
import pp.mdga.client.view.GameView;
import pp.mdga.client.view.LobbyView;
import pp.mdga.notification.*;
@@ -68,68 +70,68 @@ private void handleLobby(Notification notification) {
private void handleGame(Notification notification) {
GameView gameView = (GameView) app.getView();
GuiHandler guiHandler = gameView.getGuiHandler();
BoardHandler boardHandler = gameView.getBoardHandler();
if (notification instanceof AcquireCardNotification) {
// Handle AcquireCardNotification
if (notification instanceof AcquireCardNotification n) {
guiHandler.addCard(n.getBonusCard(), n.getCardId());
} else if (notification instanceof ActivePlayerNotification n) {
gameView.getGuiHandler().setActivePlayer(n.getColor());
guiHandler.setActivePlayer(n.getColor());
} else if (notification instanceof CeremonyNotification) {
app.enter(MdgaState.CEREMONY);
} else if (notification instanceof DiceNowNotification) {
// Handle DiceNowNotification
} else if (notification instanceof DicingNotification) {
// Handle DicingNotification
} else if (notification instanceof DrawCardNotification) {
// Handle DrawCardNotification
guiHandler.showDice();
} else if (notification instanceof DicingNotification n) {
//TODO
} else if (notification instanceof DrawCardNotification n) {
//TODO ???
} else if (notification instanceof HomeMoveNotification home) {
gameView.getBoardHandler().moveHomePiece(home.getPieceId(), home.getHomeIndex());
boardHandler.moveHomePiece(home.getPieceId(), home.getHomeIndex());
} else if (notification instanceof InterruptNotification) {
// Handle InterruptNotification
//TODO
} else if (notification instanceof MovePieceNotification n) {
if(n.isMoveStart()) {
//StartMove
gameView.getBoardHandler().movePieceStart(n.getPiece(), n.getMoveIndex());
boardHandler.movePieceStart(n.getPiece(), n.getMoveIndex());
}
else {
//InfieldMove
gameView.getBoardHandler().movePiece(n.getPiece(), n.getStartIndex(), n.getMoveIndex());
boardHandler.movePiece(n.getPiece(), n.getStartIndex(), n.getMoveIndex());
}
} else if (notification instanceof ThrowPieceNotification n) {
boardHandler.throwPiece(n.getPieceId());
} else if (notification instanceof NoShieldNotification n) {
boardHandler.unshieldPiece(n.getPieceId());
} else if (notification instanceof PlayCardNotification n) {
switch(n.getCard()){
case SWAP -> guiHandler.swap();
case TURBO -> guiHandler.turbo();
case SHIELD -> guiHandler.shield();
default -> throw new RuntimeException("invalid card");
}
} else if (notification instanceof MoveThrowPieceNotification) {
MoveThrowPieceNotification n = (MoveThrowPieceNotification)notification;
//gameView.getBoardHandler().throwPiece(n.); //TODO
} else if (notification instanceof NoShieldNotification) {
NoShieldNotification n = (NoShieldNotification)notification;
gameView.getBoardHandler().unshieldPiece(n.getPieceId());
} else if (notification instanceof PieceInGameNotification) {
// Handle PieceInGameNotification
} else if (notification instanceof PlayCardNotification) {
// Handle PlayCardNotification
} else if (notification instanceof PlayerInGameNotification n) {
// Handle PlayerInGameNotification
gameView.getBoardHandler().addPlayer(n.getColor(),n.getPiecesList());
gameView.getGuiHandler().addPlayer(n.getColor(),n.getName());
boardHandler.addPlayer(n.getColor(),n.getPiecesList());
guiHandler.addPlayer(n.getColor(),n.getName());
} else if (notification instanceof ResumeNotification) {
// Handle ResumeNotification
} else if (notification instanceof RollDiceNotification) {
// Handle RollDiceNotification
} else if (notification instanceof SelectableCardsNotification) {
// Handle SelectableCardsNotification
} else if (notification instanceof ShieldActiveNotification) {
ShieldActiveNotification n = (ShieldActiveNotification)notification;
gameView.getBoardHandler().shieldPiece(n.getPieceId());
} else if (notification instanceof ShieldSuppressedNotification) {
ShieldSuppressedNotification n = (ShieldSuppressedNotification)notification;
gameView.getBoardHandler().suppressShield(n.getPieceId());
} else if (notification instanceof RollDiceNotification n) {
guiHandler.rollDice(n.getEyes());
//TODO multiplicator
} else if (notification instanceof SelectableCardsNotification n) {
guiHandler.setSelectableCards(n.getCards());
} else if (notification instanceof ShieldActiveNotification n) {
boardHandler.shieldPiece(n.getPieceId());
} else if (notification instanceof ShieldSuppressedNotification n) {
boardHandler.suppressShield(n.getPieceId());
} else if (notification instanceof StartDialogNotification) {
app.enter(MdgaState.MAIN);
} else if (notification instanceof SwapPieceNotification n) {
gameView.getBoardHandler().swapPieces(n.getFirstPiece(), n.getSecondPiece());
boardHandler.swapPieces(n.getFirstPiece(), n.getSecondPiece());
} else if (notification instanceof WaitMoveNotification) {
// Handle WaitMoveNotification
//TODO disable all hover, highlight, etc
} else if (notification instanceof SelectableMoveNotification n) {
gameView.getBoardHandler().outlineMove(n.getPieces(), n.getMoveIndexe(), n.getHomeMoves());
boardHandler.outlineMove(n.getPieces(), n.getMoveIndexe(), n.getHomeMoves());
} else if (notification instanceof SelectableSwapNotification n) {
gameView.getBoardHandler().outlineSwap(n.getOwnPieces(), n.getEnemyPieces());
boardHandler.outlineSwap(n.getOwnPieces(), n.getEnemyPieces());
} else {
throw new RuntimeException("notification not expected: " + notification.toString());
}

View File

@@ -1,5 +1,6 @@
package pp.mdga.client.gui;
import com.jme3.math.FastMath;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
@@ -17,6 +18,8 @@ public class DiceControl extends AbstractControl {
private boolean slerp = false;
private float timeElapsed = 0.0f;
private float rollDuration = 0.0001f;
private static final int ANGULAR_MIN = 5;
private static final int ANGULAR_MAX = 15;
@Override
protected void controlUpdate(float tpf) {
@@ -64,13 +67,14 @@ protected void controlUpdate(float tpf) {
protected void controlRender(RenderManager rm, ViewPort vp) {
}
public void rollDice(int diceNum) {
if (isRolling) return;
angularVelocity.set(
random.nextFloat() * 1000f + 100f,
random.nextFloat() * 1000f + 100f,
random.nextFloat() * 1000f + 100f
FastMath.nextRandomInt(ANGULAR_MIN,ANGULAR_MAX),
FastMath.nextRandomInt(ANGULAR_MIN,ANGULAR_MAX),
FastMath.nextRandomInt(ANGULAR_MIN,ANGULAR_MAX)
);
targetRotation = getRotationForDiceNum(diceNum);
@@ -94,4 +98,13 @@ public static float lerp(float t) {
return (float) Math.sqrt(1 - Math.pow(t - 1, 2));
}
public void randomRotation() {
Quaternion randomRotation = new Quaternion();
randomRotation.fromAngles(
FastMath.nextRandomFloat() * FastMath.TWO_PI, // Random X rotation
FastMath.nextRandomFloat() * FastMath.TWO_PI, // Random Y rotation
FastMath.nextRandomFloat() * FastMath.TWO_PI // Random Z rotation
);
spatial.setLocalRotation(randomRotation);
}
}

View File

@@ -96,13 +96,15 @@ public void addCard(BonusCard card, UUID uuid) {
bonusCardControlMap.get(card).setNumCard(newNum);
}
public void showDice(int rollNum){
public void rollDice(int rollNum){
if(!(1 <= rollNum && rollNum <= 6)) throw new RuntimeException("rollNum is not in the range [1,6]");
cardLayer.addSpatial(diceControl.getSpatial());
diceControl.rollDice(rollNum);
}
public void showDice(){
cardLayer.addSpatial(diceControl.getSpatial());
}
public void hideDice(){
cardLayer.deleteSpatial(diceControl.getSpatial());
}
@@ -232,7 +234,7 @@ public CardLayer getCardLayer(){
}
public void setSelectableCards(List<UUID> selectUuids) {
public void setSelectableCards_UUID(List<UUID> selectUuids) {
for(UUID uuid : selectUuids) {
selectableCards.add(bonusCardControlMap.get(uuidBonusCardMap.get(uuid)));
}
@@ -243,6 +245,17 @@ public void setSelectableCards(List<UUID> selectUuids) {
}
}
public void setSelectableCards(List<BonusCard> select) {
for(BonusCard uuid : select) {
selectableCards.add(bonusCardControlMap.get(uuid));
}
for(CardControl control : selectableCards){
control.setSelectable(true);
control.setHoverable(true);
control.setHighlight();
}
}
public void clearSelectableCards(){
for(CardControl control : selectableCards){
control.setSelectable(false);

View File

@@ -31,6 +31,8 @@ public class GameView extends MdgaView {
private SingleButtonLeftDialog leaveButton;
private SingleButtonRightDialog continueButton;
private Color ownColor = null;
public GameView(MdgaApp app) {
super(app);
@@ -115,4 +117,12 @@ public BoardHandler getBoardHandler() {
public GuiHandler getGuiHandler() {
return guiHandler;
}
public void setOwnColor(Color ownColor) {
this.ownColor = ownColor;
}
public Color getOwnColor() {
return ownColor;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff