Compare commits
7 Commits
dev/client
...
dev/client
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4430b37581 | ||
|
|
e14b8cb510 | ||
|
|
6d3c733f91 | ||
|
|
1a079dad44 | ||
|
|
32f49a6181 | ||
|
|
29c6b13300 | ||
|
|
2ac2de645b |
@@ -1,19 +0,0 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
|
||||||
<configuration default="false" name="MdgaApp" type="Application" factoryName="Application" singleton="false" nameIsGenerated="true">
|
|
||||||
<option name="ALTERNATIVE_JRE_PATH" value="temurin-20" />
|
|
||||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
|
|
||||||
<option name="MAIN_CLASS_NAME" value="pp.mdga.client.MdgaApp" />
|
|
||||||
<module name="Projekte.mdga.client.main" />
|
|
||||||
<option name="VM_PARAMETERS" value="-Djava.util.logging.config.file=logging.properties -ea" />
|
|
||||||
<option name="WORKING_DIRECTORY" value="$MODULE_WORKING_DIR$" />
|
|
||||||
<extension name="coverage">
|
|
||||||
<pattern>
|
|
||||||
<option name="PATTERN" value="pp.mdga.client.board.outline.*" />
|
|
||||||
<option name="ENABLED" value="true" />
|
|
||||||
</pattern>
|
|
||||||
</extension>
|
|
||||||
<method v="2">
|
|
||||||
<option name="Make" enabled="true" />
|
|
||||||
</method>
|
|
||||||
</configuration>
|
|
||||||
</component>
|
|
||||||
@@ -39,7 +39,11 @@ public enum Asset {
|
|||||||
shieldCard,
|
shieldCard,
|
||||||
shieldSymbol("Models/shieldCard/shieldSymbol.j3o", "Models/shieldCard/shieldCard_diff.png"),
|
shieldSymbol("Models/shieldCard/shieldSymbol.j3o", "Models/shieldCard/shieldCard_diff.png"),
|
||||||
dice,
|
dice,
|
||||||
missile("Models/missile/AVMT300.obj", "Models/missile/texture.jpg", 0.1f),
|
tankShoot("Models/tank/tankShoot_bot.j3o", "Models/tank/tank_diff.png"),
|
||||||
|
tankShootTop("Models/tank/tankShoot_top.j3o", "Models/tank/tank_diff.png"),
|
||||||
|
treesSmallBackground("Models/treeSmall/treesSmallBackground.j3o", "Models/treeSmall/treeSmall_diff.png", 1.2f),
|
||||||
|
treesBigBackground("Models/treeBig/treesBigBackground.j3o", "Models/treeBig/treeBig_diff.png", 1.2f),
|
||||||
|
shell
|
||||||
;
|
;
|
||||||
|
|
||||||
private final String modelPath;
|
private final String modelPath;
|
||||||
|
|||||||
@@ -149,16 +149,25 @@ else if(boardSelect != null) {
|
|||||||
if (name.equals("Right")) {
|
if (name.equals("Right")) {
|
||||||
isRotateRight = !isRotateRight;
|
isRotateRight = !isRotateRight;
|
||||||
}
|
}
|
||||||
if(name.equals("Test2") &&isPressed){
|
if(name.equals("Test") &&isPressed){
|
||||||
if(app.getView() instanceof GameView gameView){
|
if(app.getView() instanceof GameView gameView){
|
||||||
|
|
||||||
if(p == null) {
|
if(p == null) {
|
||||||
p = UUID.randomUUID();
|
p = UUID.randomUUID();
|
||||||
gameView.getBoardHandler().addPlayer(Color.AIRFORCE,List.of(p,UUID.randomUUID(),UUID.randomUUID(),UUID.randomUUID()));
|
gameView.getBoardHandler().addPlayer(Color.AIRFORCE,List.of(p,UUID.randomUUID(),UUID.randomUUID(),UUID.randomUUID()));
|
||||||
gameView.getBoardHandler().movePieceStartAnim(p,0);
|
gameView.getBoardHandler().movePieceStartAnim(p,0);
|
||||||
//gameView.getBoardHandler().movePieceAnim(p,0, 8);
|
gameView.getGuiHandler().addCardOwn(BonusCard.SHIELD);
|
||||||
|
gameView.getGuiHandler().setSelectableCards(List.of(BonusCard.SHIELD));
|
||||||
|
|
||||||
|
// gameView.getBoardHandler().movePieceAnim(p,0, 8);
|
||||||
} else {
|
} else {
|
||||||
gameView.getBoardHandler().throwMissileAnim(p);
|
// gameView.getBoardHandler().throwBombAnim(p);
|
||||||
|
gameView.getBoardHandler().throwPiece(p,Color.ARMY);
|
||||||
|
// gameView.getBoardHandler().movePieceAnim(p,0,20);
|
||||||
|
// gameView.getBoardHandler().throwPiece(p,Color.CYBER);
|
||||||
|
// gameView.getBoardHandler().throwPiece(p,Color.AIRFORCE);
|
||||||
|
|
||||||
|
|
||||||
//gameView.getBoardHandler().movePieceStartAnim(p,0);
|
//gameView.getBoardHandler().movePieceStartAnim(p,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,11 +74,10 @@ public void selectCard(BonusCard card) {
|
|||||||
this.card = card;
|
this.card = card;
|
||||||
|
|
||||||
GameView gameView = (GameView) app.getView();
|
GameView gameView = (GameView) app.getView();
|
||||||
|
if(card != null) {
|
||||||
if(card == null) {
|
|
||||||
gameView.needConfirm();
|
gameView.needConfirm();
|
||||||
} else {
|
} else {
|
||||||
gameView.needNoPower();
|
gameView.noConfirm();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,17 +93,14 @@ public void confirm() {
|
|||||||
} else if (a != null) {
|
} else if (a != null) {
|
||||||
selectPiece(a);
|
selectPiece(a);
|
||||||
gameView.getBoardHandler().clearSelectable();
|
gameView.getBoardHandler().clearSelectable();
|
||||||
|
} else if (card != null){
|
||||||
|
selectCard(card);
|
||||||
|
gameView.getGuiHandler().clearSelectableCards();
|
||||||
} else {
|
} else {
|
||||||
if(null == card) {
|
throw new RuntimeException("nothing to confirm");
|
||||||
selectCard(null);
|
|
||||||
} else {
|
|
||||||
selectCard(card);
|
|
||||||
gameView.getGuiHandler().clearSelectableCards();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gameView.noConfirm();
|
gameView.noConfirm();
|
||||||
gameView.noNoPower();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectTsk(Color color) {
|
public void selectTsk(Color color) {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package pp.mdga.client;
|
package pp.mdga.client;
|
||||||
|
|
||||||
import pp.mdga.client.acoustic.MdgaSound;
|
|
||||||
import pp.mdga.client.board.BoardHandler;
|
import pp.mdga.client.board.BoardHandler;
|
||||||
import pp.mdga.client.gui.GuiHandler;
|
import pp.mdga.client.gui.GuiHandler;
|
||||||
import pp.mdga.client.view.CeremonyView;
|
import pp.mdga.client.view.CeremonyView;
|
||||||
@@ -86,14 +85,13 @@ private void handleGame(Notification notification) {
|
|||||||
GuiHandler guiHandler = gameView.getGuiHandler();
|
GuiHandler guiHandler = gameView.getGuiHandler();
|
||||||
BoardHandler boardHandler = gameView.getBoardHandler();
|
BoardHandler boardHandler = gameView.getBoardHandler();
|
||||||
ModelSynchronizer modelSynchronizer = app.getModelSynchronize();
|
ModelSynchronizer modelSynchronizer = app.getModelSynchronize();
|
||||||
|
Color ownColor = gameView.getOwnColor();
|
||||||
|
|
||||||
if (notification instanceof AcquireCardNotification n) {
|
if (notification instanceof AcquireCardNotification n) {
|
||||||
guiHandler.addCardOwn(n.getBonusCard());
|
guiHandler.addCardOwn(n.getBonusCard());
|
||||||
app.getAcousticHandler().playSound(MdgaSound.BONUS);
|
|
||||||
} else if (notification instanceof ActivePlayerNotification n) {
|
} else if (notification instanceof ActivePlayerNotification n) {
|
||||||
gameView.getGuiHandler().setActivePlayer(n.getColor());
|
gameView.getGuiHandler().setActivePlayer(n.getColor());
|
||||||
boardHandler.showDice(n.getColor());
|
if(n.getColor() != ownColor) boardHandler.showDice(n.getColor());
|
||||||
app.getAcousticHandler().playSound(MdgaSound.UI90);
|
|
||||||
} else if (notification instanceof CeremonyNotification ceremonyNotification) {
|
} else if (notification instanceof CeremonyNotification ceremonyNotification) {
|
||||||
app.enter(MdgaState.CEREMONY);
|
app.enter(MdgaState.CEREMONY);
|
||||||
CeremonyView ceremonyView = (CeremonyView) app.getView();
|
CeremonyView ceremonyView = (CeremonyView) app.getView();
|
||||||
@@ -128,8 +126,8 @@ private void handleGame(Notification notification) {
|
|||||||
} else if (notification instanceof HomeMoveNotification home) {
|
} else if (notification instanceof HomeMoveNotification home) {
|
||||||
boardHandler.movePieceHomeAnim(home.getPieceId(), home.getHomeIndex());
|
boardHandler.movePieceHomeAnim(home.getPieceId(), home.getHomeIndex());
|
||||||
guiHandler.hideText();
|
guiHandler.hideText();
|
||||||
} else if (notification instanceof InterruptNotification notification1) {
|
} else if (notification instanceof InterruptNotification) {
|
||||||
gameView.enterInterrupt(notification1.getColor());
|
gameView.enterInterrupt();
|
||||||
} else if (notification instanceof MovePieceNotification n) {
|
} else if (notification instanceof MovePieceNotification n) {
|
||||||
if(n.isMoveStart()) {
|
if(n.isMoveStart()) {
|
||||||
//StartMove
|
//StartMove
|
||||||
@@ -141,11 +139,11 @@ private void handleGame(Notification notification) {
|
|||||||
}
|
}
|
||||||
guiHandler.hideText();
|
guiHandler.hideText();
|
||||||
} else if (notification instanceof ThrowPieceNotification n) {
|
} else if (notification instanceof ThrowPieceNotification n) {
|
||||||
boardHandler.throwBombAnim(n.getPieceId());
|
boardHandler.throwPiece(n.getPieceId(), n.getThrowColor());
|
||||||
} else if (notification instanceof NoShieldNotification n) {
|
} else if (notification instanceof NoShieldNotification n) {
|
||||||
boardHandler.unshieldPiece(n.getPieceId());
|
boardHandler.unshieldPiece(n.getPieceId());
|
||||||
} else if (notification instanceof PlayCardNotification n) {
|
} else if (notification instanceof PlayCardNotification n) {
|
||||||
if(n.getColor() == gameView.getOwnColor()) guiHandler.playCardOwn(n.getCard());
|
if(n.getColor() == ownColor) guiHandler.playCardOwn(n.getCard());
|
||||||
else guiHandler.playCardEnemy(n.getColor(), n.getCard());
|
else guiHandler.playCardEnemy(n.getColor(), n.getCard());
|
||||||
} else if (notification instanceof PlayerInGameNotification n) {
|
} else if (notification instanceof PlayerInGameNotification n) {
|
||||||
boardHandler.addPlayer(n.getColor(),n.getPiecesList());
|
boardHandler.addPlayer(n.getColor(),n.getPiecesList());
|
||||||
@@ -154,7 +152,7 @@ private void handleGame(Notification notification) {
|
|||||||
gameView.leaveInterrupt();
|
gameView.leaveInterrupt();
|
||||||
} else if (notification instanceof RollDiceNotification n) {
|
} else if (notification instanceof RollDiceNotification n) {
|
||||||
gameView.getGuiHandler().hideText();
|
gameView.getGuiHandler().hideText();
|
||||||
if(n.getColor() == gameView.getOwnColor()){
|
if(n.getColor() == ownColor){
|
||||||
guiHandler.rollDice(n.getEyes(), n.isTurbo() ? n.getMultiplier() : -1);
|
guiHandler.rollDice(n.getEyes(), n.isTurbo() ? n.getMultiplier() : -1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -164,7 +162,6 @@ private void handleGame(Notification notification) {
|
|||||||
}
|
}
|
||||||
} else if (notification instanceof SelectableCardsNotification n) {
|
} else if (notification instanceof SelectableCardsNotification n) {
|
||||||
guiHandler.setSelectableCards(n.getCards());
|
guiHandler.setSelectableCards(n.getCards());
|
||||||
gameView.needNoPower();
|
|
||||||
} else if (notification instanceof ShieldActiveNotification n) {
|
} else if (notification instanceof ShieldActiveNotification n) {
|
||||||
boardHandler.shieldPiece(n.getPieceId());
|
boardHandler.shieldPiece(n.getPieceId());
|
||||||
} else if (notification instanceof ShieldSuppressedNotification n) {
|
} else if (notification instanceof ShieldSuppressedNotification n) {
|
||||||
|
|||||||
47
Projekte/mdga/client/src/main/java/pp/mdga/client/Util.java
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
package pp.mdga.client;
|
||||||
|
|
||||||
|
import com.jme3.math.Vector3f;
|
||||||
|
|
||||||
|
public class Util {
|
||||||
|
private Util(){}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Performs linear interpolation between two values.
|
||||||
|
*
|
||||||
|
* @param start The starting value.
|
||||||
|
* @param end The ending value.
|
||||||
|
* @param t A parameter between 0 and 1 representing the interpolation progress.
|
||||||
|
* @return The interpolated value.
|
||||||
|
*/
|
||||||
|
public static float linInt(float start, float end, float t) {
|
||||||
|
return start + t * (end - start);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Performs quadratic interpolation between three points.
|
||||||
|
*
|
||||||
|
* @param p1 The initial point.
|
||||||
|
* @param p2 The middle point.
|
||||||
|
* @param p3 The final point.
|
||||||
|
* @param t The interpolation parameter (0 <= t <= 1).
|
||||||
|
* @return The interpolated point.
|
||||||
|
*/
|
||||||
|
public static Vector3f quadInt(Vector3f p1, Vector3f p2, Vector3f p3, float t) {
|
||||||
|
// Quadratic interpolation: (1-t)^2 * p1 + 2 * (1-t) * t * p2 + t^2 * p3
|
||||||
|
float oneMinusT = 1 - t;
|
||||||
|
return p1.mult(oneMinusT * oneMinusT)
|
||||||
|
.add(p2.mult(2 * oneMinusT * t))
|
||||||
|
.add(p3.mult(t * t));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A smooth ease-in-out function for interpolation.
|
||||||
|
* It accelerates and decelerates the interpolation for a smoother effect.
|
||||||
|
*
|
||||||
|
* @param x The interpolation parameter (0 <= x <= 1).
|
||||||
|
* @return The adjusted interpolation value.
|
||||||
|
*/
|
||||||
|
public static float easeInOut(float x){
|
||||||
|
return x < 0.5 ? 4 * x * x * x : (float) (1 - Math.pow(-2 * x + 2, 3) / 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -113,9 +113,9 @@ public void playSound(MdgaSound sound) {
|
|||||||
assets.add(new SoundAssetDelayVolume(SoundAsset.JET, 1.0f, 0.0f));
|
assets.add(new SoundAssetDelayVolume(SoundAsset.JET, 1.0f, 0.0f));
|
||||||
break;
|
break;
|
||||||
case EXPLOSION:
|
case EXPLOSION:
|
||||||
assets.add(new SoundAssetDelayVolume(SoundAsset.EXPLOSION_1, 1.0f, 0f));
|
assets.add(new SoundAssetDelayVolume(SoundAsset.EXPLOSION_1, 1.0f, 4f));
|
||||||
assets.add(new SoundAssetDelayVolume(SoundAsset.EXPLOSION_2, 1.0f, 0f));
|
assets.add(new SoundAssetDelayVolume(SoundAsset.EXPLOSION_2, 1.0f, 4f));
|
||||||
assets.add(new SoundAssetDelayVolume(SoundAsset.THUNDER, 1.0f, 0f));
|
assets.add(new SoundAssetDelayVolume(SoundAsset.THUNDER, 1.0f, 4f));
|
||||||
break;
|
break;
|
||||||
case LOSE:
|
case LOSE:
|
||||||
assets.add(new SoundAssetDelayVolume(SoundAsset.LOSE, 1.0f, 0.0f));
|
assets.add(new SoundAssetDelayVolume(SoundAsset.LOSE, 1.0f, 0.0f));
|
||||||
@@ -123,14 +123,14 @@ public void playSound(MdgaSound sound) {
|
|||||||
case BONUS:
|
case BONUS:
|
||||||
assets.add(new SoundAssetDelayVolume(SoundAsset.BONUS, 1.0f, 0.0f));
|
assets.add(new SoundAssetDelayVolume(SoundAsset.BONUS, 1.0f, 0.0f));
|
||||||
break;
|
break;
|
||||||
case UI90:
|
case TURRET_ROTATE:
|
||||||
assets.add(new SoundAssetDelayVolume(SoundAsset.UI90, 1.0f, 0.0f));
|
assets.add(new SoundAssetDelayVolume(SoundAsset.TURRET_ROTATE, 0.7f, 0f));
|
||||||
break;
|
break;
|
||||||
case MISSILE:
|
case TANK_SHOOT:
|
||||||
assets.add(new SoundAssetDelayVolume(SoundAsset.MISSILE, 1.0f, 0.0f));
|
assets.add(new SoundAssetDelayVolume(SoundAsset.TANK_SHOOT, 0.7f, 0f));
|
||||||
break;
|
break;
|
||||||
case MATRIX:
|
case TANK_EXPLOSION:
|
||||||
assets.add(new SoundAssetDelayVolume(SoundAsset.MATRIX, 1.0f, 0.0f));
|
assets.add(new SoundAssetDelayVolume(SoundAsset.EXPLOSION_1, 1.0f, 0f));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public enum MdgaSound {
|
|||||||
EXPLOSION,
|
EXPLOSION,
|
||||||
LOSE,
|
LOSE,
|
||||||
BONUS,
|
BONUS,
|
||||||
UI90,
|
TURRET_ROTATE,
|
||||||
MISSILE,
|
TANK_SHOOT,
|
||||||
MATRIX,
|
TANK_EXPLOSION
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,9 +35,11 @@ enum SoundAsset {
|
|||||||
UI90("ui90.ogg"),
|
UI90("ui90.ogg"),
|
||||||
BONUS("bonus.ogg"),
|
BONUS("bonus.ogg"),
|
||||||
LOSE("lose.ogg"),
|
LOSE("lose.ogg"),
|
||||||
MISSILE("missile.ogg"),
|
CONNECTED("connected.wav"),
|
||||||
MATRIX("matrix.wav"),
|
TURRET_ROTATE("turret_rotate.ogg"),
|
||||||
CONNECTED("connected.wav");
|
TANK_SHOOT("tank_shoot.ogg")
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
private final String path;
|
private final String path;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package pp.mdga.client.animation;
|
||||||
|
|
||||||
|
import pp.mdga.client.InitControl;
|
||||||
|
|
||||||
|
public class ActionControl extends InitControl {
|
||||||
|
private final Runnable runnable;
|
||||||
|
|
||||||
|
public ActionControl(Runnable runnable){
|
||||||
|
this.runnable = runnable;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
protected void action(){
|
||||||
|
if(runnable == null) throw new RuntimeException("runnable is null");
|
||||||
|
else runnable.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,7 +8,6 @@
|
|||||||
import com.jme3.scene.Node;
|
import com.jme3.scene.Node;
|
||||||
import com.jme3.scene.control.AbstractControl;
|
import com.jme3.scene.control.AbstractControl;
|
||||||
import pp.mdga.client.MdgaApp;
|
import pp.mdga.client.MdgaApp;
|
||||||
import pp.mdga.client.acoustic.MdgaSound;
|
|
||||||
|
|
||||||
public class Explosion {
|
public class Explosion {
|
||||||
|
|
||||||
@@ -35,6 +34,8 @@ public Explosion(MdgaApp app, Node rootNode, Vector3f location) {
|
|||||||
this.location = location;
|
this.location = location;
|
||||||
|
|
||||||
this.mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md");
|
this.mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md");
|
||||||
|
mat.getAdditionalRenderState().setDepthWrite(false);
|
||||||
|
mat.getAdditionalRenderState().setDepthTest(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -55,6 +56,7 @@ private void initializeEmitter() {
|
|||||||
fire.setParticlesPerSec(0);
|
fire.setParticlesPerSec(0);
|
||||||
|
|
||||||
fire.setLocalTranslation(location);
|
fire.setLocalTranslation(location);
|
||||||
|
fire.move(0, 0, 45);
|
||||||
|
|
||||||
smoke = new ParticleEmitter("Effect2", Type.Triangle,40);
|
smoke = new ParticleEmitter("Effect2", Type.Triangle,40);
|
||||||
smoke.setMaterial(mat);
|
smoke.setMaterial(mat);
|
||||||
@@ -72,8 +74,7 @@ private void initializeEmitter() {
|
|||||||
smoke.setParticlesPerSec(0);
|
smoke.setParticlesPerSec(0);
|
||||||
|
|
||||||
smoke.setLocalTranslation(location);
|
smoke.setLocalTranslation(location);
|
||||||
|
smoke.move(0, 0, 45);
|
||||||
app.getAcousticHandler().playSound(MdgaSound.EXPLOSION);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
package pp.mdga.client.animation;
|
||||||
|
|
||||||
|
import com.jme3.renderer.queue.RenderQueue;
|
||||||
|
import com.jme3.scene.Geometry;
|
||||||
|
import com.jme3.material.Material;
|
||||||
|
import com.jme3.math.ColorRGBA;
|
||||||
|
import pp.mdga.client.InitControl;
|
||||||
|
|
||||||
|
import static pp.mdga.client.Util.linInt;
|
||||||
|
|
||||||
|
public class FadeControl extends ActionControl {
|
||||||
|
private float duration; // Duration of the fade effect
|
||||||
|
private float timeElapsed = 0;
|
||||||
|
private boolean init = false;
|
||||||
|
private float startAlpha;
|
||||||
|
private float endAlpha;
|
||||||
|
|
||||||
|
public FadeControl(float duration, float startAlpha, float endAlpha, Runnable actionAfter) {
|
||||||
|
super(actionAfter);
|
||||||
|
this.duration = duration;
|
||||||
|
this.startAlpha = startAlpha;
|
||||||
|
this.endAlpha = endAlpha;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FadeControl(float duration, float startAlpha, float endAlpha) {
|
||||||
|
this(duration, startAlpha, endAlpha, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initSpatial() {
|
||||||
|
init = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void controlUpdate(float tpf) {
|
||||||
|
if (!init) return;
|
||||||
|
|
||||||
|
timeElapsed += tpf;
|
||||||
|
float t = timeElapsed / duration; // Calculate progress (0 to 1)
|
||||||
|
|
||||||
|
if (t >= 1) {
|
||||||
|
// Fade complete
|
||||||
|
t = 1;
|
||||||
|
init = false;
|
||||||
|
spatial.removeControl(this);
|
||||||
|
action();
|
||||||
|
}
|
||||||
|
|
||||||
|
float alpha = linInt(startAlpha, endAlpha, t); // Interpolate alpha
|
||||||
|
|
||||||
|
// Update the material's alpha
|
||||||
|
if (spatial instanceof Geometry geometry) {
|
||||||
|
Material mat = geometry.getMaterial();
|
||||||
|
if (mat != null) {
|
||||||
|
ColorRGBA diffuse = (ColorRGBA) mat.getParam("Diffuse").getValue();
|
||||||
|
mat.setColor("Diffuse", new ColorRGBA(diffuse.r, diffuse.g, diffuse.b, alpha));
|
||||||
|
|
||||||
|
ColorRGBA ambient = (ColorRGBA) mat.getParam("Ambient").getValue();
|
||||||
|
mat.setColor("Ambient", new ColorRGBA(ambient.r, ambient.g, ambient.b, alpha));
|
||||||
|
|
||||||
|
// Disable shadows when the object is nearly invisible
|
||||||
|
if (alpha <= 0.1f) {
|
||||||
|
geometry.setShadowMode(RenderQueue.ShadowMode.Off);
|
||||||
|
} else {
|
||||||
|
geometry.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
|
||||||
|
}
|
||||||
|
} else throw new RuntimeException("Material is null");
|
||||||
|
} else throw new RuntimeException("Spatial is not instance of Geometry");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -29,6 +29,7 @@ public class JetAnimation {
|
|||||||
private final float animationDuration; // Dauer der Animation
|
private final float animationDuration; // Dauer der Animation
|
||||||
private Explosion explosion;
|
private Explosion explosion;
|
||||||
private final UUID id;
|
private final UUID id;
|
||||||
|
private Runnable actionAfter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Konstruktor für die ThrowAnimation-Klasse.
|
* Konstruktor für die ThrowAnimation-Klasse.
|
||||||
@@ -40,7 +41,7 @@ public class JetAnimation {
|
|||||||
* @param curveHeight Die maximale Höhe der Flugkurve
|
* @param curveHeight Die maximale Höhe der Flugkurve
|
||||||
* @param animationDuration Die Gesamtdauer der Animation in Sekunden
|
* @param animationDuration Die Gesamtdauer der Animation in Sekunden
|
||||||
*/
|
*/
|
||||||
public JetAnimation(MdgaApp app, Node rootNode, UUID uuid, Vector3f targetPoint, float curveHeight, float animationDuration) {
|
public JetAnimation(MdgaApp app, Node rootNode, UUID uuid, Vector3f targetPoint, float curveHeight, float animationDuration, Runnable actionAfter) {
|
||||||
Vector3f spawnPoint = targetPoint.add(170, 50, 50);
|
Vector3f spawnPoint = targetPoint.add(170, 50, 50);
|
||||||
|
|
||||||
Vector3f controlPoint = targetPoint.add(new Vector3f(0, 0, -45));
|
Vector3f controlPoint = targetPoint.add(new Vector3f(0, 0, -45));
|
||||||
@@ -57,7 +58,8 @@ public JetAnimation(MdgaApp app, Node rootNode, UUID uuid, Vector3f targetPoint,
|
|||||||
|
|
||||||
id = uuid;
|
id = uuid;
|
||||||
|
|
||||||
explosion = new Explosion(app, rootNode, targetPoint);
|
explosion = new Explosion(app, rootNode, nodePoint);
|
||||||
|
this.actionAfter = actionAfter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -83,6 +85,8 @@ private void spawnJet() {
|
|||||||
jetModel.setMaterial(mat);
|
jetModel.setMaterial(mat);
|
||||||
|
|
||||||
rootNode.attachChild(jetModel);
|
rootNode.attachChild(jetModel);
|
||||||
|
|
||||||
|
app.getAcousticHandler().playSound(MdgaSound.EXPLOSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -118,10 +122,7 @@ protected void controlUpdate(float tpf) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (elapsedTime > 6.0f) {
|
if (elapsedTime > 6.0f) {
|
||||||
GameView gameView = (GameView) app.getView();
|
endAnim();
|
||||||
BoardHandler boardHandler = gameView.getBoardHandler();
|
|
||||||
|
|
||||||
boardHandler.throwPieceAnim(id);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,6 +133,10 @@ protected void controlRender(RenderManager rm, ViewPort vp) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void endAnim(){
|
||||||
|
actionAfter.run();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Repräsentiert eine 3D-Bezier-Kurve mit vier Kontrollpunkten.
|
* Repräsentiert eine 3D-Bezier-Kurve mit vier Kontrollpunkten.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,200 @@
|
|||||||
|
package pp.mdga.client.animation;
|
||||||
|
|
||||||
|
import com.jme3.effect.ParticleEmitter;
|
||||||
|
import com.jme3.effect.ParticleMesh.Type;
|
||||||
|
import com.jme3.material.Material;
|
||||||
|
import com.jme3.material.RenderState;
|
||||||
|
import com.jme3.math.ColorRGBA;
|
||||||
|
import com.jme3.math.Vector3f;
|
||||||
|
import pp.mdga.client.InitControl;
|
||||||
|
import pp.mdga.client.MdgaApp;
|
||||||
|
import pp.mdga.client.acoustic.MdgaSound;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class MatrixAnimation extends ActionControl {
|
||||||
|
private MdgaApp app;
|
||||||
|
private static final Random RANDOM = new Random();
|
||||||
|
private Vector3f radarPos;
|
||||||
|
private Runnable runnable;
|
||||||
|
private boolean init = false;
|
||||||
|
private List<ParticleEmitter> activeEmitter = new ArrayList<>();
|
||||||
|
private ParticleEmitter radarEmitter = null;
|
||||||
|
private float timeElapsed = 0f;
|
||||||
|
|
||||||
|
private enum MatrixState{
|
||||||
|
RADAR_ON,
|
||||||
|
RADAR_OFF,
|
||||||
|
MATRIX_ON,
|
||||||
|
MATRIX_OFF
|
||||||
|
}
|
||||||
|
|
||||||
|
private MatrixState state;
|
||||||
|
public MatrixAnimation(MdgaApp app, Vector3f radarPos, Runnable runnable){
|
||||||
|
super(runnable);
|
||||||
|
this.app = app;
|
||||||
|
this.radarPos = radarPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initSpatial() {
|
||||||
|
state = MatrixState.RADAR_ON;
|
||||||
|
timeElapsed = 0;
|
||||||
|
init = true;
|
||||||
|
radar();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void controlUpdate(float tpf) {
|
||||||
|
if(!init) return;
|
||||||
|
|
||||||
|
timeElapsed += tpf;
|
||||||
|
|
||||||
|
switch(state){
|
||||||
|
case RADAR_ON -> {
|
||||||
|
if(timeElapsed >= 2f){
|
||||||
|
state = MatrixState.RADAR_OFF;
|
||||||
|
timeElapsed = 0;
|
||||||
|
radarEmitter.setParticlesPerSec(0);
|
||||||
|
new Timer().schedule(new TimerTask() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
app.getRootNode().detachChild(radarEmitter);
|
||||||
|
}
|
||||||
|
}, 3000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case RADAR_OFF -> {
|
||||||
|
if(timeElapsed >= 0.1f){
|
||||||
|
state = MatrixState.MATRIX_ON;
|
||||||
|
timeElapsed = 0;
|
||||||
|
matrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
case MATRIX_ON -> {
|
||||||
|
if(timeElapsed >= 3f){
|
||||||
|
state = MatrixState.MATRIX_OFF;
|
||||||
|
timeElapsed = 0;
|
||||||
|
turnOff();
|
||||||
|
new Timer().schedule(new TimerTask() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
for (ParticleEmitter particleEmitter : activeEmitter){
|
||||||
|
app.getRootNode().detachChild(particleEmitter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 3000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case MATRIX_OFF -> {
|
||||||
|
if(timeElapsed >= 0.5f){
|
||||||
|
init = false;
|
||||||
|
spatial.removeControl(this);
|
||||||
|
action();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void turnOff(){
|
||||||
|
for (ParticleEmitter particleEmitter : activeEmitter){
|
||||||
|
particleEmitter.setParticlesPerSec(0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void radar(){
|
||||||
|
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md");
|
||||||
|
mat.setTexture("Texture", app.getAssetManager().loadTexture("Images/particle/radar_beam.png"));
|
||||||
|
ParticleEmitter emitter = new ParticleEmitter("Effect", Type.Triangle, 50);
|
||||||
|
emitter.setMaterial(mat);
|
||||||
|
emitter.setImagesX(1); // columns
|
||||||
|
emitter.setImagesY(1); // rows
|
||||||
|
emitter.setSelectRandomImage(true);
|
||||||
|
emitter.setStartColor(ColorRGBA.White);
|
||||||
|
emitter.setEndColor(ColorRGBA.Black);
|
||||||
|
emitter.getParticleInfluencer().setInitialVelocity(new Vector3f(0f, 0f, 2));
|
||||||
|
emitter.getParticleInfluencer().setVelocityVariation(0f);
|
||||||
|
emitter.setStartSize(0.1f);
|
||||||
|
emitter.setEndSize(10);
|
||||||
|
emitter.setGravity(0, 0, 0);
|
||||||
|
float life = 2.6f;
|
||||||
|
emitter.setLowLife(life);
|
||||||
|
emitter.setHighLife(life);
|
||||||
|
emitter.setLocalTranslation(radarPos.add(new Vector3f(0,0,5)));
|
||||||
|
emitter.setParticlesPerSec(1.8f);
|
||||||
|
app.getRootNode().attachChild(emitter);
|
||||||
|
radarEmitter = emitter;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void matrix(){
|
||||||
|
for(int i = 0; i < 5; i++){
|
||||||
|
particleStream(
|
||||||
|
generateMatrixColor(),
|
||||||
|
generateMatrixColor(),
|
||||||
|
getRandomFloat(0,1f),
|
||||||
|
getRandomPosition(),
|
||||||
|
getRandomFloat(1,2)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void particleStream(ColorRGBA start, ColorRGBA end, float speedVar, Vector3f pos, float spawnVar){
|
||||||
|
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md");
|
||||||
|
mat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
|
||||||
|
mat.setTexture("Texture", app.getAssetManager().loadTexture("Images/particle/particle_cir.png"));
|
||||||
|
ParticleEmitter matrix = new ParticleEmitter("Effect", Type.Triangle, 50);
|
||||||
|
matrix.setMaterial(mat);
|
||||||
|
matrix.setImagesX(2); // columns
|
||||||
|
matrix.setImagesY(1); // rows
|
||||||
|
matrix.setSelectRandomImage(true);
|
||||||
|
matrix.setStartColor(start);
|
||||||
|
matrix.setEndColor(end);
|
||||||
|
matrix.getParticleInfluencer().setInitialVelocity(new Vector3f(0f, 0f, -6f - speedVar));
|
||||||
|
matrix.getParticleInfluencer().setVelocityVariation(0f);
|
||||||
|
matrix.setStartSize(0.4f);
|
||||||
|
matrix.setEndSize(0.6f);
|
||||||
|
matrix.setGravity(0, 0, 2f);
|
||||||
|
matrix.setLowLife(3f);
|
||||||
|
matrix.setHighLife(3f);
|
||||||
|
matrix.setLocalTranslation(spatial.getLocalTranslation().add(pos).add(new Vector3f(0,0,15)));
|
||||||
|
matrix.setParticlesPerSec(spawnVar);
|
||||||
|
app.getRootNode().attachChild(matrix);
|
||||||
|
activeEmitter.add(matrix);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector3f getRandomPosition() {
|
||||||
|
// Generate a random angle in radians (0 to 2π)
|
||||||
|
float angle = (float) (2 * Math.PI * RANDOM.nextDouble());
|
||||||
|
|
||||||
|
// Generate a random radius with uniform distribution
|
||||||
|
float radius = (float) Math.sqrt(RANDOM.nextDouble());
|
||||||
|
radius *= 1f;
|
||||||
|
|
||||||
|
// Convert polar coordinates to Cartesian
|
||||||
|
float x = radius * (float) Math.cos(angle);
|
||||||
|
float y = radius * (float) Math.sin(angle);
|
||||||
|
|
||||||
|
return new Vector3f(x,y,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float getRandomFloat(float start, float end) {
|
||||||
|
if (start > end) {
|
||||||
|
throw new IllegalArgumentException("Start must be less than or equal to end.");
|
||||||
|
}
|
||||||
|
return start + RANDOM.nextFloat() * (end - start);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ColorRGBA generateMatrixColor() {
|
||||||
|
// Red is dominant
|
||||||
|
float red = 0.8f + RANDOM.nextFloat() * 0.2f; // Red channel: 0.8 to 1.0
|
||||||
|
// Green is moderately high
|
||||||
|
float green = 0.4f + RANDOM.nextFloat() * 0.3f; // Green channel: 0.4 to 0.7
|
||||||
|
// Blue is minimal
|
||||||
|
float blue = RANDOM.nextFloat() * 0.2f; // Blue channel: 0.0 to 0.2
|
||||||
|
float alpha = 1.0f; // Fully opaque
|
||||||
|
|
||||||
|
return new ColorRGBA(red, green, blue, alpha);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,138 +0,0 @@
|
|||||||
package pp.mdga.client.animation;
|
|
||||||
|
|
||||||
import com.jme3.material.Material;
|
|
||||||
import com.jme3.math.FastMath;
|
|
||||||
import com.jme3.math.Vector3f;
|
|
||||||
import com.jme3.renderer.RenderManager;
|
|
||||||
import com.jme3.renderer.ViewPort;
|
|
||||||
import com.jme3.renderer.queue.RenderQueue;
|
|
||||||
import com.jme3.scene.Node;
|
|
||||||
import com.jme3.scene.Spatial;
|
|
||||||
import com.jme3.scene.control.AbstractControl;
|
|
||||||
import pp.mdga.client.Asset;
|
|
||||||
import pp.mdga.client.MdgaApp;
|
|
||||||
import pp.mdga.client.acoustic.MdgaSound;
|
|
||||||
import pp.mdga.client.board.BoardHandler;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class MissileAnimation {
|
|
||||||
|
|
||||||
private final Node rootNode; // Root-Knoten, an den die Animation gehängt wird
|
|
||||||
private final MdgaApp app; // Referenz auf die Hauptanwendung
|
|
||||||
private final Vector3f start; // Startpunkt der Rakete
|
|
||||||
private final Vector3f target; // Zielpunkt der Rakete
|
|
||||||
private final float flightTime; // Gesamtdauer des Flugs
|
|
||||||
private Explosion explosion;
|
|
||||||
private Spatial missileModel; // 3D-Modell der Rakete
|
|
||||||
|
|
||||||
private UUID id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Konstruktor für die MissileAnimation.
|
|
||||||
*
|
|
||||||
* @param app Die Hauptanwendung.
|
|
||||||
* @param rootNode Der Root-Knoten, an den die Animation gehängt wird.
|
|
||||||
* @param target Der Zielpunkt der Rakete.
|
|
||||||
* @param flightTime Die Zeit, die die Rakete für den gesamten Flug benötigt.
|
|
||||||
*/
|
|
||||||
public MissileAnimation(MdgaApp app, Node rootNode, UUID uuid, Vector3f target, float flightTime) {
|
|
||||||
this.app = app;
|
|
||||||
this.rootNode = rootNode;
|
|
||||||
this.flightTime = flightTime;
|
|
||||||
|
|
||||||
explosion = new Explosion(app, rootNode, target);
|
|
||||||
id = uuid;
|
|
||||||
|
|
||||||
this.target = target.add(new Vector3f(1.5f, -1, 0));
|
|
||||||
|
|
||||||
|
|
||||||
start = BoardHandler.gridToWorld(12, 0);
|
|
||||||
start.add(new Vector3f(0, 0, 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Startet die Raketenanimation.
|
|
||||||
*/
|
|
||||||
public void start() {
|
|
||||||
loadMissile();
|
|
||||||
app.getAcousticHandler().playSound(MdgaSound.MISSILE);
|
|
||||||
animateMissile();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Lädt das Raketenmodell und setzt es auf den Startpunkt.
|
|
||||||
*/
|
|
||||||
private void loadMissile() {
|
|
||||||
missileModel = app.getAssetManager().loadModel(Asset.missile.getModelPath()); // Lade das Missile-Modell
|
|
||||||
missileModel.scale(Asset.missile.getSize());
|
|
||||||
missileModel.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
|
|
||||||
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
|
|
||||||
mat.setTexture("DiffuseMap", app.getAssetManager().loadTexture(Asset.missile.getDiffPath()));
|
|
||||||
missileModel.setMaterial(mat);
|
|
||||||
missileModel.setLocalTranslation(start); // Setze Startposition
|
|
||||||
rootNode.attachChild(missileModel); // Füge das Modell zur Szene hinzu
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Animiert die Rakete entlang einer Parabel.
|
|
||||||
*/
|
|
||||||
private void animateMissile() {
|
|
||||||
missileModel.addControl(new AbstractControl() {
|
|
||||||
private float elapsedTime = 0;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void controlUpdate(float tpf) {
|
|
||||||
elapsedTime += tpf;
|
|
||||||
float progress = elapsedTime / flightTime;
|
|
||||||
|
|
||||||
if (progress >= 0.95f) {
|
|
||||||
explosion.trigger();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (progress >= 1) {
|
|
||||||
explosion.trigger();
|
|
||||||
|
|
||||||
// Flug abgeschlossen
|
|
||||||
rootNode.detachChild(missileModel); // Entferne Rakete nach dem Ziel
|
|
||||||
this.spatial.removeControl(this); // Entferne die Steuerung
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Berechne die aktuelle Position entlang der Parabel
|
|
||||||
Vector3f currentPosition = computeParabolicPath(start, target, progress);
|
|
||||||
missileModel.setLocalTranslation(currentPosition);
|
|
||||||
|
|
||||||
// Passe die Ausrichtung an (Nase der Rakete zeigt in Flugrichtung)
|
|
||||||
Vector3f direction = computeParabolicPath(start, target, progress + 0.01f)
|
|
||||||
.subtract(currentPosition)
|
|
||||||
.normalizeLocal();
|
|
||||||
missileModel.lookAt(currentPosition.add(direction), Vector3f.UNIT_Y); // Z ist oben, Y ist "Up"
|
|
||||||
missileModel.rotate(0, FastMath.HALF_PI, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void controlRender(RenderManager rm, ViewPort vp) {
|
|
||||||
// Keine Render-Logik benötigt
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Berechnet eine Parabelbewegung von `start` zu `target`.
|
|
||||||
*
|
|
||||||
* @param start Der Startpunkt der Rakete.
|
|
||||||
* @param target Der Zielpunkt der Rakete.
|
|
||||||
* @param t Der Fortschritt des Flugs (0 bis 1).
|
|
||||||
* @return Die Position der Rakete entlang der Parabel.
|
|
||||||
*/
|
|
||||||
private Vector3f computeParabolicPath(Vector3f start, Vector3f target, float t) {
|
|
||||||
Vector3f midPoint = start.add(target).multLocal(0.5f); // Berechne die Mitte zwischen Start und Ziel
|
|
||||||
midPoint.addLocal(0, 0, 20); // Erhöhe den Scheitelpunkt der Parabel entlang der Z-Achse
|
|
||||||
|
|
||||||
// Quadratische Interpolation (Parabel)
|
|
||||||
Vector3f startToMid = FastMath.interpolateLinear(t, start, midPoint);
|
|
||||||
Vector3f midToTarget = FastMath.interpolateLinear(t, midPoint, target);
|
|
||||||
return FastMath.interpolateLinear(t, startToMid, midToTarget);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
package pp.mdga.client.animation;
|
package pp.mdga.client.animation;
|
||||||
|
|
||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
import pp.mdga.client.InitControl;
|
|
||||||
|
import static pp.mdga.client.Util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A control that smoothly moves a spatial from an initial position to an end position
|
* A control that smoothly moves a spatial from an initial position to an end position
|
||||||
@@ -12,16 +13,16 @@
|
|||||||
* an ease-in-out curve to create a smooth start and stop effect.
|
* an ease-in-out curve to create a smooth start and stop effect.
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public class MoveControl extends InitControl {
|
public class MoveControl extends ActionControl {
|
||||||
|
|
||||||
private boolean moving;
|
private boolean moving;
|
||||||
private final Vector3f initPos;
|
private final Vector3f initPos;
|
||||||
private final Vector3f endPos;
|
private final Vector3f endPos;
|
||||||
private final Vector3f middlePos;
|
private final Vector3f middlePos;
|
||||||
private final static float HEIGHT = 2;
|
private final float height;
|
||||||
private final static float MOVE_SPEED = 1f;
|
private final float duration;
|
||||||
private float progress = 0;
|
private float timer = 0;
|
||||||
private final Runnable actionAfter;
|
private boolean easing;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new MoveControl with specified initial and end positions, and an action to run after the movement.
|
* Creates a new MoveControl with specified initial and end positions, and an action to run after the movement.
|
||||||
@@ -32,15 +33,22 @@ public class MoveControl extends InitControl {
|
|||||||
* @param actionAfter A Runnable that will be executed after the movement finishes.
|
* @param actionAfter A Runnable that will be executed after the movement finishes.
|
||||||
*/
|
*/
|
||||||
public MoveControl(Vector3f initPos, Vector3f endPos, Runnable actionAfter){
|
public MoveControl(Vector3f initPos, Vector3f endPos, Runnable actionAfter){
|
||||||
|
this(initPos, endPos, actionAfter, 2, 1, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MoveControl(Vector3f initPos, Vector3f endPos, Runnable actionAfter, float height, float duration, boolean easing){
|
||||||
|
super(actionAfter);
|
||||||
moving = false;
|
moving = false;
|
||||||
this.initPos = initPos;
|
this.initPos = initPos;
|
||||||
this.endPos = endPos;
|
this.endPos = endPos;
|
||||||
|
this.height = height;
|
||||||
|
this.duration = duration;
|
||||||
|
this.easing = easing;
|
||||||
middlePos = new Vector3f(
|
middlePos = new Vector3f(
|
||||||
(initPos.x + endPos.x) / 2,
|
(initPos.x + endPos.x) / 2,
|
||||||
(initPos.y + endPos.y) / 2,
|
(initPos.y + endPos.y) / 2,
|
||||||
HEIGHT
|
height
|
||||||
);
|
);
|
||||||
this.actionAfter = actionAfter;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -50,7 +58,7 @@ public MoveControl(Vector3f initPos, Vector3f endPos, Runnable actionAfter){
|
|||||||
@Override
|
@Override
|
||||||
protected void initSpatial() {
|
protected void initSpatial() {
|
||||||
moving = true;
|
moving = true;
|
||||||
progress = 0;
|
timer = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -63,10 +71,16 @@ protected void initSpatial() {
|
|||||||
@Override
|
@Override
|
||||||
protected void controlUpdate(float tpf) {
|
protected void controlUpdate(float tpf) {
|
||||||
if(!moving) return;
|
if(!moving) return;
|
||||||
progress += tpf * MOVE_SPEED;
|
timer += tpf;
|
||||||
if(progress > 1) progress = 1;
|
|
||||||
spatial.setLocalTranslation(quadInt(initPos,middlePos,endPos, easeInOut(progress)));
|
float t = timer / duration;
|
||||||
if(progress == 1) end();
|
if (t >= 1) t = 1;
|
||||||
|
|
||||||
|
float interpolated = easing ? easeInOut(t) : t;
|
||||||
|
|
||||||
|
spatial.setLocalTranslation(quadInt(initPos,middlePos,endPos, interpolated));
|
||||||
|
|
||||||
|
if(t >= 1) end();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -75,35 +89,11 @@ protected void controlUpdate(float tpf) {
|
|||||||
*/
|
*/
|
||||||
private void end(){
|
private void end(){
|
||||||
moving = false;
|
moving = false;
|
||||||
actionAfter.run();
|
|
||||||
spatial.removeControl(this);
|
spatial.removeControl(this);
|
||||||
|
action();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Performs quadratic interpolation between three points.
|
|
||||||
*
|
|
||||||
* @param p1 The initial point.
|
|
||||||
* @param p2 The middle point.
|
|
||||||
* @param p3 The final point.
|
|
||||||
* @param t The interpolation parameter (0 <= t <= 1).
|
|
||||||
* @return The interpolated point.
|
|
||||||
*/
|
|
||||||
private Vector3f quadInt(Vector3f p1, Vector3f p2, Vector3f p3, float t) {
|
|
||||||
// Quadratic interpolation: (1-t)^2 * p1 + 2 * (1-t) * t * p2 + t^2 * p3
|
|
||||||
float oneMinusT = 1 - t;
|
|
||||||
return p1.mult(oneMinusT * oneMinusT)
|
|
||||||
.add(p2.mult(2 * oneMinusT * t))
|
|
||||||
.add(p3.mult(t * t));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A smooth ease-in-out function for interpolation.
|
|
||||||
* It accelerates and decelerates the interpolation for a smoother effect.
|
|
||||||
*
|
|
||||||
* @param x The interpolation parameter (0 <= x <= 1).
|
|
||||||
* @return The adjusted interpolation value.
|
|
||||||
*/
|
|
||||||
private float easeInOut(float x){
|
|
||||||
return x < 0.5 ? 4 * x * x * x : (float) (1 - Math.pow(-2 * x + 2, 3) / 2);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,167 @@
|
|||||||
|
package pp.mdga.client.animation;
|
||||||
|
|
||||||
|
import com.jme3.effect.ParticleEmitter;
|
||||||
|
import com.jme3.effect.ParticleMesh;
|
||||||
|
import com.jme3.material.Material;
|
||||||
|
import com.jme3.material.RenderState;
|
||||||
|
import com.jme3.math.ColorRGBA;
|
||||||
|
import com.jme3.math.FastMath;
|
||||||
|
import com.jme3.math.Quaternion;
|
||||||
|
import com.jme3.math.Vector3f;
|
||||||
|
import com.jme3.renderer.queue.RenderQueue;
|
||||||
|
import com.jme3.scene.Geometry;
|
||||||
|
import com.jme3.scene.Spatial;
|
||||||
|
import com.jme3.scene.shape.Box;
|
||||||
|
import pp.mdga.client.Asset;
|
||||||
|
import pp.mdga.client.InitControl;
|
||||||
|
import pp.mdga.client.MdgaApp;
|
||||||
|
import pp.mdga.client.acoustic.MdgaSound;
|
||||||
|
import pp.mdga.client.board.TankTopControl;
|
||||||
|
|
||||||
|
import java.util.Timer;
|
||||||
|
import java.util.TimerTask;
|
||||||
|
|
||||||
|
import static com.jme3.material.Materials.LIGHTING;
|
||||||
|
import static com.jme3.material.Materials.UNSHADED;
|
||||||
|
|
||||||
|
public class ShellAnimation extends ActionControl {
|
||||||
|
private static final float FLYING_DURATION = 1.25f;
|
||||||
|
private static final float FLYING_HEIGHT = 12f;
|
||||||
|
private TankTopControl tankTopControl;
|
||||||
|
private MdgaApp app;
|
||||||
|
|
||||||
|
public ShellAnimation(TankTopControl tankTopControl, MdgaApp app, Runnable actionAfter){
|
||||||
|
super(actionAfter);
|
||||||
|
this.tankTopControl = tankTopControl;
|
||||||
|
this.app = app;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initSpatial() {
|
||||||
|
tankTopControl.rotate(spatial.getLocalTranslation(), this::shoot);
|
||||||
|
app.getAcousticHandler().playSound(MdgaSound.TURRET_ROTATE);
|
||||||
|
app.getRootNode().attachChild(createShell());
|
||||||
|
}
|
||||||
|
|
||||||
|
private Vector3f getShootPos(){
|
||||||
|
Vector3f localOffset = new Vector3f(0, -5.4f, 2.9f);
|
||||||
|
Quaternion turretRotation = tankTopControl.getSpatial().getLocalRotation();
|
||||||
|
Vector3f transformedOffset = turretRotation.mult(localOffset);
|
||||||
|
return tankTopControl.getSpatial().getLocalTranslation().add(transformedOffset);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void shoot(){
|
||||||
|
app.getAcousticHandler().playSound(MdgaSound.TANK_SHOOT);
|
||||||
|
Vector3f shootPos = getShootPos();
|
||||||
|
createEffect(
|
||||||
|
shootPos,
|
||||||
|
"Images/particle/flame.png",
|
||||||
|
2, 2,
|
||||||
|
1, 3,
|
||||||
|
1f,
|
||||||
|
0.3f, 0.7f,
|
||||||
|
new ColorRGBA(1f, 0.8f, 0.4f, 0.5f),
|
||||||
|
new ColorRGBA(1f, 0f, 0f, 0f)
|
||||||
|
);
|
||||||
|
createEffect(
|
||||||
|
shootPos,
|
||||||
|
"Images/particle/vapor_cloud.png",
|
||||||
|
3, 3,
|
||||||
|
0.3f, 0.8f,
|
||||||
|
10,
|
||||||
|
0.1f, 0.35f,
|
||||||
|
new ColorRGBA(0.5f,0.5f,0.5f,0.5f),
|
||||||
|
ColorRGBA.Black
|
||||||
|
);
|
||||||
|
|
||||||
|
Spatial shell = createShell();
|
||||||
|
app.getRootNode().attachChild(shell);
|
||||||
|
shell.addControl(new ShellControl(this::hitExplosion, shootPos, spatial.getLocalTranslation(), FLYING_HEIGHT, FLYING_DURATION, app.getAssetManager()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Spatial createShell(){
|
||||||
|
Spatial model = app.getAssetManager().loadModel(Asset.shell.getModelPath());
|
||||||
|
model.scale(.16f);
|
||||||
|
model.setLocalTranslation(tankTopControl.getSpatial().getLocalTranslation());
|
||||||
|
|
||||||
|
Vector3f shootPos = tankTopControl.getSpatial().getLocalTranslation();
|
||||||
|
Vector3f targetPos = spatial.getLocalTranslation();
|
||||||
|
Vector3f direction = targetPos.subtract(shootPos).normalize();
|
||||||
|
|
||||||
|
Quaternion rotation = new Quaternion();
|
||||||
|
rotation.lookAt(direction, new Vector3f(1,0,0)); // Assuming UNIT_Y is the up vector
|
||||||
|
|
||||||
|
model.setLocalRotation(rotation);
|
||||||
|
model.rotate(FastMath.HALF_PI,0,0);
|
||||||
|
|
||||||
|
Material mat = new Material(app.getAssetManager(), LIGHTING);
|
||||||
|
mat.setBoolean("UseMaterialColors", true);
|
||||||
|
ColorRGBA color = ColorRGBA.fromRGBA255(143,117,0,255);
|
||||||
|
mat.setColor("Diffuse", color);
|
||||||
|
mat.setColor("Ambient", color);
|
||||||
|
model.setMaterial(mat);
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void hitExplosion(){
|
||||||
|
app.getAcousticHandler().playSound(MdgaSound.TANK_EXPLOSION);
|
||||||
|
createEffect(
|
||||||
|
spatial.getLocalTranslation().setZ(1),
|
||||||
|
"Images/particle/flame.png",
|
||||||
|
2, 2,
|
||||||
|
1, 5,
|
||||||
|
2f,
|
||||||
|
0.3f, 0.7f,
|
||||||
|
new ColorRGBA(1f, 0.8f, 0.4f, 0.5f),
|
||||||
|
new ColorRGBA(1f, 0f, 0f, 0f)
|
||||||
|
);
|
||||||
|
new Timer().schedule(new TimerTask() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
action();
|
||||||
|
}
|
||||||
|
}, 800);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createEffect(Vector3f shootPos,
|
||||||
|
String image,
|
||||||
|
int x, int y,
|
||||||
|
float startSize, float endSize,
|
||||||
|
float velocity,
|
||||||
|
float lowLife, float highLife,
|
||||||
|
ColorRGBA start, ColorRGBA end){
|
||||||
|
// Create a particle emitter for the explosion
|
||||||
|
ParticleEmitter explosionEmitter = new ParticleEmitter("Explosion", ParticleMesh.Type.Triangle, 100);
|
||||||
|
Material explosionMat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md");
|
||||||
|
explosionMat.setTexture("Texture", app.getAssetManager().loadTexture(image));
|
||||||
|
explosionEmitter.setMaterial(explosionMat);
|
||||||
|
|
||||||
|
// Particle properties
|
||||||
|
explosionEmitter.setImagesX(x); // Columns in the texture
|
||||||
|
explosionEmitter.setImagesY(y); // Rows in the texture
|
||||||
|
explosionEmitter.setSelectRandomImage(true); // Randomize images for variety
|
||||||
|
|
||||||
|
explosionEmitter.setStartColor(start); // Bright yellowish orange
|
||||||
|
explosionEmitter.setEndColor(end); // Fade to transparent red
|
||||||
|
|
||||||
|
explosionEmitter.setStartSize(startSize); // Initial size
|
||||||
|
explosionEmitter.setEndSize(endSize); // Final size
|
||||||
|
explosionEmitter.setLowLife(lowLife); // Minimum lifetime of particles
|
||||||
|
explosionEmitter.setHighLife(highLife); // Maximum lifetime of particles
|
||||||
|
explosionEmitter.setGravity(0, 0, 1); // Gravity to pull particles down
|
||||||
|
explosionEmitter.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 0, velocity));
|
||||||
|
explosionEmitter.getParticleInfluencer().setVelocityVariation(1f); // Adds randomness to the initial velocity
|
||||||
|
explosionEmitter.setFacingVelocity(true); // Particles face their velocity direction
|
||||||
|
explosionEmitter.setLocalTranslation(shootPos);
|
||||||
|
explosionEmitter.setParticlesPerSec(0);
|
||||||
|
explosionEmitter.emitAllParticles();
|
||||||
|
app.getRootNode().attachChild(explosionEmitter);
|
||||||
|
new Timer().schedule(new TimerTask() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
app.getRootNode().detachChild(explosionEmitter);
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
package pp.mdga.client.animation;
|
||||||
|
|
||||||
|
import com.jme3.asset.AssetManager;
|
||||||
|
import com.jme3.effect.ParticleEmitter;
|
||||||
|
import com.jme3.effect.ParticleMesh;
|
||||||
|
import com.jme3.material.Material;
|
||||||
|
import com.jme3.math.ColorRGBA;
|
||||||
|
import com.jme3.math.FastMath;
|
||||||
|
import com.jme3.math.Vector3f;
|
||||||
|
import pp.mdga.client.InitControl;
|
||||||
|
|
||||||
|
public class ShellControl extends ActionControl {
|
||||||
|
private final Vector3f shootPos;
|
||||||
|
private final Vector3f endPos;
|
||||||
|
private final float height;
|
||||||
|
private final float duration;
|
||||||
|
private Vector3f oldPos;
|
||||||
|
private ParticleEmitter emitter;
|
||||||
|
private AssetManager assetManager;
|
||||||
|
|
||||||
|
public ShellControl(Runnable runnable, Vector3f shootPos, Vector3f endPos, float height, float duration, AssetManager assetManager){
|
||||||
|
super(runnable);
|
||||||
|
this.shootPos = shootPos;
|
||||||
|
this.endPos = endPos;
|
||||||
|
this.height = height;
|
||||||
|
this.duration = duration;
|
||||||
|
this.assetManager = assetManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initSpatial() {
|
||||||
|
spatial.addControl(new MoveControl(
|
||||||
|
shootPos,
|
||||||
|
endPos,
|
||||||
|
()->{
|
||||||
|
emitter.killAllParticles();
|
||||||
|
emitter.setParticlesPerSec(0);
|
||||||
|
emitter.removeFromParent();
|
||||||
|
spatial.removeControl(this);
|
||||||
|
spatial.removeFromParent();
|
||||||
|
action();
|
||||||
|
},
|
||||||
|
height,
|
||||||
|
duration,
|
||||||
|
false
|
||||||
|
));
|
||||||
|
oldPos = spatial.getLocalTranslation().clone();
|
||||||
|
createEmitter();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createEmitter() {
|
||||||
|
emitter = new ParticleEmitter("ShellTrail", ParticleMesh.Type.Triangle, 200);
|
||||||
|
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
|
||||||
|
mat.setTexture("Texture", assetManager.loadTexture("Images/particle/line.png")); // Nutze eine schmale, linienartige Textur
|
||||||
|
emitter.setMaterial(mat);
|
||||||
|
|
||||||
|
// Comic-Style Farben
|
||||||
|
emitter.setStartColor(new ColorRGBA(1f, 1f, 1f, 1f)); // Reinweiß
|
||||||
|
emitter.setEndColor(new ColorRGBA(1f, 1f, 1f, 0f)); // Transparent
|
||||||
|
|
||||||
|
// Partikelgröße und Lebensdauer
|
||||||
|
emitter.setStartSize(0.15f); // Startgröße
|
||||||
|
emitter.setEndSize(0.1f); // Endgröße
|
||||||
|
emitter.setLowLife(0.14f); // Sehr kurze Lebensdauer
|
||||||
|
emitter.setHighLife(0.14f);
|
||||||
|
|
||||||
|
emitter.setGravity(0, 0, 0); // Keine Gravitation
|
||||||
|
emitter.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 0, 0));
|
||||||
|
emitter.getParticleInfluencer().setVelocityVariation(0f); // Kein Variationsspielraum
|
||||||
|
|
||||||
|
// Hohe Dichte für eine glatte Spur
|
||||||
|
emitter.setParticlesPerSec(500);
|
||||||
|
|
||||||
|
// Zur Shell hinzufügen
|
||||||
|
spatial.getParent().attachChild(emitter);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void controlUpdate(float tpf) {
|
||||||
|
Vector3f direction = spatial.getLocalTranslation().subtract(oldPos).normalize();
|
||||||
|
if (direction.lengthSquared() > 0) {
|
||||||
|
spatial.getLocalRotation().lookAt(direction, Vector3f.UNIT_X);
|
||||||
|
spatial.rotate(FastMath.HALF_PI,0,0);
|
||||||
|
}
|
||||||
|
oldPos = spatial.getLocalTranslation().clone();
|
||||||
|
|
||||||
|
emitter.setLocalTranslation(spatial.getLocalTranslation().clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,9 @@
|
|||||||
package pp.mdga.client.board;
|
package pp.mdga.client.board;
|
||||||
|
|
||||||
import com.jme3.material.Material;
|
import com.jme3.material.Material;
|
||||||
|
import com.jme3.material.RenderState;
|
||||||
|
import com.jme3.material.RenderState.BlendMode;
|
||||||
|
import com.jme3.math.ColorRGBA;
|
||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
import com.jme3.post.FilterPostProcessor;
|
import com.jme3.post.FilterPostProcessor;
|
||||||
import com.jme3.renderer.queue.RenderQueue;
|
import com.jme3.renderer.queue.RenderQueue;
|
||||||
@@ -10,9 +13,7 @@
|
|||||||
import pp.mdga.client.Asset;
|
import pp.mdga.client.Asset;
|
||||||
import pp.mdga.client.MdgaApp;
|
import pp.mdga.client.MdgaApp;
|
||||||
import pp.mdga.client.acoustic.MdgaSound;
|
import pp.mdga.client.acoustic.MdgaSound;
|
||||||
import pp.mdga.client.animation.MissileAnimation;
|
import pp.mdga.client.animation.*;
|
||||||
import pp.mdga.client.animation.MoveControl;
|
|
||||||
import pp.mdga.client.animation.JetAnimation;
|
|
||||||
import pp.mdga.client.gui.DiceControl;
|
import pp.mdga.client.gui.DiceControl;
|
||||||
import pp.mdga.game.Color;
|
import pp.mdga.game.Color;
|
||||||
|
|
||||||
@@ -56,6 +57,10 @@ public class BoardHandler {
|
|||||||
private PieceControl selectedOwnPiece;
|
private PieceControl selectedOwnPiece;
|
||||||
private PieceControl selectedEnemyPiece;
|
private PieceControl selectedEnemyPiece;
|
||||||
private DiceControl diceControl;
|
private DiceControl diceControl;
|
||||||
|
//Radar Position for Matrix animation
|
||||||
|
private Vector3f radarPos;
|
||||||
|
//TankTop for shellAnimation
|
||||||
|
private TankTopControl tankTop;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new BoardHandler.
|
* Creates a new BoardHandler.
|
||||||
@@ -148,12 +153,24 @@ private void initMap() {
|
|||||||
case node_wait_blue -> addHomeNode(waitingNodesMap, Color.NAVY, assetOnMap);
|
case node_wait_blue -> addHomeNode(waitingNodesMap, Color.NAVY, assetOnMap);
|
||||||
case node_wait_green -> addHomeNode(waitingNodesMap, Color.ARMY, assetOnMap);
|
case node_wait_green -> addHomeNode(waitingNodesMap, Color.ARMY, assetOnMap);
|
||||||
case node_wait_yellow -> addHomeNode(waitingNodesMap, Color.CYBER, assetOnMap);
|
case node_wait_yellow -> addHomeNode(waitingNodesMap, Color.CYBER, assetOnMap);
|
||||||
|
case radar -> addRadar(assetOnMap);
|
||||||
|
case tankShoot -> addTankShoot(assetOnMap);
|
||||||
|
|
||||||
default -> displayAsset(assetOnMap);
|
default -> displayAsset(assetOnMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addTankShoot(AssetOnMap assetOnMap) {
|
||||||
|
displayAsset(assetOnMap);
|
||||||
|
tankTop = displayAndControl(new AssetOnMap(Asset.tankShootTop, assetOnMap.x(), assetOnMap.y(), assetOnMap.rot()), new TankTopControl());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addRadar(AssetOnMap assetOnMap) {
|
||||||
|
radarPos = gridToWorld(assetOnMap.x(), assetOnMap.y());
|
||||||
|
displayAsset(assetOnMap);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts an asset to its corresponding color.
|
* Converts an asset to its corresponding color.
|
||||||
*
|
*
|
||||||
@@ -187,11 +204,16 @@ private Spatial createModel(Asset asset, Vector3f pos, float rot) {
|
|||||||
model.rotate((float) Math.toRadians(0), 0, (float) Math.toRadians(rot));
|
model.rotate((float) Math.toRadians(0), 0, (float) Math.toRadians(rot));
|
||||||
model.setLocalTranslation(pos);
|
model.setLocalTranslation(pos);
|
||||||
model.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
|
model.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
|
||||||
|
|
||||||
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
|
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
|
||||||
mat.setTexture("DiffuseMap", app.getAssetManager().loadTexture(texName));
|
mat.setTexture("DiffuseMap", app.getAssetManager().loadTexture(texName));
|
||||||
|
mat.setBoolean("UseMaterialColors", true); // Required for Material Colors
|
||||||
|
mat.setColor("Diffuse", new ColorRGBA(1, 1, 1, 1)); // White color with full alpha
|
||||||
|
mat.setColor("Ambient", new ColorRGBA(1, 1, 1, 1)); // Ambient color with full alpha
|
||||||
|
mat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
|
||||||
model.setMaterial(mat);
|
model.setMaterial(mat);
|
||||||
rootNodeBoard.attachChild(model);
|
|
||||||
|
|
||||||
|
rootNodeBoard.attachChild(model);
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,7 +224,7 @@ private Spatial createModel(Asset asset, Vector3f pos, float rot) {
|
|||||||
* @param y The y-coordinate on the grid
|
* @param y The y-coordinate on the grid
|
||||||
* @return The corresponding world position
|
* @return The corresponding world position
|
||||||
*/
|
*/
|
||||||
public static Vector3f gridToWorld(int x, int y) {
|
private static Vector3f gridToWorld(int x, int y) {
|
||||||
return new Vector3f(GRID_SIZE * x, GRID_SIZE * y, GRID_ELEVATION);
|
return new Vector3f(GRID_SIZE * x, GRID_SIZE * y, GRID_ELEVATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -723,34 +745,54 @@ public void movePieceStartAnim(UUID uuid, int moveIndex){
|
|||||||
*/
|
*/
|
||||||
public void throwPieceAnim(UUID uuid){
|
public void throwPieceAnim(UUID uuid){
|
||||||
pieces.get(uuid).getSpatial().addControl(new MoveControl(
|
pieces.get(uuid).getSpatial().addControl(new MoveControl(
|
||||||
pieces.get(uuid).getLocation(), getNextWaitingNode(pieceColor.get(uuid)).getLocation(), ()->throwPiece(uuid))
|
pieces.get(uuid).getLocation(), getNextWaitingNode(pieceColor.get(uuid)).getLocation(),
|
||||||
|
()->throwPiece(uuid))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void throwPiece(UUID uuid, Color throwColor){
|
||||||
* Animates the throwing of a piece to the next available waiting node and plays jet animation.
|
switch(throwColor){
|
||||||
*
|
case ARMY -> throwShell(uuid);
|
||||||
* @param uuid the UUID of the piece to animate
|
case NAVY -> throwMissle(uuid);
|
||||||
*/
|
case CYBER -> throwMatrix(uuid);
|
||||||
public void throwBombAnim(UUID uuid){
|
case AIRFORCE -> throwBomb(uuid);
|
||||||
Vector3f targetPoint = pieces.get(uuid).getLocation();
|
default -> throw new RuntimeException("invalid color");
|
||||||
|
}
|
||||||
JetAnimation anim = new JetAnimation(app, rootNode, uuid, targetPoint, 40, 6);
|
|
||||||
anim.start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Animates the throwing of a piece to the next available waiting node and plays ship animation.
|
* Animates the throwing of a piece to the next available waiting node.
|
||||||
*
|
*
|
||||||
* @param uuid the UUID of the piece to animate
|
* @param uuid the UUID of the piece to animate
|
||||||
*/
|
*/
|
||||||
public void throwMissileAnim(UUID uuid){
|
private void throwBomb(UUID uuid) {
|
||||||
Vector3f targetPoint = pieces.get(uuid).getLocation();
|
Vector3f targetPoint = pieces.get(uuid).getLocation();
|
||||||
|
|
||||||
MissileAnimation anim = new MissileAnimation(app, rootNode, uuid, targetPoint, 2);
|
JetAnimation anim = new JetAnimation(app, rootNode, uuid, targetPoint, 40, 6, ()->throwPieceAnim(uuid));
|
||||||
anim.start();
|
anim.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void throwMatrix(UUID uuid) {
|
||||||
|
//app.getAcousticHandler().playSound(MdgaSound.MATRIX);
|
||||||
|
Spatial piece = pieces.get(uuid).getSpatial();
|
||||||
|
piece.addControl(new MatrixAnimation(app, radarPos,()-> {
|
||||||
|
piece.addControl(new FadeControl(1,1,0,
|
||||||
|
() -> {
|
||||||
|
throwPiece(uuid);
|
||||||
|
piece.addControl(new FadeControl(1,0,1));
|
||||||
|
}
|
||||||
|
));
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void throwMissle(UUID uuid) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void throwShell(UUID uuid) {
|
||||||
|
pieces.get(uuid).getSpatial().addControl(new ShellAnimation(tankTop, app, ()-> throwPieceAnim(uuid)));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Animates the swapping of two pieces by swapping their positions and rotations.
|
* Animates the swapping of two pieces by swapping their positions and rotations.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -102,15 +102,18 @@ public void init(Color ownColor) {
|
|||||||
* and resets the camera position and rotation to its default state.
|
* and resets the camera position and rotation to its default state.
|
||||||
*/
|
*/
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
app.getRootNode().removeLight(sun);
|
init = false;
|
||||||
app.getRootNode().removeLight(ambient);
|
fpp.removeFilter(fxaaFilter);
|
||||||
|
fpp.removeFilter(ssaoFilter);
|
||||||
|
fpp.removeFilter(dlsf);
|
||||||
app.getRootNode().detachChild(sky);
|
app.getRootNode().detachChild(sky);
|
||||||
|
app.getRootNode().removeLight(ambient);
|
||||||
|
app.getRootNode().removeLight(sun);
|
||||||
|
|
||||||
|
|
||||||
// Reset the camera to its default state
|
// Reset the camera to its default state
|
||||||
app.getCamera().setLocation(defaultCameraPosition);
|
app.getCamera().setLocation(defaultCameraPosition);
|
||||||
app.getCamera().setRotation(defaultCameraRotation);
|
app.getCamera().setRotation(defaultCameraRotation);
|
||||||
|
|
||||||
fpp.removeFilter(dlsf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -109,6 +109,9 @@ private static Asset getLoadedAsset(String assetName) {
|
|||||||
case "tank" -> Asset.tank;
|
case "tank" -> Asset.tank;
|
||||||
case "treeSmall" -> Asset.treeSmall;
|
case "treeSmall" -> Asset.treeSmall;
|
||||||
case "treeBig" -> Asset.treeBig;
|
case "treeBig" -> Asset.treeBig;
|
||||||
|
case "tank_shoot" -> Asset.tankShoot;
|
||||||
|
case "treesBigBackground" -> Asset.treesBigBackground;
|
||||||
|
case "treesSmallBackground" -> Asset.treesSmallBackground;
|
||||||
default -> throw new IllegalStateException("Unexpected value: " + assetName);
|
default -> throw new IllegalStateException("Unexpected value: " + assetName);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ public void initSpatial(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void rotateInit() {
|
public void rotateInit() {
|
||||||
// rotate(rotation - initRotation);
|
setRotation(initRotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -278,4 +278,5 @@ public boolean isSelectable() {
|
|||||||
public void setHoverable(boolean hoverable) {
|
public void setHoverable(boolean hoverable) {
|
||||||
this.hoverable = hoverable;
|
this.hoverable = hoverable;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,105 @@
|
|||||||
|
package pp.mdga.client.board;
|
||||||
|
|
||||||
|
import com.jme3.math.FastMath;
|
||||||
|
import com.jme3.math.Quaternion;
|
||||||
|
import com.jme3.math.Vector3f;
|
||||||
|
import pp.mdga.client.InitControl;
|
||||||
|
|
||||||
|
import static pp.mdga.client.Util.linInt;
|
||||||
|
|
||||||
|
public class TankTopControl extends InitControl {
|
||||||
|
|
||||||
|
private float timer = 0; // Time elapsed
|
||||||
|
private final static float DURATION = 1.5f; // Total rotation duration in seconds
|
||||||
|
private boolean rotating = false; // Flag to track if rotation is active
|
||||||
|
private float startAngle = 0;
|
||||||
|
private float endAngle = 0;
|
||||||
|
private Runnable actionAfter = null;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void controlUpdate(float tpf) {
|
||||||
|
if (!rotating) return;
|
||||||
|
|
||||||
|
// Update the timer
|
||||||
|
timer += tpf;
|
||||||
|
|
||||||
|
// Calculate interpolation factor (0 to 1)
|
||||||
|
float t = timer / DURATION;
|
||||||
|
|
||||||
|
if (t >= 1) t = 1;
|
||||||
|
|
||||||
|
float curAngle = linInt(startAngle, endAngle, t);
|
||||||
|
|
||||||
|
// Interpolate the rotation
|
||||||
|
Quaternion interpolatedRotation = new Quaternion();
|
||||||
|
interpolatedRotation.fromAngleAxis((float) Math.toRadians(curAngle), Vector3f.UNIT_Z);
|
||||||
|
|
||||||
|
// Apply the interpolated rotation to the spatial
|
||||||
|
spatial.setLocalRotation(interpolatedRotation);
|
||||||
|
|
||||||
|
if(t >= 1){
|
||||||
|
rotating = false;
|
||||||
|
if(actionAfter != null) actionAfter.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void rotate(Vector3f enemyPos, Runnable actionAfter) {
|
||||||
|
if (spatial == null) throw new RuntimeException("spatial is null");
|
||||||
|
|
||||||
|
startAngle = getOwnAngle();
|
||||||
|
endAngle = getEnemyAngle(enemyPos);
|
||||||
|
|
||||||
|
// Adjust endAngle to ensure the shortest path
|
||||||
|
float deltaAngle = endAngle - startAngle;
|
||||||
|
if (deltaAngle > 180) {
|
||||||
|
endAngle -= 360; // Rotate counterclockwise
|
||||||
|
} else if (deltaAngle < -180) {
|
||||||
|
endAngle += 360; // Rotate clockwise
|
||||||
|
}
|
||||||
|
|
||||||
|
timer = 0;
|
||||||
|
rotating = true;
|
||||||
|
this.actionAfter = actionAfter; // Store the action to execute after rotation
|
||||||
|
}
|
||||||
|
|
||||||
|
private float getEnemyAngle(Vector3f enemyPos){
|
||||||
|
// Direction to the enemy in the XY plane
|
||||||
|
Vector3f direction = enemyPos.subtract(spatial.getLocalTranslation());
|
||||||
|
direction.z = 0; // Project to XY plane
|
||||||
|
direction.normalizeLocal();
|
||||||
|
|
||||||
|
Vector3f reference = Vector3f.UNIT_Y.mult(-1);
|
||||||
|
|
||||||
|
// Calculate the angle between the direction vector and the reference vector
|
||||||
|
float angle = FastMath.acos(reference.dot(direction));
|
||||||
|
|
||||||
|
// Determine rotation direction using the cross product
|
||||||
|
Vector3f cross = reference.cross(direction);
|
||||||
|
if (cross.z < 0) {
|
||||||
|
angle = -angle;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (float) Math.toDegrees(angle); // Return the absolute angle in degrees
|
||||||
|
}
|
||||||
|
|
||||||
|
private float getOwnAngle() {
|
||||||
|
// Tank's forward direction in the XY plane
|
||||||
|
Vector3f forward = spatial.getLocalRotation().mult(Vector3f.UNIT_Y);
|
||||||
|
forward.z = 0; // Project to XY plane
|
||||||
|
forward.normalizeLocal();
|
||||||
|
|
||||||
|
// Reference vector: Positive X-axis
|
||||||
|
Vector3f reference = Vector3f.UNIT_Y;
|
||||||
|
|
||||||
|
// Calculate the angle between the forward vector and the reference vector
|
||||||
|
float angle = FastMath.acos(reference.dot(forward));
|
||||||
|
|
||||||
|
// Determine rotation direction using the cross product
|
||||||
|
Vector3f cross = reference.cross(forward);
|
||||||
|
if (cross.z < 0) { // For Z-up, check the Z component of the cross product
|
||||||
|
angle = -angle;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (float) Math.toDegrees(angle); // Return the absolute angle in radians
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,21 +8,18 @@
|
|||||||
import pp.mdga.client.button.LabelButton;
|
import pp.mdga.client.button.LabelButton;
|
||||||
import pp.mdga.client.button.MenuButton;
|
import pp.mdga.client.button.MenuButton;
|
||||||
import pp.mdga.client.view.MdgaView;
|
import pp.mdga.client.view.MdgaView;
|
||||||
import pp.mdga.game.Color;
|
|
||||||
|
|
||||||
public class InterruptDialog extends Dialog {
|
public class InterruptDialog extends Dialog {
|
||||||
private ButtonRight forceButton;
|
private ButtonRight forceButton;
|
||||||
|
|
||||||
private LabelButton label;
|
private LabelButton label;
|
||||||
|
|
||||||
private String text = "";
|
|
||||||
|
|
||||||
public InterruptDialog(MdgaApp app, Node node) {
|
public InterruptDialog(MdgaApp app, Node node) {
|
||||||
super(app, node);
|
super(app, node);
|
||||||
|
|
||||||
forceButton = new ButtonRight(app, node, () -> app.getModelSynchronize().force(), "Erzwingen", 1);
|
forceButton = new ButtonRight(app, node, () -> app.getModelSynchronize().force(), "Erzwingen", 1);
|
||||||
|
|
||||||
label = new LabelButton(app, node, "Warte auf " + text + "...", new Vector2f(5.5f * 1.5f, 2), new Vector2f(0.5f, 0f), false);
|
label = new LabelButton(app, node, "Warte auf Spieler...", new Vector2f(5.5f * 1.5f, 2), new Vector2f(0.5f, 0f), false);
|
||||||
|
|
||||||
float offset = 2.8f;
|
float offset = 2.8f;
|
||||||
|
|
||||||
@@ -43,21 +40,4 @@ protected void onHide() {
|
|||||||
forceButton.hide();
|
forceButton.hide();
|
||||||
label.hide();
|
label.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setColor(Color color) {
|
|
||||||
switch (color) {
|
|
||||||
case AIRFORCE:
|
|
||||||
text = "Luftwaffe";
|
|
||||||
break;
|
|
||||||
case ARMY:
|
|
||||||
text = "Heer";
|
|
||||||
break;
|
|
||||||
case NAVY:
|
|
||||||
text = "Marine";
|
|
||||||
break;
|
|
||||||
case CYBER:
|
|
||||||
text = "CIR";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -152,5 +152,4 @@ void rollRankingResultOwn(Color color, int eye){
|
|||||||
void diceNow(){
|
void diceNow(){
|
||||||
createTopText("Klicke zum Würfeln", 5, 80, ColorRGBA.White, 0);
|
createTopText("Klicke zum Würfeln", 5, 80, ColorRGBA.White, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
import com.jme3.post.FilterPostProcessor;
|
import com.jme3.post.FilterPostProcessor;
|
||||||
import com.jme3.post.filters.ComposeFilter;
|
import com.jme3.post.filters.ComposeFilter;
|
||||||
|
import com.jme3.post.filters.FXAAFilter;
|
||||||
import com.jme3.renderer.Camera;
|
import com.jme3.renderer.Camera;
|
||||||
import com.jme3.renderer.RenderManager;
|
import com.jme3.renderer.RenderManager;
|
||||||
import com.jme3.renderer.ViewPort;
|
import com.jme3.renderer.ViewPort;
|
||||||
@@ -31,35 +32,46 @@ public class CardLayer extends AbstractAppState {
|
|||||||
private List<Spatial> cardBuffer;
|
private List<Spatial> cardBuffer;
|
||||||
private final FilterPostProcessor fpp;
|
private final FilterPostProcessor fpp;
|
||||||
private final Camera overlayCam;
|
private final Camera overlayCam;
|
||||||
Texture2D backTexture;
|
private Texture2D backTexture;
|
||||||
|
private FXAAFilter fxaaFilter;
|
||||||
|
private ViewPort view;
|
||||||
|
private DirectionalLightShadowFilter dlsf;
|
||||||
|
DirectionalLight sun;
|
||||||
|
ComposeFilter compose;
|
||||||
|
|
||||||
|
|
||||||
public CardLayer(FilterPostProcessor fpp, Camera overlayCam, Texture2D backTexture) {
|
public CardLayer(FilterPostProcessor fpp, Camera overlayCam, Texture2D backTexture) {
|
||||||
this.overlayCam = overlayCam;
|
this.overlayCam = overlayCam;
|
||||||
this.fpp = fpp;
|
this.fpp = fpp;
|
||||||
this.cardBuffer = new ArrayList<>();
|
|
||||||
init = false;
|
|
||||||
this.backTexture = backTexture;
|
this.backTexture = backTexture;
|
||||||
|
cardBuffer = new ArrayList<>();
|
||||||
|
init = false;
|
||||||
|
fxaaFilter = new FXAAFilter();
|
||||||
|
view = null;
|
||||||
|
dlsf = null;
|
||||||
|
|
||||||
|
sun = new DirectionalLight();
|
||||||
|
sun.setColor(ColorRGBA.White);
|
||||||
|
sun.setDirection(new Vector3f(.5f, -.5f, -1));
|
||||||
|
compose = new ComposeFilter(backTexture);
|
||||||
|
root = new Node("Under gui viewport Root");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(AppStateManager stateManager, Application app) {
|
public void initialize(AppStateManager stateManager, Application app) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
root = new Node("Under gui viewport Root");
|
|
||||||
|
|
||||||
ViewPort view = app.getRenderManager().createMainView("Under gui ViewPort", overlayCam);
|
view = app.getRenderManager().createMainView("Under gui ViewPort", overlayCam);
|
||||||
view.setEnabled(true);
|
view.setEnabled(true);
|
||||||
view.setClearFlags(true, true, true);
|
view.setClearFlags(true, true, true);
|
||||||
view.attachScene(root);
|
view.attachScene(root);
|
||||||
fpp.setFrameBufferFormat(Image.Format.RGBA8);
|
fpp.setFrameBufferFormat(Image.Format.RGBA8);
|
||||||
fpp.addFilter(new ComposeFilter(backTexture));
|
fpp.addFilter(compose);
|
||||||
|
fpp.addFilter(fxaaFilter);
|
||||||
|
|
||||||
|
|
||||||
DirectionalLight sun = new DirectionalLight();
|
|
||||||
sun.setColor(ColorRGBA.White);
|
|
||||||
sun.setDirection(new Vector3f(.5f, -.5f, -1));
|
|
||||||
root.addLight(sun);
|
root.addLight(sun);
|
||||||
|
|
||||||
DirectionalLightShadowFilter dlsf = new DirectionalLightShadowFilter(app.getAssetManager(), SHADOWMAP_SIZE, 3);
|
dlsf = new DirectionalLightShadowFilter(app.getAssetManager(), SHADOWMAP_SIZE, 3);
|
||||||
dlsf.setLight(sun);
|
dlsf.setLight(sun);
|
||||||
dlsf.setEnabled(true);
|
dlsf.setEnabled(true);
|
||||||
dlsf.setEdgeFilteringMode(EdgeFilteringMode.PCFPOISSON);
|
dlsf.setEdgeFilteringMode(EdgeFilteringMode.PCFPOISSON);
|
||||||
@@ -72,6 +84,15 @@ public void initialize(AppStateManager stateManager, Application app) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
|
view.clearProcessors();
|
||||||
|
fpp.removeFilter(dlsf);
|
||||||
|
dlsf = null;
|
||||||
|
root.removeLight(sun);
|
||||||
|
fpp.removeFilter(fxaaFilter);
|
||||||
|
fpp.removeFilter(compose);
|
||||||
|
view.detachScene(root);
|
||||||
|
app.getRenderManager().removeMainView(view);
|
||||||
|
|
||||||
cardBuffer.clear();
|
cardBuffer.clear();
|
||||||
root.detachAllChildren();
|
root.detachAllChildren();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,8 +131,6 @@ public void selectCard(CardControl cardControl) {
|
|||||||
cardControl.select();
|
cardControl.select();
|
||||||
cardSelect = getKeyByValue(bonusCardControlMap, cardControl);
|
cardSelect = getKeyByValue(bonusCardControlMap, cardControl);
|
||||||
}
|
}
|
||||||
|
|
||||||
app.getModelSynchronize().selectCard(cardSelect);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Camera getCardLayerCamera() {
|
public Camera getCardLayerCamera() {
|
||||||
|
|||||||
@@ -39,14 +39,15 @@ public DiceControl(AssetManager assetManager){
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void controlUpdate(float tpf) {
|
protected void controlUpdate(float tpf) {
|
||||||
|
float clampedTpf = Math.min(tpf, 0.05f); // Max 50 ms per frame
|
||||||
if (isRolling) {
|
if (isRolling) {
|
||||||
if(!slerp) {
|
if(!slerp) {
|
||||||
// Apply rotational velocity to the dice
|
// Apply rotational velocity to the dice
|
||||||
spinWithAngularVelocity(tpf);
|
spinWithAngularVelocity(clampedTpf);
|
||||||
|
|
||||||
// Gradually reduce rotational velocity (simulate deceleration)
|
// Gradually reduce rotational velocity (simulate deceleration)
|
||||||
angularVelocity.subtractLocal(
|
angularVelocity.subtractLocal(
|
||||||
angularVelocity.mult(deceleration * tpf)
|
angularVelocity.mult(deceleration * clampedTpf)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Stop rolling when angular velocity is close to zero
|
// Stop rolling when angular velocity is close to zero
|
||||||
@@ -55,7 +56,7 @@ protected void controlUpdate(float tpf) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
timeElapsed += tpf * rollDuration;
|
timeElapsed += clampedTpf * rollDuration;
|
||||||
|
|
||||||
|
|
||||||
if (timeElapsed > 1.0f) timeElapsed = 1.0f;
|
if (timeElapsed > 1.0f) timeElapsed = 1.0f;
|
||||||
@@ -71,7 +72,7 @@ protected void controlUpdate(float tpf) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else if(spin){
|
}else if(spin){
|
||||||
spinWithAngularVelocity(tpf);
|
spinWithAngularVelocity(clampedTpf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
import com.jme3.asset.AssetManager;
|
import com.jme3.asset.AssetManager;
|
||||||
import com.jme3.math.ColorRGBA;
|
import com.jme3.math.ColorRGBA;
|
||||||
import com.jme3.post.FilterPostProcessor;
|
import com.jme3.post.FilterPostProcessor;
|
||||||
|
import com.jme3.post.filters.FXAAFilter;
|
||||||
import com.jme3.renderer.Camera;
|
import com.jme3.renderer.Camera;
|
||||||
import com.jme3.renderer.RenderManager;
|
import com.jme3.renderer.RenderManager;
|
||||||
import com.jme3.renderer.ViewPort;
|
import com.jme3.renderer.ViewPort;
|
||||||
@@ -54,7 +55,6 @@ public void select(Spatial model, ColorRGBA color, int width) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void hideOutlineFilterEffect(Spatial model) {
|
private void hideOutlineFilterEffect(Spatial model) {
|
||||||
// app.enqueue(() -> {
|
|
||||||
outlineFilter.setEnabled(false);
|
outlineFilter.setEnabled(false);
|
||||||
outlineFilter.getOutlinePreFilter().setEnabled(false);
|
outlineFilter.getOutlinePreFilter().setEnabled(false);
|
||||||
fpp.removeFilter(outlineFilter);
|
fpp.removeFilter(outlineFilter);
|
||||||
@@ -62,18 +62,14 @@ private void hideOutlineFilterEffect(Spatial model) {
|
|||||||
outlineViewport.clearProcessors();
|
outlineViewport.clearProcessors();
|
||||||
renderManager.removePreView(outlineViewport);
|
renderManager.removePreView(outlineViewport);
|
||||||
outlineViewport = null;
|
outlineViewport = null;
|
||||||
// return null;
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showOutlineFilterEffect(Spatial model, int width, ColorRGBA color) {
|
private void showOutlineFilterEffect(Spatial model, int width, ColorRGBA color) {
|
||||||
// app.enqueue(() -> {
|
|
||||||
outlineViewport = renderManager.createPreView("outlineViewport", cam);
|
outlineViewport = renderManager.createPreView("outlineViewport", cam);
|
||||||
FilterPostProcessor outlineFpp = new FilterPostProcessor(assetManager);
|
FilterPostProcessor outlineFpp = new FilterPostProcessor(assetManager);
|
||||||
|
|
||||||
OutlinePreFilter outlinePreFilter = new OutlinePreFilter();
|
OutlinePreFilter outlinePreFilter = new OutlinePreFilter();
|
||||||
outlineFpp.addFilter(outlinePreFilter);
|
outlineFpp.addFilter(outlinePreFilter);
|
||||||
|
|
||||||
outlineViewport.attachScene(model);
|
outlineViewport.attachScene(model);
|
||||||
outlineViewport.addProcessor(outlineFpp);
|
outlineViewport.addProcessor(outlineFpp);
|
||||||
|
|
||||||
@@ -82,7 +78,5 @@ private void showOutlineFilterEffect(Spatial model, int width, ColorRGBA color)
|
|||||||
outlineFilter.setOutlineWidth(width);
|
outlineFilter.setOutlineWidth(width);
|
||||||
|
|
||||||
fpp.addFilter(outlineFilter);
|
fpp.addFilter(outlineFilter);
|
||||||
// return null;
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
import com.jme3.network.serializing.serializers.EnumSerializer;
|
import com.jme3.network.serializing.serializers.EnumSerializer;
|
||||||
import pp.mdga.Resources;
|
import pp.mdga.Resources;
|
||||||
import pp.mdga.game.*;
|
import pp.mdga.game.*;
|
||||||
import pp.mdga.game.card.*;
|
|
||||||
import pp.mdga.message.client.*;
|
import pp.mdga.message.client.*;
|
||||||
import pp.mdga.message.server.*;
|
import pp.mdga.message.server.*;
|
||||||
import pp.mdga.server.ServerGameLogic;
|
import pp.mdga.server.ServerGameLogic;
|
||||||
@@ -125,7 +124,7 @@ private void initializeSerializables() {
|
|||||||
Serializer.registerClass(NoTurnMessage.class);
|
Serializer.registerClass(NoTurnMessage.class);
|
||||||
Serializer.registerClass(PauseGameMessage.class);
|
Serializer.registerClass(PauseGameMessage.class);
|
||||||
Serializer.registerClass(PlayCardMessage.class);
|
Serializer.registerClass(PlayCardMessage.class);
|
||||||
Serializer.registerClass(PossibleCardsMessage.class);
|
Serializer.registerClass(PossibleCardMessage.class);
|
||||||
Serializer.registerClass(PossiblePieceMessage.class);
|
Serializer.registerClass(PossiblePieceMessage.class);
|
||||||
Serializer.registerClass(RankingResponseMessage.class);
|
Serializer.registerClass(RankingResponseMessage.class);
|
||||||
Serializer.registerClass(RankingRollAgainMessage.class);
|
Serializer.registerClass(RankingRollAgainMessage.class);
|
||||||
@@ -145,17 +144,12 @@ private void initializeSerializables() {
|
|||||||
Serializer.registerClass(Piece.class);
|
Serializer.registerClass(Piece.class);
|
||||||
Serializer.registerClass(BonusNode.class);
|
Serializer.registerClass(BonusNode.class);
|
||||||
Serializer.registerClass(StartNode.class);
|
Serializer.registerClass(StartNode.class);
|
||||||
|
Serializer.registerClass(PlayerData.class);
|
||||||
Serializer.registerClass(HomeNode.class);
|
Serializer.registerClass(HomeNode.class);
|
||||||
Serializer.registerClass(PowerCard.class);
|
|
||||||
Serializer.registerClass(TurboCard.class);
|
|
||||||
Serializer.registerClass(SwapCard.class);
|
|
||||||
Serializer.registerClass(ShieldCard.class);
|
|
||||||
Serializer.registerClass(HiddenCard.class);
|
|
||||||
|
|
||||||
Serializer.registerClass(Color.class, new EnumSerializer());
|
Serializer.registerClass(Color.class, new EnumSerializer());
|
||||||
Serializer.registerClass(PieceState.class, new EnumSerializer());
|
Serializer.registerClass(PieceState.class, new EnumSerializer());
|
||||||
Serializer.registerClass(ShieldState.class, new EnumSerializer());
|
Serializer.registerClass(ShieldState.class, new EnumSerializer());
|
||||||
Serializer.registerClass(BonusCard.class, new EnumSerializer());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerListeners() {
|
private void registerListeners() {
|
||||||
|
|||||||
@@ -20,8 +20,6 @@ public class GameView extends MdgaView {
|
|||||||
private ButtonLeft leaveButton;
|
private ButtonLeft leaveButton;
|
||||||
private ButtonRight confirmButton;
|
private ButtonRight confirmButton;
|
||||||
|
|
||||||
private ButtonRight noPowerButton;
|
|
||||||
|
|
||||||
private Color ownColor = null;
|
private Color ownColor = null;
|
||||||
|
|
||||||
private InterruptDialog interruptDialog;
|
private InterruptDialog interruptDialog;
|
||||||
@@ -33,13 +31,10 @@ public class GameView extends MdgaView {
|
|||||||
public GameView(MdgaApp app) {
|
public GameView(MdgaApp app) {
|
||||||
super(app);
|
super(app);
|
||||||
|
|
||||||
setOwnColor(Color.AIRFORCE);
|
|
||||||
leaveButton = new ButtonLeft(app, settingsNode, () -> app.getModelSynchronize().leave(), "Spiel verlassen", 1);
|
leaveButton = new ButtonLeft(app, settingsNode, () -> app.getModelSynchronize().leave(), "Spiel verlassen", 1);
|
||||||
|
|
||||||
confirmButton = new ButtonRight(app, guiNode, () -> app.getModelSynchronize().confirm(), "Bestätigen", 1);
|
confirmButton = new ButtonRight(app, guiNode, () -> app.getModelSynchronize().confirm(), "Bestätigen", 1);
|
||||||
|
|
||||||
noPowerButton = new ButtonRight(app, guiNode, () -> app.getModelSynchronize().confirm(), "Verzichten", 1);
|
|
||||||
|
|
||||||
interruptDialog = new InterruptDialog(app, guiNode);
|
interruptDialog = new InterruptDialog(app, guiNode);
|
||||||
|
|
||||||
fpp = new FilterPostProcessor(app.getAssetManager());
|
fpp = new FilterPostProcessor(app.getAssetManager());
|
||||||
@@ -70,7 +65,6 @@ public void onLeave() {
|
|||||||
|
|
||||||
|
|
||||||
confirmButton.hide();
|
confirmButton.hide();
|
||||||
noPowerButton.hide();
|
|
||||||
|
|
||||||
app.getViewPort().removeProcessor(fpp);
|
app.getViewPort().removeProcessor(fpp);
|
||||||
}
|
}
|
||||||
@@ -115,7 +109,6 @@ public Color getOwnColor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void needConfirm() {
|
public void needConfirm() {
|
||||||
noPowerButton.hide();
|
|
||||||
confirmButton.show();
|
confirmButton.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,16 +116,7 @@ public void noConfirm() {
|
|||||||
confirmButton.hide();
|
confirmButton.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void needNoPower() {
|
public void enterInterrupt() {
|
||||||
confirmButton.hide();
|
|
||||||
noPowerButton.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void noNoPower() {
|
|
||||||
noPowerButton.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void enterInterrupt(Color color) {
|
|
||||||
enterOverlay(Overlay.INTERRUPT);
|
enterOverlay(Overlay.INTERRUPT);
|
||||||
|
|
||||||
guiNode.detachChild(guiHandlerNode);
|
guiNode.detachChild(guiHandlerNode);
|
||||||
@@ -140,7 +124,6 @@ public void enterInterrupt(Color color) {
|
|||||||
|
|
||||||
app.getInputSynchronize().setClickAllowed(false);
|
app.getInputSynchronize().setClickAllowed(false);
|
||||||
|
|
||||||
interruptDialog.setColor(color);
|
|
||||||
interruptDialog.show();
|
interruptDialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,8 +135,6 @@ public void leaveInterrupt() {
|
|||||||
|
|
||||||
app.getInputSynchronize().setClickAllowed(true);
|
app.getInputSynchronize().setClickAllowed(true);
|
||||||
|
|
||||||
app.getAcousticHandler().playSound(MdgaSound.START);
|
|
||||||
|
|
||||||
interruptDialog.hide();
|
interruptDialog.hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
|
After Width: | Height: | Size: 46 KiB |
BIN
Projekte/mdga/client/src/main/resources/Images/particle/line.png
Normal file
|
After Width: | Height: | Size: 140 B |
|
After Width: | Height: | Size: 29 KiB |
|
After Width: | Height: | Size: 18 KiB |
@@ -1,4 +1,6 @@
|
|||||||
world 0,0 90
|
world 0,0 90
|
||||||
|
treesBigBackground 0,0 90
|
||||||
|
treesSmallBackground 0,0 90
|
||||||
|
|
||||||
|
|
||||||
#Marine Pos
|
#Marine Pos
|
||||||
@@ -56,7 +58,8 @@ big_tent -10,-9 130
|
|||||||
big_tent 9,-10 225
|
big_tent 9,-10 225
|
||||||
radar 0,10 -20
|
radar 0,10 -20
|
||||||
tank -1,-10 135
|
tank -1,-10 135
|
||||||
tank 0,-18 180
|
#tank 0,-18 180
|
||||||
|
tank_shoot 0,-18 180
|
||||||
tank 3,-18 180
|
tank 3,-18 180
|
||||||
tank -3,-18 180
|
tank -3,-18 180
|
||||||
|
|
||||||
@@ -270,3 +273,4 @@ treeBig 12,22 360
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
# Blender MTL File: 'untitled.blend'
|
|
||||||
# Material Count: 3
|
|
||||||
|
|
||||||
newmtl Material.001
|
|
||||||
Ns 96.078431
|
|
||||||
Ka 0.000000 0.000000 0.000000
|
|
||||||
Kd 0.640000 0.640000 0.640000
|
|
||||||
Ks 0.500000 0.500000 0.500000
|
|
||||||
Ni 1.000000
|
|
||||||
d 1.000000
|
|
||||||
illum 2
|
|
||||||
map_Kd untiffftled.jpg
|
|
||||||
|
|
||||||
newmtl Material.002
|
|
||||||
Ns 96.078431
|
|
||||||
Ka 0.000000 0.000000 0.000000
|
|
||||||
Kd 0.640000 0.640000 0.640000
|
|
||||||
Ks 0.500000 0.500000 0.500000
|
|
||||||
Ni 1.000000
|
|
||||||
d 1.000000
|
|
||||||
illum 2
|
|
||||||
map_Kd untiffftled.jpg
|
|
||||||
|
|
||||||
newmtl Material.004
|
|
||||||
Ns 96.078431
|
|
||||||
Ka 0.000000 0.000000 0.000000
|
|
||||||
Kd 0.640000 0.640000 0.640000
|
|
||||||
Ks 0.500000 0.500000 0.500000
|
|
||||||
Ni 1.000000
|
|
||||||
d 1.000000
|
|
||||||
illum 2
|
|
||||||
map_Kd untiffftled.jpg
|
|
||||||
|
Before Width: | Height: | Size: 42 KiB |
BIN
Projekte/mdga/client/src/main/resources/Models/shell/shell.j3o
Normal file
|
Before Width: | Height: | Size: 10 MiB After Width: | Height: | Size: 13 MiB |
|
After Width: | Height: | Size: 10 MiB |
BIN
Projekte/mdga/client/src/main/resources/Sounds/tank_shoot.ogg
Normal file
BIN
Projekte/mdga/client/src/main/resources/Sounds/turret_rotate.ogg
Normal file
@@ -1,8 +1,9 @@
|
|||||||
package pp.mdga.client;
|
package pp.mdga.client;
|
||||||
|
|
||||||
import pp.mdga.client.ceremonystate.CeremonyStates;
|
import pp.mdga.client.ceremonyState.CeremonyStates;
|
||||||
import pp.mdga.client.ceremonystate.PodiumState;
|
import pp.mdga.client.ceremonyState.PodiumState;
|
||||||
import pp.mdga.client.ceremonystate.StatisticsState;
|
import pp.mdga.client.ceremonyState.StatisticsState;
|
||||||
|
import pp.mdga.notification.CeremonyNotification;
|
||||||
|
|
||||||
public class CeremonyState extends ClientState {
|
public class CeremonyState extends ClientState {
|
||||||
|
|
||||||
|
|||||||
@@ -5,13 +5,13 @@
|
|||||||
import pp.mdga.game.Color;
|
import pp.mdga.game.Color;
|
||||||
import pp.mdga.game.Game;
|
import pp.mdga.game.Game;
|
||||||
import pp.mdga.game.Piece;
|
import pp.mdga.game.Piece;
|
||||||
|
import pp.mdga.game.PlayerData;
|
||||||
import pp.mdga.message.client.ClientMessage;
|
import pp.mdga.message.client.ClientMessage;
|
||||||
import pp.mdga.message.server.*;
|
import pp.mdga.message.server.*;
|
||||||
import pp.mdga.notification.InfoNotification;
|
import pp.mdga.notification.*;
|
||||||
import pp.mdga.notification.Notification;
|
|
||||||
import pp.mdga.notification.StartDialogNotification;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -52,21 +52,20 @@ public ClientGameLogic(ClientSender clientSender) {
|
|||||||
*
|
*
|
||||||
* @param msg the message to be sent
|
* @param msg the message to be sent
|
||||||
*/
|
*/
|
||||||
public void send(ClientMessage msg) {
|
public void send(ClientMessage msg){
|
||||||
LOGGER.log(System.Logger.Level.INFO, "send {0}", msg);
|
LOGGER.log(System.Logger.Level.INFO, "send {0}", msg);
|
||||||
clientSender.send(msg);
|
clientSender.send(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is used to get a piece by its id
|
* This method is used to get a piece by its id
|
||||||
*
|
|
||||||
* @param pieceId the UUID of the piece
|
* @param pieceId the UUID of the piece
|
||||||
* @return the piece
|
* @return the piece
|
||||||
*/
|
*/
|
||||||
private Piece getPiece(UUID pieceId) {
|
private Piece getPiece(UUID pieceId){
|
||||||
for (var player : this.game.getPlayers().values()) {
|
for(Map.Entry<Color, PlayerData> entry : game.getBoard().getPlayerData().entrySet()){
|
||||||
for (Piece piece : player.getPieces()) {
|
for(Piece piece : entry.getValue().getPieces()){
|
||||||
if (piece.getUuid().equals(pieceId)) {
|
if(piece.getUuid().equals(pieceId)){
|
||||||
return piece;
|
return piece;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -79,7 +78,7 @@ private Piece getPiece(UUID pieceId) {
|
|||||||
*
|
*
|
||||||
* @return the clientSender
|
* @return the clientSender
|
||||||
*/
|
*/
|
||||||
public ClientSender getClientSender() {
|
public ClientSender getClientSender(){
|
||||||
return clientSender;
|
return clientSender;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,7 +123,7 @@ public void setOwnPlayerId(int ownPlayerId) {
|
|||||||
*
|
*
|
||||||
* @return the game
|
* @return the game
|
||||||
*/
|
*/
|
||||||
public Game getGame() {
|
public Game getGame(){
|
||||||
return game;
|
return game;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,7 +132,7 @@ public Game getGame() {
|
|||||||
*
|
*
|
||||||
* @return the current State
|
* @return the current State
|
||||||
*/
|
*/
|
||||||
public ClientState getState() {
|
public ClientState getState(){
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,7 +141,7 @@ public ClientState getState() {
|
|||||||
*
|
*
|
||||||
* @return if the client is a host
|
* @return if the client is a host
|
||||||
*/
|
*/
|
||||||
public boolean isHost() {
|
public boolean isHost(){
|
||||||
return isHost;
|
return isHost;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,8 +150,8 @@ public boolean isHost() {
|
|||||||
*
|
*
|
||||||
* @return the calculated moves as int
|
* @return the calculated moves as int
|
||||||
*/
|
*/
|
||||||
public int getCalculatedMoves() {
|
public int getCalculatedMoves(){
|
||||||
return 0;
|
return game.getDiceEyes() * game.getDiceModifier();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -160,7 +159,7 @@ public int getCalculatedMoves() {
|
|||||||
*
|
*
|
||||||
* @param isHost the boolean value
|
* @param isHost the boolean value
|
||||||
*/
|
*/
|
||||||
public void setHost(boolean isHost) {
|
public void setHost(boolean isHost){
|
||||||
this.isHost = isHost;
|
this.isHost = isHost;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -330,7 +329,7 @@ public void received(PlayCardMessage msg) {
|
|||||||
* @param msg the PossibleCard message received
|
* @param msg the PossibleCard message received
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(PossibleCardsMessage msg) {
|
public void received(PossibleCardMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -413,7 +412,7 @@ public void received(ShutdownMessage msg) {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(IncorrectRequestMessage msg) {
|
public void received(IncorrectRequestMessage msg) {
|
||||||
addNotification(new InfoNotification(Resources.stringLookup("incorrect.request." + msg.getId())));
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -481,14 +480,14 @@ public void received(SelectPieceMessage msg) {
|
|||||||
*
|
*
|
||||||
* @param pieceId the pieceID
|
* @param pieceId the pieceID
|
||||||
*/
|
*/
|
||||||
public void selectPiece(UUID pieceId) {
|
public void selectPiece(UUID pieceId){
|
||||||
state.selectPiece(getPiece(pieceId));
|
state.selectPiece(getPiece(pieceId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method call the method selectNExt of the state
|
* This method call the method selectNExt of the state
|
||||||
*/
|
*/
|
||||||
public void selectNext() {
|
public void selectNext(){
|
||||||
state.selectNext();
|
state.selectNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -497,7 +496,7 @@ public void selectNext() {
|
|||||||
*
|
*
|
||||||
* @param card the BonusCard to selected
|
* @param card the BonusCard to selected
|
||||||
*/
|
*/
|
||||||
public void selectCard(BonusCard card) {
|
public void selectCard(BonusCard card){
|
||||||
state.selectCard(card);
|
state.selectCard(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -506,7 +505,7 @@ public void selectCard(BonusCard card) {
|
|||||||
*
|
*
|
||||||
* @param color the Color to be selected
|
* @param color the Color to be selected
|
||||||
*/
|
*/
|
||||||
public void selectTsk(Color color) {
|
public void selectTsk(Color color){
|
||||||
state.selectTSK(color);
|
state.selectTSK(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -515,14 +514,14 @@ public void selectTsk(Color color) {
|
|||||||
*
|
*
|
||||||
* @param color the color to be deselcted
|
* @param color the color to be deselcted
|
||||||
*/
|
*/
|
||||||
public void deselectTSK(Color color) {
|
public void deselectTSK(Color color){
|
||||||
state.deselectTSK(color);
|
state.deselectTSK(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method calls the selectDice method of the state
|
* This method calls the selectDice method of the state
|
||||||
*/
|
*/
|
||||||
public void selectDice() {
|
public void selectDice(){
|
||||||
state.selectDice();
|
state.selectDice();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -531,7 +530,7 @@ public void selectDice() {
|
|||||||
*
|
*
|
||||||
* @param name the name to be set
|
* @param name the name to be set
|
||||||
*/
|
*/
|
||||||
public void selectName(String name) {
|
public void selectName(String name){
|
||||||
state.setName(name);
|
state.setName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -540,8 +539,8 @@ public void selectName(String name) {
|
|||||||
*
|
*
|
||||||
* @param ready the value if this method should ready or unready
|
* @param ready the value if this method should ready or unready
|
||||||
*/
|
*/
|
||||||
public void selectReady(boolean ready) {
|
public void selectReady(boolean ready){
|
||||||
if (ready) {
|
if(ready){
|
||||||
state.selectReady();
|
state.selectReady();
|
||||||
} else {
|
} else {
|
||||||
state.selectUnready();
|
state.selectUnready();
|
||||||
@@ -553,14 +552,14 @@ public void selectReady(boolean ready) {
|
|||||||
*
|
*
|
||||||
* @param name the name of the player hosting
|
* @param name the name of the player hosting
|
||||||
*/
|
*/
|
||||||
public void selectHost(String name) {
|
public void selectHost(String name){
|
||||||
state.selectHost(name);
|
state.selectHost(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method calls the selectLeave method of the state
|
* This method calls the selectLeave method of the state
|
||||||
*/
|
*/
|
||||||
public void selectLeave() {
|
public void selectLeave(){
|
||||||
state.selectLeave();
|
state.selectLeave();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -569,28 +568,28 @@ public void selectLeave() {
|
|||||||
*
|
*
|
||||||
* @param ip the ip to cennect to
|
* @param ip the ip to cennect to
|
||||||
*/
|
*/
|
||||||
public void selectJoin(String ip) {
|
public void selectJoin(String ip){
|
||||||
state.selectJoin(ip);
|
state.selectJoin(ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method calls the selectAnimationEnd method of the state
|
* This method calls the selectAnimationEnd method of the state
|
||||||
*/
|
*/
|
||||||
public void selectAnimationEnd() {
|
public void selectAnimationEnd(){
|
||||||
state.selectAnimationEnd();
|
state.selectAnimationEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method calls the selectStart method of the state
|
* This method calls the selectStart method of the state
|
||||||
*/
|
*/
|
||||||
public void selectStart() {
|
public void selectStart(){
|
||||||
state.selectStart();
|
state.selectStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method calls the selectResume method of the state
|
* This method calls the selectResume method of the state
|
||||||
*/
|
*/
|
||||||
public void selectResume() {
|
public void selectResume(){
|
||||||
state.selectResume();
|
state.selectResume();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -599,7 +598,7 @@ public void selectResume() {
|
|||||||
*
|
*
|
||||||
* @param state the new state
|
* @param state the new state
|
||||||
*/
|
*/
|
||||||
public void setState(ClientState state) {
|
public void setState(ClientState state){
|
||||||
this.state.exit();
|
this.state.exit();
|
||||||
state.enter();
|
state.enter();
|
||||||
this.state = state;
|
this.state = state;
|
||||||
@@ -608,7 +607,7 @@ public void setState(ClientState state) {
|
|||||||
/**
|
/**
|
||||||
* This method is used to enter the interrupt state and save the previous state
|
* This method is used to enter the interrupt state and save the previous state
|
||||||
*/
|
*/
|
||||||
public void enterInterrupt() {
|
public void enterInterrupt(){
|
||||||
interruptState.enter();
|
interruptState.enter();
|
||||||
interruptState.setPreviousState(state);
|
interruptState.setPreviousState(state);
|
||||||
this.state = interruptState;
|
this.state = interruptState;
|
||||||
@@ -619,7 +618,7 @@ public void enterInterrupt() {
|
|||||||
*
|
*
|
||||||
* @return the GameState
|
* @return the GameState
|
||||||
*/
|
*/
|
||||||
public GameState getGameState() {
|
public GameState getGameState(){
|
||||||
return gameState;
|
return gameState;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -628,7 +627,7 @@ public GameState getGameState() {
|
|||||||
*
|
*
|
||||||
* @return the CeremonyState
|
* @return the CeremonyState
|
||||||
*/
|
*/
|
||||||
public CeremonyState getCeremony() {
|
public CeremonyState getCeremony(){
|
||||||
return ceremonyState;
|
return ceremonyState;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -637,7 +636,7 @@ public CeremonyState getCeremony() {
|
|||||||
*
|
*
|
||||||
* @return the InterruptState
|
* @return the InterruptState
|
||||||
*/
|
*/
|
||||||
public InterruptState getInterrupt() {
|
public InterruptState getInterrupt(){
|
||||||
return interruptState;
|
return interruptState;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -646,7 +645,7 @@ public InterruptState getInterrupt() {
|
|||||||
*
|
*
|
||||||
* @return the DialogsState
|
* @return the DialogsState
|
||||||
*/
|
*/
|
||||||
public DialogsState getDialogs() {
|
public DialogsState getDialogs(){
|
||||||
return dialogsState;
|
return dialogsState;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -655,7 +654,7 @@ public DialogsState getDialogs() {
|
|||||||
*
|
*
|
||||||
* @return the SettingsState
|
* @return the SettingsState
|
||||||
*/
|
*/
|
||||||
public SettingsState getSettings() {
|
public SettingsState getSettings(){
|
||||||
return settingsState;
|
return settingsState;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -664,8 +663,8 @@ public SettingsState getSettings() {
|
|||||||
*
|
*
|
||||||
* @return the next notification
|
* @return the next notification
|
||||||
*/
|
*/
|
||||||
public Notification getNotification() {
|
public Notification getNotification(){
|
||||||
if (!notifications.isEmpty()) {
|
if(!notifications.isEmpty()){
|
||||||
return notifications.remove(0);
|
return notifications.remove(0);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
@@ -677,7 +676,7 @@ public Notification getNotification() {
|
|||||||
*
|
*
|
||||||
* @param notification the notification to be added
|
* @param notification the notification to be added
|
||||||
*/
|
*/
|
||||||
public void addNotification(Notification notification) {
|
public void addNotification(Notification notification){
|
||||||
notifications.add(notification);
|
notifications.add(notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ public void received(PlayCardMessage msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(PossibleCardsMessage msg) {
|
public void received(PossibleCardMessage msg) {
|
||||||
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
|
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package pp.mdga.client;
|
package pp.mdga.client;
|
||||||
|
|
||||||
import pp.mdga.client.dialogstate.DialogStates;
|
import pp.mdga.client.dialogState.DialogStates;
|
||||||
import pp.mdga.client.dialogstate.LobbyState;
|
import pp.mdga.client.dialogState.LobbyState;
|
||||||
import pp.mdga.client.dialogstate.NetworkDialogState;
|
import pp.mdga.client.dialogState.NetworkDialogState;
|
||||||
import pp.mdga.client.dialogstate.StartDialogState;
|
import pp.mdga.client.dialogState.StartDialogState;
|
||||||
import pp.mdga.game.Color;
|
import pp.mdga.game.Color;
|
||||||
import pp.mdga.message.server.*;
|
import pp.mdga.message.server.*;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package pp.mdga.client;
|
package pp.mdga.client;
|
||||||
|
|
||||||
import pp.mdga.client.gamestate.*;
|
import pp.mdga.client.gameState.*;
|
||||||
import pp.mdga.game.BonusCard;
|
import pp.mdga.game.BonusCard;
|
||||||
import pp.mdga.game.Piece;
|
import pp.mdga.game.Piece;
|
||||||
import pp.mdga.message.client.LeaveGameMessage;
|
import pp.mdga.message.client.LeaveGameMessage;
|
||||||
@@ -241,7 +241,7 @@ public void received(DiceAgainMessage msg){
|
|||||||
* @param msg the message to be received
|
* @param msg the message to be received
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(PossibleCardsMessage msg){
|
public void received(PossibleCardMessage msg){
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package pp.mdga.client;
|
package pp.mdga.client;
|
||||||
|
|
||||||
import pp.mdga.client.settingsstate.AudioSettingsState;
|
import pp.mdga.client.settingsState.AudioSettingsState;
|
||||||
import pp.mdga.client.settingsstate.MainSettingsState;
|
import pp.mdga.client.settingsState.MainSettingsState;
|
||||||
import pp.mdga.client.settingsstate.SettingStates;
|
import pp.mdga.client.settingsState.SettingStates;
|
||||||
import pp.mdga.client.settingsstate.VideoSettingsState;
|
import pp.mdga.client.settingsState.VideoSettingsState;
|
||||||
|
|
||||||
public class SettingsState extends ClientState {
|
public class SettingsState extends ClientState {
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package pp.mdga.client.ceremonystate;
|
package pp.mdga.client.ceremonyState;
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
import pp.mdga.client.ClientGameLogic;
|
||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package pp.mdga.client.ceremonystate;
|
package pp.mdga.client.ceremonyState;
|
||||||
|
|
||||||
import pp.mdga.client.CeremonyState;
|
import pp.mdga.client.CeremonyState;
|
||||||
import pp.mdga.client.ClientGameLogic;
|
import pp.mdga.client.ClientGameLogic;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package pp.mdga.client.ceremonystate;
|
package pp.mdga.client.ceremonyState;
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
import pp.mdga.client.ClientGameLogic;
|
||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package pp.mdga.client.dialogstate;
|
package pp.mdga.client.dialogState;
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
import pp.mdga.client.ClientGameLogic;
|
||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package pp.mdga.client.dialogstate;
|
package pp.mdga.client.dialogState;
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
import pp.mdga.client.ClientGameLogic;
|
||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
@@ -6,14 +6,16 @@
|
|||||||
import pp.mdga.game.Color;
|
import pp.mdga.game.Color;
|
||||||
import pp.mdga.game.Piece;
|
import pp.mdga.game.Piece;
|
||||||
import pp.mdga.game.Player;
|
import pp.mdga.game.Player;
|
||||||
|
import pp.mdga.game.PlayerData;
|
||||||
import pp.mdga.message.client.*;
|
import pp.mdga.message.client.*;
|
||||||
import pp.mdga.message.server.*;
|
import pp.mdga.message.server.LobbyPlayerJoinedMessage;
|
||||||
|
import pp.mdga.message.server.LobbyPlayerLeaveMessage;
|
||||||
|
import pp.mdga.message.server.ServerStartGameMessage;
|
||||||
|
import pp.mdga.message.server.UpdateReadyMessage;
|
||||||
|
import pp.mdga.message.server.UpdateTSKMessage;
|
||||||
import pp.mdga.notification.*;
|
import pp.mdga.notification.*;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class LobbyState extends DialogStates {
|
public class LobbyState extends DialogStates {
|
||||||
|
|
||||||
@@ -56,47 +58,41 @@ public void selectReady() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void selectUnready() {
|
public void selectUnready(){
|
||||||
logic.send(new LobbyNotReadyMessage());
|
logic.send(new LobbyNotReadyMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void selectStart() {
|
public void selectStart(){
|
||||||
if (logic.isHost() && logic.getGame().areAllReady()) {
|
if(logic.isHost() && logic.getGame().areAllReady()){
|
||||||
logic.send(new StartGameMessage());
|
logic.send(new StartGameMessage(false));
|
||||||
|
} else if(logic.isHost() && !logic.getGame().areAllReady()) {
|
||||||
|
logic.send(new StartGameMessage(true));
|
||||||
} else {
|
} else {
|
||||||
logic.send(new StartGameMessage());
|
|
||||||
LOGGER.log(System.Logger.Level.ERROR, "You are not the host");
|
LOGGER.log(System.Logger.Level.ERROR, "You are not the host");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(ServerStartGameMessage msg) {
|
public void received(ServerStartGameMessage msg){
|
||||||
for (Player player: msg.getPlayers()) {
|
|
||||||
for (Map.Entry<Integer, Player> entry: this.logic.getGame().getPlayers().entrySet()) {
|
|
||||||
if (entry.getValue().getColor() == player.getColor()) {
|
|
||||||
this.logic.getGame().getPlayers().put(entry.getKey(), player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logic.getGame().setBoard(msg.getBoard());
|
logic.getGame().setBoard(msg.getBoard());
|
||||||
logic.addNotification(new GameNotification(logic.getGame().getPlayerById(logic.getOwnPlayerId()).getColor()));
|
logic.addNotification(new GameNotification(logic.getGame().getPlayerById(logic.getOwnPlayerId()).getColor()));
|
||||||
for (var player : logic.getGame().getPlayers().values()) {
|
for (Map.Entry<Integer, Player> entry : logic.getGame().getPlayers().entrySet()) {
|
||||||
List<UUID> pieces = new ArrayList<>();
|
List<UUID> pieces = new ArrayList<>();
|
||||||
for (Piece piece : player.getPieces()) {
|
for (Piece piece : logic.getGame().getBoard().getPlayerData().get(entry.getValue().getColor()).getPieces()) {
|
||||||
pieces.add(piece.getUuid());
|
pieces.add(piece.getUuid());
|
||||||
}
|
}
|
||||||
logic.addNotification(new PlayerInGameNotification(player.getColor(), pieces, player.getName()));
|
logic.addNotification(new PlayerInGameNotification(entry.getValue().getColor(), pieces, entry.getValue().getName()));
|
||||||
}
|
}
|
||||||
logic.setState(logic.getGameState());
|
logic.setState(logic.getGameState());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(LobbyPlayerJoinedMessage msg) {
|
public void received(LobbyPlayerJoinedMessage msg){
|
||||||
if (msg.getPlayer().getName().equals(logic.getOwnPlayerName())) {
|
if(msg.getPlayer().getName().equals(logic.getOwnPlayerName())){
|
||||||
logic.setOwnPlayerId(msg.getId());
|
logic.setOwnPlayerId(msg.getId());
|
||||||
}
|
}
|
||||||
if (msg.isHost() && msg.getId() == logic.getOwnPlayerId()) {
|
if (msg.isHost() && msg.getId() == logic.getOwnPlayerId()){
|
||||||
logic.setHost(true);
|
logic.setHost(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,9 +101,9 @@ public void received(LobbyPlayerJoinedMessage msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(UpdateTSKMessage msg) {
|
public void received(UpdateTSKMessage msg){
|
||||||
if (msg.isTaken()) {
|
if(msg.isTaken()) {
|
||||||
logic.addNotification(new TskSelectNotification(msg.getColor(), logic.getGame().getPlayers().get(msg.getId()).getName(), logic.getOwnPlayerId() == msg.getId()));
|
logic.addNotification(new TskSelectNotification(msg.getColor(), logic.getGame().getPlayers().get(msg.getId()).getName(), logic.getOwnPlayerId()== msg.getId()));
|
||||||
} else {
|
} else {
|
||||||
logic.addNotification(new TskUnselectNotification(logic.getGame().getPlayers().get(msg.getId()).getColor()));
|
logic.addNotification(new TskUnselectNotification(logic.getGame().getPlayers().get(msg.getId()).getColor()));
|
||||||
}
|
}
|
||||||
@@ -116,13 +112,13 @@ public void received(UpdateTSKMessage msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(LobbyPlayerLeaveMessage msg) {
|
public void received(LobbyPlayerLeaveMessage msg){
|
||||||
logic.addNotification(new TskUnselectNotification(logic.getGame().getPlayers().get(msg.getId()).getColor()));
|
logic.addNotification(new TskUnselectNotification(logic.getGame().getPlayers().get(msg.getId()).getColor()));
|
||||||
logic.getGame().getPlayers().remove(msg.getId());
|
logic.getGame().getPlayers().remove(msg.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(UpdateReadyMessage msg) {
|
public void received(UpdateReadyMessage msg){
|
||||||
//TODO server sendet kein update on UNready
|
//TODO server sendet kein update on UNready
|
||||||
logic.addNotification(new LobbyReadyNotification(logic.getGame().getPlayers().get(msg.getPlayerId()).getColor(), msg.isReady()));
|
logic.addNotification(new LobbyReadyNotification(logic.getGame().getPlayers().get(msg.getPlayerId()).getColor(), msg.isReady()));
|
||||||
logic.getGame().getPlayers().get(msg.getPlayerId()).setReady(msg.isReady());
|
logic.getGame().getPlayers().get(msg.getPlayerId()).setReady(msg.isReady());
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package pp.mdga.client.dialogstate;
|
package pp.mdga.client.dialogState;
|
||||||
|
|
||||||
import pp.mdga.Resources;
|
import pp.mdga.Resources;
|
||||||
import pp.mdga.client.ClientGameLogic;
|
import pp.mdga.client.ClientGameLogic;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package pp.mdga.client.dialogstate;
|
package pp.mdga.client.dialogState;
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
import pp.mdga.client.ClientGameLogic;
|
||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package pp.mdga.client.gamestate;
|
package pp.mdga.client.gameState;
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
import pp.mdga.client.ClientGameLogic;
|
||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
@@ -1,14 +1,11 @@
|
|||||||
package pp.mdga.client.gamestate;
|
package pp.mdga.client.gameState;
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
import pp.mdga.client.ClientGameLogic;
|
||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
import pp.mdga.client.GameState;
|
import pp.mdga.client.GameState;
|
||||||
import pp.mdga.client.gamestate.determinestartplayerstate.DetermineStartPlayerStates;
|
import pp.mdga.client.gameState.determineStartPlayerState.DetermineStartPlayerStates;
|
||||||
import pp.mdga.client.gamestate.determinestartplayerstate.Intro;
|
import pp.mdga.client.gameState.determineStartPlayerState.RollRankingDiceState;
|
||||||
import pp.mdga.client.gamestate.determinestartplayerstate.RollRankingDiceState;
|
import pp.mdga.client.gameState.determineStartPlayerState.WaitRankingState;
|
||||||
import pp.mdga.client.gamestate.determinestartplayerstate.WaitRankingState;
|
|
||||||
import pp.mdga.message.client.AnimationEndMessage;
|
|
||||||
import pp.mdga.message.server.ActivePlayerMessage;
|
|
||||||
import pp.mdga.message.server.DieMessage;
|
import pp.mdga.message.server.DieMessage;
|
||||||
import pp.mdga.message.server.RankingResponseMessage;
|
import pp.mdga.message.server.RankingResponseMessage;
|
||||||
import pp.mdga.message.server.RankingRollAgainMessage;
|
import pp.mdga.message.server.RankingRollAgainMessage;
|
||||||
@@ -20,33 +17,12 @@ public class DetermineStartPlayerState extends GameStates {
|
|||||||
|
|
||||||
private final RollRankingDiceState rollRankingDiceState = new RollRankingDiceState(this, logic);
|
private final RollRankingDiceState rollRankingDiceState = new RollRankingDiceState(this, logic);
|
||||||
private final WaitRankingState waitRankingState = new WaitRankingState(this, logic);
|
private final WaitRankingState waitRankingState = new WaitRankingState(this, logic);
|
||||||
private final Intro intro = new Intro(this, logic);
|
|
||||||
|
|
||||||
public DetermineStartPlayerState(ClientState parent, ClientGameLogic logic) {
|
public DetermineStartPlayerState(ClientState parent, ClientGameLogic logic) {
|
||||||
super(parent, logic);
|
super(parent, logic);
|
||||||
this.parent = (GameState) parent;
|
this.parent = (GameState) parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RollRankingDiceState getRollRankingDice() {
|
|
||||||
return rollRankingDiceState;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WaitRankingState getWaitRanking() {
|
|
||||||
return waitRankingState;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DetermineStartPlayerStates getState(){
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Intro getIntro(){
|
|
||||||
return intro;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GameState getParent() {
|
|
||||||
return parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enter() {
|
public void enter() {
|
||||||
this.setState(this.rollRankingDiceState);
|
this.setState(this.rollRankingDiceState);
|
||||||
@@ -70,11 +46,6 @@ public void selectDice() {
|
|||||||
state.selectDice();
|
state.selectDice();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void selectAnimationEnd(){
|
|
||||||
state.selectAnimationEnd();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(DieMessage msg){
|
public void received(DieMessage msg){
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
@@ -90,8 +61,19 @@ public void received(RankingResponseMessage msg){
|
|||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public RollRankingDiceState getRollRankingDice() {
|
||||||
public void received(ActivePlayerMessage msg){
|
return rollRankingDiceState;
|
||||||
state.received(msg);
|
}
|
||||||
|
|
||||||
|
public WaitRankingState getWaitRanking() {
|
||||||
|
return waitRankingState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DetermineStartPlayerStates getState(){
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GameState getParent() {
|
||||||
|
return parent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package pp.mdga.client.gamestate;
|
package pp.mdga.client.gameState;
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
import pp.mdga.client.ClientGameLogic;
|
||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
@@ -12,45 +12,39 @@
|
|||||||
import pp.mdga.notification.SwapPieceNotification;
|
import pp.mdga.notification.SwapPieceNotification;
|
||||||
import pp.mdga.notification.ThrowPieceNotification;
|
import pp.mdga.notification.ThrowPieceNotification;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public abstract class GameStates extends ClientState {
|
public abstract class GameStates extends ClientState {
|
||||||
public GameStates(ClientState parent, ClientGameLogic logic) {
|
public GameStates(ClientState parent, ClientGameLogic logic) {
|
||||||
super(parent, logic);
|
super(parent, logic);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void handlePowerCard(PlayCardMessage msg) {
|
protected void handlePowerCard(PlayCardMessage msg){
|
||||||
if (msg.getCard().getCard().equals(BonusCard.TURBO)) {
|
if (msg.getCard().equals(BonusCard.TURBO)){
|
||||||
logic.getGame().setDiceModifier(msg.getDiceModifier());
|
logic.getGame().setDiceModifier(msg.getDiceModifier());
|
||||||
} else if (msg.getCard().getCard().equals(BonusCard.SHIELD)) {
|
} else if (msg.getCard().equals(BonusCard.SHIELD)){
|
||||||
handleShield(msg.getPieces().get(0).getUuid());
|
if (logic.getGame().getBoard().getInfieldIndexOfPiece(logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier())) % 10 != 0) {
|
||||||
|
logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).setShield(ShieldState.SUPPRESSED);
|
||||||
|
logic.addNotification(new ShieldSuppressedNotification(logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).getUuid()));
|
||||||
|
} else {
|
||||||
|
logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).setShield(ShieldState.ACTIVE);
|
||||||
|
logic.addNotification(new ShieldActiveNotification(logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).getUuid()));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Piece ownPiece = logic.getGame().getPieceThroughUUID(msg.getPieces().get(0).getUuid());
|
Piece ownPiece = logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier());
|
||||||
Piece enemyPiece = logic.getGame().getPieceThroughUUID(msg.getPieces().get(1).getUuid());
|
Piece enemyPiece = logic.getGame().getPieceThroughUUID(msg.getPieceIdentifierEnemy());
|
||||||
int ownIndex = logic.getGame().getBoard().getInfieldIndexOfPiece(ownPiece);
|
int ownIndex = logic.getGame().getBoard().getInfieldIndexOfPiece(ownPiece);
|
||||||
logic.addNotification(new SwapPieceNotification(ownPiece.getUuid(), enemyPiece.getUuid()));
|
logic.addNotification(new SwapPieceNotification(ownPiece.getUuid(), enemyPiece.getUuid()));
|
||||||
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(enemyPiece)].setOccupant(ownPiece);
|
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(enemyPiece)].setOccupant(ownPiece);
|
||||||
logic.getGame().getBoard().getInfield()[ownIndex].setOccupant(enemyPiece);
|
logic.getGame().getBoard().getInfield()[ownIndex].setOccupant(enemyPiece);
|
||||||
}
|
}
|
||||||
logic.getGame().getDiscardPile().add(msg.getCard());
|
logic.getGame().getDiscardPile().add(logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).removeHandCard(msg.getCard()));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void throwPiece(Piece piece) {
|
protected void throwPiece(Piece piece){
|
||||||
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant();
|
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant();
|
||||||
logic.getGame().getPlayerByColor(piece.getColor()).addWaitingPiece(piece);
|
logic.getGame().getBoard().getPlayerData().get(piece.getColor()).addWaitingPiece(piece);
|
||||||
logic.addNotification(new ThrowPieceNotification(piece.getUuid()));
|
// logic.addNotification(new ThrowPieceNotification(piece.getUuid()));
|
||||||
logic.getGame().getPlayerByColor(piece.getColor()).getPlayerStatistic().increasePiecesBeingThrown();
|
logic.getGame().getPlayerByColor(piece.getColor()).getPlayerStatistic().increasePiecesBeingThrown();
|
||||||
logic.getGame().getGameStatistics().increasePiecesBeingThrown();
|
logic.getGame().getGameStatistics().increasePiecesBeingThrown();
|
||||||
piece.setState(PieceState.WAITING);
|
piece.setState(PieceState.WAITING);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleShield(UUID uuid) {
|
|
||||||
if (logic.getGame().getBoard().getInfieldIndexOfPiece(logic.getGame().getPieceThroughUUID(uuid)) % 10 != 0) {
|
|
||||||
logic.getGame().getPieceThroughUUID(uuid).setShield(ShieldState.SUPPRESSED);
|
|
||||||
logic.addNotification(new ShieldSuppressedNotification(uuid));
|
|
||||||
} else {
|
|
||||||
logic.getGame().getPieceThroughUUID(uuid).setShield(ShieldState.ACTIVE);
|
|
||||||
logic.addNotification(new ShieldActiveNotification(uuid));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,14 +1,11 @@
|
|||||||
package pp.mdga.client.gamestate;
|
package pp.mdga.client.gameState;
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
import pp.mdga.client.ClientGameLogic;
|
||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
import pp.mdga.client.GameState;
|
import pp.mdga.client.GameState;
|
||||||
import pp.mdga.game.Piece;
|
import pp.mdga.game.Piece;
|
||||||
import pp.mdga.message.server.*;
|
import pp.mdga.message.server.*;
|
||||||
import pp.mdga.notification.ActivePlayerNotification;
|
import pp.mdga.notification.*;
|
||||||
import pp.mdga.notification.HomeMoveNotification;
|
|
||||||
import pp.mdga.notification.MovePieceNotification;
|
|
||||||
import pp.mdga.notification.PlayCardNotification;
|
|
||||||
|
|
||||||
public class SpectatorState extends GameStates {
|
public class SpectatorState extends GameStates {
|
||||||
|
|
||||||
@@ -30,15 +27,15 @@ public void exit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(CeremonyMessage msg) {
|
public void received(CeremonyMessage msg){
|
||||||
logic.setState(logic.getCeremony());
|
logic.setState(logic.getCeremony());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(DieMessage msg) {
|
public void received(DieMessage msg){
|
||||||
//logic.getGame().setDiceEyes(msg.getDiceEye());
|
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) {
|
if(msg.getDiceEye() == 6){
|
||||||
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseDiced6();
|
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseDiced6();
|
||||||
logic.getGame().getGameStatistics().increaseDiced6();
|
logic.getGame().getGameStatistics().increaseDiced6();
|
||||||
}
|
}
|
||||||
@@ -46,8 +43,8 @@ public void received(DieMessage msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(PlayCardMessage msg) {
|
public void received(PlayCardMessage msg){
|
||||||
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard().getCard()));
|
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard()));
|
||||||
handlePowerCard(msg);
|
handlePowerCard(msg);
|
||||||
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseCardsPlayed();
|
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseCardsPlayed();
|
||||||
logic.getGame().getGameStatistics().increaseCardsPlayed();
|
logic.getGame().getGameStatistics().increaseCardsPlayed();
|
||||||
@@ -55,26 +52,26 @@ public void received(PlayCardMessage msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(ActivePlayerMessage msg) {
|
public void received(ActivePlayerMessage msg){
|
||||||
logic.addNotification(new ActivePlayerNotification(msg.getColor()));
|
logic.addNotification(new ActivePlayerNotification(msg.getColor()));
|
||||||
logic.getGame().setActiveColor(msg.getColor());
|
logic.getGame().setActiveColor(msg.getColor());
|
||||||
parent.setState(parent.getAnimation());
|
parent.setState(parent.getAnimation());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(MoveMessage msg) {
|
public void received(MoveMessage msg){
|
||||||
Piece pieceToMove = logic.getGame().getPieceThroughUUID(msg.getIdentifier());
|
Piece pieceToMove = logic.getGame().getPieceThroughUUID(msg.getIdentifier());
|
||||||
if (msg.isHomeMove()) {
|
if (msg.isHomeMove()){
|
||||||
logic.addNotification(new HomeMoveNotification(pieceToMove.getUuid(), msg.getTargetIndex()));
|
logic.addNotification(new HomeMoveNotification(pieceToMove.getUuid(), msg.getTargetIndex()));
|
||||||
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)].clearOccupant();
|
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)].clearOccupant();
|
||||||
logic.getGame().getPlayerByColor(pieceToMove.getColor()).setPieceInHome(msg.getTargetIndex(), pieceToMove);
|
logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).setPieceInHome(msg.getTargetIndex(), pieceToMove);
|
||||||
} else {
|
} else {
|
||||||
if (logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].isOccupied()) {
|
if (logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].isOccupied()) {
|
||||||
throwPiece(logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant());
|
throwPiece(logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant());
|
||||||
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increasePiecesThrown();
|
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increasePiecesThrown();
|
||||||
logic.getGame().getGameStatistics().increasePiecesThrown();
|
logic.getGame().getGameStatistics().increasePiecesThrown();
|
||||||
}
|
}
|
||||||
if (logic.getGame().getPlayerByColor(pieceToMove.getColor()).getStartNodeIndex() == logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)) {
|
if(logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).getStartNodeIndex() == logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)){
|
||||||
logic.addNotification(new MovePieceNotification(pieceToMove.getUuid(), msg.getTargetIndex(), true));
|
logic.addNotification(new MovePieceNotification(pieceToMove.getUuid(), msg.getTargetIndex(), true));
|
||||||
logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(pieceToMove);
|
logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(pieceToMove);
|
||||||
} else {
|
} else {
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
package pp.mdga.client.gamestate;
|
package pp.mdga.client.gameState;
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
import pp.mdga.client.ClientGameLogic;
|
||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
import pp.mdga.client.GameState;
|
import pp.mdga.client.GameState;
|
||||||
import pp.mdga.client.gamestate.turnstate.ChoosePieceState;
|
import pp.mdga.client.gameState.turnState.ChoosePieceState;
|
||||||
import pp.mdga.client.gamestate.turnstate.MovePieceState;
|
import pp.mdga.client.gameState.turnState.MovePieceState;
|
||||||
import pp.mdga.client.gamestate.turnstate.PlayPowerCardState;
|
import pp.mdga.client.gameState.turnState.PlayPowerCardState;
|
||||||
import pp.mdga.client.gamestate.turnstate.PowerCardState;
|
import pp.mdga.client.gameState.turnState.PowerCardState;
|
||||||
import pp.mdga.client.gamestate.turnstate.RollDiceState;
|
import pp.mdga.client.gameState.turnState.RollDiceState;
|
||||||
import pp.mdga.client.gamestate.turnstate.TurnStates;
|
import pp.mdga.client.gameState.turnState.TurnStates;
|
||||||
import pp.mdga.game.BonusCard;
|
import pp.mdga.game.BonusCard;
|
||||||
import pp.mdga.game.Piece;
|
import pp.mdga.game.Piece;
|
||||||
import pp.mdga.message.server.*;
|
import pp.mdga.message.server.*;
|
||||||
@@ -108,7 +108,7 @@ public void received(DiceAgainMessage msg){
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(PossibleCardsMessage msg){
|
public void received(PossibleCardMessage msg){
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
package pp.mdga.client.gamestate;
|
package pp.mdga.client.gameState;
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
import pp.mdga.client.ClientGameLogic;
|
||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
import pp.mdga.client.GameState;
|
import pp.mdga.client.GameState;
|
||||||
import pp.mdga.game.Piece;
|
import pp.mdga.game.*;
|
||||||
import pp.mdga.game.PieceState;
|
|
||||||
import pp.mdga.message.server.*;
|
import pp.mdga.message.server.*;
|
||||||
import pp.mdga.notification.*;
|
import pp.mdga.notification.*;
|
||||||
|
|
||||||
@@ -28,21 +27,21 @@ public void exit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(CeremonyMessage msg) {
|
public void received(CeremonyMessage msg){
|
||||||
logic.setState(logic.getCeremony());
|
logic.setState(logic.getCeremony());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(DiceNowMessage msg) {
|
public void received(DiceNowMessage msg){
|
||||||
logic.addNotification(new DiceNowNotification());
|
logic.addNotification(new DiceNowNotification());
|
||||||
parent.setState(parent.getTurn());
|
parent.setState(parent.getTurn());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(DieMessage msg) {
|
public void received(DieMessage msg){
|
||||||
logic.getGame().setDiceEyes(msg.getDiceEye());
|
logic.getGame().setDiceEyes(msg.getDiceEye());
|
||||||
logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes()));
|
// logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes(), logic.getGame().getDiceEyes() * logic.getGame().getDiceModifier()));
|
||||||
if (msg.getDiceEye() == 6) {
|
if(msg.getDiceEye() == 6){
|
||||||
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseDiced6();
|
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseDiced6();
|
||||||
logic.getGame().getGameStatistics().increaseDiced6();
|
logic.getGame().getGameStatistics().increaseDiced6();
|
||||||
}
|
}
|
||||||
@@ -50,8 +49,8 @@ public void received(DieMessage msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(PlayCardMessage msg) {
|
public void received(PlayCardMessage msg){
|
||||||
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard().getCard()));
|
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard()));
|
||||||
handlePowerCard(msg);
|
handlePowerCard(msg);
|
||||||
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseCardsPlayed();
|
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseCardsPlayed();
|
||||||
logic.getGame().getGameStatistics().increaseCardsPlayed();
|
logic.getGame().getGameStatistics().increaseCardsPlayed();
|
||||||
@@ -59,21 +58,21 @@ public void received(PlayCardMessage msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(ActivePlayerMessage msg) {
|
public void received(ActivePlayerMessage msg){
|
||||||
logic.addNotification(new ActivePlayerNotification(msg.getColor()));
|
logic.addNotification(new ActivePlayerNotification(msg.getColor()));
|
||||||
logic.getGame().setActiveColor(msg.getColor());
|
logic.getGame().setActiveColor(msg.getColor());
|
||||||
parent.setState(parent.getAnimation());
|
parent.setState(parent.getAnimation());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(MoveMessage msg) {
|
public void received(MoveMessage msg){
|
||||||
Piece pieceToMove = logic.getGame().getPieceThroughUUID(msg.getIdentifier());
|
Piece pieceToMove = logic.getGame().getPieceThroughUUID(msg.getIdentifier());
|
||||||
if (msg.isHomeMove()) {
|
if (msg.isHomeMove()){
|
||||||
logic.addNotification(new HomeMoveNotification(pieceToMove.getUuid(), msg.getTargetIndex()));
|
logic.addNotification(new HomeMoveNotification(pieceToMove.getUuid(), msg.getTargetIndex()));
|
||||||
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)].clearOccupant();
|
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)].clearOccupant();
|
||||||
logic.getGame().getPlayerByColor(pieceToMove.getColor()).setPieceInHome(msg.getTargetIndex(), pieceToMove);
|
logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).setPieceInHome(msg.getTargetIndex(), pieceToMove);
|
||||||
for (int i = msg.getTargetIndex() + 1; i < 4; i++) {
|
for(int i = msg.getTargetIndex() + 1; i < 4; i++){
|
||||||
if (!logic.getGame().getPlayerByColor(pieceToMove.getColor()).getHomeNodes()[i].isOccupied()) {
|
if(!logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).getHomeNodes()[i].isOccupied()){
|
||||||
pieceToMove.setState(PieceState.HOME);
|
pieceToMove.setState(PieceState.HOME);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -85,7 +84,7 @@ public void received(MoveMessage msg) {
|
|||||||
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increasePiecesThrown();
|
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increasePiecesThrown();
|
||||||
logic.getGame().getGameStatistics().increasePiecesThrown();
|
logic.getGame().getGameStatistics().increasePiecesThrown();
|
||||||
}
|
}
|
||||||
if (logic.getGame().getPlayerByColor(pieceToMove.getColor()).getStartNodeIndex() == logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)) {
|
if(logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).getStartNodeIndex() == logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)){
|
||||||
logic.addNotification(new MovePieceNotification(pieceToMove.getUuid(), msg.getTargetIndex(), true));
|
logic.addNotification(new MovePieceNotification(pieceToMove.getUuid(), msg.getTargetIndex(), true));
|
||||||
logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(pieceToMove);
|
logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(pieceToMove);
|
||||||
} else {
|
} else {
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package pp.mdga.client.gamestate.determinestartplayerstate;
|
package pp.mdga.client.gameState.determineStartPlayerState;
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
import pp.mdga.client.ClientGameLogic;
|
||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
import pp.mdga.client.gamestate.GameStates;
|
import pp.mdga.client.gameState.GameStates;
|
||||||
|
|
||||||
public abstract class DetermineStartPlayerStates extends GameStates {
|
public abstract class DetermineStartPlayerStates extends GameStates {
|
||||||
public DetermineStartPlayerStates(ClientState parent, ClientGameLogic logic) {
|
public DetermineStartPlayerStates(ClientState parent, ClientGameLogic logic) {
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package pp.mdga.client.gamestate.determinestartplayerstate;
|
package pp.mdga.client.gameState.determineStartPlayerState;
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
import pp.mdga.client.ClientGameLogic;
|
||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
import pp.mdga.client.gamestate.DetermineStartPlayerState;
|
import pp.mdga.client.gameState.DetermineStartPlayerState;
|
||||||
import pp.mdga.message.client.RequestDieMessage;
|
import pp.mdga.message.client.RequestDieMessage;
|
||||||
import pp.mdga.message.server.DieMessage;
|
import pp.mdga.message.server.DieMessage;
|
||||||
import pp.mdga.notification.DiceNowNotification;
|
import pp.mdga.notification.DiceNowNotification;
|
||||||
@@ -28,12 +28,13 @@ public void exit() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void selectDice(){
|
public void selectDice(){
|
||||||
|
System.out.println("selectDice");
|
||||||
logic.send(new RequestDieMessage());
|
logic.send(new RequestDieMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(DieMessage msg){
|
public void received(DieMessage msg){
|
||||||
parent.setState(parent.getWaitRanking());
|
|
||||||
logic.addNotification(new RollDiceNotification(logic.getGame().getPlayerById(logic.getOwnPlayerId()).getColor(), msg.getDiceEye(),true));
|
logic.addNotification(new RollDiceNotification(logic.getGame().getPlayerById(logic.getOwnPlayerId()).getColor(), msg.getDiceEye(),true));
|
||||||
|
parent.setState(parent.getWaitRanking());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package pp.mdga.client.gameState.determineStartPlayerState;
|
||||||
|
|
||||||
|
import pp.mdga.client.ClientGameLogic;
|
||||||
|
import pp.mdga.client.ClientState;
|
||||||
|
import pp.mdga.client.gameState.DetermineStartPlayerState;
|
||||||
|
import pp.mdga.message.server.RankingResponseMessage;
|
||||||
|
import pp.mdga.message.server.RankingRollAgainMessage;
|
||||||
|
import pp.mdga.notification.ActivePlayerNotification;
|
||||||
|
|
||||||
|
public class WaitRankingState extends DetermineStartPlayerStates {
|
||||||
|
|
||||||
|
private final DetermineStartPlayerState parent;
|
||||||
|
|
||||||
|
public WaitRankingState(ClientState parent, ClientGameLogic logic) {
|
||||||
|
super(parent, logic);
|
||||||
|
this.parent = (DetermineStartPlayerState) parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void enter() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void exit() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void received(RankingRollAgainMessage msg){
|
||||||
|
parent.setState(parent.getRollRankingDice());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void received(RankingResponseMessage msg){
|
||||||
|
logic.addNotification(new ActivePlayerNotification(logic.getGame().getPlayers().get(msg.getStartingPlayerId()).getColor()));
|
||||||
|
logic.getGame().setActiveColor(logic.getGame().getPlayers().get(msg.getStartingPlayerId()).getColor());
|
||||||
|
parent.getParent().setState(parent.getParent().getWaiting());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
package pp.mdga.client.gamestate.turnstate;
|
package pp.mdga.client.gameState.turnState;
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
import pp.mdga.client.ClientGameLogic;
|
||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
import pp.mdga.client.gamestate.TurnState;
|
import pp.mdga.client.gameState.TurnState;
|
||||||
import pp.mdga.client.gamestate.turnstate.choosepiecestate.*;
|
import pp.mdga.client.gameState.turnState.choosePieceState.*;
|
||||||
import pp.mdga.game.Piece;
|
import pp.mdga.game.Piece;
|
||||||
import pp.mdga.message.server.*;
|
import pp.mdga.message.server.*;
|
||||||
|
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package pp.mdga.client.gamestate.turnstate;
|
package pp.mdga.client.gameState.turnState;
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
import pp.mdga.client.ClientGameLogic;
|
||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
import pp.mdga.client.gamestate.TurnState;
|
import pp.mdga.client.gameState.TurnState;
|
||||||
import pp.mdga.message.client.AnimationEndMessage;
|
import pp.mdga.message.client.AnimationEndMessage;
|
||||||
import pp.mdga.message.server.*;
|
import pp.mdga.message.server.*;
|
||||||
|
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package pp.mdga.client.gamestate.turnstate;
|
package pp.mdga.client.gameState.turnState;
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
import pp.mdga.client.ClientGameLogic;
|
||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
import pp.mdga.client.gamestate.TurnState;
|
import pp.mdga.client.gameState.TurnState;
|
||||||
import pp.mdga.message.client.AnimationEndMessage;
|
import pp.mdga.message.client.AnimationEndMessage;
|
||||||
import pp.mdga.message.server.PlayCardMessage;
|
import pp.mdga.message.server.PlayCardMessage;
|
||||||
import pp.mdga.notification.PlayCardNotification;
|
import pp.mdga.notification.PlayCardNotification;
|
||||||
@@ -20,7 +20,7 @@ public PlayPowerCardState(ClientState parent, ClientGameLogic logic) {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enter() {
|
public void enter() {
|
||||||
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor() , playCardMessage.getCard().getCard()));
|
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor() , playCardMessage.getCard()));
|
||||||
handlePowerCard(playCardMessage);
|
handlePowerCard(playCardMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,17 +1,17 @@
|
|||||||
package pp.mdga.client.gamestate.turnstate;
|
package pp.mdga.client.gameState.turnState;
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
import pp.mdga.client.ClientGameLogic;
|
||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
import pp.mdga.client.gamestate.TurnState;
|
import pp.mdga.client.gameState.TurnState;
|
||||||
import pp.mdga.client.gamestate.turnstate.powercardstate.ChoosePowerCardState;
|
import pp.mdga.client.gameState.turnState.powerCardState.ChoosePowerCardState;
|
||||||
import pp.mdga.client.gamestate.turnstate.powercardstate.PowerCardStates;
|
import pp.mdga.client.gameState.turnState.powerCardState.PowerCardStates;
|
||||||
import pp.mdga.client.gamestate.turnstate.powercardstate.ShieldState;
|
import pp.mdga.client.gameState.turnState.powerCardState.ShieldState;
|
||||||
import pp.mdga.client.gamestate.turnstate.powercardstate.SwapState;
|
import pp.mdga.client.gameState.turnState.powerCardState.SwapState;
|
||||||
import pp.mdga.game.BonusCard;
|
import pp.mdga.game.BonusCard;
|
||||||
import pp.mdga.game.Piece;
|
import pp.mdga.game.Piece;
|
||||||
import pp.mdga.message.server.DiceNowMessage;
|
import pp.mdga.message.server.DiceNowMessage;
|
||||||
import pp.mdga.message.server.PlayCardMessage;
|
import pp.mdga.message.server.PlayCardMessage;
|
||||||
import pp.mdga.message.server.PossibleCardsMessage;
|
import pp.mdga.message.server.PossibleCardMessage;
|
||||||
import pp.mdga.message.server.PossiblePieceMessage;
|
import pp.mdga.message.server.PossiblePieceMessage;
|
||||||
|
|
||||||
public class PowerCardState extends TurnStates {
|
public class PowerCardState extends TurnStates {
|
||||||
@@ -48,7 +48,7 @@ public void setState(PowerCardStates state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(PossibleCardsMessage msg){
|
public void received(PossibleCardMessage msg){
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,13 +1,10 @@
|
|||||||
package pp.mdga.client.gamestate.turnstate;
|
package pp.mdga.client.gameState.turnState;
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
import pp.mdga.client.ClientGameLogic;
|
||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
import pp.mdga.client.gamestate.TurnState;
|
import pp.mdga.client.gameState.TurnState;
|
||||||
import pp.mdga.message.client.RequestDieMessage;
|
|
||||||
import pp.mdga.message.server.DieMessage;
|
import pp.mdga.message.server.DieMessage;
|
||||||
import pp.mdga.message.server.NoTurnMessage;
|
import pp.mdga.message.server.NoTurnMessage;
|
||||||
import pp.mdga.notification.DiceNowNotification;
|
|
||||||
import pp.mdga.notification.RollDiceNotification;
|
|
||||||
|
|
||||||
public class RollDiceState extends TurnStates {
|
public class RollDiceState extends TurnStates {
|
||||||
|
|
||||||
@@ -20,7 +17,7 @@ public RollDiceState(ClientState parent, ClientGameLogic logic) {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enter() {
|
public void enter() {
|
||||||
logic.addNotification(new DiceNowNotification());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -32,11 +29,6 @@ public TurnState getParent() {
|
|||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void selectDice(){
|
|
||||||
logic.send(new RequestDieMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void received(DieMessage msg){
|
public void received(DieMessage msg){
|
||||||
logic.getGame().setDiceEyes(msg.getDiceEye());
|
logic.getGame().setDiceEyes(msg.getDiceEye());
|
||||||
parent.setState(parent.getChoosePiece());
|
parent.setState(parent.getChoosePiece());
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package pp.mdga.client.gamestate.turnstate;
|
package pp.mdga.client.gameState.turnState;
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
import pp.mdga.client.ClientGameLogic;
|
||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
import pp.mdga.client.gamestate.GameStates;
|
import pp.mdga.client.gameState.GameStates;
|
||||||
|
|
||||||
public abstract class TurnStates extends GameStates {
|
public abstract class TurnStates extends GameStates {
|
||||||
public TurnStates(ClientState parent, ClientGameLogic logic) {
|
public TurnStates(ClientState parent, ClientGameLogic logic) {
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package pp.mdga.client.gamestate.turnstate.choosepiecestate;
|
package pp.mdga.client.gameState.turnState.choosePieceState;
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
import pp.mdga.client.ClientGameLogic;
|
||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
import pp.mdga.client.gamestate.turnstate.TurnStates;
|
import pp.mdga.client.gameState.turnState.TurnStates;
|
||||||
|
|
||||||
public abstract class ChoosePieceStates extends TurnStates {
|
public abstract class ChoosePieceStates extends TurnStates {
|
||||||
public ChoosePieceStates(ClientState parent, ClientGameLogic logic) {
|
public ChoosePieceStates(ClientState parent, ClientGameLogic logic) {
|
||||||
@@ -1,11 +1,12 @@
|
|||||||
package pp.mdga.client.gamestate.turnstate.choosepiecestate;
|
package pp.mdga.client.gameState.turnState.choosePieceState;
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
import pp.mdga.client.ClientGameLogic;
|
||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
import pp.mdga.client.gamestate.turnstate.ChoosePieceState;
|
import pp.mdga.client.gameState.turnState.ChoosePieceState;
|
||||||
import pp.mdga.game.Piece;
|
import pp.mdga.game.Piece;
|
||||||
import pp.mdga.message.server.*;
|
import pp.mdga.message.server.*;
|
||||||
import pp.mdga.message.server.StartPieceMessage;
|
import pp.mdga.message.server.StartPieceMessage;
|
||||||
|
import pp.mdga.notification.MovePieceNotification;
|
||||||
import pp.mdga.notification.SelectableMoveNotification;
|
import pp.mdga.notification.SelectableMoveNotification;
|
||||||
import pp.mdga.notification.WaitMoveNotification;
|
import pp.mdga.notification.WaitMoveNotification;
|
||||||
|
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package pp.mdga.client.gamestate.turnstate.choosepiecestate;
|
package pp.mdga.client.gameState.turnState.choosePieceState;
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
import pp.mdga.client.ClientGameLogic;
|
||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
import pp.mdga.client.gamestate.turnstate.ChoosePieceState;
|
import pp.mdga.client.gameState.turnState.ChoosePieceState;
|
||||||
import pp.mdga.game.Piece;
|
import pp.mdga.game.Piece;
|
||||||
import pp.mdga.message.client.SelectedPiecesMessage;
|
import pp.mdga.message.client.SelectedPiecesMessage;
|
||||||
import pp.mdga.message.server.MoveMessage;
|
import pp.mdga.message.server.MoveMessage;
|
||||||
@@ -31,26 +31,24 @@ public void exit() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPossiblePieces(ArrayList<Piece> possiblePieces) {
|
public void setPossiblePieces(ArrayList<Piece> possiblePieces){
|
||||||
this.possiblePieces = possiblePieces;
|
this.possiblePieces = possiblePieces;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void selectPiece(Piece piece) {
|
public void selectPiece(Piece piece){
|
||||||
ArrayList<Piece> pieces = new ArrayList<>();
|
|
||||||
if(possiblePieces.contains(piece)){
|
if(possiblePieces.contains(piece)){
|
||||||
pieces.add(piece);
|
logic.send(new SelectedPiecesMessage(piece.getUuid()));
|
||||||
logic.send(new SelectedPiecesMessage(pieces));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(MoveMessage msg) {
|
public void received(MoveMessage msg){
|
||||||
Piece piece = logic.getGame().getPieceThroughUUID(msg.getIdentifier());
|
Piece piece = logic.getGame().getPieceThroughUUID(msg.getIdentifier());
|
||||||
if (msg.isHomeMove()) {
|
if(msg.isHomeMove()){
|
||||||
logic.addNotification(new HomeMoveNotification(piece.getUuid(), msg.getTargetIndex()));
|
logic.addNotification(new HomeMoveNotification(piece.getUuid(), msg.getTargetIndex()));
|
||||||
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant();
|
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant();
|
||||||
logic.getGame().getPlayerByColor(piece.getColor()).setPieceInHome(msg.getTargetIndex(), piece);
|
logic.getGame().getBoard().getPlayerData().get(piece.getColor()).setPieceInHome(msg.getTargetIndex(), piece);
|
||||||
} else {
|
} else {
|
||||||
if (logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].isOccupied()) {
|
if (logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].isOccupied()) {
|
||||||
throwPiece(logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant());
|
throwPiece(logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant());
|
||||||
@@ -1,14 +1,12 @@
|
|||||||
package pp.mdga.client.gamestate.turnstate.choosepiecestate;
|
package pp.mdga.client.gameState.turnState.choosePieceState;
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
import pp.mdga.client.ClientGameLogic;
|
||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
import pp.mdga.client.gamestate.turnstate.ChoosePieceState;
|
import pp.mdga.client.gameState.turnState.ChoosePieceState;
|
||||||
import pp.mdga.game.Piece;
|
import pp.mdga.game.Piece;
|
||||||
import pp.mdga.message.client.SelectedPiecesMessage;
|
import pp.mdga.message.client.SelectedPiecesMessage;
|
||||||
import pp.mdga.message.server.MoveMessage;
|
import pp.mdga.message.server.MoveMessage;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class StartPieceState extends ChoosePieceStates {
|
public class StartPieceState extends ChoosePieceStates {
|
||||||
|
|
||||||
private final ChoosePieceState parent;
|
private final ChoosePieceState parent;
|
||||||
@@ -32,10 +30,8 @@ public void exit() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void selectPiece(Piece piece){
|
public void selectPiece(Piece piece){
|
||||||
ArrayList<Piece> pieces = new ArrayList<>();
|
|
||||||
if(moveablePiece.equals(piece)){
|
if(moveablePiece.equals(piece)){
|
||||||
pieces.add(piece);
|
logic.send(new SelectedPiecesMessage(piece.getUuid()));
|
||||||
logic.send(new SelectedPiecesMessage(pieces));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,16 +1,13 @@
|
|||||||
package pp.mdga.client.gamestate.turnstate.choosepiecestate;
|
package pp.mdga.client.gameState.turnState.choosePieceState;
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
import pp.mdga.client.ClientGameLogic;
|
||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
import pp.mdga.client.gamestate.turnstate.ChoosePieceState;
|
import pp.mdga.client.gameState.turnState.ChoosePieceState;
|
||||||
import pp.mdga.game.Piece;
|
import pp.mdga.game.Piece;
|
||||||
import pp.mdga.game.PieceState;
|
import pp.mdga.game.PieceState;
|
||||||
import pp.mdga.message.client.SelectedPiecesMessage;
|
import pp.mdga.message.client.SelectedPiecesMessage;
|
||||||
import pp.mdga.message.server.MoveMessage;
|
import pp.mdga.message.server.MoveMessage;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class WaitingPieceState extends ChoosePieceStates {
|
public class WaitingPieceState extends ChoosePieceStates {
|
||||||
|
|
||||||
private final ChoosePieceState parent;
|
private final ChoosePieceState parent;
|
||||||
@@ -32,10 +29,8 @@ public void exit() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void selectPiece(Piece piece){
|
public void selectPiece(Piece piece){
|
||||||
ArrayList<Piece> pieces = new ArrayList<>();
|
|
||||||
if(moveablePiece.equals(piece)){
|
if(moveablePiece.equals(piece)){
|
||||||
pieces.add(piece);
|
logic.send(new SelectedPiecesMessage(piece.getUuid()));
|
||||||
logic.send(new SelectedPiecesMessage(pieces));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,15 +1,14 @@
|
|||||||
package pp.mdga.client.gamestate.turnstate.powercardstate;
|
package pp.mdga.client.gameState.turnState.powerCardState;
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
import pp.mdga.client.ClientGameLogic;
|
||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
import pp.mdga.client.gamestate.turnstate.PowerCardState;
|
import pp.mdga.client.gameState.turnState.PowerCardState;
|
||||||
import pp.mdga.game.BonusCard;
|
import pp.mdga.game.BonusCard;
|
||||||
import pp.mdga.game.card.*;
|
|
||||||
import pp.mdga.message.client.NoPowerCardMessage;
|
import pp.mdga.message.client.NoPowerCardMessage;
|
||||||
import pp.mdga.message.client.SelectCardMessage;
|
import pp.mdga.message.client.SelectCardMessage;
|
||||||
import pp.mdga.message.server.DiceNowMessage;
|
import pp.mdga.message.server.DiceNowMessage;
|
||||||
import pp.mdga.message.server.PlayCardMessage;
|
import pp.mdga.message.server.PlayCardMessage;
|
||||||
import pp.mdga.message.server.PossibleCardsMessage;
|
import pp.mdga.message.server.PossibleCardMessage;
|
||||||
import pp.mdga.message.server.PossiblePieceMessage;
|
import pp.mdga.message.server.PossiblePieceMessage;
|
||||||
import pp.mdga.notification.SelectableCardsNotification;
|
import pp.mdga.notification.SelectableCardsNotification;
|
||||||
|
|
||||||
@@ -22,7 +21,7 @@
|
|||||||
public class ChoosePowerCardState extends PowerCardStates {
|
public class ChoosePowerCardState extends PowerCardStates {
|
||||||
|
|
||||||
private final PowerCardState parent;
|
private final PowerCardState parent;
|
||||||
private ArrayList<PowerCard> possibleCards = new ArrayList<>();
|
private ArrayList<BonusCard> possibleCards;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@@ -39,6 +38,8 @@ public ChoosePowerCardState(ClientState parent, ClientGameLogic logic) {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void enter() {
|
public void enter() {
|
||||||
|
possibleCards = new ArrayList<>();
|
||||||
|
//TODO: logic.send(new RequestPossibleCardsMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -46,7 +47,7 @@ public void enter() {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void exit() {
|
public void exit() {
|
||||||
possibleCards = new ArrayList<>();
|
possibleCards = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,15 +55,9 @@ public void exit() {
|
|||||||
* @param msg possible cards message
|
* @param msg possible cards message
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(PossibleCardsMessage msg){
|
public void received(PossibleCardMessage msg){
|
||||||
possibleCards = (ArrayList<PowerCard>)msg.getPossibleCards();
|
possibleCards = (ArrayList<BonusCard>) msg.getPossibleCards();
|
||||||
ArrayList<BonusCard> possibleBonusCards = new ArrayList<>();
|
logic.addNotification(new SelectableCardsNotification(possibleCards));
|
||||||
for (PowerCard card : possibleCards) {
|
|
||||||
if (!possibleBonusCards.contains(card.getCard())) {
|
|
||||||
possibleBonusCards.add(card.getCard());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logic.addNotification(new SelectableCardsNotification(possibleBonusCards));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -72,7 +67,7 @@ public void received(PossibleCardsMessage msg){
|
|||||||
@Override
|
@Override
|
||||||
public void selectCard(BonusCard card){
|
public void selectCard(BonusCard card){
|
||||||
if(card != null){
|
if(card != null){
|
||||||
logic.send(new SelectCardMessage(logic.getGame().getPlayers().get(logic.getOwnPlayerId()).getPowerCardByType(card)));
|
logic.send(new SelectCardMessage(card));
|
||||||
} else {
|
} else {
|
||||||
logic.send(new NoPowerCardMessage());
|
logic.send(new NoPowerCardMessage());
|
||||||
}
|
}
|
||||||
@@ -84,9 +79,10 @@ public void selectCard(BonusCard card){
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(PlayCardMessage msg){
|
public void received(PlayCardMessage msg){
|
||||||
if(msg.getCard().getCard().equals(BonusCard.TURBO)){
|
if(msg.getCard().equals(BonusCard.TURBO)){
|
||||||
parent.getParent().getPlayPowerCard().setPlayCard(msg);
|
logic.getGame().setDiceModifier(msg.getDiceModifier());
|
||||||
parent.getParent().setState(parent.getParent().getPlayPowerCard());
|
} else {
|
||||||
|
LOGGER.log(System.Logger.Level.ERROR, "Received card that is not turbo");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package pp.mdga.client.gamestate.turnstate.powercardstate;
|
package pp.mdga.client.gameState.turnState.powerCardState;
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
import pp.mdga.client.ClientGameLogic;
|
||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
import pp.mdga.client.gamestate.turnstate.TurnStates;
|
import pp.mdga.client.gameState.turnState.TurnStates;
|
||||||
|
|
||||||
public abstract class PowerCardStates extends TurnStates {
|
public abstract class PowerCardStates extends TurnStates {
|
||||||
public PowerCardStates(ClientState parent, ClientGameLogic logic) {
|
public PowerCardStates(ClientState parent, ClientGameLogic logic) {
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package pp.mdga.client.gamestate.turnstate.powercardstate;
|
package pp.mdga.client.gameState.turnState.powerCardState;
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
import pp.mdga.client.ClientGameLogic;
|
||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
import pp.mdga.client.gamestate.turnstate.PowerCardState;
|
import pp.mdga.client.gameState.turnState.PowerCardState;
|
||||||
import pp.mdga.game.Piece;
|
import pp.mdga.game.Piece;
|
||||||
import pp.mdga.message.client.RequestPlayCardMessage;
|
import pp.mdga.message.client.RequestPlayCardMessage;
|
||||||
import pp.mdga.message.server.PlayCardMessage;
|
import pp.mdga.message.server.PlayCardMessage;
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package pp.mdga.client.gamestate.turnstate.powercardstate;
|
package pp.mdga.client.gameState.turnState.powerCardState;
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
import pp.mdga.client.ClientGameLogic;
|
||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
import pp.mdga.client.gamestate.turnstate.PowerCardState;
|
import pp.mdga.client.gameState.turnState.PowerCardState;
|
||||||
import pp.mdga.game.Piece;
|
import pp.mdga.game.Piece;
|
||||||
import pp.mdga.message.client.RequestPlayCardMessage;
|
import pp.mdga.message.client.RequestPlayCardMessage;
|
||||||
import pp.mdga.message.server.PlayCardMessage;
|
import pp.mdga.message.server.PlayCardMessage;
|
||||||
@@ -1,85 +0,0 @@
|
|||||||
package pp.mdga.client.gamestate.determinestartplayerstate;
|
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
|
||||||
import pp.mdga.client.ClientState;
|
|
||||||
import pp.mdga.client.gamestate.DetermineStartPlayerState;
|
|
||||||
import pp.mdga.game.Player;
|
|
||||||
import pp.mdga.message.client.AnimationEndMessage;
|
|
||||||
import pp.mdga.notification.AcquireCardNotification;
|
|
||||||
import pp.mdga.notification.ActivePlayerNotification;
|
|
||||||
import pp.mdga.notification.DrawCardNotification;
|
|
||||||
import pp.mdga.notification.MovePieceNotification;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class Intro extends DetermineStartPlayerStates{
|
|
||||||
|
|
||||||
private final DetermineStartPlayerState parent;
|
|
||||||
|
|
||||||
private int animationCounter = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for Intro
|
|
||||||
*
|
|
||||||
* @param parent the parent state
|
|
||||||
* @param logic the client game logic
|
|
||||||
*/
|
|
||||||
public Intro(ClientState parent, ClientGameLogic logic) {
|
|
||||||
super(parent, logic);
|
|
||||||
this.parent = (DetermineStartPlayerState) parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is used to get the parent state;
|
|
||||||
*
|
|
||||||
* @return the parent state
|
|
||||||
*/
|
|
||||||
public DetermineStartPlayerState getParent(){
|
|
||||||
return parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is used to enter this state and play all necessary intro animations.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void enter() {
|
|
||||||
for(Map.Entry<Integer, Player> entry : logic.getGame().getPlayers().entrySet()){
|
|
||||||
//logic.addNotification(new WaitMoveNotification(entry.getValue().getPieces()[0].getUuid()));
|
|
||||||
logic.addNotification(new MovePieceNotification(entry.getValue().getPieces()[0].getUuid(), entry.getValue().getStartNodeIndex(), true));
|
|
||||||
logic.getGame().getBoard().getInfield()[entry.getValue().getStartNodeIndex()].setOccupant(entry.getValue().getPieces()[0]);
|
|
||||||
animationCounter++;
|
|
||||||
if(entry.getKey() == logic.getOwnPlayerId()){
|
|
||||||
logic.addNotification(new AcquireCardNotification(entry.getValue().getHandCards().get(0).getCard()));
|
|
||||||
} else {
|
|
||||||
logic.addNotification(new DrawCardNotification(entry.getValue().getColor(), entry.getValue().getHandCards().get(0).getCard()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method i s used to exit this state.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void exit() {
|
|
||||||
animationCounter = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is used when the view has completed the animation.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void selectAnimationEnd(){
|
|
||||||
animationCounter--;
|
|
||||||
if(animationCounter != 0){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
logic.send(new AnimationEndMessage());
|
|
||||||
if (logic.getGame().getActivePlayerId() == logic.getOwnPlayerId()){
|
|
||||||
parent.getParent().setState(parent.getParent().getTurn());
|
|
||||||
logic.addNotification(new ActivePlayerNotification(logic.getGame().getActiveColor()));
|
|
||||||
} else {
|
|
||||||
parent.getParent().setState(parent.getParent().getWaiting());
|
|
||||||
logic.addNotification(new ActivePlayerNotification(logic.getGame().getActiveColor()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
package pp.mdga.client.gamestate.determinestartplayerstate;
|
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
|
||||||
import pp.mdga.client.ClientState;
|
|
||||||
import pp.mdga.client.gamestate.DetermineStartPlayerState;
|
|
||||||
import pp.mdga.message.client.AnimationEndMessage;
|
|
||||||
import pp.mdga.message.server.*;
|
|
||||||
import pp.mdga.notification.ActivePlayerNotification;
|
|
||||||
|
|
||||||
public class WaitRankingState extends DetermineStartPlayerStates {
|
|
||||||
|
|
||||||
private final DetermineStartPlayerState parent;
|
|
||||||
private boolean canChange = false;
|
|
||||||
|
|
||||||
public WaitRankingState(ClientState parent, ClientGameLogic logic) {
|
|
||||||
super(parent, logic);
|
|
||||||
this.parent = (DetermineStartPlayerState) parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void changeToIntro(){
|
|
||||||
if(!canChange){
|
|
||||||
canChange = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
parent.setState(parent.getIntro());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void enter() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void exit() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(DiceNowMessage msg){
|
|
||||||
parent.setState(parent.getRollRankingDice());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(RankingResponseMessage msg){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void selectAnimationEnd(){
|
|
||||||
changeToIntro();
|
|
||||||
logic.send(new AnimationEndMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void received(ActivePlayerMessage msg){
|
|
||||||
logic.getGame().setActiveColor(msg.getColor());
|
|
||||||
changeToIntro();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package pp.mdga.client.settingsstate;
|
package pp.mdga.client.settingsState;
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
import pp.mdga.client.ClientGameLogic;
|
||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package pp.mdga.client.settingsstate;
|
package pp.mdga.client.settingsState;
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
import pp.mdga.client.ClientGameLogic;
|
||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package pp.mdga.client.settingsstate;
|
package pp.mdga.client.settingsState;
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
import pp.mdga.client.ClientGameLogic;
|
||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package pp.mdga.client.settingsstate;
|
package pp.mdga.client.settingsState;
|
||||||
|
|
||||||
import pp.mdga.client.ClientGameLogic;
|
import pp.mdga.client.ClientGameLogic;
|
||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
@@ -2,38 +2,31 @@
|
|||||||
|
|
||||||
import com.jme3.network.serializing.Serializable;
|
import com.jme3.network.serializing.Serializable;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class will be used to hold all Board relevant data.
|
* This class will be used to hold all Board relevant data.
|
||||||
*/
|
*/
|
||||||
@Serializable
|
@Serializable
|
||||||
public class Board {
|
public class Board {
|
||||||
/**
|
private Map<Color, PlayerData> playerData = new HashMap<>();
|
||||||
* The size of the board.
|
|
||||||
*/
|
|
||||||
public static final int BOARD_SIZE = 40;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create Board attributes.
|
|
||||||
*/
|
|
||||||
private final Node[] infield;
|
private final Node[] infield;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This constructor is used to create a new board
|
* This constructor is used to create a new board
|
||||||
*/
|
*/
|
||||||
public Board() {
|
public Board() {
|
||||||
infield = new Node[BOARD_SIZE];
|
infield = new Node[40];
|
||||||
initializeBoard();
|
for (int i = 0; i < 40; i++) {
|
||||||
}
|
if (i % 10 == 0) {
|
||||||
|
infield[i] = new StartNode(
|
||||||
/**
|
i == 0 ? Color.AIRFORCE :
|
||||||
* Initializes the board by setting up the nodes.
|
i == 10 ? Color.CYBER :
|
||||||
* Start nodes, bonus nodes, and regular nodes are created based on their positions.
|
i == 20 ? Color.NAVY :
|
||||||
*/
|
Color.ARMY
|
||||||
private void initializeBoard() {
|
);
|
||||||
for (int i = 0; i < BOARD_SIZE; i++) {
|
} else if (i == 4 || i == 14 || i == 24 || i == 34) {
|
||||||
if (isStartNode(i)) {
|
|
||||||
infield[i] = createStartNode(i);
|
|
||||||
} else if (isBonusNode(i)) {
|
|
||||||
infield[i] = new BonusNode();
|
infield[i] = new BonusNode();
|
||||||
} else {
|
} else {
|
||||||
infield[i] = new Node(null);
|
infield[i] = new Node(null);
|
||||||
@@ -42,48 +35,23 @@ private void initializeBoard() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the given index is a start node.
|
* This method will be used to add the given color and playerData parameters to the playerData attribute of
|
||||||
|
* Board class.
|
||||||
*
|
*
|
||||||
* @param i the index to check
|
* @param color as the color of the player as a Color enumeration.
|
||||||
* @return true if the index is a start node, false otherwise
|
* @param playerData as the playerData of the player as a PlayerData object.
|
||||||
*/
|
*/
|
||||||
private boolean isStartNode(int i) {
|
public void addPlayerData(Color color, PlayerData playerData) {
|
||||||
return i % 10 == 0;
|
this.playerData.put(color, playerData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the given index is a bonus node.
|
* This method returns the playerData
|
||||||
*
|
*
|
||||||
* @param i the index to check
|
* @return the playerData
|
||||||
* @return true if the index is a bonus node, false otherwise
|
|
||||||
*/
|
*/
|
||||||
private boolean isBonusNode(int i) {
|
public Map<Color, PlayerData> getPlayerData() {
|
||||||
return i % 10 == 4;
|
return playerData;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a start node with the appropriate color based on the index.
|
|
||||||
*
|
|
||||||
* @param i the index of the start node
|
|
||||||
* @return a new StartNode with the corresponding color
|
|
||||||
*/
|
|
||||||
private StartNode createStartNode(int i) {
|
|
||||||
return new StartNode(Color.getColor(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method returns the index of a specific piece on the board
|
|
||||||
*
|
|
||||||
* @param piece the piece to be searched for
|
|
||||||
* @return the index of the piece
|
|
||||||
*/
|
|
||||||
public int getInfieldIndexOfPiece(Piece piece) {
|
|
||||||
for (int i = 0; i < infield.length; i++) {
|
|
||||||
if (infield[i].getOccupant() == piece) {
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -105,8 +73,18 @@ public void setPieceOnBoard(int index, Piece piece) {
|
|||||||
infield[index].setOccupant(piece);
|
infield[index].setOccupant(piece);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public String toString() {
|
* This method returns the index of a specific piece on the board
|
||||||
return "Default Board";
|
*
|
||||||
|
* @param piece the piece to be searched for
|
||||||
|
* @return the index of the piece
|
||||||
|
*/
|
||||||
|
public int getInfieldIndexOfPiece(Piece piece) {
|
||||||
|
for (int i = 0; i < infield.length; i++) {
|
||||||
|
if (infield[i].getOccupant() == piece) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
package pp.mdga.game;
|
package pp.mdga.game;
|
||||||
|
|
||||||
import com.jme3.network.serializing.Serializable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enum representing the different types of bonus cards.
|
* Enum representing the different types of bonus cards.
|
||||||
*/
|
*/
|
||||||
@Serializable
|
|
||||||
public enum BonusCard {
|
public enum BonusCard {
|
||||||
/**
|
/**
|
||||||
* The hidden bonus card.
|
* The hidden bonus card.
|
||||||
|
|||||||