merge development into test #26
@@ -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";
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
5342
Projekte/mdga/client/src/main/resources/Models/cir/cir_newOrigin.obj
Normal file
5342
Projekte/mdga/client/src/main/resources/Models/cir/cir_newOrigin.obj
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
6557
Projekte/mdga/client/src/main/resources/Models/lw/lw_newOrigin.obj
Normal file
6557
Projekte/mdga/client/src/main/resources/Models/lw/lw_newOrigin.obj
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,7 @@
|
||||
package pp.mdga.notification;
|
||||
|
||||
import pp.mdga.game.BonusCard;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
@@ -8,12 +10,14 @@
|
||||
public class AcquireCardNotification extends Notification{
|
||||
|
||||
private UUID cardId;
|
||||
private BonusCard bonusCard;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param cardId The id of the card that was acquired.
|
||||
*/
|
||||
public AcquireCardNotification(UUID cardId) {
|
||||
public AcquireCardNotification(BonusCard bonusCard, UUID cardId) {
|
||||
this.bonusCard = bonusCard;
|
||||
this.cardId = cardId;
|
||||
}
|
||||
|
||||
@@ -24,4 +28,8 @@ public AcquireCardNotification(UUID cardId) {
|
||||
public UUID getCardId() {
|
||||
return cardId;
|
||||
}
|
||||
|
||||
public BonusCard getBonusCard() {
|
||||
return bonusCard;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
package pp.mdga.notification;
|
||||
|
||||
import pp.mdga.game.Color;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class MoveThrowPieceNotification extends Notification{
|
||||
|
||||
private UUID pieceId1;
|
||||
private UUID pieceId2;
|
||||
private int nodeIndex;
|
||||
private Color colorPiece2;
|
||||
|
||||
/**
|
||||
* This constructor is used to create a new MoveThrowPieceNotification
|
||||
*
|
||||
* @param pieceId1 the pieceId1
|
||||
* @param pieceId2 the pieceId2
|
||||
* @param nodeIndex the nodeIndex
|
||||
* @param colorPiece2 the color
|
||||
*/
|
||||
public MoveThrowPieceNotification(UUID pieceId1, UUID pieceId2, int nodeIndex, Color colorPiece2) {
|
||||
this.pieceId1 = pieceId1;
|
||||
this.pieceId2 = pieceId2;
|
||||
this.nodeIndex = nodeIndex;
|
||||
this.colorPiece2 = colorPiece2;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the pieceId1
|
||||
*
|
||||
* @return the pieceId1
|
||||
*/
|
||||
public UUID getPieceId1() {
|
||||
return pieceId1;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the pieceId2
|
||||
*
|
||||
* @return the pieceId2
|
||||
*/
|
||||
public UUID getPieceId2() {
|
||||
return pieceId2;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the nodeIndex
|
||||
*
|
||||
* @return the nodeIndex
|
||||
*/
|
||||
public int getNodeIndex() {
|
||||
return nodeIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the color
|
||||
*
|
||||
* @return the color
|
||||
*/
|
||||
public Color getColor() {
|
||||
return colorPiece2;
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package pp.mdga.notification;
|
||||
|
||||
import pp.mdga.game.Color;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Notification that a piece is in the game
|
||||
*/
|
||||
public class PieceInGameNotification extends Notification{
|
||||
private Color color;
|
||||
private UUID id;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param color the color of the piece
|
||||
* @param id the id of the piece
|
||||
*/
|
||||
PieceInGameNotification(Color color, UUID id) {
|
||||
this.color = color;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the color of the piece
|
||||
*/
|
||||
public Color getColor() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id of the piece
|
||||
*/
|
||||
public UUID getId() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package pp.mdga.notification;
|
||||
|
||||
import pp.mdga.game.Color;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class ThrowPieceNotification extends Notification{
|
||||
|
||||
private UUID pieceId;
|
||||
|
||||
/**
|
||||
* This constructor is used to create a new ThrowPieceNotification
|
||||
*
|
||||
* @param pieceId1 the pieceId1
|
||||
* @param pieceId2 the pieceId2
|
||||
* @param nodeIndex the nodeIndex
|
||||
* @param colorPiece2 the color
|
||||
*/
|
||||
public ThrowPieceNotification(UUID pieceId) {
|
||||
this.pieceId = pieceId;
|
||||
}
|
||||
|
||||
public UUID getPieceId() {
|
||||
return pieceId;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user