Compare commits
	
		
			63 Commits
		
	
	
		
			dev/client
			...
			developmen
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					ee94d901f4 | ||
| 
						 | 
					bca02bfe4b | ||
| 
						 | 
					acdf5ec6a9 | ||
| 
						 | 
					41d6f70d51 | ||
| 
						 | 
					4c064cb615 | ||
| 
						 | 
					121f47d070 | ||
| 
						 | 
					ae436589a2 | ||
| 
						 | 
					bc399b1bf9 | ||
| 
						 | 
					98a6f2e689 | ||
| 
						 | 
					9a07375fed | ||
| 
						 | 
					498c2eb054 | ||
| 
						 | 
					ce55ca8bb5 | ||
| 
						 | 
					9c729059bf | ||
| 
						 | 
					3b7ef37364 | ||
| 
						 | 
					ec295c94f1 | ||
| 
						 | 
					adfe2b94b8 | ||
| 
						 | 
					69108063a0 | ||
| 
						 | 
					16e7488fae | ||
| 
						 | 
					c9c99709ba | ||
| 
						 | 
					e069017375 | ||
| 
						 | 
					8b27ccce22 | ||
| 
						 | 
					8c22d935a9 | ||
| 
						 | 
					c8d7d91de0 | ||
| 
						 | 
					389d1b6056 | ||
| 
						 | 
					4430b37581 | ||
| 
						 | 
					e5abcbdc8c | ||
| 
						 | 
					e14b8cb510 | ||
| 
						 | 
					bf84bfa0f9 | ||
| 
						 | 
					0c49d7ed1c | ||
| 
						 | 
					2ba6a22422 | ||
| 
						 | 
					c37bac4614 | ||
| 
						 | 
					06b37584cb | ||
| 
						 | 
					0c42a2df88 | ||
| 
						 | 
					d75d704878 | ||
| 
						 | 
					6d3c733f91 | ||
| 
						 | 
					f96da2c46c | ||
| 
						 | 
					1a079dad44 | ||
| 
						 | 
					32f49a6181 | ||
| 
						 | 
					525809899e | ||
| 
						 | 
					fd9708752c | ||
| 
						 | 
					5a9f7a8118 | ||
| 
						 | 
					236d3db930 | ||
| 
						 | 
					29c6b13300 | ||
| 
						 | 
					6059e93276 | ||
| 
						 | 
					f2eeb6dab4 | ||
| 
						 | 
					2e1fe3c050 | ||
| 
						 | 
					2ac2de645b | ||
| 
						 | 
					d39f85fbe9 | ||
| 
						 | 
					960a57caba | ||
| 
						 | 
					36631df2e9 | ||
| 
						 | 
					df27c23cd5 | ||
| 
						 | 
					acd64d1507 | ||
| 
						 | 
					76f86c8a66 | ||
| 
						 | 
					308b592b65 | ||
| 
						 | 
					c4e7fb1d41 | ||
| 
						 | 
					aacc0440b3 | ||
| 
						 | 
					43c0e3bcc7 | ||
| 
						 | 
					95635f5fb7 | ||
| 
						 | 
					4904b32ea3 | ||
| 
						 | 
					b00219c4fb | ||
| 
						 | 
					12cf5f3e71 | ||
| 
						 | 
					77b0207214 | ||
| 
						 | 
					a18165bc02 | 
							
								
								
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						@@ -1,3 +1,5 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					.run/
 | 
				
			||||||
.gradle
 | 
					.gradle
 | 
				
			||||||
build/
 | 
					build/
 | 
				
			||||||
#!gradle/wrapper/gradle-wrapper.jar
 | 
					#!gradle/wrapper/gradle-wrapper.jar
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -40,6 +40,11 @@ public enum Asset {
 | 
				
			|||||||
    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),
 | 
					    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;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -156,9 +156,10 @@ else if(boardSelect != 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().outlineMove(List.of(p),List.of(2),List.of(false));
 | 
				
			||||||
                        //gameView.getBoardHandler().movePieceAnim(p,0, 8);
 | 
					                        //gameView.getBoardHandler().movePieceAnim(p,0, 8);
 | 
				
			||||||
                    } else {
 | 
					                    } else {
 | 
				
			||||||
                        gameView.getBoardHandler().throwMissileAnim(p);
 | 
					                        gameView.getBoardHandler().throwPiece(p, Color.ARMY);
 | 
				
			||||||
                        //gameView.getBoardHandler().movePieceStartAnim(p,0);
 | 
					                        //gameView.getBoardHandler().movePieceStartAnim(p,0);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,16 +1,8 @@
 | 
				
			|||||||
package pp.mdga.client;
 | 
					package pp.mdga.client;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import pp.mdga.client.acoustic.MdgaSound;
 | 
					 | 
				
			||||||
import pp.mdga.client.server.MdgaServer;
 | 
					 | 
				
			||||||
import pp.mdga.client.view.CeremonyView;
 | 
					 | 
				
			||||||
import pp.mdga.client.view.GameView;
 | 
					import pp.mdga.client.view.GameView;
 | 
				
			||||||
import pp.mdga.client.view.LobbyView;
 | 
					 | 
				
			||||||
import pp.mdga.game.BonusCard;
 | 
					import pp.mdga.game.BonusCard;
 | 
				
			||||||
import pp.mdga.game.Color;
 | 
					import pp.mdga.game.Color;
 | 
				
			||||||
import pp.mdga.message.client.LobbyReadyMessage;
 | 
					 | 
				
			||||||
import pp.mdga.notification.AcquireCardNotification;
 | 
					 | 
				
			||||||
import pp.mdga.notification.DrawCardNotification;
 | 
					 | 
				
			||||||
import pp.mdga.notification.TskSelectNotification;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.util.UUID;
 | 
					import java.util.UUID;
 | 
				
			||||||
import java.util.logging.Level;
 | 
					import java.util.logging.Level;
 | 
				
			||||||
@@ -75,10 +67,10 @@ public void selectCard(BonusCard 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.showNoPower();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -88,23 +80,19 @@ public void confirm() {
 | 
				
			|||||||
        GameView gameView = (GameView) app.getView();
 | 
					        GameView gameView = (GameView) app.getView();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(a != null && b != null) {
 | 
					        if(a != null && b != null) {
 | 
				
			||||||
            selectPiece(a);
 | 
					            app.getGameLogic().selectPiece(a);
 | 
				
			||||||
            selectPiece(b);
 | 
					            app.getGameLogic().selectPiece(b);
 | 
				
			||||||
            gameView.getBoardHandler().clearSelectable();
 | 
					            gameView.getBoardHandler().clearSelectable();
 | 
				
			||||||
        } else if (a != null) {
 | 
					        } else if (a != null) {
 | 
				
			||||||
            selectPiece(a);
 | 
					            app.getGameLogic().selectPiece(a);
 | 
				
			||||||
            gameView.getBoardHandler().clearSelectable();
 | 
					            gameView.getBoardHandler().clearSelectable();
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            if(null == card) {
 | 
					            app.getGameLogic().selectCard(card);
 | 
				
			||||||
                selectCard(null);
 | 
					            gameView.getGuiHandler().clearSelectableCards();
 | 
				
			||||||
            } else {
 | 
					 | 
				
			||||||
                selectCard(card);
 | 
					 | 
				
			||||||
                gameView.getGuiHandler().clearSelectableCards();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        gameView.noConfirm();
 | 
					        gameView.noConfirm();
 | 
				
			||||||
        gameView.noNoPower();
 | 
					        gameView.hideNoPower();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void selectTsk(Color color) {
 | 
					    public void selectTsk(Color color) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,6 @@
 | 
				
			|||||||
package pp.mdga.client;
 | 
					package pp.mdga.client;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.jme3.system.NanoTimer;
 | 
				
			||||||
import pp.mdga.client.acoustic.MdgaSound;
 | 
					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;
 | 
				
			||||||
@@ -16,13 +17,28 @@ public class NotificationSynchronizer {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    private ArrayList<Notification> notifications = new ArrayList<>();
 | 
					    private ArrayList<Notification> notifications = new ArrayList<>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private NanoTimer timer = new NanoTimer();
 | 
				
			||||||
 | 
					    private float delay = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private static final float STANDARD_DELAY = 2.5f;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    NotificationSynchronizer(MdgaApp app) {
 | 
					    NotificationSynchronizer(MdgaApp app) {
 | 
				
			||||||
        this.app = app;
 | 
					        this.app = app;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void update() {
 | 
					    public void update() {
 | 
				
			||||||
        Notification n = app.getGameLogic().getNotification();
 | 
					        while (timer.getTimeInSeconds() >= delay) {
 | 
				
			||||||
        while (n != null) {
 | 
					            Notification n = app.getGameLogic().getNotification();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if(n == null) {
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            System.out.println("receive notification:" + n.getClass().getName());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            timer.reset();
 | 
				
			||||||
 | 
					            delay = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if(n instanceof InfoNotification infoNotification) {
 | 
					            if(n instanceof InfoNotification infoNotification) {
 | 
				
			||||||
                app.getView().showInfo(infoNotification.getMessage(), infoNotification.isError());
 | 
					                app.getView().showInfo(infoNotification.getMessage(), infoNotification.isError());
 | 
				
			||||||
                return;
 | 
					                return;
 | 
				
			||||||
@@ -46,8 +62,6 @@ public void update() {
 | 
				
			|||||||
                        throw new RuntimeException("no notification expected: " + n.getClass().getName());
 | 
					                        throw new RuntimeException("no notification expected: " + n.getClass().getName());
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					 | 
				
			||||||
            n = app.getGameLogic().getNotification();
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -86,14 +100,17 @@ 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);
 | 
					            app.getAcousticHandler().playSound(MdgaSound.BONUS);
 | 
				
			||||||
 | 
					            delay = STANDARD_DELAY;
 | 
				
			||||||
        } 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);
 | 
					            app.getAcousticHandler().playSound(MdgaSound.UI90);
 | 
				
			||||||
 | 
					            delay = STANDARD_DELAY;
 | 
				
			||||||
        } 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();
 | 
				
			||||||
@@ -141,11 +158,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 +171,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 {
 | 
				
			||||||
@@ -162,9 +179,10 @@ private void handleGame(Notification notification) {
 | 
				
			|||||||
                if (n.isTurbo()) guiHandler.showRolledDiceMult(n.getEyes(), n.getMultiplier(), n.getColor());
 | 
					                if (n.isTurbo()) guiHandler.showRolledDiceMult(n.getEyes(), n.getMultiplier(), n.getColor());
 | 
				
			||||||
                else guiHandler.showRolledDice(n.getEyes(), n.getColor());
 | 
					                else guiHandler.showRolledDice(n.getEyes(), n.getColor());
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            delay = 7;
 | 
				
			||||||
        } else if (notification instanceof SelectableCardsNotification n) {
 | 
					        } else if (notification instanceof SelectableCardsNotification n) {
 | 
				
			||||||
            guiHandler.setSelectableCards(n.getCards());
 | 
					            guiHandler.setSelectableCards(n.getCards());
 | 
				
			||||||
            gameView.needNoPower();
 | 
					            gameView.showNoPower();
 | 
				
			||||||
        } 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) {
 | 
				
			||||||
@@ -173,7 +191,7 @@ private void handleGame(Notification notification) {
 | 
				
			|||||||
            app.afterGameCleanup();
 | 
					            app.afterGameCleanup();
 | 
				
			||||||
            app.enter(MdgaState.MAIN);
 | 
					            app.enter(MdgaState.MAIN);
 | 
				
			||||||
        } else if (notification instanceof SwapPieceNotification n) {
 | 
					        } else if (notification instanceof SwapPieceNotification n) {
 | 
				
			||||||
//            boardHandler.swapPieces(n.getFirstPiece(), n.getSecondPiece());
 | 
					            boardHandler.swapPieceAnim(n.getFirstPiece(), n.getSecondPiece());
 | 
				
			||||||
            guiHandler.swap();
 | 
					            guiHandler.swap();
 | 
				
			||||||
        } else if (notification instanceof WaitMoveNotification) {
 | 
					        } else if (notification instanceof WaitMoveNotification) {
 | 
				
			||||||
            //TODO ???
 | 
					            //TODO ???
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										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);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -18,12 +18,14 @@ public class AcousticHandler {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    private boolean fading = false; // Indicates if a fade is in progress
 | 
					    private boolean fading = false; // Indicates if a fade is in progress
 | 
				
			||||||
    private NanoTimer fadeTimer = new NanoTimer(); // Timer to track fade progress
 | 
					    private NanoTimer fadeTimer = new NanoTimer(); // Timer to track fade progress
 | 
				
			||||||
    private static final float FADE_DURATION = 3.0f; // Duration for outfade
 | 
					    private static final float FADE_DURATION = 2.0f; // Duration for outfade
 | 
				
			||||||
    private static final float CROSSFADE_DURATION = 1.5f; // Duration for infade
 | 
					    private static final float CROSSFADE_DURATION = 1.5f; // Duration for infade
 | 
				
			||||||
    private GameMusic playing = null; // Currently playing track
 | 
					    private GameMusic playing = null; // Currently playing track
 | 
				
			||||||
    private GameMusic scheduled = null; // Scheduled track to play next
 | 
					    private GameMusic scheduled = null; // Scheduled track to play next
 | 
				
			||||||
    private GameMusic old = null; // Old track being faded out
 | 
					    private GameMusic old = null; // Old track being faded out
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private GameMusic birds;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private float mainVolume = 0.0f;
 | 
					    private float mainVolume = 0.0f;
 | 
				
			||||||
    private float musicVolume = 1.0f;
 | 
					    private float musicVolume = 1.0f;
 | 
				
			||||||
    private float soundVolume = 1.0f;
 | 
					    private float soundVolume = 1.0f;
 | 
				
			||||||
@@ -38,6 +40,8 @@ public AcousticHandler(MdgaApp app) {
 | 
				
			|||||||
        mainVolume = prefs.getFloat("mainVolume", 1.0f);
 | 
					        mainVolume = prefs.getFloat("mainVolume", 1.0f);
 | 
				
			||||||
        musicVolume = prefs.getFloat("musicVolume", 1.0f);
 | 
					        musicVolume = prefs.getFloat("musicVolume", 1.0f);
 | 
				
			||||||
        soundVolume = prefs.getFloat("soundVolume", 1.0f);
 | 
					        soundVolume = prefs.getFloat("soundVolume", 1.0f);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        birds = new GameMusic(app, MusicAsset.BIRDS, getSoundVolumeTotal(), MusicAsset.BIRDS.getSubVolume(), MusicAsset.BIRDS.getLoop(), 0.0f);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -60,6 +64,8 @@ public void update() {
 | 
				
			|||||||
                iterator.remove();
 | 
					                iterator.remove();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        birds.update(Math.min(getSoundVolumeTotal(), getMusicVolumeTotal() > 0 ? 0 : 1));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -132,6 +138,15 @@ public void playSound(MdgaSound sound) {
 | 
				
			|||||||
            case MATRIX:
 | 
					            case MATRIX:
 | 
				
			||||||
                assets.add(new SoundAssetDelayVolume(SoundAsset.MATRIX, 1.0f, 0.0f));
 | 
					                assets.add(new SoundAssetDelayVolume(SoundAsset.MATRIX, 1.0f, 0.0f));
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
 | 
					            case TURRET_ROTATE:
 | 
				
			||||||
 | 
					                assets.add(new SoundAssetDelayVolume(SoundAsset.TURRET_ROTATE, 0.7f, 0f));
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            case TANK_SHOOT:
 | 
				
			||||||
 | 
					                assets.add(new SoundAssetDelayVolume(SoundAsset.TANK_SHOOT, 0.7f, 0f));
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            case TANK_EXPLOSION:
 | 
				
			||||||
 | 
					                assets.add(new SoundAssetDelayVolume(SoundAsset.EXPLOSION_1, 1.0f, 0f));
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
            default:
 | 
					            default:
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -153,6 +168,10 @@ public void playState(MdgaState state) {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        MusicAsset asset = null;
 | 
					        MusicAsset asset = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        birds.pause();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        float pause = 0.0f;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        switch (state) {
 | 
					        switch (state) {
 | 
				
			||||||
            case MAIN:
 | 
					            case MAIN:
 | 
				
			||||||
                playGame = false;
 | 
					                playGame = false;
 | 
				
			||||||
@@ -163,10 +182,12 @@ public void playState(MdgaState state) {
 | 
				
			|||||||
                asset = MusicAsset.LOBBY;
 | 
					                asset = MusicAsset.LOBBY;
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            case GAME:
 | 
					            case GAME:
 | 
				
			||||||
 | 
					                birds.play();
 | 
				
			||||||
                addGameTracks();
 | 
					                addGameTracks();
 | 
				
			||||||
                playGame = true;
 | 
					                playGame = true;
 | 
				
			||||||
                assert (!gameTracks.isEmpty()) : "no more game music available";
 | 
					                assert (!gameTracks.isEmpty()) : "no more game music available";
 | 
				
			||||||
                asset = gameTracks.remove(0);
 | 
					                asset = gameTracks.remove(0);
 | 
				
			||||||
 | 
					                pause = 2.0f;
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            case CEREMONY:
 | 
					            case CEREMONY:
 | 
				
			||||||
                playGame = false;
 | 
					                playGame = false;
 | 
				
			||||||
@@ -178,7 +199,7 @@ public void playState(MdgaState state) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        assert (null != asset) : "music sceduling went wrong";
 | 
					        assert (null != asset) : "music sceduling went wrong";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        scheduled = new GameMusic(app, asset, getMusicVolumeTotal(), asset.getSubVolume(), asset.getLoop(), 0.0f);
 | 
					        scheduled = new GameMusic(app, asset, getMusicVolumeTotal(), asset.getSubVolume(), asset.getLoop(), pause);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -454,7 +475,7 @@ public void setSoundVolume(float soundVolume) {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    float getMusicVolumeTotal() {
 | 
					    float getMusicVolumeTotal() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return getMusicVolume() * getMainVolume();
 | 
					        return getMusicVolume() * getMainVolume() / 2;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -38,4 +38,7 @@ public enum MdgaSound {
 | 
				
			|||||||
    UI90,
 | 
					    UI90,
 | 
				
			||||||
    MISSILE,
 | 
					    MISSILE,
 | 
				
			||||||
    MATRIX,
 | 
					    MATRIX,
 | 
				
			||||||
 | 
					    TURRET_ROTATE,
 | 
				
			||||||
 | 
					    TANK_SHOOT,
 | 
				
			||||||
 | 
					    TANK_EXPLOSION
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,12 +10,13 @@ enum MusicAsset {
 | 
				
			|||||||
    MAIN_MENU("Spaceship.wav", true, 1.0f),
 | 
					    MAIN_MENU("Spaceship.wav", true, 1.0f),
 | 
				
			||||||
    LOBBY("DeadPlanet.wav", true, 1.0f),
 | 
					    LOBBY("DeadPlanet.wav", true, 1.0f),
 | 
				
			||||||
    CEREMONY("80s,Disco,Life.wav", true, 1.0f),
 | 
					    CEREMONY("80s,Disco,Life.wav", true, 1.0f),
 | 
				
			||||||
    GAME_1("NeonRoadTrip.wav", 1.0f),
 | 
					    GAME_1("NeonRoadTrip.wav", 0.5f),
 | 
				
			||||||
    GAME_2("NoPressureTrance.wav", 1.0f),
 | 
					    GAME_2("NoPressureTrance.wav", 0.5f),
 | 
				
			||||||
    GAME_3("TheSynthRave.wav", 1.0f),
 | 
					    GAME_3("TheSynthRave.wav", 0.5f),
 | 
				
			||||||
    GAME_4("LaserParty.wav", 1.0f),
 | 
					    GAME_4("LaserParty.wav", 0.5f),
 | 
				
			||||||
    GAME_5("RetroNoir.wav", 1.0f),
 | 
					    GAME_5("RetroNoir.wav", 0.5f),
 | 
				
			||||||
    GAME_6("SpaceInvaders.wav", 1.0f);
 | 
					    GAME_6("SpaceInvaders.wav", 0.5f),
 | 
				
			||||||
 | 
					    BIRDS("nature-ambience.ogg", true, 1.0f);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private final String path;
 | 
					    private final String path;
 | 
				
			||||||
    private final boolean loop;
 | 
					    private final boolean loop;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -37,7 +37,11 @@ enum SoundAsset {
 | 
				
			|||||||
    LOSE("lose.ogg"),
 | 
					    LOSE("lose.ogg"),
 | 
				
			||||||
    MISSILE("missile.ogg"),
 | 
					    MISSILE("missile.ogg"),
 | 
				
			||||||
    MATRIX("matrix.wav"),
 | 
					    MATRIX("matrix.wav"),
 | 
				
			||||||
    CONNECTED("connected.wav");
 | 
					    CONNECTED("connected.wav"),
 | 
				
			||||||
 | 
					    TURRET_ROTATE("turret_rotate.ogg"),
 | 
				
			||||||
 | 
					    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();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -10,6 +10,10 @@
 | 
				
			|||||||
import pp.mdga.client.MdgaApp;
 | 
					import pp.mdga.client.MdgaApp;
 | 
				
			||||||
import pp.mdga.client.acoustic.MdgaSound;
 | 
					import pp.mdga.client.acoustic.MdgaSound;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * The {@code Explosion} class represents an explosion effect in a 3D environment.
 | 
				
			||||||
 | 
					 * It manages the creation, configuration, and triggering of particle emitters for fire and smoke effects.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
public class Explosion {
 | 
					public class Explosion {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private final Node rootNode;
 | 
					    private final Node rootNode;
 | 
				
			||||||
@@ -23,11 +27,11 @@ public class Explosion {
 | 
				
			|||||||
    private final Material mat;
 | 
					    private final Material mat;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Konstruktor für die Explosion.
 | 
					     * Constructor for the {@code Explosion} class.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     * @param app      Die Hauptanwendung.
 | 
					     * @param app      The main application managing the explosion.
 | 
				
			||||||
     * @param rootNode Der Root-Knoten, an den die Explosion angefügt wird.
 | 
					     * @param rootNode The root node to which the explosion effects will be attached.
 | 
				
			||||||
     * @param location Der Ort der Explosion in World-Koordinaten.
 | 
					     * @param location The location of the explosion in world coordinates.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public Explosion(MdgaApp app, Node rootNode, Vector3f location) {
 | 
					    public Explosion(MdgaApp app, Node rootNode, Vector3f location) {
 | 
				
			||||||
        this.app = app;
 | 
					        this.app = app;
 | 
				
			||||||
@@ -35,20 +39,24 @@ 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.setTexture("Texture", app.getAssetManager().loadTexture("Images/particle/flame.png"));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Initialisiert den Partikel-Emitter für die Explosion.
 | 
					     * Initializes the particle emitters for the explosion effect.
 | 
				
			||||||
 | 
					     * Configures the fire and smoke emitters with appearance, behavior, and lifespan.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private void initializeEmitter() {
 | 
					    private void initializeEmitter() {
 | 
				
			||||||
        fire = new ParticleEmitter("Effect", Type.Triangle,50);
 | 
					        fire = new ParticleEmitter("Effect", Type.Triangle,50);
 | 
				
			||||||
        fire.setMaterial(mat);
 | 
					        fire.setMaterial(mat);
 | 
				
			||||||
 | 
					        fire.setImagesX(2);
 | 
				
			||||||
 | 
					        fire.setImagesY(2);
 | 
				
			||||||
        fire.setStartColor(ColorRGBA.Yellow);
 | 
					        fire.setStartColor(ColorRGBA.Yellow);
 | 
				
			||||||
        fire.setEndColor(ColorRGBA.Red);
 | 
					        fire.setEndColor(ColorRGBA.Red);
 | 
				
			||||||
        fire.getParticleInfluencer().setInitialVelocity(new Vector3f(0.2f,0.2f,4f));
 | 
					        fire.getParticleInfluencer().setInitialVelocity(new Vector3f(0.2f,0.2f,4f));
 | 
				
			||||||
        fire.getParticleInfluencer().setVelocityVariation(0.4f);
 | 
					        fire.getParticleInfluencer().setVelocityVariation(0.4f);
 | 
				
			||||||
        fire.setStartSize(0.1f);
 | 
					        fire.setStartSize(0.7f);
 | 
				
			||||||
        fire.setEndSize(0.8f);
 | 
					        fire.setEndSize(1.8f);
 | 
				
			||||||
        fire.setGravity(0, 0, -0.1f);
 | 
					        fire.setGravity(0, 0, -0.1f);
 | 
				
			||||||
        fire.setLowLife(0.5f);
 | 
					        fire.setLowLife(0.5f);
 | 
				
			||||||
        fire.setHighLife(2.2f);
 | 
					        fire.setHighLife(2.2f);
 | 
				
			||||||
@@ -58,14 +66,14 @@ private void initializeEmitter() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        smoke = new ParticleEmitter("Effect2", Type.Triangle,40);
 | 
					        smoke = new ParticleEmitter("Effect2", Type.Triangle,40);
 | 
				
			||||||
        smoke.setMaterial(mat);
 | 
					        smoke.setMaterial(mat);
 | 
				
			||||||
        smoke.setImagesX(2);
 | 
					        smoke.setImagesX(3);
 | 
				
			||||||
        smoke.setImagesY(2);
 | 
					        smoke.setImagesY(3);
 | 
				
			||||||
        smoke.setStartColor(ColorRGBA.DarkGray);
 | 
					        smoke.setStartColor(ColorRGBA.DarkGray);
 | 
				
			||||||
        smoke.setEndColor(new ColorRGBA(0.05f, 0.05f, 0.05f, 1));
 | 
					        smoke.setEndColor(new ColorRGBA(0.05f, 0.05f, 0.05f, 1));
 | 
				
			||||||
        smoke.getParticleInfluencer().setInitialVelocity(new Vector3f(0.0f,0.0f,0.7f));
 | 
					        smoke.getParticleInfluencer().setInitialVelocity(new Vector3f(0.0f,0.0f,0.7f));
 | 
				
			||||||
        smoke.getParticleInfluencer().setVelocityVariation(0.5f);
 | 
					        smoke.getParticleInfluencer().setVelocityVariation(0.5f);
 | 
				
			||||||
        smoke.setStartSize(0.2f);
 | 
					        smoke.setStartSize(0.8f);
 | 
				
			||||||
        smoke.setEndSize(0.5f);
 | 
					        smoke.setEndSize(1.5f);
 | 
				
			||||||
        smoke.setGravity(0, 0, -0.3f);
 | 
					        smoke.setGravity(0, 0, -0.3f);
 | 
				
			||||||
        smoke.setLowLife(1.2f);
 | 
					        smoke.setLowLife(1.2f);
 | 
				
			||||||
        smoke.setHighLife(5.5f);
 | 
					        smoke.setHighLife(5.5f);
 | 
				
			||||||
@@ -77,7 +85,8 @@ private void initializeEmitter() {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Löst die Explosion aus.
 | 
					     * Triggers the explosion effect by attaching and activating the particle emitters for fire and smoke.
 | 
				
			||||||
 | 
					     * Both emitters are automatically detached after a predefined duration.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public void trigger() {
 | 
					    public void trigger() {
 | 
				
			||||||
        if (!triggered) {
 | 
					        if (!triggered) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -17,30 +17,34 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import java.util.UUID;
 | 
					import java.util.UUID;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * The {@code JetAnimation} class handles the animation of a jet model in a 3D environment.
 | 
				
			||||||
 | 
					 * It creates a jet model, animates its movement along a curved path, triggers an explosion at a target point,
 | 
				
			||||||
 | 
					 * and performs additional actions upon animation completion.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
public class JetAnimation {
 | 
					public class JetAnimation {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private final MdgaApp app;         // Referenz auf die Hauptanwendung
 | 
					    private final MdgaApp app;
 | 
				
			||||||
    private final Node rootNode;      // Root-Knoten, an dem die Animation hängt
 | 
					    private final Node rootNode;
 | 
				
			||||||
    private Spatial jetModel;         // Das Model des "jet"
 | 
					    private Spatial jetModel;
 | 
				
			||||||
    private final Vector3f spawnPoint; // Spawnpunkt des Jets
 | 
					    private final Vector3f spawnPoint;
 | 
				
			||||||
    private final Vector3f nodePoint; // Punkt des überflogenen Knotens
 | 
					    private final Vector3f nodePoint;
 | 
				
			||||||
    private final Vector3f despawnPoint; // Punkt, an dem der Jet despawnt
 | 
					    private final Vector3f despawnPoint;
 | 
				
			||||||
    private final float curveHeight;  // Maximale Höhe der Kurve
 | 
					    private final float curveHeight;
 | 
				
			||||||
    private final float animationDuration; // Dauer der Animation
 | 
					    private final float animationDuration;
 | 
				
			||||||
    private Explosion explosion;
 | 
					    private Explosion explosion;
 | 
				
			||||||
    private final UUID id;
 | 
					    private Runnable actionAfter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Konstruktor für die ThrowAnimation-Klasse.
 | 
					     * Constructor for the {@code JetAnimation} class.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     * @param app                Die Hauptanwendung
 | 
					     * @param app              The main application managing the jet animation.
 | 
				
			||||||
     * @param rootNode           Der Root-Knoten, an dem der Jet angefügt wird
 | 
					     * @param rootNode         The root node to which the jet model will be attached.
 | 
				
			||||||
     * @param uuid              Die UUID des pieces
 | 
					     * @param targetPoint      The target point where the explosion will occur.
 | 
				
			||||||
     * @param targetPoint         Der Punkt, an dem der Jet spawnt
 | 
					     * @param curveHeight      The height of the curve for the jet's flight path.
 | 
				
			||||||
     * @param curveHeight        Die maximale Höhe der Flugkurve
 | 
					     * @param animationDuration The total duration of the jet animation.
 | 
				
			||||||
     * @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, 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));
 | 
				
			||||||
@@ -55,13 +59,12 @@ public JetAnimation(MdgaApp app, Node rootNode, UUID uuid, Vector3f targetPoint,
 | 
				
			|||||||
        this.curveHeight = curveHeight;
 | 
					        this.curveHeight = curveHeight;
 | 
				
			||||||
        this.animationDuration = animationDuration;
 | 
					        this.animationDuration = animationDuration;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        id = uuid;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        explosion = new Explosion(app, rootNode, targetPoint);
 | 
					        explosion = new Explosion(app, rootNode, targetPoint);
 | 
				
			||||||
 | 
					        this.actionAfter = actionAfter;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Startet die Animation.
 | 
					     * Starts the jet animation by spawning the jet model and initiating its movement along the predefined path.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public void start() {
 | 
					    public void start() {
 | 
				
			||||||
        app.getAcousticHandler().playSound(MdgaSound.JET);
 | 
					        app.getAcousticHandler().playSound(MdgaSound.JET);
 | 
				
			||||||
@@ -70,7 +73,7 @@ public void start() {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Spawnt den Jet an der spezifizierten Position.
 | 
					     * Spawns the jet model at the designated spawn point, applying material, scaling, and rotation.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private void spawnJet() {
 | 
					    private void spawnJet() {
 | 
				
			||||||
        jetModel = app.getAssetManager().loadModel(Asset.jet.getModelPath());
 | 
					        jetModel = app.getAssetManager().loadModel(Asset.jet.getModelPath());
 | 
				
			||||||
@@ -85,8 +88,9 @@ private void spawnJet() {
 | 
				
			|||||||
        rootNode.attachChild(jetModel);
 | 
					        rootNode.attachChild(jetModel);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**actionAfter
 | 
				
			||||||
     * Animiert den Jet entlang einer Kurve und lässt ihn anschließend verschwinden.
 | 
					     * Animates the jet along a Bezier curve path, triggers the explosion effect at the appropriate time,
 | 
				
			||||||
 | 
					     * and performs cleanup operations after the animation completes.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private void animateJet() {
 | 
					    private void animateJet() {
 | 
				
			||||||
        Vector3f controlPoint1 = spawnPoint.add(0, curveHeight, 0);
 | 
					        Vector3f controlPoint1 = spawnPoint.add(0, curveHeight, 0);
 | 
				
			||||||
@@ -118,26 +122,34 @@ 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);
 | 
					 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            @Override
 | 
					            @Override
 | 
				
			||||||
            protected void controlRender(RenderManager rm, ViewPort vp) {
 | 
					            protected void controlRender(RenderManager rm, ViewPort vp) {}
 | 
				
			||||||
                // Wird hier nicht benötigt
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void endAnim(){
 | 
				
			||||||
 | 
					        actionAfter.run();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Repräsentiert eine 3D-Bezier-Kurve mit vier Kontrollpunkten.
 | 
					     * The {@code BezierCurve3f} class represents a 3D cubic Bezier curve.
 | 
				
			||||||
 | 
					     * It provides methods to interpolate positions and derivatives along the curve.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private static class BezierCurve3f {
 | 
					    private static class BezierCurve3f {
 | 
				
			||||||
        private final Vector3f p0, p1, p2, p3;
 | 
					        private final Vector3f p0, p1, p2, p3;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /**
 | 
				
			||||||
 | 
					         * Constructor for the {@code BezierCurve3f} class.
 | 
				
			||||||
 | 
					         *
 | 
				
			||||||
 | 
					         * @param p0 The starting point of the curve.
 | 
				
			||||||
 | 
					         * @param p1 The first control point influencing the curve's shape.
 | 
				
			||||||
 | 
					         * @param p2 The second control point influencing the curve's shape.
 | 
				
			||||||
 | 
					         * @param p3 The endpoint of the curve.
 | 
				
			||||||
 | 
					         */
 | 
				
			||||||
        public BezierCurve3f(Vector3f p0, Vector3f p1, Vector3f p2, Vector3f p3) {
 | 
					        public BezierCurve3f(Vector3f p0, Vector3f p1, Vector3f p2, Vector3f p3) {
 | 
				
			||||||
            this.p0 = p0;
 | 
					            this.p0 = p0;
 | 
				
			||||||
            this.p1 = p1;
 | 
					            this.p1 = p1;
 | 
				
			||||||
@@ -145,6 +157,12 @@ public BezierCurve3f(Vector3f p0, Vector3f p1, Vector3f p2, Vector3f p3) {
 | 
				
			|||||||
            this.p3 = p3;
 | 
					            this.p3 = p3;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /**
 | 
				
			||||||
 | 
					         * Interpolates a position along the curve at a given progress value {@code t}.
 | 
				
			||||||
 | 
					         *
 | 
				
			||||||
 | 
					         * @param t The progress value (0.0 to 1.0) along the curve.
 | 
				
			||||||
 | 
					         * @return The interpolated position on the curve.
 | 
				
			||||||
 | 
					         */
 | 
				
			||||||
        public Vector3f interpolate(float t) {
 | 
					        public Vector3f interpolate(float t) {
 | 
				
			||||||
            float u = 1 - t;
 | 
					            float u = 1 - t;
 | 
				
			||||||
            float tt = t * t;
 | 
					            float tt = t * t;
 | 
				
			||||||
@@ -159,6 +177,12 @@ public Vector3f interpolate(float t) {
 | 
				
			|||||||
            return point;
 | 
					            return point;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /**
 | 
				
			||||||
 | 
					         * Computes the derivative at a given progress value {@code t}, representing the direction along the curve.
 | 
				
			||||||
 | 
					         *
 | 
				
			||||||
 | 
					         * @param t The progress value (0.0 to 1.0) along the curve.
 | 
				
			||||||
 | 
					         * @return The derivative (direction vector) at the specified progress.
 | 
				
			||||||
 | 
					         */
 | 
				
			||||||
        public Vector3f interpolateDerivative(float t) {
 | 
					        public Vector3f interpolateDerivative(float t) {
 | 
				
			||||||
            float u = 1 - t;
 | 
					            float u = 1 - t;
 | 
				
			||||||
            float tt = t * t;
 | 
					            float tt = t * t;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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,6 +1,9 @@
 | 
				
			|||||||
package pp.mdga.client.animation;
 | 
					package pp.mdga.client.animation;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.jme3.effect.ParticleEmitter;
 | 
				
			||||||
 | 
					import com.jme3.effect.ParticleMesh;
 | 
				
			||||||
import com.jme3.material.Material;
 | 
					import com.jme3.material.Material;
 | 
				
			||||||
 | 
					import com.jme3.math.ColorRGBA;
 | 
				
			||||||
import com.jme3.math.FastMath;
 | 
					import com.jme3.math.FastMath;
 | 
				
			||||||
import com.jme3.math.Vector3f;
 | 
					import com.jme3.math.Vector3f;
 | 
				
			||||||
import com.jme3.renderer.RenderManager;
 | 
					import com.jme3.renderer.RenderManager;
 | 
				
			||||||
@@ -16,121 +19,165 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import java.util.UUID;
 | 
					import java.util.UUID;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * The {@code MissileAnimation} class handles the animation of a missile moving along a parabolic path
 | 
				
			||||||
 | 
					 * towards a target point in a 3D environment. It also triggers an explosion at the target upon impact.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
public class MissileAnimation {
 | 
					public class MissileAnimation {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private final Node rootNode;       // Root-Knoten, an den die Animation gehängt wird
 | 
					    private final Node rootNode;
 | 
				
			||||||
    private final MdgaApp app;        // Referenz auf die Hauptanwendung
 | 
					    private final MdgaApp app;
 | 
				
			||||||
    private final Vector3f start;     // Startpunkt der Rakete
 | 
					    private final Vector3f start;
 | 
				
			||||||
    private final Vector3f target;    // Zielpunkt der Rakete
 | 
					    private final Vector3f target;
 | 
				
			||||||
    private final float flightTime;   // Gesamtdauer des Flugs
 | 
					    private final float flightTime;
 | 
				
			||||||
    private Explosion explosion;
 | 
					    private Explosion explosion;
 | 
				
			||||||
    private Spatial missileModel;     // 3D-Modell der Rakete
 | 
					    private Spatial missileModel;
 | 
				
			||||||
 | 
					    private Runnable actionAfter;
 | 
				
			||||||
 | 
					    private ParticleEmitter smoke;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private UUID id;
 | 
					    private Node missileNode = new Node();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private final Material mat;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Konstruktor für die MissileAnimation.
 | 
					     * Constructor for the {@code MissileAnimation} class.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     * @param app       Die Hauptanwendung.
 | 
					     * @param app       The main application managing the missile animation.
 | 
				
			||||||
     * @param rootNode  Der Root-Knoten, an den die Animation gehängt wird.
 | 
					     * @param rootNode  The root node to which the missile model will be attached.
 | 
				
			||||||
     * @param target    Der Zielpunkt der Rakete.
 | 
					     * @param target    The target point where the missile will explode.
 | 
				
			||||||
     * @param flightTime Die Zeit, die die Rakete für den gesamten Flug benötigt.
 | 
					     * @param flightTime The total flight time of the missile.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public MissileAnimation(MdgaApp app, Node rootNode, UUID uuid, Vector3f target, float flightTime) {
 | 
					    public MissileAnimation(MdgaApp app, Node rootNode, Vector3f target, float flightTime, Runnable actionAfter) {
 | 
				
			||||||
        this.app = app;
 | 
					        this.app = app;
 | 
				
			||||||
        this.rootNode = rootNode;
 | 
					        this.rootNode = rootNode;
 | 
				
			||||||
        this.flightTime = flightTime;
 | 
					        this.flightTime = flightTime;
 | 
				
			||||||
 | 
					        this.actionAfter = actionAfter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        explosion = new Explosion(app, rootNode, target);
 | 
					        explosion = new Explosion(app, rootNode, target);
 | 
				
			||||||
        id = uuid;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.target = target.add(new Vector3f(1.5f, -1, 0));
 | 
					        this.target = target.add(new Vector3f(1.5f, -1, 0));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        start = BoardHandler.gridToWorld(12, 0);
 | 
					        start = BoardHandler.gridToWorld(12, 0);
 | 
				
			||||||
        start.add(new Vector3f(0, 0, 0));
 | 
					        start.add(new Vector3f(0, 0, 0));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        this.mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md");
 | 
				
			||||||
 | 
					        mat.setTexture("Texture", app.getAssetManager().loadTexture("Images/particle/vapor_cloud.png"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        smoke = new ParticleEmitter("Effect2", ParticleMesh.Type.Triangle,400);
 | 
				
			||||||
 | 
					        smoke.setMaterial(mat);
 | 
				
			||||||
 | 
					        smoke.setImagesX(3);
 | 
				
			||||||
 | 
					        smoke.setImagesY(3);
 | 
				
			||||||
 | 
					        smoke.setStartColor(ColorRGBA.DarkGray);
 | 
				
			||||||
 | 
					        smoke.setEndColor(new ColorRGBA(0.05f, 0.05f, 0.05f, 1));
 | 
				
			||||||
 | 
					        smoke.getParticleInfluencer().setInitialVelocity(new Vector3f(0.0f,0.0f,0.0f));
 | 
				
			||||||
 | 
					        smoke.getParticleInfluencer().setVelocityVariation(0.1f);
 | 
				
			||||||
 | 
					        smoke.setStartSize(0.8f);
 | 
				
			||||||
 | 
					        smoke.setEndSize(1.5f);
 | 
				
			||||||
 | 
					        smoke.setGravity(0, 0, -0.3f);
 | 
				
			||||||
 | 
					        smoke.setLowLife(1.2f);
 | 
				
			||||||
 | 
					        smoke.setHighLife(3.5f);
 | 
				
			||||||
 | 
					        smoke.setParticlesPerSec(100);
 | 
				
			||||||
 | 
					        missileNode.attachChild(smoke);
 | 
				
			||||||
 | 
					        smoke.move(1, 0.85f, 1.0f);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Startet die Raketenanimation.
 | 
					     * Starts the missile animation by loading the missile model and initiating its parabolic movement.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public void start() {
 | 
					    public void start() {
 | 
				
			||||||
 | 
					        Smoke s = new Smoke(app, rootNode, start);
 | 
				
			||||||
 | 
					        s.trigger();
 | 
				
			||||||
        loadMissile();
 | 
					        loadMissile();
 | 
				
			||||||
        app.getAcousticHandler().playSound(MdgaSound.MISSILE);
 | 
					        app.getAcousticHandler().playSound(MdgaSound.MISSILE);
 | 
				
			||||||
        animateMissile();
 | 
					        animateMissile();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Lädt das Raketenmodell und setzt es auf den Startpunkt.
 | 
					     * Loads the missile model into the scene, applies scaling, material, and sets its initial position.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private void loadMissile() {
 | 
					    private void loadMissile() {
 | 
				
			||||||
        missileModel = app.getAssetManager().loadModel(Asset.missile.getModelPath()); // Lade das Missile-Modell
 | 
					        missileModel = app.getAssetManager().loadModel(Asset.missile.getModelPath());
 | 
				
			||||||
        missileModel.scale(Asset.missile.getSize());
 | 
					        missileModel.scale(Asset.missile.getSize());
 | 
				
			||||||
        missileModel.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
 | 
					        missileModel.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(Asset.missile.getDiffPath()));
 | 
					        mat.setTexture("DiffuseMap", app.getAssetManager().loadTexture(Asset.missile.getDiffPath()));
 | 
				
			||||||
        missileModel.setMaterial(mat);
 | 
					        missileModel.setMaterial(mat);
 | 
				
			||||||
        missileModel.setLocalTranslation(start); // Setze Startposition
 | 
					
 | 
				
			||||||
        rootNode.attachChild(missileModel); // Füge das Modell zur Szene hinzu
 | 
					        missileNode.setLocalTranslation(start);
 | 
				
			||||||
 | 
					        missileNode.attachChild(missileModel);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        rootNode.attachChild(missileNode);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Animiert die Rakete entlang einer Parabel.
 | 
					     * Animates the missile along a parabolic path, triggers the explosion near the target,
 | 
				
			||||||
 | 
					     * and removes the missile model after the animation completes.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private void animateMissile() {
 | 
					    private void animateMissile() {
 | 
				
			||||||
        missileModel.addControl(new AbstractControl() {
 | 
					        missileNode.addControl(new AbstractControl() {
 | 
				
			||||||
            private float elapsedTime = 0;
 | 
					            private float elapsedTime = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            @Override
 | 
					            @Override
 | 
				
			||||||
            protected void controlUpdate(float tpf) {
 | 
					            protected void controlUpdate(float tpf) {
 | 
				
			||||||
 | 
					                if(elapsedTime > 6) {
 | 
				
			||||||
 | 
					                    endAnim();
 | 
				
			||||||
 | 
					                    rootNode.detachChild(missileNode);
 | 
				
			||||||
 | 
					                    this.spatial.removeControl(this);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                elapsedTime += tpf;
 | 
					                elapsedTime += tpf;
 | 
				
			||||||
                float progress = elapsedTime / flightTime;
 | 
					                float progress = elapsedTime / flightTime;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (progress >= 0.55) {
 | 
				
			||||||
 | 
					                    smoke.setParticlesPerSec(30);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (progress >= 0.7) {
 | 
				
			||||||
 | 
					                    smoke.setParticlesPerSec(0);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (progress >= 0.95f) {
 | 
					                if (progress >= 0.95f) {
 | 
				
			||||||
                    explosion.trigger();
 | 
					                    explosion.trigger();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (progress >= 1) {
 | 
					                if (progress >= 1) {
 | 
				
			||||||
                    explosion.trigger();
 | 
					                    explosion.trigger();
 | 
				
			||||||
 | 
					                    missileNode.detachChild(missileModel);
 | 
				
			||||||
                    // 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);
 | 
					                Vector3f currentPosition = computeParabolicPath(start, target, progress);
 | 
				
			||||||
                missileModel.setLocalTranslation(currentPosition);
 | 
					                missileNode.setLocalTranslation(currentPosition);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                // Passe die Ausrichtung an (Nase der Rakete zeigt in Flugrichtung)
 | 
					 | 
				
			||||||
                Vector3f direction = computeParabolicPath(start, target, progress + 0.01f)
 | 
					                Vector3f direction = computeParabolicPath(start, target, progress + 0.01f)
 | 
				
			||||||
                    .subtract(currentPosition)
 | 
					                    .subtract(currentPosition)
 | 
				
			||||||
                    .normalizeLocal();
 | 
					                    .normalizeLocal();
 | 
				
			||||||
                missileModel.lookAt(currentPosition.add(direction), Vector3f.UNIT_Y); // Z ist oben, Y ist "Up"
 | 
					                missileModel.lookAt(currentPosition.add(direction), Vector3f.UNIT_Y);
 | 
				
			||||||
                missileModel.rotate(0, FastMath.HALF_PI, 0);
 | 
					                missileModel.rotate(0, FastMath.HALF_PI, 0);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            @Override
 | 
					            @Override
 | 
				
			||||||
            protected void controlRender(RenderManager rm, ViewPort vp) {
 | 
					            protected void controlRender(RenderManager rm, ViewPort vp) {
 | 
				
			||||||
                // Keine Render-Logik benötigt
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void endAnim(){
 | 
				
			||||||
 | 
					        actionAfter.run();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Berechnet eine Parabelbewegung von `start` zu `target`.
 | 
					     * Computes a position along a parabolic path at a given progress value {@code t}.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     * @param start Der Startpunkt der Rakete.
 | 
					     * @param start The starting point of the missile's flight.
 | 
				
			||||||
     * @param target Der Zielpunkt der Rakete.
 | 
					     * @param target The target point of the missile's flight.
 | 
				
			||||||
     * @param t Der Fortschritt des Flugs (0 bis 1).
 | 
					     * @param t The progress value (0.0 to 1.0) along the flight path.
 | 
				
			||||||
     * @return Die Position der Rakete entlang der Parabel.
 | 
					     * @return The interpolated position along the parabolic path.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private Vector3f computeParabolicPath(Vector3f start, Vector3f target, float t) {
 | 
					    private Vector3f computeParabolicPath(Vector3f start, Vector3f target, float t) {
 | 
				
			||||||
        Vector3f midPoint = start.add(target).multLocal(0.5f); // Berechne die Mitte zwischen Start und Ziel
 | 
					        Vector3f midPoint = start.add(target).multLocal(0.5f);
 | 
				
			||||||
        midPoint.addLocal(0, 0, 20); // Erhöhe den Scheitelpunkt der Parabel entlang der Z-Achse
 | 
					        midPoint.addLocal(0, 0, 20);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Quadratische Interpolation (Parabel)
 | 
					 | 
				
			||||||
        Vector3f startToMid = FastMath.interpolateLinear(t, start, midPoint);
 | 
					        Vector3f startToMid = FastMath.interpolateLinear(t, start, midPoint);
 | 
				
			||||||
        Vector3f midToTarget = FastMath.interpolateLinear(t, midPoint, target);
 | 
					        Vector3f midToTarget = FastMath.interpolateLinear(t, midPoint, target);
 | 
				
			||||||
        return FastMath.interpolateLinear(t, startToMid, midToTarget);
 | 
					        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());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,127 @@
 | 
				
			|||||||
 | 
					package pp.mdga.client.animation;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.jme3.effect.ParticleEmitter;
 | 
				
			||||||
 | 
					import com.jme3.effect.ParticleMesh;
 | 
				
			||||||
 | 
					import com.jme3.material.Material;
 | 
				
			||||||
 | 
					import com.jme3.math.ColorRGBA;
 | 
				
			||||||
 | 
					import com.jme3.math.Vector3f;
 | 
				
			||||||
 | 
					import com.jme3.scene.Node;
 | 
				
			||||||
 | 
					import com.jme3.scene.control.AbstractControl;
 | 
				
			||||||
 | 
					import pp.mdga.client.MdgaApp;
 | 
				
			||||||
 | 
					import pp.mdga.client.acoustic.MdgaSound;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class Smoke {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private final Node rootNode;
 | 
				
			||||||
 | 
					    private final MdgaApp app;
 | 
				
			||||||
 | 
					    private final Vector3f location;
 | 
				
			||||||
 | 
					    private ParticleEmitter fire;
 | 
				
			||||||
 | 
					    private ParticleEmitter smoke;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private boolean triggered = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private final Material mat;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Constructor for the {@code Explosion} class.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param app      The main application managing the explosion.
 | 
				
			||||||
 | 
					     * @param rootNode The root node to which the explosion effects will be attached.
 | 
				
			||||||
 | 
					     * @param location The location of the explosion in world coordinates.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public Smoke(MdgaApp app, Node rootNode, Vector3f location) {
 | 
				
			||||||
 | 
					        this.app = app;
 | 
				
			||||||
 | 
					        this.rootNode = rootNode;
 | 
				
			||||||
 | 
					        this.location = location;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        this.mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md");
 | 
				
			||||||
 | 
					        mat.setTexture("Texture", app.getAssetManager().loadTexture("Images/particle/vapor_cloud.png"));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Initializes the particle emitters for the explosion effect.
 | 
				
			||||||
 | 
					     * Configures the fire and smoke emitters with appearance, behavior, and lifespan.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    private void initializeEmitter() {
 | 
				
			||||||
 | 
					        fire = new ParticleEmitter("Effect", ParticleMesh.Type.Triangle,50);
 | 
				
			||||||
 | 
					        fire.setMaterial(mat);
 | 
				
			||||||
 | 
					        fire.setStartColor(ColorRGBA.DarkGray);
 | 
				
			||||||
 | 
					        fire.setEndColor(ColorRGBA.DarkGray);
 | 
				
			||||||
 | 
					        fire.getParticleInfluencer().setInitialVelocity(new Vector3f(0.2f,0.2f,4f));
 | 
				
			||||||
 | 
					        fire.getParticleInfluencer().setVelocityVariation(0.4f);
 | 
				
			||||||
 | 
					        fire.setStartSize(0.7f);
 | 
				
			||||||
 | 
					        fire.setEndSize(3.8f);
 | 
				
			||||||
 | 
					        fire.setGravity(0, 0, -0.1f);
 | 
				
			||||||
 | 
					        fire.setLowLife(0.5f);
 | 
				
			||||||
 | 
					        fire.setHighLife(1.2f);
 | 
				
			||||||
 | 
					        fire.setParticlesPerSec(0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        fire.setLocalTranslation(location);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        smoke = new ParticleEmitter("Effect2", ParticleMesh.Type.Triangle,40);
 | 
				
			||||||
 | 
					        smoke.setMaterial(mat);
 | 
				
			||||||
 | 
					        smoke.setImagesX(2);
 | 
				
			||||||
 | 
					        smoke.setImagesY(2);
 | 
				
			||||||
 | 
					        smoke.setStartColor(ColorRGBA.DarkGray);
 | 
				
			||||||
 | 
					        smoke.setEndColor(new ColorRGBA(0.05f, 0.05f, 0.05f, 1));
 | 
				
			||||||
 | 
					        smoke.getParticleInfluencer().setInitialVelocity(new Vector3f(0.0f,0.0f,2f));
 | 
				
			||||||
 | 
					        smoke.getParticleInfluencer().setVelocityVariation(0.5f);
 | 
				
			||||||
 | 
					        smoke.setStartSize(0.5f);
 | 
				
			||||||
 | 
					        smoke.setEndSize(1.5f);
 | 
				
			||||||
 | 
					        smoke.setGravity(0, 0, -0.3f);
 | 
				
			||||||
 | 
					        smoke.setLowLife(1.2f);
 | 
				
			||||||
 | 
					        smoke.setHighLife(2.5f);
 | 
				
			||||||
 | 
					        smoke.setParticlesPerSec(0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        smoke.setLocalTranslation(location);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        app.getAcousticHandler().playSound(MdgaSound.EXPLOSION);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Triggers the explosion effect by attaching and activating the particle emitters for fire and smoke.
 | 
				
			||||||
 | 
					     * Both emitters are automatically detached after a predefined duration.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public void trigger() {
 | 
				
			||||||
 | 
					        if (!triggered) {
 | 
				
			||||||
 | 
					            triggered = true;
 | 
				
			||||||
 | 
					            initializeEmitter();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        rootNode.attachChild(fire);
 | 
				
			||||||
 | 
					        fire.emitAllParticles();
 | 
				
			||||||
 | 
					        fire.addControl(new AbstractControl() {
 | 
				
			||||||
 | 
					            private float elapsedTime = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            protected void controlUpdate(float tpf) {
 | 
				
			||||||
 | 
					                elapsedTime += tpf;
 | 
				
			||||||
 | 
					                if (elapsedTime > 10f) {
 | 
				
			||||||
 | 
					                    rootNode.detachChild(fire);
 | 
				
			||||||
 | 
					                    fire.removeControl(this);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            protected void controlRender(com.jme3.renderer.RenderManager rm, com.jme3.renderer.ViewPort vp) {}
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        rootNode.attachChild(smoke);
 | 
				
			||||||
 | 
					        smoke.emitAllParticles();
 | 
				
			||||||
 | 
					        smoke.addControl(new AbstractControl() {
 | 
				
			||||||
 | 
					            private float elapsedTime = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            protected void controlUpdate(float tpf) {
 | 
				
			||||||
 | 
					                elapsedTime += tpf;
 | 
				
			||||||
 | 
					                if (elapsedTime > 10f) {
 | 
				
			||||||
 | 
					                    rootNode.detachChild(smoke);
 | 
				
			||||||
 | 
					                    smoke.removeControl(this);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            protected void controlRender(com.jme3.renderer.RenderManager rm, com.jme3.renderer.ViewPort vp) {}
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -52,10 +53,15 @@ public class BoardHandler {
 | 
				
			|||||||
    // Flags and lists for handling piece selection and movement
 | 
					    // Flags and lists for handling piece selection and movement
 | 
				
			||||||
    private List<PieceControl> selectableOwnPieces;
 | 
					    private List<PieceControl> selectableOwnPieces;
 | 
				
			||||||
    private List<PieceControl> selectableEnemyPieces;
 | 
					    private List<PieceControl> selectableEnemyPieces;
 | 
				
			||||||
 | 
					    private Map<PieceControl, NodeControl> selectedPieceNodeMap;
 | 
				
			||||||
    private List<NodeControl> outlineNodes;
 | 
					    private List<NodeControl> outlineNodes;
 | 
				
			||||||
    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.
 | 
				
			||||||
@@ -82,6 +88,7 @@ public void init() {
 | 
				
			|||||||
        isInitialised = true;
 | 
					        isInitialised = true;
 | 
				
			||||||
        selectableOwnPieces = new ArrayList<>();
 | 
					        selectableOwnPieces = new ArrayList<>();
 | 
				
			||||||
        selectableEnemyPieces = new ArrayList<>();
 | 
					        selectableEnemyPieces = new ArrayList<>();
 | 
				
			||||||
 | 
					        selectedPieceNodeMap = new HashMap<>();
 | 
				
			||||||
        outlineNodes = new ArrayList<>();
 | 
					        outlineNodes = new ArrayList<>();
 | 
				
			||||||
        selectedOwnPiece = null;
 | 
					        selectedOwnPiece = null;
 | 
				
			||||||
        selectedEnemyPiece = null;
 | 
					        selectedEnemyPiece = null;
 | 
				
			||||||
@@ -148,12 +155,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 +206,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;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -218,16 +242,38 @@ private Spatial displayAsset(AssetOnMap assetOnMap) {
 | 
				
			|||||||
        return createModel(assetOnMap.asset(), gridToWorld(x, y), assetOnMap.rot());
 | 
					        return createModel(assetOnMap.asset(), gridToWorld(x, y), assetOnMap.rot());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Adds a visual representation of an asset to the scene, attaches a control to it, and returns the control.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param assetOnMap The asset to be displayed in the 3D environment.
 | 
				
			||||||
 | 
					     * @param control    The control to be added to the spatial representing the asset.
 | 
				
			||||||
 | 
					     * @param <T>        The type of control, extending {@code AbstractControl}.
 | 
				
			||||||
 | 
					     * @return The control that was added to the spatial.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    private <T extends AbstractControl> T displayAndControl(AssetOnMap assetOnMap, T control) {
 | 
					    private <T extends AbstractControl> T displayAndControl(AssetOnMap assetOnMap, T control) {
 | 
				
			||||||
        Spatial spatial = displayAsset(assetOnMap);
 | 
					        Spatial spatial = displayAsset(assetOnMap);
 | 
				
			||||||
        spatial.addControl(control);
 | 
					        spatial.addControl(control);
 | 
				
			||||||
        return control;
 | 
					        return control;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Moves a piece in the 3D environment to the location of a specified node.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param pieceControl The control managing the piece to be moved.
 | 
				
			||||||
 | 
					     * @param nodeControl  The control managing the target node to which the piece will move.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    private void movePieceToNode(PieceControl pieceControl, NodeControl nodeControl){
 | 
					    private void movePieceToNode(PieceControl pieceControl, NodeControl nodeControl){
 | 
				
			||||||
        pieceControl.setLocation(nodeControl.getLocation());
 | 
					        pieceControl.setLocation(nodeControl.getLocation());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Adds a home node for a specific player color, attaching it to the map of home nodes.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param map          The map storing lists of home nodes by player color.
 | 
				
			||||||
 | 
					     * @param color        The color associated with the home nodes to be added.
 | 
				
			||||||
 | 
					     * @param assetOnMap   The asset representing the home node in the 3D environment.
 | 
				
			||||||
 | 
					     * @throws RuntimeException if more than 4 home nodes are added for a single color.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    private void addHomeNode(Map<Color, List<NodeControl>> map, Color color, AssetOnMap assetOnMap){
 | 
					    private void addHomeNode(Map<Color, List<NodeControl>> map, Color color, AssetOnMap assetOnMap){
 | 
				
			||||||
        List<NodeControl> homeNodes = addItemToMapList(map, color, displayAndControl(assetOnMap, new NodeControl(app, fpp)));
 | 
					        List<NodeControl> homeNodes = addItemToMapList(map, color, displayAndControl(assetOnMap, new NodeControl(app, fpp)));
 | 
				
			||||||
        if (homeNodes.size() > 4) throw new RuntimeException("too many homeNodes for " + color);
 | 
					        if (homeNodes.size() > 4) throw new RuntimeException("too many homeNodes for " + color);
 | 
				
			||||||
@@ -271,6 +317,16 @@ private void movePieceRek(UUID uuid, int curIndex, int moveIndex){
 | 
				
			|||||||
        movePieceRek(uuid, curIndex, moveIndex);
 | 
					        movePieceRek(uuid, curIndex, moveIndex);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Adds an item to a list in a map. If the key does not exist in the map, a new list is created.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param map  The map containing lists of items.
 | 
				
			||||||
 | 
					     * @param key  The key associated with the list in the map.
 | 
				
			||||||
 | 
					     * @param item The item to be added to the list.
 | 
				
			||||||
 | 
					     * @param <T>  The type of items in the list.
 | 
				
			||||||
 | 
					     * @param <E>  The type of the key in the map.
 | 
				
			||||||
 | 
					     * @return The updated list associated with the specified key.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    private <T, E> List<T> addItemToMapList(Map<E,List<T>> map, E key, T item){
 | 
					    private <T, E> List<T> addItemToMapList(Map<E,List<T>> map, E key, T item){
 | 
				
			||||||
        List<T> list = map.getOrDefault(key, new ArrayList<>());
 | 
					        List<T> list = map.getOrDefault(key, new ArrayList<>());
 | 
				
			||||||
        list.add(item);
 | 
					        list.add(item);
 | 
				
			||||||
@@ -278,12 +334,27 @@ private <T, E> List<T> addItemToMapList(Map<E,List<T>> map, E key, T item){
 | 
				
			|||||||
        return list;
 | 
					        return list;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Removes an item from a list in a map. If the key does not exist in the map, a new list is created.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param map  The map containing lists of items.
 | 
				
			||||||
 | 
					     * @param key  The key associated with the list in the map.
 | 
				
			||||||
 | 
					     * @param item The item to be removed from the list.
 | 
				
			||||||
 | 
					     * @param <T>  The type of items in the list.
 | 
				
			||||||
 | 
					     * @param <E>  The type of the key in the map.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    private <T, E> void removeItemFromMapList(Map<E,List<T>> map, E key, T item){
 | 
					    private <T, E> void removeItemFromMapList(Map<E,List<T>> map, E key, T item){
 | 
				
			||||||
        List<T> list = map.getOrDefault(key, new ArrayList<>());
 | 
					        List<T> list = map.getOrDefault(key, new ArrayList<>());
 | 
				
			||||||
        list.remove(item);
 | 
					        list.remove(item);
 | 
				
			||||||
        map.put(key, list);
 | 
					        map.put(key, list);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Calculates the mean position of the waiting nodes for a specific color.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param color The color associated with the waiting nodes.
 | 
				
			||||||
 | 
					     * @return The mean position of the waiting nodes as a {@code Vector3f}.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    private Vector3f getWaitingPos(Color color){
 | 
					    private Vector3f getWaitingPos(Color color){
 | 
				
			||||||
        return getMeanPosition(waitingNodesMap.get(color).stream().map(NodeControl::getLocation).toList());
 | 
					        return getMeanPosition(waitingNodesMap.get(color).stream().map(NodeControl::getLocation).toList());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -534,6 +605,7 @@ public void outlineMove(List<UUID> pieces, List<Integer> moveIndexe, List<Boolea
 | 
				
			|||||||
            pieceControl.setSelectable(true);
 | 
					            pieceControl.setSelectable(true);
 | 
				
			||||||
            outlineNodes.add(nodeControl);
 | 
					            outlineNodes.add(nodeControl);
 | 
				
			||||||
            selectableOwnPieces.add(pieceControl);
 | 
					            selectableOwnPieces.add(pieceControl);
 | 
				
			||||||
 | 
					            selectedPieceNodeMap.put(pieceControl, nodeControl);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -599,10 +671,12 @@ public void pieceSelect(PieceControl pieceSelected) {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
            if (!isSelected) {
 | 
					            if (!isSelected) {
 | 
				
			||||||
                pieceSelected.select();
 | 
					                pieceSelected.select();
 | 
				
			||||||
 | 
					                selectedPieceNodeMap.get(pieceSelected).select();
 | 
				
			||||||
                selectedOwnPiece = pieceSelected;
 | 
					                selectedOwnPiece = pieceSelected;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            else {
 | 
					            else {
 | 
				
			||||||
                pieceSelected.unSelect();
 | 
					                pieceSelected.unSelect();
 | 
				
			||||||
 | 
					                selectedPieceNodeMap.get(pieceSelected).highlight();
 | 
				
			||||||
                selectedOwnPiece = null;
 | 
					                selectedOwnPiece = null;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -632,11 +706,13 @@ public void clearSelectable(){
 | 
				
			|||||||
            p.unSelect();
 | 
					            p.unSelect();
 | 
				
			||||||
            p.unHighlight();
 | 
					            p.unHighlight();
 | 
				
			||||||
            p.setSelectable(false);
 | 
					            p.setSelectable(false);
 | 
				
			||||||
 | 
					            p.setHoverable(false);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        for(PieceControl p : selectableOwnPieces) {
 | 
					        for(PieceControl p : selectableOwnPieces) {
 | 
				
			||||||
            p.unSelect();
 | 
					            p.unSelect();
 | 
				
			||||||
            p.unHighlight();
 | 
					            p.unHighlight();
 | 
				
			||||||
            p.setSelectable(false);
 | 
					            p.setSelectable(false);
 | 
				
			||||||
 | 
					            p.setHoverable(false);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        for(NodeControl n : outlineNodes){
 | 
					        for(NodeControl n : outlineNodes){
 | 
				
			||||||
            n.deOutline();
 | 
					            n.deOutline();
 | 
				
			||||||
@@ -644,6 +720,7 @@ public void clearSelectable(){
 | 
				
			|||||||
        outlineNodes.clear();
 | 
					        outlineNodes.clear();
 | 
				
			||||||
        selectableEnemyPieces.clear();
 | 
					        selectableEnemyPieces.clear();
 | 
				
			||||||
        selectableOwnPieces.clear();
 | 
					        selectableOwnPieces.clear();
 | 
				
			||||||
 | 
					        selectedPieceNodeMap.clear();
 | 
				
			||||||
        selectedEnemyPiece = null;
 | 
					        selectedEnemyPiece = null;
 | 
				
			||||||
        selectedOwnPiece = null;
 | 
					        selectedOwnPiece = null;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -723,34 +800,57 @@ 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 -> throwMissile(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, 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 throwMissile(UUID uuid) {
 | 
				
			||||||
 | 
					        Vector3f targetPoint = pieces.get(uuid).getLocation();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        MissileAnimation anim = new MissileAnimation(app, rootNode, targetPoint, 2f, ()->throwPieceAnim(uuid));
 | 
				
			||||||
 | 
					        anim.start();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    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);
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,6 +16,8 @@ public class NodeControl extends OutlineControl {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    private static final ColorRGBA OUTLINE_HIGHLIGHT_COLOR = ColorRGBA.White;
 | 
					    private static final ColorRGBA OUTLINE_HIGHLIGHT_COLOR = ColorRGBA.White;
 | 
				
			||||||
    private static final int OUTLINE_HIGHLIGHT_WIDTH = 6;
 | 
					    private static final int OUTLINE_HIGHLIGHT_WIDTH = 6;
 | 
				
			||||||
 | 
					    private static final ColorRGBA OUTLINE_SELECT_COLOR = ColorRGBA.Cyan;
 | 
				
			||||||
 | 
					    private static final int OUTLINE_SELECT_WIDTH = 6;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Constructs a {@link NodeControl} with the specified application and post processor.
 | 
					     * Constructs a {@link NodeControl} with the specified application and post processor.
 | 
				
			||||||
@@ -45,4 +47,8 @@ public Vector3f getLocation(){
 | 
				
			|||||||
    public void highlight() {
 | 
					    public void highlight() {
 | 
				
			||||||
        super.outline(OUTLINE_HIGHLIGHT_COLOR, OUTLINE_HIGHLIGHT_WIDTH);
 | 
					        super.outline(OUTLINE_HIGHLIGHT_COLOR, OUTLINE_HIGHLIGHT_WIDTH);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void select() {
 | 
				
			||||||
 | 
					        super.outline(OUTLINE_SELECT_COLOR, OUTLINE_SELECT_WIDTH);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,17 +18,37 @@ public class OutlineControl extends InitControl {
 | 
				
			|||||||
    private static final int THICKNESS_DEFAULT = 6;
 | 
					    private static final int THICKNESS_DEFAULT = 6;
 | 
				
			||||||
    private MdgaApp app;
 | 
					    private MdgaApp app;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Constructs an {@code OutlineControl} with default thickness for the object outline.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param app The main application managing the outline control.
 | 
				
			||||||
 | 
					     * @param fpp The {@code FilterPostProcessor} used for post-processing effects.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    public OutlineControl(MdgaApp app, FilterPostProcessor fpp){
 | 
					    public OutlineControl(MdgaApp app, FilterPostProcessor fpp){
 | 
				
			||||||
        this.app = app;
 | 
					        this.app = app;
 | 
				
			||||||
        outlineOwn = new SelectObjectOutliner(THICKNESS_DEFAULT, fpp, app.getRenderManager(), app.getAssetManager(), app.getCamera(), app);
 | 
					        outlineOwn = new SelectObjectOutliner(THICKNESS_DEFAULT, fpp, app.getRenderManager(), app.getAssetManager(), app.getCamera(), app);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Constructs an {@code OutlineControl} with default thickness, allowing a custom camera to be specified.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param app The main application managing the outline control.
 | 
				
			||||||
 | 
					     * @param fpp The {@code FilterPostProcessor} used for post-processing effects.
 | 
				
			||||||
 | 
					     * @param cam The camera used for rendering the outlined objects.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    public OutlineControl(MdgaApp app, FilterPostProcessor fpp, Camera cam){
 | 
					    public OutlineControl(MdgaApp app, FilterPostProcessor fpp, Camera cam){
 | 
				
			||||||
        this.app = app;
 | 
					        this.app = app;
 | 
				
			||||||
        outlineOwn = new SelectObjectOutliner(THICKNESS_DEFAULT, fpp, app.getRenderManager(), app.getAssetManager(), cam, app);
 | 
					        outlineOwn = new SelectObjectOutliner(THICKNESS_DEFAULT, fpp, app.getRenderManager(), app.getAssetManager(), cam, app);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Constructs an {@code OutlineControl} with a specified thickness and custom camera.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param app       The main application managing the outline control.
 | 
				
			||||||
 | 
					     * @param fpp       The {@code FilterPostProcessor} used for post-processing effects.
 | 
				
			||||||
 | 
					     * @param cam       The camera used for rendering the outlined objects.
 | 
				
			||||||
 | 
					     * @param thickness The thickness of the outline.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    public OutlineControl(MdgaApp app, FilterPostProcessor fpp, Camera cam, int thickness){
 | 
					    public OutlineControl(MdgaApp app, FilterPostProcessor fpp, Camera cam, int thickness){
 | 
				
			||||||
        this.app = app;
 | 
					        this.app = app;
 | 
				
			||||||
        outlineOwn = new SelectObjectOutliner(thickness, fpp, app.getRenderManager(), app.getAssetManager(), cam, app);
 | 
					        outlineOwn = new SelectObjectOutliner(thickness, fpp, app.getRenderManager(), app.getAssetManager(), cam, app);
 | 
				
			||||||
@@ -61,6 +81,11 @@ public void deOutline(){
 | 
				
			|||||||
        outlineOwn.deselect(spatial);
 | 
					        outlineOwn.deselect(spatial);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Retrieves the instance of the {@code MdgaApp} associated with this control.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @return The {@code MdgaApp} instance.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    public MdgaApp getApp() {
 | 
					    public MdgaApp getApp() {
 | 
				
			||||||
        return app;
 | 
					        return app;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -77,12 +77,17 @@ public SliderButton(MdgaApp app, Node node, String label) {
 | 
				
			|||||||
        QuadBackgroundComponent background = new QuadBackgroundComponent(BUTTON_NORMAL);
 | 
					        QuadBackgroundComponent background = new QuadBackgroundComponent(BUTTON_NORMAL);
 | 
				
			||||||
        slider.setBackground(background);
 | 
					        slider.setBackground(background);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Set label background
 | 
				
			||||||
 | 
					        QuadBackgroundComponent labelBackground = new QuadBackgroundComponent(BUTTON_NORMAL);
 | 
				
			||||||
 | 
					        this.label.setBackground(labelBackground);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Configure the label font
 | 
					        // Configure the label font
 | 
				
			||||||
        this.label.setFont(font);
 | 
					        this.label.setFont(font);
 | 
				
			||||||
 | 
					        this.label.setTextHAlignment(HAlignment.Center);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Default position and size
 | 
					        // Default position and size
 | 
				
			||||||
        pos = new Vector2f(0, 0);
 | 
					        pos = new Vector2f(0, 0);
 | 
				
			||||||
        size = new Vector2f(5.5f, 1);
 | 
					        size = new Vector2f(6f, 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Add label and slider to container
 | 
					        // Add label and slider to container
 | 
				
			||||||
        container.addChild(this.label);
 | 
					        container.addChild(this.label);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,6 +7,11 @@
 | 
				
			|||||||
import pp.mdga.client.button.SliderButton;
 | 
					import pp.mdga.client.button.SliderButton;
 | 
				
			||||||
import pp.mdga.client.view.MdgaView;
 | 
					import pp.mdga.client.view.MdgaView;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * The {@code AudioSettingsDialog} class represents a dialog for adjusting audio settings in the application.
 | 
				
			||||||
 | 
					 * It provides controls for managing main volume, music volume, and sound effect volume, and includes
 | 
				
			||||||
 | 
					 * a button to return to the previous menu.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
public class AudioSettingsDialog extends Dialog {
 | 
					public class AudioSettingsDialog extends Dialog {
 | 
				
			||||||
    private final MdgaView view;
 | 
					    private final MdgaView view;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -18,6 +23,13 @@ public class AudioSettingsDialog extends Dialog {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    private boolean active = false;
 | 
					    private boolean active = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Constructs an {@code AudioSettingsDialog}.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param app  The main application managing the dialog.
 | 
				
			||||||
 | 
					     * @param node The root node for attaching UI elements.
 | 
				
			||||||
 | 
					     * @param view The current view, used for navigation and interaction with the dialog.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    public AudioSettingsDialog(MdgaApp app, Node node, MdgaView view) {
 | 
					    public AudioSettingsDialog(MdgaApp app, Node node, MdgaView view) {
 | 
				
			||||||
        super(app, node);
 | 
					        super(app, node);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -42,6 +54,9 @@ public AudioSettingsDialog(MdgaApp app, Node node, MdgaView view) {
 | 
				
			|||||||
        backButton.setPos(new Vector2f(0, 1.8f));
 | 
					        backButton.setPos(new Vector2f(0, 1.8f));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Called when the dialog is shown. Initializes and displays the volume controls and back button.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    protected void onShow() {
 | 
					    protected void onShow() {
 | 
				
			||||||
        active = true;
 | 
					        active = true;
 | 
				
			||||||
@@ -57,6 +72,9 @@ protected void onShow() {
 | 
				
			|||||||
        soundVolume.show();
 | 
					        soundVolume.show();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Called when the dialog is hidden. Hides all volume controls and the back button.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    protected void onHide() {
 | 
					    protected void onHide() {
 | 
				
			||||||
        active = false;
 | 
					        active = false;
 | 
				
			||||||
@@ -68,6 +86,10 @@ protected void onHide() {
 | 
				
			|||||||
        soundVolume.hide();
 | 
					        soundVolume.hide();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Updates the application audio settings based on the current values of the sliders.
 | 
				
			||||||
 | 
					     * This method is called continuously while the dialog is active.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    public void update() {
 | 
					    public void update() {
 | 
				
			||||||
        if(!active) {
 | 
					        if(!active) {
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,17 +10,30 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import java.util.ArrayList;
 | 
					import java.util.ArrayList;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * The {@code CeremonyDialog} class displays a dialog containing statistical data in a tabular format.
 | 
				
			||||||
 | 
					 * It allows adding rows of statistics and manages their visibility when shown or hidden.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
public class CeremonyDialog extends Dialog {
 | 
					public class CeremonyDialog extends Dialog {
 | 
				
			||||||
    private ArrayList<ArrayList<LabelButton>> labels;
 | 
					    private ArrayList<ArrayList<LabelButton>> labels;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    float offsetX;
 | 
					    float offsetX;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Constructs a {@code CeremonyDialog}.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param app  The main application managing the dialog.
 | 
				
			||||||
 | 
					     * @param node The root node for attaching UI elements.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    public CeremonyDialog(MdgaApp app, Node node) {
 | 
					    public CeremonyDialog(MdgaApp app, Node node) {
 | 
				
			||||||
        super(app, node);
 | 
					        super(app, node);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        prepare();
 | 
					        prepare();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Called when the dialog is shown. Makes all label buttons in the table visible.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    protected void onShow() {
 | 
					    protected void onShow() {
 | 
				
			||||||
        for (ArrayList<LabelButton> row : labels) {
 | 
					        for (ArrayList<LabelButton> row : labels) {
 | 
				
			||||||
@@ -30,6 +43,9 @@ protected void onShow() {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Called when the dialog is hidden. Hides all label buttons in the table.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    protected void onHide() {
 | 
					    protected void onHide() {
 | 
				
			||||||
        for (ArrayList<LabelButton> row : labels) {
 | 
					        for (ArrayList<LabelButton> row : labels) {
 | 
				
			||||||
@@ -39,6 +55,17 @@ protected void onHide() {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Adds a row of statistical data to the dialog.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param name The name of the player or category for the row.
 | 
				
			||||||
 | 
					     * @param v1   The value for the first column.
 | 
				
			||||||
 | 
					     * @param v2   The value for the second column.
 | 
				
			||||||
 | 
					     * @param v3   The value for the third column.
 | 
				
			||||||
 | 
					     * @param v4   The value for the fourth column.
 | 
				
			||||||
 | 
					     * @param v5   The value for the fifth column.
 | 
				
			||||||
 | 
					     * @param v6   The value for the sixth column.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    public void addStatisticsRow(String name, int v1, int v2, int v3, int v4, int v5, int v6) {
 | 
					    public void addStatisticsRow(String name, int v1, int v2, int v3, int v4, int v5, int v6) {
 | 
				
			||||||
        float offsetYSmall = 0.5f;
 | 
					        float offsetYSmall = 0.5f;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -76,6 +103,9 @@ public void addStatisticsRow(String name, int v1, int v2, int v3, int v4, int v5
 | 
				
			|||||||
        labels.add(row);
 | 
					        labels.add(row);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Prepares the initial layout of the dialog, including header labels.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    public void prepare() {
 | 
					    public void prepare() {
 | 
				
			||||||
        offsetX = 0.5f;
 | 
					        offsetX = 0.5f;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,30 +4,53 @@
 | 
				
			|||||||
import com.simsilica.lemur.Container;
 | 
					import com.simsilica.lemur.Container;
 | 
				
			||||||
import pp.mdga.client.MdgaApp;
 | 
					import pp.mdga.client.MdgaApp;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * The {@code Dialog} class serves as an abstract base class for dialogs in the application.
 | 
				
			||||||
 | 
					 * It provides functionality for showing and hiding the dialog and defines abstract methods
 | 
				
			||||||
 | 
					 * for custom behavior when the dialog is shown or hidden.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
public abstract class Dialog {
 | 
					public abstract class Dialog {
 | 
				
			||||||
    protected final MdgaApp app;
 | 
					    protected final MdgaApp app;
 | 
				
			||||||
    protected final Node node = new Node();
 | 
					    protected final Node node = new Node();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private final Node root;
 | 
					    private final Node root;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Constructs a {@code Dialog}.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param app  The main application managing the dialog.
 | 
				
			||||||
 | 
					     * @param node The root node to which the dialog's node will be attached.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    Dialog(MdgaApp app, Node node) {
 | 
					    Dialog(MdgaApp app, Node node) {
 | 
				
			||||||
        this.app = app;
 | 
					        this.app = app;
 | 
				
			||||||
        this.root = node;
 | 
					        this.root = node;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Shows the dialog by attaching its node to the root node and invoking the {@code onShow} method.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    public void show() {
 | 
					    public void show() {
 | 
				
			||||||
        root.attachChild(node);
 | 
					        root.attachChild(node);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        onShow();
 | 
					        onShow();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Hides the dialog by detaching its node from the root node and invoking the {@code onHide} method.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    public void hide() {
 | 
					    public void hide() {
 | 
				
			||||||
        root.detachChild(node);
 | 
					        root.detachChild(node);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        onHide();
 | 
					        onHide();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Called when the dialog is shown. Subclasses must implement this method to define custom behavior.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    protected abstract void onShow();
 | 
					    protected abstract void onShow();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Called when the dialog is hidden. Subclasses must implement this method to define custom behavior.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    protected abstract void onHide();
 | 
					    protected abstract void onHide();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,6 +12,10 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import java.util.prefs.Preferences;
 | 
					import java.util.prefs.Preferences;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * The {@code HostDialog} class represents a dialog for hosting a network game session.
 | 
				
			||||||
 | 
					 * It allows users to input a port number, start hosting a server, and navigate back to the previous view.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
public class HostDialog  extends NetworkDialog {
 | 
					public class HostDialog  extends NetworkDialog {
 | 
				
			||||||
    private InputButton portInput;
 | 
					    private InputButton portInput;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -22,6 +26,13 @@ public class HostDialog  extends NetworkDialog {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    private Preferences prefs = Preferences.userNodeForPackage(JoinDialog.class);
 | 
					    private Preferences prefs = Preferences.userNodeForPackage(JoinDialog.class);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Constructs a {@code HostDialog}.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param app  The main application managing the dialog.
 | 
				
			||||||
 | 
					     * @param node The root node for attaching UI elements.
 | 
				
			||||||
 | 
					     * @param view The main view used for navigation and interaction with the dialog.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    public HostDialog(MdgaApp app, Node node, MainView view) {
 | 
					    public HostDialog(MdgaApp app, Node node, MainView view) {
 | 
				
			||||||
        super(app, node, (NetworkSupport) app.getNetworkSupport());
 | 
					        super(app, node, (NetworkSupport) app.getNetworkSupport());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -39,6 +50,9 @@ public HostDialog(MdgaApp app, Node node, MainView view) {
 | 
				
			|||||||
        offset += 1.5f;
 | 
					        offset += 1.5f;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Called when the dialog is shown. Displays all input fields and buttons.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    protected void onShow() {
 | 
					    protected void onShow() {
 | 
				
			||||||
        portInput.show();
 | 
					        portInput.show();
 | 
				
			||||||
@@ -46,6 +60,9 @@ protected void onShow() {
 | 
				
			|||||||
        backButton.show();
 | 
					        backButton.show();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Called when the dialog is hidden. Hides all input fields and buttons.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    protected void onHide() {
 | 
					    protected void onHide() {
 | 
				
			||||||
        portInput.hide();
 | 
					        portInput.hide();
 | 
				
			||||||
@@ -53,27 +70,44 @@ protected void onHide() {
 | 
				
			|||||||
        backButton.hide();
 | 
					        backButton.hide();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Updates the state of the port input field.
 | 
				
			||||||
 | 
					     * This method is called periodically to synchronize the dialog state.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    public void update() {
 | 
					    public void update() {
 | 
				
			||||||
        portInput.update();
 | 
					        portInput.update();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Retrieves the currently entered port number, saves it to preferences, and sets it as the active port.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @return The port number as a string.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    public String getPort() {
 | 
					    public String getPort() {
 | 
				
			||||||
        prefs.put("hostPort", portInput.getString());
 | 
					        prefs.put("hostPort", portInput.getString());
 | 
				
			||||||
        setPortNumber(Integer.parseInt(portInput.getString()));
 | 
					        setPortNumber(Integer.parseInt(portInput.getString()));
 | 
				
			||||||
        return portInput.getString();
 | 
					        return portInput.getString();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Resets the port input field to its default value and updates preferences accordingly.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    public void resetPort() {
 | 
					    public void resetPort() {
 | 
				
			||||||
        portInput.reset();
 | 
					        portInput.reset();
 | 
				
			||||||
        prefs.put("hostPort", "11111");
 | 
					        prefs.put("hostPort", "11111");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Starts the server to host a network game.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    public void hostServer() {
 | 
					    public void hostServer() {
 | 
				
			||||||
        startServer();
 | 
					        startServer();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Connects to the server as a client.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    public void connectServerAsClient() {
 | 
					    public void connectServerAsClient() {
 | 
				
			||||||
        connectServer();
 | 
					        connectServer();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,6 +10,10 @@
 | 
				
			|||||||
import pp.mdga.client.view.MdgaView;
 | 
					import pp.mdga.client.view.MdgaView;
 | 
				
			||||||
import pp.mdga.game.Color;
 | 
					import pp.mdga.game.Color;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * The {@code InterruptDialog} class represents a dialog that interrupts the game flow,
 | 
				
			||||||
 | 
					 * providing a message and the option to force an action if the user is a host.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
public class InterruptDialog extends Dialog {
 | 
					public class InterruptDialog extends Dialog {
 | 
				
			||||||
    private ButtonRight forceButton;
 | 
					    private ButtonRight forceButton;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -17,33 +21,50 @@ public class InterruptDialog extends Dialog {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    private String text = "";
 | 
					    private String text = "";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Constructs an {@code InterruptDialog}.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param app  The main application managing the dialog.
 | 
				
			||||||
 | 
					     * @param node The root node for attaching UI elements.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    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);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        float offset = 2.8f;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        label.setPos(new Vector2f(0, MenuButton.VERTICAL - offset));
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Called when the dialog is shown. Displays the label and optionally the force button if the user is the host.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    protected void onShow() {
 | 
					    protected void onShow() {
 | 
				
			||||||
        if(app.getGameLogic().isHost()) {
 | 
					        if(app.getGameLogic().isHost()) {
 | 
				
			||||||
            forceButton.show();
 | 
					            forceButton.show();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        label = new LabelButton(app, node, "Warte auf " + text + "...", new Vector2f(5.5f * 1.5f, 2), new Vector2f(0.5f, 0f), false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        float offset = 2.8f;
 | 
				
			||||||
 | 
					        label.setPos(new Vector2f(0, MenuButton.VERTICAL - offset));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        label.show();
 | 
					        label.show();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Called when the dialog is hidden. Hides the label and the force button.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    protected void onHide() {
 | 
					    protected void onHide() {
 | 
				
			||||||
        forceButton.hide();
 | 
					        forceButton.hide();
 | 
				
			||||||
        label.hide();
 | 
					        label.hide();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Sets the displayed text based on the specified color.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param color The color used to determine the text (e.g., "Luftwaffe" for AIRFORCE).
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    public void setColor(Color color) {
 | 
					    public void setColor(Color color) {
 | 
				
			||||||
        switch (color) {
 | 
					        switch (color) {
 | 
				
			||||||
            case AIRFORCE:
 | 
					            case AIRFORCE:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -13,6 +13,10 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import java.util.prefs.Preferences;
 | 
					import java.util.prefs.Preferences;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * The {@code JoinDialog} class represents a dialog for joining a network game.
 | 
				
			||||||
 | 
					 * It allows users to input an IP address and port number, connect to a server, or navigate back to the previous view.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
public class JoinDialog extends NetworkDialog {
 | 
					public class JoinDialog extends NetworkDialog {
 | 
				
			||||||
    private InputButton ipInput;
 | 
					    private InputButton ipInput;
 | 
				
			||||||
    private InputButton portInput;
 | 
					    private InputButton portInput;
 | 
				
			||||||
@@ -24,6 +28,13 @@ public class JoinDialog extends NetworkDialog {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    private Preferences prefs = Preferences.userNodeForPackage(JoinDialog.class);
 | 
					    private Preferences prefs = Preferences.userNodeForPackage(JoinDialog.class);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Constructs a {@code JoinDialog}.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param app  The main application managing the dialog.
 | 
				
			||||||
 | 
					     * @param node The root node for attaching UI elements.
 | 
				
			||||||
 | 
					     * @param view The main view used for navigation and interaction with the dialog.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    public JoinDialog(MdgaApp app, Node node, MainView view) {
 | 
					    public JoinDialog(MdgaApp app, Node node, MainView view) {
 | 
				
			||||||
        super(app, node, (NetworkSupport) app.getNetworkSupport());
 | 
					        super(app, node, (NetworkSupport) app.getNetworkSupport());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -46,6 +57,9 @@ public JoinDialog(MdgaApp app, Node node, MainView view) {
 | 
				
			|||||||
        offset += 1.5f;
 | 
					        offset += 1.5f;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Called when the dialog is shown. Displays all input fields and buttons.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    protected void onShow() {
 | 
					    protected void onShow() {
 | 
				
			||||||
        ipInput.show();
 | 
					        ipInput.show();
 | 
				
			||||||
@@ -54,6 +68,9 @@ protected void onShow() {
 | 
				
			|||||||
        backButton.show();
 | 
					        backButton.show();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Called when the dialog is hidden. Hides all input fields and buttons.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    protected void onHide() {
 | 
					    protected void onHide() {
 | 
				
			||||||
        ipInput.hide();
 | 
					        ipInput.hide();
 | 
				
			||||||
@@ -62,37 +79,62 @@ protected void onHide() {
 | 
				
			|||||||
        backButton.hide();
 | 
					        backButton.hide();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Updates the state of the input fields. This method is called periodically to synchronize the dialog state.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    public void update() {
 | 
					    public void update() {
 | 
				
			||||||
        ipInput.update();
 | 
					        ipInput.update();
 | 
				
			||||||
        portInput.update();
 | 
					        portInput.update();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Retrieves the currently entered IP address, saves it to preferences, and sets it as the hostname.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @return The IP address as a string.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    public String getIpt() {
 | 
					    public String getIpt() {
 | 
				
			||||||
        prefs.put("joinIp", ipInput.getString());
 | 
					        prefs.put("joinIp", ipInput.getString());
 | 
				
			||||||
        setHostname(ipInput.getString());
 | 
					        setHostname(ipInput.getString());
 | 
				
			||||||
        return ipInput.getString();
 | 
					        return ipInput.getString();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Resets the IP input field to its default value and updates preferences accordingly.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    public void resetIp() {
 | 
					    public void resetIp() {
 | 
				
			||||||
        ipInput.reset();
 | 
					        ipInput.reset();
 | 
				
			||||||
        prefs.put("joinIp", "");
 | 
					        prefs.put("joinIp", "");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Retrieves the currently entered port number, saves it to preferences, and sets it as the active port.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @return The port number as a string.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    public String getPort() {
 | 
					    public String getPort() {
 | 
				
			||||||
        prefs.put("joinPort", portInput.getString());
 | 
					        prefs.put("joinPort", portInput.getString());
 | 
				
			||||||
        setPortNumber(Integer.parseInt(portInput.getString()));
 | 
					        setPortNumber(Integer.parseInt(portInput.getString()));
 | 
				
			||||||
        return portInput.getString();
 | 
					        return portInput.getString();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Resets the port input field to its default value and updates preferences accordingly.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    public void resetPort() {
 | 
					    public void resetPort() {
 | 
				
			||||||
        portInput.reset();
 | 
					        portInput.reset();
 | 
				
			||||||
        prefs.put("joinPort", "11111");
 | 
					        prefs.put("joinPort", "11111");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Connects to the server using the current IP address and port number.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    public void connectToServer() {
 | 
					    public void connectToServer() {
 | 
				
			||||||
        connectServer();
 | 
					        connectServer();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Disconnects from the server if a network connection exists.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    public void disconnect() {
 | 
					    public void disconnect() {
 | 
				
			||||||
        NetworkSupport network = getNetwork();
 | 
					        NetworkSupport network = getNetwork();
 | 
				
			||||||
        if (network != null) {
 | 
					        if (network != null) {
 | 
				
			||||||
@@ -104,4 +146,3 @@ public void disconnect() {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,6 +8,11 @@
 | 
				
			|||||||
import java.util.concurrent.ExecutionException;
 | 
					import java.util.concurrent.ExecutionException;
 | 
				
			||||||
import java.util.concurrent.Future;
 | 
					import java.util.concurrent.Future;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * The {@code NetworkDialog} class serves as an abstract base class for dialogs
 | 
				
			||||||
 | 
					 * that involve network-related functionalities, such as connecting to a server or hosting a game.
 | 
				
			||||||
 | 
					 * It provides methods for initializing, connecting to, and managing a network server.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
public abstract class NetworkDialog extends Dialog {
 | 
					public abstract class NetworkDialog extends Dialog {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private NetworkSupport network;
 | 
					    private NetworkSupport network;
 | 
				
			||||||
@@ -17,19 +22,41 @@ public abstract class NetworkDialog extends Dialog {
 | 
				
			|||||||
    private MdgaServer serverInstance;
 | 
					    private MdgaServer serverInstance;
 | 
				
			||||||
    private Thread serverThread;
 | 
					    private Thread serverThread;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Constructs a {@code NetworkDialog}.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param app      The main application managing the dialog.
 | 
				
			||||||
 | 
					     * @param node     The root node for attaching UI elements.
 | 
				
			||||||
 | 
					     * @param network  The network support instance for managing network interactions.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    public NetworkDialog(MdgaApp app, Node node, NetworkSupport network) {
 | 
					    public NetworkDialog(MdgaApp app, Node node, NetworkSupport network) {
 | 
				
			||||||
        super(app, node);
 | 
					        super(app, node);
 | 
				
			||||||
        this.network = network;
 | 
					        this.network = network;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Sets the hostname for the network connection.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param hostname The hostname or IP address of the server.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    public void setHostname(String hostname) {
 | 
					    public void setHostname(String hostname) {
 | 
				
			||||||
        this.hostname = hostname;
 | 
					        this.hostname = hostname;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Sets the port number for the network connection.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param portNumber The port number to use for the connection.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    public void setPortNumber(int portNumber) {
 | 
					    public void setPortNumber(int portNumber) {
 | 
				
			||||||
        this.portNumber = portNumber;
 | 
					        this.portNumber = portNumber;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Initializes the network connection using the current hostname and port number.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @return {@code null} if successful, otherwise throws an exception.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    protected Object initNetwork() {
 | 
					    protected Object initNetwork() {
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            this.network.initNetwork(this.hostname, this.portNumber);
 | 
					            this.network.initNetwork(this.hostname, this.portNumber);
 | 
				
			||||||
@@ -39,6 +66,9 @@ protected Object initNetwork() {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Starts the process of connecting to a server asynchronously.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    protected void connectServer() {
 | 
					    protected void connectServer() {
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            connectionFuture = this.network.getApp().getExecutor().submit(this::initNetwork);
 | 
					            connectionFuture = this.network.getApp().getExecutor().submit(this::initNetwork);
 | 
				
			||||||
@@ -47,6 +77,9 @@ protected void connectServer() {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Starts hosting a server in a separate thread.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    protected void startServer() {
 | 
					    protected void startServer() {
 | 
				
			||||||
        serverThread = new Thread(() -> {
 | 
					        serverThread = new Thread(() -> {
 | 
				
			||||||
            try {
 | 
					            try {
 | 
				
			||||||
@@ -60,6 +93,9 @@ protected void startServer() {
 | 
				
			|||||||
        serverThread.start();
 | 
					        serverThread.start();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Shuts down the hosted server and cleans up resources.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    public void shutdownServer() {
 | 
					    public void shutdownServer() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
@@ -85,6 +121,11 @@ public void shutdownServer() {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Updates the state of the connection process.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param delta The time elapsed since the last update call.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    public void update(float delta) {
 | 
					    public void update(float delta) {
 | 
				
			||||||
        if (this.connectionFuture != null && this.connectionFuture.isDone()) {
 | 
					        if (this.connectionFuture != null && this.connectionFuture.isDone()) {
 | 
				
			||||||
            try {
 | 
					            try {
 | 
				
			||||||
@@ -97,6 +138,11 @@ public void update(float delta) {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Retrieves the {@code NetworkSupport} instance associated with this dialog.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @return The {@code NetworkSupport} instance.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    public NetworkSupport getNetwork() {
 | 
					    public NetworkSupport getNetwork() {
 | 
				
			||||||
        return network;
 | 
					        return network;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,6 +8,10 @@
 | 
				
			|||||||
import pp.mdga.client.view.MainView;
 | 
					import pp.mdga.client.view.MainView;
 | 
				
			||||||
import pp.mdga.client.view.MdgaView;
 | 
					import pp.mdga.client.view.MdgaView;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * The {@code SettingsDialog} class represents a dialog for navigating to various settings sections,
 | 
				
			||||||
 | 
					 * such as video and audio settings, or returning to the previous view.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
public class SettingsDialog extends Dialog {
 | 
					public class SettingsDialog extends Dialog {
 | 
				
			||||||
    private MenuButton videoButton;
 | 
					    private MenuButton videoButton;
 | 
				
			||||||
    private MenuButton audioButton;
 | 
					    private MenuButton audioButton;
 | 
				
			||||||
@@ -15,6 +19,13 @@ public class SettingsDialog extends Dialog {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    private final MdgaView view;
 | 
					    private final MdgaView view;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Constructs a {@code SettingsDialog}.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param app  The main application managing the dialog.
 | 
				
			||||||
 | 
					     * @param node The root node for attaching UI elements.
 | 
				
			||||||
 | 
					     * @param view The view managing navigation and interaction with the settings dialog.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    public SettingsDialog(MdgaApp app, Node node, MdgaView view) {
 | 
					    public SettingsDialog(MdgaApp app, Node node, MdgaView view) {
 | 
				
			||||||
        super(app, node);
 | 
					        super(app, node);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -34,6 +45,9 @@ public SettingsDialog(MdgaApp app, Node node, MdgaView view) {
 | 
				
			|||||||
        backButton.setPos(new Vector2f(0, 1.8f));
 | 
					        backButton.setPos(new Vector2f(0, 1.8f));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Called when the dialog is shown. Displays all buttons for video settings, audio settings, and back navigation.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    protected void onShow() {
 | 
					    protected void onShow() {
 | 
				
			||||||
        videoButton.show();
 | 
					        videoButton.show();
 | 
				
			||||||
@@ -41,6 +55,9 @@ protected void onShow() {
 | 
				
			|||||||
        backButton.show();
 | 
					        backButton.show();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Called when the dialog is hidden. Hides all buttons for video settings, audio settings, and back navigation.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    protected void onHide() {
 | 
					    protected void onHide() {
 | 
				
			||||||
        videoButton.hide();
 | 
					        videoButton.hide();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -14,6 +14,10 @@
 | 
				
			|||||||
import java.util.Random;
 | 
					import java.util.Random;
 | 
				
			||||||
import java.util.random.RandomGenerator;
 | 
					import java.util.random.RandomGenerator;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * The {@code StartDialog} class represents the initial dialog in the application,
 | 
				
			||||||
 | 
					 * allowing the user to input their name, host or join a game, or exit the application.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
public class StartDialog extends Dialog {
 | 
					public class StartDialog extends Dialog {
 | 
				
			||||||
    private InputButton nameInput;
 | 
					    private InputButton nameInput;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -23,6 +27,13 @@ public class StartDialog extends Dialog {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    private final MainView view;
 | 
					    private final MainView view;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Constructs a {@code StartDialog}.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param app  The main application managing the dialog.
 | 
				
			||||||
 | 
					     * @param node The root node for attaching UI elements.
 | 
				
			||||||
 | 
					     * @param view The main view used for navigation and interaction with the dialog.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    public StartDialog(MdgaApp app, Node node, MainView view) {
 | 
					    public StartDialog(MdgaApp app, Node node, MainView view) {
 | 
				
			||||||
        super(app, node);
 | 
					        super(app, node);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -48,6 +59,9 @@ public StartDialog(MdgaApp app, Node node, MainView view) {
 | 
				
			|||||||
        endButton.setPos(new Vector2f(0, 1.8f));
 | 
					        endButton.setPos(new Vector2f(0, 1.8f));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Called when the dialog is shown. Displays the name input field and all buttons.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    protected void onShow() {
 | 
					    protected void onShow() {
 | 
				
			||||||
        nameInput.show();
 | 
					        nameInput.show();
 | 
				
			||||||
@@ -57,6 +71,9 @@ protected void onShow() {
 | 
				
			|||||||
        endButton.show();
 | 
					        endButton.show();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Called when the dialog is hidden. Hides the name input field and all buttons.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    protected void onHide ()
 | 
					    protected void onHide ()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
@@ -67,10 +84,18 @@ protected void onHide ()
 | 
				
			|||||||
        endButton.hide();
 | 
					        endButton.hide();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Updates the state of the name input field. This method is called periodically to synchronize the dialog state.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    public void update() {
 | 
					    public void update() {
 | 
				
			||||||
        nameInput.update();
 | 
					        nameInput.update();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Retrieves the name entered by the user. If no name is provided, a random name is generated.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @return The user's name or a randomly generated name.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    public String getName() {
 | 
					    public String getName() {
 | 
				
			||||||
        String name = nameInput.getString();
 | 
					        String name = nameInput.getString();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -206,7 +231,7 @@ public String getName() {
 | 
				
			|||||||
                "FluffiKopf",
 | 
					                "FluffiKopf",
 | 
				
			||||||
                "DonutDöner",
 | 
					                "DonutDöner",
 | 
				
			||||||
                "VollpfostenX",
 | 
					                "VollpfostenX",
 | 
				
			||||||
                "Schraubenschlüssel",
 | 
					                "Waschlappen",
 | 
				
			||||||
                "Witzepumper",
 | 
					                "Witzepumper",
 | 
				
			||||||
                "ToastTraum",
 | 
					                "ToastTraum",
 | 
				
			||||||
                "FroschFighter",
 | 
					                "FroschFighter",
 | 
				
			||||||
@@ -263,22 +288,22 @@ public String getName() {
 | 
				
			|||||||
                "VulkanKeks",
 | 
					                "VulkanKeks",
 | 
				
			||||||
                "WasserToast",
 | 
					                "WasserToast",
 | 
				
			||||||
                "MenschSalat",
 | 
					                "MenschSalat",
 | 
				
			||||||
                "KampfKohlenhydrate",
 | 
					                "KampfKohl",
 | 
				
			||||||
                "SockenZirkus",
 | 
					                "SockenZirkus",
 | 
				
			||||||
                "SchwimmBärchen",
 | 
					                "SchwimmBärchen",
 | 
				
			||||||
                "TanzenderDachgepäckträger",
 | 
					                "TanzenderPudel",
 | 
				
			||||||
                "PizzamarktMensch",
 | 
					                "PizzamarktMensch",
 | 
				
			||||||
                "ZahnarztZocker",
 | 
					                "ZahnarztZocker",
 | 
				
			||||||
                "RollerCoasterTester",
 | 
					                "RollerRudi",
 | 
				
			||||||
                "WaschmaschinenPilot",
 | 
					                "PupsPilot",
 | 
				
			||||||
                "WitzigeZwiebel",
 | 
					                "WitzigeZwiebel",
 | 
				
			||||||
                "Pillenschlucker",
 | 
					                "Pillenschlucker",
 | 
				
			||||||
                "ZwiebelReiter",
 | 
					                "ZwiebelReiter",
 | 
				
			||||||
                "HüpfenderKaktus",
 | 
					                "HüpfenderKaktus",
 | 
				
			||||||
                "KochenderAsteroid",
 | 
					                "AsteroidenAlf",
 | 
				
			||||||
                "ChaosKarotte",
 | 
					                "ChaosKarotte",
 | 
				
			||||||
                "WolkenFurz",
 | 
					                "WolkenFurz",
 | 
				
			||||||
                "SchnitzelPartikel",
 | 
					                "Krümelmonster",
 | 
				
			||||||
                "WackelBiene",
 | 
					                "WackelBiene",
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,6 +11,11 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import java.util.prefs.Preferences;
 | 
					import java.util.prefs.Preferences;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * The {@code VideoSettingsDialog} class represents a dialog for configuring video settings,
 | 
				
			||||||
 | 
					 * such as resolution and fullscreen mode. It also provides an option to restart the application
 | 
				
			||||||
 | 
					 * when certain settings are changed.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
public class VideoSettingsDialog extends Dialog {
 | 
					public class VideoSettingsDialog extends Dialog {
 | 
				
			||||||
    private static Preferences prefs = Preferences.userNodeForPackage(JoinDialog.class);
 | 
					    private static Preferences prefs = Preferences.userNodeForPackage(JoinDialog.class);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -29,6 +34,13 @@ public class VideoSettingsDialog extends Dialog {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    private boolean active = false;
 | 
					    private boolean active = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Constructs a {@code VideoSettingsDialog}.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param app  The main application managing the dialog.
 | 
				
			||||||
 | 
					     * @param node The root node for attaching UI elements.
 | 
				
			||||||
 | 
					     * @param view The view managing navigation and interaction with the video settings dialog.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    public VideoSettingsDialog(MdgaApp app, Node node, MdgaView view) {
 | 
					    public VideoSettingsDialog(MdgaApp app, Node node, MdgaView view) {
 | 
				
			||||||
        super(app, node);
 | 
					        super(app, node);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -67,6 +79,9 @@ public VideoSettingsDialog(MdgaApp app, Node node, MdgaView view) {
 | 
				
			|||||||
        backButton.setPos(new Vector2f(0, 1.8f));
 | 
					        backButton.setPos(new Vector2f(0, 1.8f));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Called when the dialog is shown. Displays all buttons and marks the dialog as active.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    protected void onShow() {
 | 
					    protected void onShow() {
 | 
				
			||||||
        active = true;
 | 
					        active = true;
 | 
				
			||||||
@@ -83,6 +98,9 @@ protected void onShow() {
 | 
				
			|||||||
        backButton.show();
 | 
					        backButton.show();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Called when the dialog is hidden. Hides all buttons and marks the dialog as inactive.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    protected void onHide() {
 | 
					    protected void onHide() {
 | 
				
			||||||
        active = false;
 | 
					        active = false;
 | 
				
			||||||
@@ -100,12 +118,23 @@ protected void onHide() {
 | 
				
			|||||||
        restartButton.hide();
 | 
					        restartButton.hide();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Updates the dialog's state. This method can be used for periodic updates while the dialog is active.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    public void update() {
 | 
					    public void update() {
 | 
				
			||||||
        if(!active) {
 | 
					        if(!active) {
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Updates the resolution settings and optionally triggers the restart button if changes are detected.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param width         The width of the resolution.
 | 
				
			||||||
 | 
					     * @param height        The height of the resolution.
 | 
				
			||||||
 | 
					     * @param imageFactor   The scaling factor for the resolution.
 | 
				
			||||||
 | 
					     * @param isFullscreen  {@code true} if fullscreen mode is enabled, {@code false} otherwise.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    public void updateResolution(int width, int height, float imageFactor, boolean isFullscreen) {
 | 
					    public void updateResolution(int width, int height, float imageFactor, boolean isFullscreen) {
 | 
				
			||||||
        if(width != prefs.getInt("width", 1280) || height != prefs.getInt("height", 720) || isFullscreen != prefs.getBoolean("fullscreen", false)) {
 | 
					        if(width != prefs.getInt("width", 1280) || height != prefs.getInt("height", 720) || isFullscreen != prefs.getBoolean("fullscreen", false)) {
 | 
				
			||||||
            restartButton.show();
 | 
					            restartButton.show();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,12 +10,25 @@
 | 
				
			|||||||
import pp.mdga.client.animation.ZoomControl;
 | 
					import pp.mdga.client.animation.ZoomControl;
 | 
				
			||||||
import pp.mdga.game.Color;
 | 
					import pp.mdga.game.Color;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * The {@code ActionTextHandler} class manages the display of animated and stylized text messages in the game's UI.
 | 
				
			||||||
 | 
					 * It supports dynamic text creation with spacing, color, and effects, such as dice rolls, player actions, and rankings.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 class ActionTextHandler {
 | 
					 class ActionTextHandler {
 | 
				
			||||||
    private Node root;
 | 
					    private Node root;
 | 
				
			||||||
    private BitmapFont font;
 | 
					    private BitmapFont font;
 | 
				
			||||||
    private AppSettings appSettings;
 | 
					    private AppSettings appSettings;
 | 
				
			||||||
    private int ranking;
 | 
					    private int ranking;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    float paddingRanked = 100;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Constructs an {@code ActionTextHandler}.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param guiNode      The GUI node where the text messages will be displayed.
 | 
				
			||||||
 | 
					     * @param assetManager The asset manager used to load fonts and other assets.
 | 
				
			||||||
 | 
					     * @param appSettings  The application settings for positioning and sizing.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
     ActionTextHandler(Node guiNode, AssetManager assetManager, AppSettings appSettings){
 | 
					     ActionTextHandler(Node guiNode, AssetManager assetManager, AppSettings appSettings){
 | 
				
			||||||
        root = new Node("actionTextRoot");
 | 
					        root = new Node("actionTextRoot");
 | 
				
			||||||
        guiNode.attachChild(root);
 | 
					        guiNode.attachChild(root);
 | 
				
			||||||
@@ -26,6 +39,16 @@ class ActionTextHandler {
 | 
				
			|||||||
        ranking = 0;
 | 
					        ranking = 0;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Creates a {@code Node} containing text with specified spacing, size, and colors for each segment of the text.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param textArr  An array of strings representing the text to be displayed.
 | 
				
			||||||
 | 
					     * @param spacing  The spacing between individual characters.
 | 
				
			||||||
 | 
					     * @param size     The size of the text.
 | 
				
			||||||
 | 
					     * @param colorArr An array of {@code ColorRGBA} representing the color for each string in {@code textArr}.
 | 
				
			||||||
 | 
					     * @return A {@code Node} containing the styled text with spacing and color applied.
 | 
				
			||||||
 | 
					     * @throws RuntimeException if the lengths of {@code textArr} and {@code colorArr} do not match.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    private Node createTextWithSpacing(String[] textArr, float spacing, float size, ColorRGBA[] colorArr) {
 | 
					    private Node createTextWithSpacing(String[] textArr, float spacing, float size, ColorRGBA[] colorArr) {
 | 
				
			||||||
        if(textArr.length != colorArr.length) throw new RuntimeException("text and color are not the same length");
 | 
					        if(textArr.length != colorArr.length) throw new RuntimeException("text and color are not the same length");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -52,18 +75,55 @@ private Node createTextWithSpacing(String[] textArr, float spacing, float size,
 | 
				
			|||||||
        return textNode;
 | 
					        return textNode;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Creates a {@code Node} containing text with specified spacing, size, and a single color.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param text    The text to be displayed.
 | 
				
			||||||
 | 
					     * @param spacing The spacing between individual characters.
 | 
				
			||||||
 | 
					     * @param size    The size of the text.
 | 
				
			||||||
 | 
					     * @param color   The color of the text.
 | 
				
			||||||
 | 
					     * @return A {@code Node} containing the styled text.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    private Node createTextWithSpacing(String text, float spacing, float size, ColorRGBA color) {
 | 
					    private Node createTextWithSpacing(String text, float spacing, float size, ColorRGBA color) {
 | 
				
			||||||
        return createTextWithSpacing(new String[]{text}, spacing, size, new ColorRGBA[]{color});
 | 
					        return createTextWithSpacing(new String[]{text}, spacing, size, new ColorRGBA[]{color});
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Calculates the center position of a rectangle given its width, height, and an origin position.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param width  The width of the rectangle.
 | 
				
			||||||
 | 
					     * @param height The height of the rectangle.
 | 
				
			||||||
 | 
					     * @param pos    The origin position of the rectangle.
 | 
				
			||||||
 | 
					     * @return A {@code Vector3f} representing the center position.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    private Vector3f center(float width, float height, Vector3f pos){
 | 
					    private Vector3f center(float width, float height, Vector3f pos){
 | 
				
			||||||
        return new Vector3f(pos.x+width/2, pos.y+height/2,0);
 | 
					        return new Vector3f(pos.x+width/2, pos.y+height/2,0);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Creates and positions a single-line text at the top of the screen with a specified vertical offset.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param name    The text to be displayed.
 | 
				
			||||||
 | 
					     * @param spacing The spacing between individual characters.
 | 
				
			||||||
 | 
					     * @param size    The size of the text.
 | 
				
			||||||
 | 
					     * @param color   The color of the text.
 | 
				
			||||||
 | 
					     * @param top     The vertical offset from the top of the screen.
 | 
				
			||||||
 | 
					     * @return A {@code Node} containing the styled text positioned at the top.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    private Node createTopText(String name, float spacing, float size, ColorRGBA color, float top){
 | 
					    private Node createTopText(String name, float spacing, float size, ColorRGBA color, float top){
 | 
				
			||||||
        return createTopText(new String[]{name}, spacing, size, new ColorRGBA[]{color}, top);
 | 
					        return createTopText(new String[]{name}, spacing, size, new ColorRGBA[]{color}, top);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Creates and positions multi-line text at the top of the screen with specified vertical offset, spacing, and colors.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param name    An array of strings representing the text to be displayed.
 | 
				
			||||||
 | 
					     * @param spacing The spacing between individual characters.
 | 
				
			||||||
 | 
					     * @param size    The size of the text.
 | 
				
			||||||
 | 
					     * @param color   An array of {@code ColorRGBA} representing the color for each string in {@code name}.
 | 
				
			||||||
 | 
					     * @param top     The vertical offset from the top of the screen.
 | 
				
			||||||
 | 
					     * @return A {@code Node} containing the styled text positioned at the top.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    private Node createTopText(String[] name, float spacing, float size, ColorRGBA color[], float top){
 | 
					    private Node createTopText(String[] name, float spacing, float size, ColorRGBA color[], float top){
 | 
				
			||||||
        Node text = createTextWithSpacing(name, spacing, size, color);
 | 
					        Node text = createTextWithSpacing(name, spacing, size, color);
 | 
				
			||||||
        text.setLocalTranslation(0, (appSettings.getHeight()/2f)*0.8f-top,0);
 | 
					        text.setLocalTranslation(0, (appSettings.getHeight()/2f)*0.8f-top,0);
 | 
				
			||||||
@@ -71,18 +131,44 @@ private Node createTopText(String[] name, float spacing, float size, ColorRGBA c
 | 
				
			|||||||
        return text;
 | 
					        return text;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Calculates the center position of a rectangle with negative width offset.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param width  The negative width of the rectangle.
 | 
				
			||||||
 | 
					     * @param height The height of the rectangle.
 | 
				
			||||||
 | 
					     * @param pos    The origin position of the rectangle.
 | 
				
			||||||
 | 
					     * @return A {@code Vector3f} representing the center position.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    private Vector3f centerText(float width, float height, Vector3f pos){
 | 
					    private Vector3f centerText(float width, float height, Vector3f pos){
 | 
				
			||||||
        return center(-width, height, pos);
 | 
					        return center(-width, height, pos);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Displays a message indicating the active player.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param name  The name of the active player.
 | 
				
			||||||
 | 
					     * @param color The color representing the player's team.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
     void activePlayer(String name, Color color){
 | 
					     void activePlayer(String name, Color color){
 | 
				
			||||||
        createTopText(new String[]{name," ist dran"}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl());
 | 
					        createTopText(new String[]{name," ist dran"}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Displays a message indicating that the current player is active.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param color The color representing the player's team.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
     void ownActive(Color color){
 | 
					     void ownActive(Color color){
 | 
				
			||||||
        createTopText(new String[]{"Du"," bist dran"}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl());
 | 
					        createTopText(new String[]{"Du"," bist dran"}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Displays a dice roll result for a player.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param diceNum The number rolled on the dice.
 | 
				
			||||||
 | 
					     * @param name    The name of the player.
 | 
				
			||||||
 | 
					     * @param color   The color representing the player's team.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
     void diceNum(int diceNum, String name, Color color){
 | 
					     void diceNum(int diceNum, String name, Color color){
 | 
				
			||||||
        createTopText(new String[]{name," würfelt:"}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0);
 | 
					        createTopText(new String[]{name," würfelt:"}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -90,38 +176,84 @@ void diceNum(int diceNum, String name, Color color){
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Displays a dice roll result with a multiplier for a player.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param diceNum The number rolled on the dice.
 | 
				
			||||||
 | 
					     * @param mult    The multiplier applied to the dice result.
 | 
				
			||||||
 | 
					     * @param name    The name of the player.
 | 
				
			||||||
 | 
					     * @param color   The color representing the player's team.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
     void diceNumMult(int diceNum,int mult, String name, Color color){
 | 
					     void diceNumMult(int diceNum,int mult, String name, Color color){
 | 
				
			||||||
        createTopText(new String[]{name," würfelt:"}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0);
 | 
					        createTopText(new String[]{name," würfelt:"}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        createTopText(new String[]{String.valueOf(diceNum), " x" + mult + " = " + (diceNum*mult)}, 20, 100, new ColorRGBA[]{ColorRGBA.White,ColorRGBA.Red}, 100);
 | 
					        createTopText(new String[]{String.valueOf(diceNum), " x" + mult + " = " + (diceNum*mult)}, 20, 100, new ColorRGBA[]{ColorRGBA.White,ColorRGBA.Red}, 100);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Displays the dice roll result for the current player.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param diceNum The number rolled on the dice.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
     void ownDice(int diceNum){
 | 
					     void ownDice(int diceNum){
 | 
				
			||||||
        createTopText(String.valueOf(diceNum), 10, 100, ColorRGBA.White, 0);
 | 
					        createTopText(String.valueOf(diceNum), 10, 100, ColorRGBA.White, 0);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Displays the dice roll result with a multiplier for the current player.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param diceNum The number rolled on the dice.
 | 
				
			||||||
 | 
					     * @param mult    The multiplier applied to the dice result.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
     void ownDiceMult(int diceNum, int mult){
 | 
					     void ownDiceMult(int diceNum, int mult){
 | 
				
			||||||
        createTopText(new String[]{String.valueOf(diceNum), " x" + mult + " = " + (diceNum*mult)}, 20, 100, new ColorRGBA[]{ColorRGBA.White,ColorRGBA.Red}, 0);
 | 
					        createTopText(new String[]{String.valueOf(diceNum), " x" + mult + " = " + (diceNum*mult)}, 20, 100, new ColorRGBA[]{ColorRGBA.White,ColorRGBA.Red}, 0);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Displays a message indicating that a specified player received a bonus card.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param name  The name of the player who received the bonus card.
 | 
				
			||||||
 | 
					     * @param color The color representing the player's team.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
     void drawCard(String name, Color color){
 | 
					     void drawCard(String name, Color color){
 | 
				
			||||||
        createTopText(new String[]{name," erhält eine Bonuskarte"}, 7,70, new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl());
 | 
					        createTopText(new String[]{name," erhält eine Bonuskarte"}, 7,70, new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Displays a message indicating that the current player received a bonus card.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param color The color representing the player's team.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
     void drawCardOwn(Color color){
 | 
					     void drawCardOwn(Color color){
 | 
				
			||||||
        createTopText(new String[]{"Du","  erhälst eine Bonuskarte"}, 5,70, new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl());
 | 
					        createTopText(new String[]{"Du","  erhälst eine Bonuskarte"}, 5,70, new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Displays a message indicating that a specified player has completed their turn or action.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param name  The name of the player who finished.
 | 
				
			||||||
 | 
					     * @param color The color representing the player's team.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
     void finishText(String name, Color color){
 | 
					     void finishText(String name, Color color){
 | 
				
			||||||
        createTopText(new String[]{name," ist fertig!"}, 7,70, new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl());
 | 
					        createTopText(new String[]{name," ist fertig!"}, 7,70, new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Displays a message indicating that the current player has completed their turn or action.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param color The color representing the player's team.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
     void finishTextOwn(Color color){
 | 
					     void finishTextOwn(Color color){
 | 
				
			||||||
        createTopText(new String[]{"Du", " bist fertig!"}, 7,70, new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl());
 | 
					        createTopText(new String[]{"Du", " bist fertig!"}, 7,70, new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Converts a player's team color to a corresponding {@code ColorRGBA}.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param color The player's team color.
 | 
				
			||||||
 | 
					     * @return The corresponding {@code ColorRGBA}.
 | 
				
			||||||
 | 
					     * @throws RuntimeException if the color is invalid.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    private ColorRGBA playerColorToColorRGBA(Color color){
 | 
					    private ColorRGBA playerColorToColorRGBA(Color color){
 | 
				
			||||||
        return switch (color){
 | 
					        return switch (color){
 | 
				
			||||||
            case ARMY -> ColorRGBA.Green;
 | 
					            case ARMY -> ColorRGBA.Green;
 | 
				
			||||||
@@ -132,25 +264,41 @@ private ColorRGBA playerColorToColorRGBA(Color color){
 | 
				
			|||||||
        };
 | 
					        };
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Hides all text messages displayed by the handler and resets the ranking counter.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
     void hide(){
 | 
					     void hide(){
 | 
				
			||||||
         ranking = 0;
 | 
					         ranking = 0;
 | 
				
			||||||
         root.detachAllChildren();
 | 
					         root.detachAllChildren();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    float paddingRanked = 100;
 | 
					    /**
 | 
				
			||||||
 | 
					     * Displays a ranked dice roll result for a specified player.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param name  The name of the player.
 | 
				
			||||||
 | 
					     * @param color The color representing the player's team.
 | 
				
			||||||
 | 
					     * @param eye   The dice roll result.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    void rollRankingResult(String name, Color color, int eye){
 | 
					    void rollRankingResult(String name, Color color, int eye){
 | 
				
			||||||
        createTopText(new String[]{name,":  "+eye}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, paddingRanked*ranking);
 | 
					        createTopText(new String[]{name,":  "+eye}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, paddingRanked*ranking);
 | 
				
			||||||
        ranking++;
 | 
					        ranking++;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Displays a ranked dice roll result for the current player.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param color The color representing the player's team.
 | 
				
			||||||
 | 
					     * @param eye   The dice roll result.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
     void rollRankingResultOwn(Color color, int eye){
 | 
					     void rollRankingResultOwn(Color color, int eye){
 | 
				
			||||||
         createTopText(new String[]{"Du",":  "+eye}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, paddingRanked*ranking);
 | 
					         createTopText(new String[]{"Du",":  "+eye}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, paddingRanked*ranking);
 | 
				
			||||||
         ranking++;
 | 
					         ranking++;
 | 
				
			||||||
     }
 | 
					     }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Displays a message prompting the player to roll the dice.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
     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();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -50,9 +50,10 @@ public void init() {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void shutdown() {
 | 
					    public void shutdown() {
 | 
				
			||||||
 | 
					        clearSelectableCards();
 | 
				
			||||||
        if (cardLayer != null) {
 | 
					        if (cardLayer != null) {
 | 
				
			||||||
            cardLayer.shutdown();
 | 
					            cardLayer.shutdown();
 | 
				
			||||||
            clearSelectableCards();
 | 
					            app.getStateManager().detach(cardLayer);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        cardLayer = null;
 | 
					        cardLayer = null;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -95,6 +96,7 @@ public void rollDice(int diceNum, Runnable actionAfter) {
 | 
				
			|||||||
        if (isRolling) return;
 | 
					        if (isRolling) return;
 | 
				
			||||||
        spin = false;
 | 
					        spin = false;
 | 
				
			||||||
        slerp = false;
 | 
					        slerp = false;
 | 
				
			||||||
 | 
					        timeElapsed = 0;
 | 
				
			||||||
        this.actionAfter = actionAfter;
 | 
					        this.actionAfter = actionAfter;
 | 
				
			||||||
        angularVelocity.set(
 | 
					        angularVelocity.set(
 | 
				
			||||||
                FastMath.nextRandomInt(ANGULAR_MIN,ANGULAR_MAX),
 | 
					                FastMath.nextRandomInt(ANGULAR_MIN,ANGULAR_MAX),
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -141,10 +141,11 @@ public void addPlayer(Color color, String name, boolean own){
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void setActivePlayer(Color color) {
 | 
					    public void setActivePlayer(Color color) {
 | 
				
			||||||
        Color lastFirst = playerOrder.remove(0);
 | 
					        if(playerOrder.get(0) == color) return;
 | 
				
			||||||
 | 
					        Color oldFirst = playerOrder.remove(0);
 | 
				
			||||||
        playerOrder.remove(color);
 | 
					        playerOrder.remove(color);
 | 
				
			||||||
        playerOrder.add(0, color);
 | 
					        playerOrder.add(0, color);
 | 
				
			||||||
        playerOrder.add(lastFirst);
 | 
					        playerOrder.add(oldFirst);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        drawPlayers();
 | 
					        drawPlayers();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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;
 | 
					 | 
				
			||||||
//        });
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -108,6 +108,7 @@ private void initializeSerializables() {
 | 
				
			|||||||
        Serializer.registerClass(RequestPlayCardMessage.class);
 | 
					        Serializer.registerClass(RequestPlayCardMessage.class);
 | 
				
			||||||
        Serializer.registerClass(SelectCardMessage.class);
 | 
					        Serializer.registerClass(SelectCardMessage.class);
 | 
				
			||||||
        Serializer.registerClass(SelectedPiecesMessage.class);
 | 
					        Serializer.registerClass(SelectedPiecesMessage.class);
 | 
				
			||||||
 | 
					        Serializer.registerClass(SelectPieceMessage.class);
 | 
				
			||||||
        Serializer.registerClass(SelectTSKMessage.class);
 | 
					        Serializer.registerClass(SelectTSKMessage.class);
 | 
				
			||||||
        Serializer.registerClass(ActivePlayerMessage.class);
 | 
					        Serializer.registerClass(ActivePlayerMessage.class);
 | 
				
			||||||
        Serializer.registerClass(AnyPieceMessage.class);
 | 
					        Serializer.registerClass(AnyPieceMessage.class);
 | 
				
			||||||
@@ -204,7 +205,7 @@ public void messageReceived(HostedConnection source, Message message) {
 | 
				
			|||||||
     * @param message as the received message as a Message object.
 | 
					     * @param message as the received message as a Message object.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private void messageReceived(HostedConnection source, ClientMessage message) {
 | 
					    private void messageReceived(HostedConnection source, ClientMessage message) {
 | 
				
			||||||
        LOGGER.log(Level.INFO, "message received from {0}: {1}", source.getId(), message); //NON-NLS
 | 
					        System.out.println("server received from: " + source.getId() + " " + message.getClass().getName());
 | 
				
			||||||
        pendingMessages.add(new ReceivedMessage(message, source.getId()));
 | 
					        pendingMessages.add(new ReceivedMessage(message, source.getId()));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -279,10 +280,11 @@ public void send(int id, ServerMessage message) {
 | 
				
			|||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        final HostedConnection connection = myServer.getConnection(id);
 | 
					        final HostedConnection connection = myServer.getConnection(id);
 | 
				
			||||||
        if (connection != null)
 | 
					        if (connection != null){
 | 
				
			||||||
 | 
					            System.out.println("server sends to: " + id + " " + message.getClass().getName());
 | 
				
			||||||
            connection.send(message);
 | 
					            connection.send(message);
 | 
				
			||||||
        else
 | 
					        }
 | 
				
			||||||
            LOGGER.log(Level.ERROR, "there is no connection with id={0}", id); //NON-NLS
 | 
					        else LOGGER.log(Level.ERROR, "there is no connection with id={0}", id); //NON-NLS
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -33,7 +33,6 @@ 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);
 | 
				
			||||||
@@ -123,13 +122,13 @@ public void noConfirm() {
 | 
				
			|||||||
        confirmButton.hide();
 | 
					        confirmButton.hide();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void needNoPower() {
 | 
					    public void showNoPower() {
 | 
				
			||||||
        confirmButton.hide();
 | 
					        confirmButton.hide();
 | 
				
			||||||
        noPowerButton.show();
 | 
					        noPowerButton.show();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void noNoPower() {
 | 
					    public void hideNoPower() {
 | 
				
			||||||
        noPowerButton.show();
 | 
					        noPowerButton.hide();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void enterInterrupt(Color color) {
 | 
					    public void enterInterrupt(Color color) {
 | 
				
			||||||
 
 | 
				
			|||||||
| 
		 Before Width: | Height: | Size: 216 KiB  | 
| 
		 Before Width: | Height: | Size: 274 KiB  | 
| 
		 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,7 +1,6 @@
 | 
				
			|||||||
// Samplers for textures
 | 
					// Samplers for textures
 | 
				
			||||||
uniform sampler2D m_Texture;
 | 
					uniform sampler2D m_Texture;
 | 
				
			||||||
uniform sampler2D m_OutlineDepthTexture;
 | 
					uniform sampler2D m_OutlineDepthTexture;
 | 
				
			||||||
uniform sampler2D m_DepthTexture;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Input texture coordinates from the vertex shader
 | 
					// Input texture coordinates from the vertex shader
 | 
				
			||||||
in vec2 texCoord;
 | 
					in vec2 texCoord;
 | 
				
			||||||
@@ -15,26 +14,25 @@ uniform float m_OutlineWidth;
 | 
				
			|||||||
out vec4 fragColor;
 | 
					out vec4 fragColor;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void main() {
 | 
					void main() {
 | 
				
			||||||
    // Sample depth textures
 | 
					    // Sample depth textures at various offsets
 | 
				
			||||||
    vec4 depth = texture(m_OutlineDepthTexture, texCoord);
 | 
					    vec4 depth = texture(m_OutlineDepthTexture, texCoord);
 | 
				
			||||||
    vec4 depth1 = texture(m_OutlineDepthTexture, ((texCoord * m_Resolution) + vec2(m_OutlineWidth, m_OutlineWidth)) / m_Resolution);
 | 
					    vec4 depth1 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(m_OutlineWidth, m_OutlineWidth)) / m_Resolution);
 | 
				
			||||||
    vec4 depth2 = texture(m_OutlineDepthTexture, ((texCoord * m_Resolution) + vec2(m_OutlineWidth, -m_OutlineWidth)) / m_Resolution);
 | 
					    vec4 depth2 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(m_OutlineWidth, -m_OutlineWidth)) / m_Resolution);
 | 
				
			||||||
    vec4 depth3 = texture(m_OutlineDepthTexture, ((texCoord * m_Resolution) + vec2(-m_OutlineWidth, m_OutlineWidth)) / m_Resolution);
 | 
					    vec4 depth3 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(-m_OutlineWidth, m_OutlineWidth)) / m_Resolution);
 | 
				
			||||||
    vec4 depth4 = texture(m_OutlineDepthTexture, ((texCoord * m_Resolution) + vec2(-m_OutlineWidth, -m_OutlineWidth)) / m_Resolution);
 | 
					    vec4 depth4 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(-m_OutlineWidth, -m_OutlineWidth)) / m_Resolution);
 | 
				
			||||||
    vec4 depth5 = texture(m_OutlineDepthTexture, ((texCoord * m_Resolution) + vec2(0.0, m_OutlineWidth)) / m_Resolution);
 | 
					    vec4 depth5 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(0.0, m_OutlineWidth)) / m_Resolution);
 | 
				
			||||||
    vec4 depth6 = texture(m_OutlineDepthTexture, ((texCoord * m_Resolution) + vec2(0.0, -m_OutlineWidth)) / m_Resolution);
 | 
					    vec4 depth6 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(0.0, -m_OutlineWidth)) / m_Resolution);
 | 
				
			||||||
    vec4 depth7 = texture(m_OutlineDepthTexture, ((texCoord * m_Resolution) + vec2(m_OutlineWidth, 0.0)) / m_Resolution);
 | 
					    vec4 depth7 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(m_OutlineWidth, 0.0)) / m_Resolution);
 | 
				
			||||||
    vec4 depth8 = texture(m_OutlineDepthTexture, ((texCoord * m_Resolution) + vec2(-m_OutlineWidth, 0.0)) / m_Resolution);
 | 
					    vec4 depth8 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(-m_OutlineWidth, 0.0)) / m_Resolution);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Sample the main texture
 | 
					    // Sample the main texture
 | 
				
			||||||
    vec4 color = texture(m_Texture, texCoord);
 | 
					    vec4 color = texture(m_Texture, texCoord);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Determine whether to apply the outline color
 | 
					    // Check if an outline should be applied
 | 
				
			||||||
    if (depth == vec4(0.0) &&
 | 
					    bool isEdge = (depth == vec4(0.0)) &&
 | 
				
			||||||
       (depth1 != depth || depth2 != depth || depth3 != depth || depth4 != depth ||
 | 
					                  (depth1 != depth || depth2 != depth || depth3 != depth || depth4 != depth ||
 | 
				
			||||||
        depth5 != depth || depth6 != depth || depth7 != depth || depth8 != depth)) {
 | 
					                   depth5 != depth || depth6 != depth || depth7 != depth || depth8 != depth);
 | 
				
			||||||
        fragColor = m_OutlineColor; // Apply outline color
 | 
					
 | 
				
			||||||
    } else {
 | 
					    // Output the final color
 | 
				
			||||||
        fragColor = color; // Use the original texture color
 | 
					    fragColor = isEdge ? m_OutlineColor : color;
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,11 +1,10 @@
 | 
				
			|||||||
 | 
					// Input texture coordinates from the vertex shader
 | 
				
			||||||
// Use 'in' instead of 'varying' for inputs from the vertex shader
 | 
					 | 
				
			||||||
in vec2 texCoord;
 | 
					in vec2 texCoord;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Declare a custom output variable for the fragment color
 | 
					// Output variable for the fragment color
 | 
				
			||||||
out vec4 fragColor;
 | 
					out vec4 fragColor;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Uniform samplers
 | 
					// Uniform samplers for textures
 | 
				
			||||||
uniform sampler2D m_Texture;
 | 
					uniform sampler2D m_Texture;
 | 
				
			||||||
uniform sampler2D m_NormalsTexture;
 | 
					uniform sampler2D m_NormalsTexture;
 | 
				
			||||||
uniform sampler2D m_DepthTexture;
 | 
					uniform sampler2D m_DepthTexture;
 | 
				
			||||||
@@ -13,6 +12,7 @@ uniform sampler2D m_DepthTexture;
 | 
				
			|||||||
void main() {
 | 
					void main() {
 | 
				
			||||||
    // Sample the texture at the given texture coordinates
 | 
					    // Sample the texture at the given texture coordinates
 | 
				
			||||||
    vec4 color = texture(m_Texture, texCoord);
 | 
					    vec4 color = texture(m_Texture, texCoord);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Assign the color to the output variable
 | 
					    // Assign the color to the output variable
 | 
				
			||||||
    fragColor = color;
 | 
					    fragColor = color;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,109 +1,78 @@
 | 
				
			|||||||
 | 
					// Uniform samplers
 | 
				
			||||||
uniform sampler2D m_Texture;
 | 
					uniform sampler2D m_Texture;
 | 
				
			||||||
uniform sampler2D m_OutlineDepthTexture;
 | 
					uniform sampler2D m_OutlineDepthTexture;
 | 
				
			||||||
uniform sampler2D m_DepthTexture;
 | 
					uniform sampler2D m_DepthTexture;
 | 
				
			||||||
varying vec2 texCoord;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Input texture coordinates from the vertex shader
 | 
				
			||||||
 | 
					in vec2 texCoord;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Uniforms for resolution, outline color, and width
 | 
				
			||||||
uniform vec2 m_Resolution;
 | 
					uniform vec2 m_Resolution;
 | 
				
			||||||
uniform vec4 m_OutlineColor;
 | 
					uniform vec4 m_OutlineColor;
 | 
				
			||||||
uniform float m_OutlineWidth;
 | 
					uniform float m_OutlineWidth;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Output variable for fragment color
 | 
				
			||||||
 | 
					out vec4 fragColor;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void main() {
 | 
					void main() {
 | 
				
			||||||
	vec4 depth = texture2D(m_OutlineDepthTexture, texCoord);
 | 
					    vec4 depth = texture(m_OutlineDepthTexture, texCoord);
 | 
				
			||||||
	vec4 depth1 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(m_OutlineWidth,m_OutlineWidth))/m_Resolution);
 | 
					    vec4 depth1 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(m_OutlineWidth, m_OutlineWidth)) / m_Resolution);
 | 
				
			||||||
	vec4 depth2 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(m_OutlineWidth,-m_OutlineWidth))/m_Resolution);
 | 
					    vec4 depth2 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(m_OutlineWidth, -m_OutlineWidth)) / m_Resolution);
 | 
				
			||||||
	vec4 depth3 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(-m_OutlineWidth,m_OutlineWidth))/m_Resolution);
 | 
					    vec4 depth3 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(-m_OutlineWidth, m_OutlineWidth)) / m_Resolution);
 | 
				
			||||||
	vec4 depth4 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(-m_OutlineWidth,-m_OutlineWidth))/m_Resolution);
 | 
					    vec4 depth4 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(-m_OutlineWidth, -m_OutlineWidth)) / m_Resolution);
 | 
				
			||||||
	vec4 depth5 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(0.,m_OutlineWidth))/m_Resolution);
 | 
					    vec4 depth5 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(0.0, m_OutlineWidth)) / m_Resolution);
 | 
				
			||||||
	vec4 depth6 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(0.,-m_OutlineWidth))/m_Resolution);
 | 
					    vec4 depth6 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(0.0, -m_OutlineWidth)) / m_Resolution);
 | 
				
			||||||
	vec4 depth7 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(m_OutlineWidth,0.))/m_Resolution);
 | 
					    vec4 depth7 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(m_OutlineWidth, 0.0)) / m_Resolution);
 | 
				
			||||||
	vec4 depth8 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(-m_OutlineWidth,0.))/m_Resolution);
 | 
					    vec4 depth8 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(-m_OutlineWidth, 0.0)) / m_Resolution);
 | 
				
			||||||
	vec4 color = texture2D(m_Texture, texCoord);
 | 
					
 | 
				
			||||||
	//如果是背景
 | 
					    vec4 color = texture(m_Texture, texCoord);
 | 
				
			||||||
	float ratio=0.;
 | 
					
 | 
				
			||||||
	if(depth==vec4(0.) && (depth1 != depth || depth2 != depth || depth3 != depth || depth4 != depth||depth5 != depth || depth6 != depth || depth7 != depth || depth8 != depth)){
 | 
					    float ratio = 0.0;
 | 
				
			||||||
		float dist=m_OutlineWidth;
 | 
					    if (depth == vec4(0.0) &&
 | 
				
			||||||
		//距离边的像素
 | 
					        (depth1 != depth || depth2 != depth || depth3 != depth || depth4 != depth ||
 | 
				
			||||||
		vec4 nearDepth;
 | 
					         depth5 != depth || depth6 != depth || depth7 != depth || depth8 != depth)) {
 | 
				
			||||||
		if(depth1 != depth){
 | 
					        float dist = m_OutlineWidth;
 | 
				
			||||||
			for(float i=0.;i<m_OutlineWidth;i++){
 | 
					        vec4 nearDepth;
 | 
				
			||||||
				nearDepth = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(i,i))/m_Resolution);
 | 
					
 | 
				
			||||||
				if(nearDepth != depth){
 | 
					        // Iterate to find the distance to the nearest edge
 | 
				
			||||||
					dist = i;
 | 
					        for (float i = 0.0; i < m_OutlineWidth; i++) {
 | 
				
			||||||
					break;
 | 
					            if (depth1 != depth) {
 | 
				
			||||||
				}
 | 
					                nearDepth = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(i, i)) / m_Resolution);
 | 
				
			||||||
			}
 | 
					                if (nearDepth != depth) { dist = i; break; }
 | 
				
			||||||
		}else
 | 
					            } else if (depth2 != depth) {
 | 
				
			||||||
		if(depth2 != depth){
 | 
					                nearDepth = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(i, -i)) / m_Resolution);
 | 
				
			||||||
			for(float i=0.;i<m_OutlineWidth;i++){
 | 
					                if (nearDepth != depth) { dist = i; break; }
 | 
				
			||||||
				nearDepth = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(i,-i))/m_Resolution);
 | 
					            } else if (depth3 != depth) {
 | 
				
			||||||
				if(nearDepth != depth){
 | 
					                nearDepth = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(-i, i)) / m_Resolution);
 | 
				
			||||||
					dist = i;
 | 
					                if (nearDepth != depth) { dist = i; break; }
 | 
				
			||||||
					break;
 | 
					            } else if (depth4 != depth) {
 | 
				
			||||||
				}
 | 
					                nearDepth = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(-i, -i)) / m_Resolution);
 | 
				
			||||||
			}
 | 
					                if (nearDepth != depth) { dist = i; break; }
 | 
				
			||||||
		}else
 | 
					            } else if (depth5 != depth) {
 | 
				
			||||||
		if(depth3 != depth){
 | 
					                nearDepth = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(0.0, i)) / m_Resolution);
 | 
				
			||||||
			for(float i=0.;i<m_OutlineWidth;i++){
 | 
					                if (nearDepth != depth) { dist = i; break; }
 | 
				
			||||||
				nearDepth = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(-i,i))/m_Resolution);
 | 
					            } else if (depth6 != depth) {
 | 
				
			||||||
				if(nearDepth != depth){
 | 
					                nearDepth = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(0.0, -i)) / m_Resolution);
 | 
				
			||||||
					dist = i;
 | 
					                if (nearDepth != depth) { dist = i; break; }
 | 
				
			||||||
					break;
 | 
					            } else if (depth7 != depth) {
 | 
				
			||||||
				}
 | 
					                nearDepth = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(i, 0.0)) / m_Resolution);
 | 
				
			||||||
			}
 | 
					                if (nearDepth != depth) { dist = i; break; }
 | 
				
			||||||
		}else
 | 
					            } else if (depth8 != depth) {
 | 
				
			||||||
		if(depth4 != depth){
 | 
					                nearDepth = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(-i, 0.0)) / m_Resolution);
 | 
				
			||||||
			for(float i=0.;i<m_OutlineWidth;i++){
 | 
					                if (nearDepth != depth) { dist = i; break; }
 | 
				
			||||||
				nearDepth = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(-i,-i))/m_Resolution);
 | 
					            }
 | 
				
			||||||
				if(nearDepth != depth){
 | 
					        }
 | 
				
			||||||
					dist = i;
 | 
					
 | 
				
			||||||
					break;
 | 
					        // Calculate ratio for outline blending
 | 
				
			||||||
				}
 | 
					        ratio = clamp(1.0 - dist / m_OutlineWidth, 0.0, 1.0);
 | 
				
			||||||
			}
 | 
					
 | 
				
			||||||
		}else
 | 
					        // Blend the outline color with the base color
 | 
				
			||||||
		if(depth5 != depth){
 | 
					        fragColor = color * (1.0 - ratio) + m_OutlineColor * ratio;
 | 
				
			||||||
			for(float i=0.;i<m_OutlineWidth;i++){
 | 
					    } else {
 | 
				
			||||||
				nearDepth = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(0.,i))/m_Resolution);
 | 
					        // No outline, use the base texture color
 | 
				
			||||||
				if(nearDepth != depth){
 | 
					        fragColor = color;
 | 
				
			||||||
					dist = i;
 | 
					    }
 | 
				
			||||||
					break;
 | 
					
 | 
				
			||||||
				}
 | 
					    // Optional: Debugging outline visualization
 | 
				
			||||||
			}
 | 
					    // fragColor = vec4(0.0, 1.0 - ratio, 0.0, 1.0);
 | 
				
			||||||
		}else
 | 
					}
 | 
				
			||||||
		if(depth6 != depth){
 | 
					 | 
				
			||||||
			for(float i=0.;i<m_OutlineWidth;i++){
 | 
					 | 
				
			||||||
				nearDepth = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(0.,-i))/m_Resolution);
 | 
					 | 
				
			||||||
				if(nearDepth != depth){
 | 
					 | 
				
			||||||
					dist = i;
 | 
					 | 
				
			||||||
					break;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}else
 | 
					 | 
				
			||||||
		if(depth7 != depth){
 | 
					 | 
				
			||||||
			for(float i=0.;i<m_OutlineWidth;i++){
 | 
					 | 
				
			||||||
				nearDepth = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(i,0.))/m_Resolution);
 | 
					 | 
				
			||||||
				if(nearDepth != depth){
 | 
					 | 
				
			||||||
					dist = i;
 | 
					 | 
				
			||||||
					break;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}else
 | 
					 | 
				
			||||||
		if(depth8 != depth){
 | 
					 | 
				
			||||||
			for(float i=0.;i<m_OutlineWidth;i++){
 | 
					 | 
				
			||||||
				nearDepth = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(-i,0.))/m_Resolution);
 | 
					 | 
				
			||||||
				if(nearDepth != depth){
 | 
					 | 
				
			||||||
					dist = i;
 | 
					 | 
				
			||||||
					break;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		//0:场景颜色		1:outline颜色 
 | 
					 | 
				
			||||||
		ratio = clamp(1.- dist/m_OutlineWidth,0.,1.);
 | 
					 | 
				
			||||||
		//float off = (1.-ratio*ratio)*(1.-ratio*ratio);
 | 
					 | 
				
			||||||
		gl_FragColor = color*(1.-ratio) +m_OutlineColor*ratio;
 | 
					 | 
				
			||||||
		//gl_FragColor = m_OutlineColor;
 | 
					 | 
				
			||||||
	}else{
 | 
					 | 
				
			||||||
		gl_FragColor = color;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	//debug
 | 
					 | 
				
			||||||
	//gl_FragColor = vec4(0.,(1.-ratio),0.,1.);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,8 +1,8 @@
 | 
				
			|||||||
// Use 'in' for vertex attributes
 | 
					// Vertex attributes
 | 
				
			||||||
in vec4 inPosition;
 | 
					in vec4 inPosition;
 | 
				
			||||||
in vec2 inTexCoord;
 | 
					in vec2 inTexCoord;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Use 'out' for passing data to the fragment shader
 | 
					// Output to fragment shader
 | 
				
			||||||
out vec2 texCoord;
 | 
					out vec2 texCoord;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void main() {
 | 
					void main() {
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										
											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
									
								
							
							
						
						@@ -56,6 +56,7 @@ public void setState(GameStates newState){
 | 
				
			|||||||
        if(this.state != null){
 | 
					        if(this.state != null){
 | 
				
			||||||
            this.state.exit();
 | 
					            this.state.exit();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        System.out.println("CLIENT STATE old:" + this.state + " new:" + newState);
 | 
				
			||||||
        newState.enter();
 | 
					        newState.enter();
 | 
				
			||||||
        state = newState;
 | 
					        state = newState;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -275,6 +276,11 @@ public void received(ActivePlayerMessage msg){
 | 
				
			|||||||
        state.received(msg);
 | 
					        state.received(msg);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void received(PossiblePieceMessage msg){
 | 
				
			||||||
 | 
					        state.received(msg);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * This method returns the current state
 | 
					     * This method returns the current state
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -94,6 +94,7 @@ public void received(ServerStartGameMessage msg) {
 | 
				
			|||||||
    @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())) {
 | 
				
			||||||
 | 
					            System.out.println(msg.getId());
 | 
				
			||||||
            logic.setOwnPlayerId(msg.getId());
 | 
					            logic.setOwnPlayerId(msg.getId());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (msg.isHost() && msg.getId() == logic.getOwnPlayerId()) {
 | 
					        if (msg.isHost() && msg.getId() == logic.getOwnPlayerId()) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,6 +7,8 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
public class AnimationState extends GameStates {
 | 
					public class AnimationState extends GameStates {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private final System.Logger LOGGER = System.getLogger(this.getClass().getName());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private final GameState parent;
 | 
					    private final GameState parent;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public AnimationState(ClientState parent, ClientGameLogic logic) {
 | 
					    public AnimationState(ClientState parent, ClientGameLogic logic) {
 | 
				
			||||||
@@ -16,7 +18,7 @@ public AnimationState(ClientState parent, ClientGameLogic logic) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void enter() {
 | 
					    public void enter() {
 | 
				
			||||||
 | 
					        LOGGER.log(System.Logger.Level.INFO, "Entering AnimationState");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,10 +8,7 @@
 | 
				
			|||||||
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.client.AnimationEndMessage;
 | 
				
			||||||
import pp.mdga.message.server.ActivePlayerMessage;
 | 
					import pp.mdga.message.server.*;
 | 
				
			||||||
import pp.mdga.message.server.DieMessage;
 | 
					 | 
				
			||||||
import pp.mdga.message.server.RankingResponseMessage;
 | 
					 | 
				
			||||||
import pp.mdga.message.server.RankingRollAgainMessage;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class DetermineStartPlayerState extends GameStates {
 | 
					public class DetermineStartPlayerState extends GameStates {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -61,8 +58,8 @@ public void setState(DetermineStartPlayerStates state) {
 | 
				
			|||||||
        if(this.state != null){
 | 
					        if(this.state != null){
 | 
				
			||||||
            this.state.exit();
 | 
					            this.state.exit();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        state.enter();
 | 
					 | 
				
			||||||
        this.state = state;
 | 
					        this.state = state;
 | 
				
			||||||
 | 
					        this.state.enter();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
@@ -80,6 +77,11 @@ public void received(DieMessage msg){
 | 
				
			|||||||
        state.received(msg);
 | 
					        state.received(msg);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void received(DiceNowMessage msg){
 | 
				
			||||||
 | 
					        state.received(msg);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void received(RankingRollAgainMessage msg){
 | 
					    public void received(RankingRollAgainMessage msg){
 | 
				
			||||||
        state.received(msg);
 | 
					        state.received(msg);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,6 +15,9 @@
 | 
				
			|||||||
import java.util.UUID;
 | 
					import java.util.UUID;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public abstract class GameStates extends ClientState {
 | 
					public abstract class GameStates extends ClientState {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private final System.Logger LOGGER = System.getLogger(this.getClass().getName());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public GameStates(ClientState parent, ClientGameLogic logic) {
 | 
					    public GameStates(ClientState parent, ClientGameLogic logic) {
 | 
				
			||||||
        super(parent, logic);
 | 
					        super(parent, logic);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -27,6 +30,7 @@ protected void handlePowerCard(PlayCardMessage msg) {
 | 
				
			|||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            Piece ownPiece = logic.getGame().getPieceThroughUUID(msg.getPieces().get(0).getUuid());
 | 
					            Piece ownPiece = logic.getGame().getPieceThroughUUID(msg.getPieces().get(0).getUuid());
 | 
				
			||||||
            Piece enemyPiece = logic.getGame().getPieceThroughUUID(msg.getPieces().get(1).getUuid());
 | 
					            Piece enemyPiece = logic.getGame().getPieceThroughUUID(msg.getPieces().get(1).getUuid());
 | 
				
			||||||
 | 
					            LOGGER.log(System.Logger.Level.INFO, "Swapping");
 | 
				
			||||||
            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);
 | 
				
			||||||
@@ -38,7 +42,7 @@ protected void handlePowerCard(PlayCardMessage msg) {
 | 
				
			|||||||
    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().getPlayerByColor(piece.getColor()).addWaitingPiece(piece);
 | 
				
			||||||
        logic.addNotification(new ThrowPieceNotification(piece.getUuid()));
 | 
					        logic.addNotification(new ThrowPieceNotification(piece.getUuid(), piece.getColor()));
 | 
				
			||||||
        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);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -63,7 +63,7 @@ public void received(ActivePlayerMessage msg) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @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.getPiece().getUuid());
 | 
				
			||||||
        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();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -47,6 +47,11 @@ public void setState(TurnStates state){
 | 
				
			|||||||
        this.state = state;
 | 
					        this.state = state;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void selectDice(){
 | 
				
			||||||
 | 
					        state.selectDice();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void selectPiece(Piece piece){
 | 
					    public void selectPiece(Piece piece){
 | 
				
			||||||
        state.selectPiece(piece);
 | 
					        state.selectPiece(piece);
 | 
				
			||||||
@@ -127,6 +132,11 @@ public void received(DieMessage msg){
 | 
				
			|||||||
        state.received(msg);
 | 
					        state.received(msg);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void received(PossiblePieceMessage msg){
 | 
				
			||||||
 | 
					        state.received(msg);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public ChoosePieceState getChoosePiece() {
 | 
					    public ChoosePieceState getChoosePiece() {
 | 
				
			||||||
        return choosePieceState;
 | 
					        return choosePieceState;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,6 +11,7 @@
 | 
				
			|||||||
public class WaitingState extends GameStates {
 | 
					public class WaitingState extends GameStates {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private final GameState parent;
 | 
					    private final GameState parent;
 | 
				
			||||||
 | 
					    private final System.Logger LOGGER = System.getLogger(this.getClass().getName());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public WaitingState(ClientState parent, ClientGameLogic logic) {
 | 
					    public WaitingState(ClientState parent, ClientGameLogic logic) {
 | 
				
			||||||
        super(parent, logic);
 | 
					        super(parent, logic);
 | 
				
			||||||
@@ -46,7 +47,6 @@ public void received(DieMessage msg) {
 | 
				
			|||||||
            logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseDiced6();
 | 
					            logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseDiced6();
 | 
				
			||||||
            logic.getGame().getGameStatistics().increaseDiced6();
 | 
					            logic.getGame().getGameStatistics().increaseDiced6();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        parent.setState(parent.getAnimation());
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
@@ -62,36 +62,33 @@ public void received(PlayCardMessage msg) {
 | 
				
			|||||||
    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.getTurn());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void received(MoveMessage msg) {
 | 
					    public void received(MoveMessage msg) {
 | 
				
			||||||
        Piece pieceToMove = logic.getGame().getPieceThroughUUID(msg.getIdentifier());
 | 
					        Piece piece = logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid());
 | 
				
			||||||
 | 
					        //logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant();
 | 
				
			||||||
        if (msg.isHomeMove()) {
 | 
					        if (msg.isHomeMove()) {
 | 
				
			||||||
            logic.addNotification(new HomeMoveNotification(pieceToMove.getUuid(), msg.getTargetIndex()));
 | 
					            logic.addNotification(new HomeMoveNotification(piece.getUuid(), msg.getTargetIndex()));
 | 
				
			||||||
            logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)].clearOccupant();
 | 
					            logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant();
 | 
				
			||||||
            logic.getGame().getPlayerByColor(pieceToMove.getColor()).setPieceInHome(msg.getTargetIndex(), pieceToMove);
 | 
					            logic.getGame().getPlayerByColor(piece.getColor()).setPieceInHome(msg.getTargetIndex(), piece);
 | 
				
			||||||
            for (int i = msg.getTargetIndex() + 1; i < 4; i++) {
 | 
					 | 
				
			||||||
                if (!logic.getGame().getPlayerByColor(pieceToMove.getColor()).getHomeNodes()[i].isOccupied()) {
 | 
					 | 
				
			||||||
                    pieceToMove.setState(PieceState.HOME);
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                pieceToMove.setState(PieceState.HOMEFINISHED);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            if (logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].isOccupied()) {
 | 
					            int oldIndex = logic.getGame().getBoard().getInfieldIndexOfPiece(piece);
 | 
				
			||||||
                throwPiece(logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant());
 | 
					
 | 
				
			||||||
                logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increasePiecesThrown();
 | 
					            Piece occ = logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant();
 | 
				
			||||||
                logic.getGame().getGameStatistics().increasePiecesThrown();
 | 
					            //logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].moveOccupant(piece);
 | 
				
			||||||
            }
 | 
					            if (occ != null) {
 | 
				
			||||||
            if (logic.getGame().getPlayerByColor(pieceToMove.getColor()).getStartNodeIndex() == logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)) {
 | 
					                //TODO: MoveThrowNotification
 | 
				
			||||||
                logic.addNotification(new MovePieceNotification(pieceToMove.getUuid(), msg.getTargetIndex(), true));
 | 
					                logic.addNotification(new ThrowPieceNotification(occ.getUuid(), piece.getColor()));
 | 
				
			||||||
                logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(pieceToMove);
 | 
					                //set occ to waiting
 | 
				
			||||||
            } else {
 | 
					                logic.getGame().getPlayerByColor(occ.getColor()).addWaitingPiece(occ);
 | 
				
			||||||
                logic.addNotification(new MovePieceNotification(pieceToMove.getUuid(), logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove), msg.getTargetIndex()));
 | 
					 | 
				
			||||||
                logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(pieceToMove);
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            logic.addNotification(new MovePieceNotification(msg.getPiece().getUuid(), oldIndex, msg.getTargetIndex()));
 | 
				
			||||||
 | 
					            //clear old node
 | 
				
			||||||
 | 
					            logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant();
 | 
				
			||||||
 | 
					            //set new node
 | 
				
			||||||
 | 
					            logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(piece);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        parent.setState(parent.getAnimation());
 | 
					        parent.setState(parent.getAnimation());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -44,9 +44,9 @@ public DetermineStartPlayerState getParent(){
 | 
				
			|||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void enter() {
 | 
					    public void enter() {
 | 
				
			||||||
        for(Map.Entry<Integer, Player> entry : logic.getGame().getPlayers().entrySet()){
 | 
					        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.addNotification(new MovePieceNotification(entry.getValue().getPieces()[0].getUuid(), entry.getValue().getStartNodeIndex(), true));
 | 
				
			||||||
            logic.getGame().getBoard().getInfield()[entry.getValue().getStartNodeIndex()].setOccupant(entry.getValue().getPieces()[0]);
 | 
					            logic.getGame().getBoard().getInfield()[entry.getValue().getStartNodeIndex()].setOccupant(entry.getValue().getPieces()[0]);
 | 
				
			||||||
 | 
					            entry.getValue().getWaitingArea()[0] = null;
 | 
				
			||||||
            animationCounter++;
 | 
					            animationCounter++;
 | 
				
			||||||
            if(entry.getKey() == logic.getOwnPlayerId()){
 | 
					            if(entry.getKey() == logic.getOwnPlayerId()){
 | 
				
			||||||
                logic.addNotification(new AcquireCardNotification(entry.getValue().getHandCards().get(0).getCard()));
 | 
					                logic.addNotification(new AcquireCardNotification(entry.getValue().getHandCards().get(0).getCard()));
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,6 +10,8 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
public class RollRankingDiceState extends DetermineStartPlayerStates {
 | 
					public class RollRankingDiceState extends DetermineStartPlayerStates {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private final System.Logger LOGGER = System.getLogger(this.getClass().getName());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private final DetermineStartPlayerState parent;
 | 
					    private final DetermineStartPlayerState parent;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public RollRankingDiceState(ClientState parent, ClientGameLogic logic) {
 | 
					    public RollRankingDiceState(ClientState parent, ClientGameLogic logic) {
 | 
				
			||||||
@@ -19,11 +21,13 @@ public RollRankingDiceState(ClientState parent, ClientGameLogic logic) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void enter() {
 | 
					    public void enter() {
 | 
				
			||||||
 | 
					        LOGGER.log(System.Logger.Level.INFO, "Entering RollRankingDiceState");
 | 
				
			||||||
        logic.addNotification(new DiceNowNotification());
 | 
					        logic.addNotification(new DiceNowNotification());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void exit() {
 | 
					    public void exit() {
 | 
				
			||||||
 | 
					        LOGGER.log(System.Logger.Level.INFO, "Exiting RollRankingDiceState");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,6 +9,8 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
public class WaitRankingState extends DetermineStartPlayerStates {
 | 
					public class WaitRankingState extends DetermineStartPlayerStates {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private final System.Logger LOGGER = System.getLogger(this.getClass().getName());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private final DetermineStartPlayerState parent;
 | 
					    private final DetermineStartPlayerState parent;
 | 
				
			||||||
    private boolean canChange = false;
 | 
					    private boolean canChange = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -27,11 +29,13 @@ private void changeToIntro(){
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void enter() {
 | 
					    public void enter() {
 | 
				
			||||||
 | 
					        LOGGER.log(System.Logger.Level.INFO, "Entering WaitRankingState");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void exit() {
 | 
					    public void exit() {
 | 
				
			||||||
 | 
					        canChange = false;
 | 
				
			||||||
 | 
					        LOGGER.log(System.Logger.Level.INFO, "Exiting WaitRankingState");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -46,7 +46,7 @@ public void received(SpectatorMessage msg){
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void received(DiceAgainMessage msg){
 | 
					    public void received(DiceNowMessage msg){
 | 
				
			||||||
        parent.setState(parent.getRollDice());
 | 
					        parent.setState(parent.getRollDice());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -35,7 +35,7 @@ public void setPlayCard(PlayCardMessage playCardMessage) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void selectAnimationEnd(){
 | 
					    public void selectAnimationEnd(){
 | 
				
			||||||
        parent.setState(parent.getRollDice());
 | 
					 | 
				
			||||||
        logic.send(new AnimationEndMessage());
 | 
					        logic.send(new AnimationEndMessage());
 | 
				
			||||||
 | 
					        parent.setState(parent.getRollDice());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,6 +3,7 @@
 | 
				
			|||||||
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.RequestDieMessage;
 | 
					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;
 | 
				
			||||||
@@ -37,11 +38,23 @@ public void selectDice(){
 | 
				
			|||||||
        logic.send(new RequestDieMessage());
 | 
					        logic.send(new RequestDieMessage());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @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().getPlayerById(logic.getOwnPlayerId()).getColor(), msg.getDiceEye(),false));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void selectAnimationEnd(){
 | 
				
			||||||
 | 
					        logic.send(new AnimationEndMessage());
 | 
				
			||||||
        parent.setState(parent.getChoosePiece());
 | 
					        parent.setState(parent.getChoosePiece());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//    @Override
 | 
				
			||||||
 | 
					//    public void received(ChoosePieceStateMessage msg){
 | 
				
			||||||
 | 
					//        parent.setState(parent.getChoosePiece());
 | 
				
			||||||
 | 
					//    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void received(NoTurnMessage msg){
 | 
					    public void received(NoTurnMessage msg){
 | 
				
			||||||
        parent.getParent().setState(parent.getParent().getWaiting());
 | 
					        parent.getParent().setState(parent.getParent().getWaiting());
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,6 +16,8 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
public class NoPieceState extends ChoosePieceStates {
 | 
					public class NoPieceState extends ChoosePieceStates {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private final System.Logger LOGGER = System.getLogger(this.getClass().getName());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private final ChoosePieceState parent;
 | 
					    private final ChoosePieceState parent;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public NoPieceState(ClientState parent, ClientGameLogic logic) {
 | 
					    public NoPieceState(ClientState parent, ClientGameLogic logic) {
 | 
				
			||||||
@@ -25,7 +27,7 @@ public NoPieceState(ClientState parent, ClientGameLogic logic) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void enter() {
 | 
					    public void enter() {
 | 
				
			||||||
 | 
					        LOGGER.log(System.Logger.Level.INFO, "Entering NoPieceState");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
@@ -35,14 +37,16 @@ public void exit() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void received(SelectPieceMessage msg) {
 | 
					    public void received(SelectPieceMessage msg) {
 | 
				
			||||||
        parent.setState(parent.getSelectPiece());
 | 
					        ArrayList<Piece> pieces = msg.getPieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(piece.getUuid())).collect(Collectors.toCollection(ArrayList::new));
 | 
				
			||||||
        ArrayList<Piece> pieces = msg.getPieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(piece)).collect(Collectors.toCollection(ArrayList::new));
 | 
					 | 
				
			||||||
        parent.getSelectPiece().setPossiblePieces(pieces);
 | 
					        parent.getSelectPiece().setPossiblePieces(pieces);
 | 
				
			||||||
 | 
					        LOGGER.log(System.Logger.Level.INFO, "Received " + msg.getPieces().size() + " pieces");
 | 
				
			||||||
        logic.addNotification(new SelectableMoveNotification(pieces.stream().map(Piece::getUuid).collect(Collectors.toCollection(ArrayList::new)), msg.getTargetIndex(), msg.getIsHomeMove()));
 | 
					        logic.addNotification(new SelectableMoveNotification(pieces.stream().map(Piece::getUuid).collect(Collectors.toCollection(ArrayList::new)), msg.getTargetIndex(), msg.getIsHomeMove()));
 | 
				
			||||||
 | 
					        parent.setState(parent.getSelectPiece());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void received(WaitPieceMessage msg){
 | 
					    public void received(WaitPieceMessage msg){
 | 
				
			||||||
 | 
					        LOGGER.log(System.Logger.Level.INFO, "Received WaitPieceMessage");
 | 
				
			||||||
        logic.addNotification(new WaitMoveNotification(msg.getPieceID()));
 | 
					        logic.addNotification(new WaitMoveNotification(msg.getPieceID()));
 | 
				
			||||||
        parent.setState(parent.getWaitingPiece());
 | 
					        parent.setState(parent.getWaitingPiece());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -56,6 +60,8 @@ public void received(StartPieceMessage msg){
 | 
				
			|||||||
        listPiece.add(piece.getUuid());
 | 
					        listPiece.add(piece.getUuid());
 | 
				
			||||||
        listIndex.add(msg.getTargetIndex());
 | 
					        listIndex.add(msg.getTargetIndex());
 | 
				
			||||||
        homeMove.add(false);
 | 
					        homeMove.add(false);
 | 
				
			||||||
 | 
					        parent.getStartPiece().setMoveablePiece(piece);
 | 
				
			||||||
 | 
					        LOGGER.log(System.Logger.Level.INFO, "Received start piece " + listPiece.get(0));
 | 
				
			||||||
        logic.addNotification(new SelectableMoveNotification(listPiece, listIndex, homeMove));
 | 
					        logic.addNotification(new SelectableMoveNotification(listPiece, listIndex, homeMove));
 | 
				
			||||||
        parent.setState(parent.getStartPiece());
 | 
					        parent.setState(parent.getStartPiece());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,10 +4,12 @@
 | 
				
			|||||||
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.RequestMoveMessage;
 | 
				
			||||||
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 pp.mdga.notification.HomeMoveNotification;
 | 
					import pp.mdga.notification.HomeMoveNotification;
 | 
				
			||||||
import pp.mdga.notification.MovePieceNotification;
 | 
					import pp.mdga.notification.MovePieceNotification;
 | 
				
			||||||
 | 
					import pp.mdga.notification.ThrowPieceNotification;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.util.ArrayList;
 | 
					import java.util.ArrayList;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -15,6 +17,7 @@ public class SelectPieceState extends ChoosePieceStates {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    private final ChoosePieceState parent;
 | 
					    private final ChoosePieceState parent;
 | 
				
			||||||
    private ArrayList<Piece> possiblePieces;
 | 
					    private ArrayList<Piece> possiblePieces;
 | 
				
			||||||
 | 
					    private final System.Logger LOGGER = System.getLogger(this.getClass().getName());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public SelectPieceState(ClientState parent, ClientGameLogic logic) {
 | 
					    public SelectPieceState(ClientState parent, ClientGameLogic logic) {
 | 
				
			||||||
        super(parent, logic);
 | 
					        super(parent, logic);
 | 
				
			||||||
@@ -37,28 +40,38 @@ public void setPossiblePieces(ArrayList<Piece> 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 RequestMoveMessage(piece));
 | 
				
			||||||
            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.getPiece().getUuid());
 | 
				
			||||||
 | 
					        //logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant();
 | 
				
			||||||
        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().getPlayerByColor(piece.getColor()).setPieceInHome(msg.getTargetIndex(), piece);
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            if (logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].isOccupied()) {
 | 
					            int oldIndex = logic.getGame().getBoard().getInfieldIndexOfPiece(piece);
 | 
				
			||||||
                throwPiece(logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant());
 | 
					
 | 
				
			||||||
                logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increasePiecesThrown();
 | 
					            Piece occ = logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant();
 | 
				
			||||||
                logic.getGame().getGameStatistics().increasePiecesThrown();
 | 
					            //logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].moveOccupant(piece);
 | 
				
			||||||
 | 
					            if (occ != null) {
 | 
				
			||||||
 | 
					                //TODO: MoveThrowNotification
 | 
				
			||||||
 | 
					                logic.addNotification(new ThrowPieceNotification(occ.getUuid(), piece.getColor()));
 | 
				
			||||||
 | 
					                //set occ to waiting
 | 
				
			||||||
 | 
					                logic.getGame().getPlayerByColor(occ.getColor()).addWaitingPiece(occ);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            logic.addNotification(new MovePieceNotification(piece.getUuid(), logic.getGame().getBoard().getInfieldIndexOfPiece(piece), msg.getTargetIndex()));
 | 
					            logic.addNotification(new MovePieceNotification(msg.getPiece().getUuid(), oldIndex, msg.getTargetIndex()));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //clear old node
 | 
				
			||||||
 | 
					            logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant();
 | 
				
			||||||
 | 
					            //set new node
 | 
				
			||||||
 | 
					            logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(piece);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        parent.getParent().setState(parent.getParent().getMovePiece());
 | 
					        parent.getParent().setState(parent.getParent().getMovePiece());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,13 +4,18 @@
 | 
				
			|||||||
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.RequestMoveMessage;
 | 
				
			||||||
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 pp.mdga.notification.MovePieceNotification;
 | 
				
			||||||
 | 
					import pp.mdga.notification.ThrowPieceNotification;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.util.ArrayList;
 | 
					import java.util.ArrayList;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class StartPieceState extends ChoosePieceStates {
 | 
					public class StartPieceState extends ChoosePieceStates {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private final System.Logger LOGGER = System.getLogger(this.getClass().getName());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private final ChoosePieceState parent;
 | 
					    private final ChoosePieceState parent;
 | 
				
			||||||
    private Piece moveablePiece;
 | 
					    private Piece moveablePiece;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -27,20 +32,31 @@ public void enter() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void exit() {
 | 
					    public void exit() {
 | 
				
			||||||
 | 
					        moveablePiece = null;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setMoveablePiece(Piece moveablePiece) {
 | 
				
			||||||
 | 
					        this.moveablePiece = moveablePiece;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @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 RequestMoveMessage(piece));
 | 
				
			||||||
            logic.send(new SelectedPiecesMessage(pieces));
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void received(MoveMessage msg){
 | 
					    public void received(MoveMessage msg){
 | 
				
			||||||
 | 
					        Piece piece = logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid());
 | 
				
			||||||
 | 
					        int i = logic.getGame().getBoard().getInfieldIndexOfPiece(piece);
 | 
				
			||||||
 | 
					        LOGGER.log(System.Logger.Level.INFO, "Received MoveMessage with start index: " + i);
 | 
				
			||||||
 | 
					        logic.addNotification(new MovePieceNotification(msg.getPiece().getUuid(), i, msg.getTargetIndex()));
 | 
				
			||||||
 | 
					        Piece occ = logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].moveOccupant(piece);
 | 
				
			||||||
 | 
					        if (occ != null){
 | 
				
			||||||
 | 
					            logic.getGame().getPlayerByColor(occ.getColor()).addWaitingPiece(occ);
 | 
				
			||||||
 | 
					            logic.addNotification(new ThrowPieceNotification(occ.getUuid(), piece.getColor()));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        parent.getParent().setState(parent.getParent().getMovePiece());
 | 
					        parent.getParent().setState(parent.getParent().getMovePiece());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,8 +5,11 @@
 | 
				
			|||||||
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.RequestMoveMessage;
 | 
				
			||||||
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 pp.mdga.notification.MovePieceNotification;
 | 
				
			||||||
 | 
					import pp.mdga.notification.ThrowPieceNotification;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.util.ArrayList;
 | 
					import java.util.ArrayList;
 | 
				
			||||||
import java.util.List;
 | 
					import java.util.List;
 | 
				
			||||||
@@ -32,16 +35,20 @@ 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 RequestMoveMessage(piece));
 | 
				
			||||||
            logic.send(new SelectedPiecesMessage(pieces));
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @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.getPiece().getUuid());
 | 
				
			||||||
 | 
					        Piece occ = logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].moveOccupant(pieceToMove);
 | 
				
			||||||
 | 
					        logic.addNotification(new MovePieceNotification(pieceToMove.getUuid(), logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getStartNodeIndex(), true));
 | 
				
			||||||
 | 
					        if (occ != null){
 | 
				
			||||||
 | 
					            logic.getGame().getPlayerByColor(occ.getColor()).addWaitingPiece(occ);
 | 
				
			||||||
 | 
					            logic.addNotification(new ThrowPieceNotification(occ.getUuid(), pieceToMove.getColor()));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        pieceToMove.setState(PieceState.ACTIVE);
 | 
					        pieceToMove.setState(PieceState.ACTIVE);
 | 
				
			||||||
        parent.getParent().setState(parent.getParent().getMovePiece());
 | 
					        parent.getParent().setState(parent.getParent().getMovePiece());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -106,11 +106,12 @@ public void received(DiceNowMessage msg){
 | 
				
			|||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void received(PossiblePieceMessage msg){
 | 
					    public void received(PossiblePieceMessage msg){
 | 
				
			||||||
        if (msg.getEnemyPossiblePieces().isEmpty()){
 | 
					        if (msg.getEnemyPossiblePieces().isEmpty()){
 | 
				
			||||||
            parent.getShield().setPossiblePieces(msg.getOwnPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(piece)).collect(Collectors.toCollection(ArrayList::new)));
 | 
					            parent.getShield().setPossiblePieces(msg.getOwnPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(piece.getUuid())).collect(Collectors.toCollection(ArrayList::new)));
 | 
				
			||||||
            parent.setState(parent.getShield());
 | 
					            parent.setState(parent.getShield());
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            parent.getSwap().setPossibleOwnPieces(msg.getOwnPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(piece)).collect(Collectors.toCollection(ArrayList::new)));
 | 
					            System.out.println("Should enter Swap State");
 | 
				
			||||||
            parent.getSwap().setPossibleEnemyPieces(msg.getEnemyPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(piece)).collect(Collectors.toCollection(ArrayList::new)));
 | 
					            parent.getSwap().setPossibleOwnPieces(msg.getOwnPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(piece.getUuid())).collect(Collectors.toCollection(ArrayList::new)));
 | 
				
			||||||
 | 
					            parent.getSwap().setPossibleEnemyPieces(msg.getEnemyPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(piece.getUuid())).collect(Collectors.toCollection(ArrayList::new)));
 | 
				
			||||||
            parent.setState(parent.getSwap());
 | 
					            parent.setState(parent.getSwap());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -13,6 +13,7 @@
 | 
				
			|||||||
public class ShieldState extends PowerCardStates {
 | 
					public class ShieldState extends PowerCardStates {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private final PowerCardState parent;
 | 
					    private final PowerCardState parent;
 | 
				
			||||||
 | 
					    private final System.Logger LOGGER = System.getLogger(this.getClass().getName());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private ArrayList<Piece> possiblePieces;
 | 
					    private ArrayList<Piece> possiblePieces;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,6 +5,8 @@
 | 
				
			|||||||
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.client.SelectCardMessage;
 | 
				
			||||||
 | 
					import pp.mdga.message.client.SelectedPiecesMessage;
 | 
				
			||||||
import pp.mdga.message.server.PlayCardMessage;
 | 
					import pp.mdga.message.server.PlayCardMessage;
 | 
				
			||||||
import pp.mdga.notification.SelectableSwapNotification;
 | 
					import pp.mdga.notification.SelectableSwapNotification;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -13,6 +15,8 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
public class SwapState extends PowerCardStates {
 | 
					public class SwapState extends PowerCardStates {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private final System.Logger LOGGER = System.getLogger(this.getClass().getName());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private final PowerCardState parent;
 | 
					    private final PowerCardState parent;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private ArrayList<Piece> possibleOwnPieces;
 | 
					    private ArrayList<Piece> possibleOwnPieces;
 | 
				
			||||||
@@ -29,6 +33,7 @@ public SwapState(ClientState parent, ClientGameLogic logic) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void enter() {
 | 
					    public void enter() {
 | 
				
			||||||
 | 
					        LOGGER.log(System.Logger.Level.INFO, "Entering SwapState");
 | 
				
			||||||
        ArrayList<UUID> ownPieces = new ArrayList<>(possibleOwnPieces.stream().map(Piece::getUuid).toList());
 | 
					        ArrayList<UUID> ownPieces = new ArrayList<>(possibleOwnPieces.stream().map(Piece::getUuid).toList());
 | 
				
			||||||
        ArrayList<UUID> enemyPieces = new ArrayList<>(possibleEnemyPieces.stream().map(Piece::getUuid).toList());
 | 
					        ArrayList<UUID> enemyPieces = new ArrayList<>(possibleEnemyPieces.stream().map(Piece::getUuid).toList());
 | 
				
			||||||
        logic.addNotification(new SelectableSwapNotification(ownPieces, enemyPieces));
 | 
					        logic.addNotification(new SelectableSwapNotification(ownPieces, enemyPieces));
 | 
				
			||||||
@@ -36,6 +41,7 @@ public void enter() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void exit() {
 | 
					    public void exit() {
 | 
				
			||||||
 | 
					        LOGGER.log(System.Logger.Level.INFO, "Exiting SwapState");
 | 
				
			||||||
        possibleOwnPieces = null;
 | 
					        possibleOwnPieces = null;
 | 
				
			||||||
        possibleEnemyPieces = null;
 | 
					        possibleEnemyPieces = null;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -56,7 +62,10 @@ public void selectPiece(Piece piece){
 | 
				
			|||||||
            selectedEnemyPiece = piece;
 | 
					            selectedEnemyPiece = piece;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (selectedOwnPiece != null && selectedEnemyPiece != null){
 | 
					        if (selectedOwnPiece != null && selectedEnemyPiece != null){
 | 
				
			||||||
            logic.send(RequestPlayCardMessage.requestPlaySwap(selectedOwnPiece.getUuid(), selectedEnemyPiece.getUuid()));
 | 
					            ArrayList<Piece> temp = new ArrayList<>();
 | 
				
			||||||
 | 
					            temp.add(selectedOwnPiece);
 | 
				
			||||||
 | 
					            temp.add(selectedEnemyPiece);
 | 
				
			||||||
 | 
					            logic.send(new SelectedPiecesMessage(temp));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -79,8 +79,10 @@ private StartNode createStartNode(int i) {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public int getInfieldIndexOfPiece(Piece piece) {
 | 
					    public int getInfieldIndexOfPiece(Piece piece) {
 | 
				
			||||||
        for (int i = 0; i < infield.length; i++) {
 | 
					        for (int i = 0; i < infield.length; i++) {
 | 
				
			||||||
            if (infield[i].getOccupant() == piece) {
 | 
					            if(infield[i].isOccupied()) {
 | 
				
			||||||
                return i;
 | 
					                if (infield[i].getOccupant().equals(piece)) {
 | 
				
			||||||
 | 
					                    return i;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return -1;
 | 
					        return -1;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -71,7 +71,7 @@ public class Game {
 | 
				
			|||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * The dice modifier.
 | 
					     * The dice modifier.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private int diceModifier;
 | 
					    private int diceModifier = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * The number of eyes on the dice.
 | 
					     * The number of eyes on the dice.
 | 
				
			||||||
@@ -92,9 +92,9 @@ public Game() {
 | 
				
			|||||||
     * This method initializes the draw pile with the predefined number of bonus cards.
 | 
					     * This method initializes the draw pile with the predefined number of bonus cards.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private void initializeDrawPile() {
 | 
					    private void initializeDrawPile() {
 | 
				
			||||||
        this.addBonusCards(new TurboCard(), AMOUNT_OF_TURBO_CARDS);
 | 
					//        this.addBonusCards(new TurboCard(), AMOUNT_OF_TURBO_CARDS);
 | 
				
			||||||
        this.addBonusCards(new SwapCard(), AMOUNT_OF_SWAP_CARDS);
 | 
					        this.addBonusCards(new SwapCard(), AMOUNT_OF_SWAP_CARDS);
 | 
				
			||||||
        this.addBonusCards(new ShieldCard(), AMOUNT_OF_SHIELD_CARDS);
 | 
					//        this.addBonusCards(new ShieldCard(), AMOUNT_OF_SHIELD_CARDS);
 | 
				
			||||||
        Collections.shuffle(this.drawPile);
 | 
					        Collections.shuffle(this.drawPile);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -49,6 +49,25 @@ public void setOccupant(Piece occupant) {
 | 
				
			|||||||
        this.occupant = occupant;
 | 
					        this.occupant = occupant;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * This method handles the event when a new occupant is moved to the node,
 | 
				
			||||||
 | 
					     * it then returns the old occupant.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param newOccupant the new occupant of the node
 | 
				
			||||||
 | 
					     * @return the old occupant of the node
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public Piece moveOccupant(Piece newOccupant) {
 | 
				
			||||||
 | 
					        if (occupant == null) {
 | 
				
			||||||
 | 
					            setOccupant(newOccupant);
 | 
				
			||||||
 | 
					            return null;
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            occupant.setShield(ShieldState.NONE);
 | 
				
			||||||
 | 
					            occupant.setState(PieceState.WAITING);
 | 
				
			||||||
 | 
					            setOccupant(newOccupant);
 | 
				
			||||||
 | 
					            return occupant;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * This method is used to clear the node of its occupant
 | 
					     * This method is used to clear the node of its occupant
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,6 +2,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import com.jme3.network.serializing.Serializable;
 | 
					import com.jme3.network.serializing.Serializable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.Objects;
 | 
				
			||||||
import java.util.UUID;
 | 
					import java.util.UUID;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
@@ -159,7 +160,8 @@ public boolean equals(Object obj) {
 | 
				
			|||||||
        if (obj instanceof Piece) {
 | 
					        if (obj instanceof Piece) {
 | 
				
			||||||
            Piece piece = (Piece) obj;
 | 
					            Piece piece = (Piece) obj;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return this.hashCode() == piece.hashCode();
 | 
					            System.out.println("own UUID: " + this.uuid + ". Other UUID: " + piece.uuid);
 | 
				
			||||||
 | 
					            return uuid.toString().equals(piece.uuid.toString());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -152,6 +152,57 @@ public PowerCard getPowerCardByType(BonusCard bonusCard) {
 | 
				
			|||||||
        return null;
 | 
					        return null;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public Piece getWaitingPiece(){
 | 
				
			||||||
 | 
					        for (Piece piece : this.waitingArea) {
 | 
				
			||||||
 | 
					            if (piece != null){
 | 
				
			||||||
 | 
					                return piece;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * This method returns a boolean based on if the Player has a piece in its waiting area
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @return the boolean if the waiting area contains a piece
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public boolean hasPieceInWaitingArea(){
 | 
				
			||||||
 | 
					        for (Piece piece : this.waitingArea) {
 | 
				
			||||||
 | 
					            if (piece != null){
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public int getHomeIndexOfPiece(Piece piece) {
 | 
				
			||||||
 | 
					        for (int i = 0; i < Resources.MAX_PIECES; i++) {
 | 
				
			||||||
 | 
					            if (this.homeNodes[i].getOccupant().equals(piece)) {
 | 
				
			||||||
 | 
					                return i;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return -1;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public boolean pieceInsideOfHome(Piece piece) {
 | 
				
			||||||
 | 
					        for (Node node : this.homeNodes) {
 | 
				
			||||||
 | 
					            if (piece.equals(node.getOccupant())) {
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public boolean isHomeFinished(Piece piece) {
 | 
				
			||||||
 | 
					        for (int i = getHomeIndexOfPiece(piece); i < Resources.MAX_PIECES; i++) {
 | 
				
			||||||
 | 
					            if (!this.homeNodes[i].isOccupied()) {
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * This method returns the give name of the Player
 | 
					     * This method returns the give name of the Player
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,7 @@
 | 
				
			|||||||
package pp.mdga.message.client;
 | 
					package pp.mdga.message.client;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.jme3.network.serializing.Serializable;
 | 
					import com.jme3.network.serializing.Serializable;
 | 
				
			||||||
 | 
					import pp.mdga.game.Piece;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.util.UUID;
 | 
					import java.util.UUID;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -12,22 +13,22 @@ public class RequestMoveMessage extends ClientMessage {
 | 
				
			|||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * The identifier for the piece.
 | 
					     * The identifier for the piece.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private final UUID pieceIdentifier;
 | 
					    private final Piece piece;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Constructor for RequestMove
 | 
					     * Constructor for RequestMove
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     * @param pieceIdentifier the piece identifier
 | 
					     * @param piece the piece
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public RequestMoveMessage(UUID pieceIdentifier) {
 | 
					    public RequestMoveMessage(Piece piece) {
 | 
				
			||||||
        this.pieceIdentifier = pieceIdentifier;
 | 
					        this.piece = piece;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Default constructor for serialization purposes.
 | 
					     * Default constructor for serialization purposes.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private RequestMoveMessage() {
 | 
					    private RequestMoveMessage() {
 | 
				
			||||||
        pieceIdentifier = null;
 | 
					        piece = null;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -35,8 +36,8 @@ private RequestMoveMessage() {
 | 
				
			|||||||
     *
 | 
					     *
 | 
				
			||||||
     * @return the piece identifier
 | 
					     * @return the piece identifier
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public UUID getPieceIdentifier() {
 | 
					    public Piece getPiece() {
 | 
				
			||||||
        return pieceIdentifier;
 | 
					        return piece;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -46,7 +47,8 @@ public UUID getPieceIdentifier() {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public String toString() {
 | 
					    public String toString() {
 | 
				
			||||||
        return "RequestMove{pieceIdentifier = " + pieceIdentifier + '}';
 | 
					        assert piece != null;
 | 
				
			||||||
 | 
					        return "RequestMove{pieceIdentifier = " + piece.toString() + '}';
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,7 @@
 | 
				
			|||||||
package pp.mdga.message.server;
 | 
					package pp.mdga.message.server;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.jme3.network.serializing.Serializable;
 | 
					import com.jme3.network.serializing.Serializable;
 | 
				
			||||||
 | 
					import pp.mdga.game.Piece;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.util.UUID;
 | 
					import java.util.UUID;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -12,7 +13,7 @@ public class MoveMessage extends ServerMessage {
 | 
				
			|||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * The identifier of the piece that should be moved.
 | 
					     * The identifier of the piece that should be moved.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private final UUID pieceUUID;
 | 
					    private final Piece piece;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * The index of the target node;
 | 
					     * The index of the target node;
 | 
				
			||||||
@@ -27,11 +28,13 @@ public class MoveMessage extends ServerMessage {
 | 
				
			|||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Constructs a new MoveMessage instance.
 | 
					     * Constructs a new MoveMessage instance.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     * @param identifier the identifier of the piece that should be moved
 | 
					     * @param piece the identifier of the piece that should be moved
 | 
				
			||||||
 | 
					     * @param isHomeMove boolean flag declaring home move or not
 | 
				
			||||||
 | 
					     * @param targetIndex the targetIndex
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public MoveMessage(UUID identifier, boolean isHomeMove, int targetIndex) {
 | 
					    public MoveMessage(Piece piece, boolean isHomeMove, int targetIndex) {
 | 
				
			||||||
        super();
 | 
					        super();
 | 
				
			||||||
        this.pieceUUID = identifier;
 | 
					        this.piece = piece;
 | 
				
			||||||
        this.isHomeMove = isHomeMove;
 | 
					        this.isHomeMove = isHomeMove;
 | 
				
			||||||
        this.targetIndex = targetIndex;
 | 
					        this.targetIndex = targetIndex;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -41,7 +44,7 @@ public MoveMessage(UUID identifier, boolean isHomeMove, int targetIndex) {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    private MoveMessage() {
 | 
					    private MoveMessage() {
 | 
				
			||||||
        super();
 | 
					        super();
 | 
				
			||||||
        pieceUUID = null;
 | 
					        piece = null;
 | 
				
			||||||
        targetIndex = 0;
 | 
					        targetIndex = 0;
 | 
				
			||||||
        isHomeMove = false;
 | 
					        isHomeMove = false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -51,8 +54,8 @@ private MoveMessage() {
 | 
				
			|||||||
     *
 | 
					     *
 | 
				
			||||||
     * @return the identifier of the piece that should be moved
 | 
					     * @return the identifier of the piece that should be moved
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public UUID getIdentifier() {
 | 
					    public Piece getPiece() {
 | 
				
			||||||
        return pieceUUID;
 | 
					        return piece;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -90,6 +93,6 @@ public void accept(ServerInterpreter interpreter) {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public String toString() {
 | 
					    public String toString() {
 | 
				
			||||||
        return "MoveMessage{" + "pieceUUID=" + pieceUUID + ", targetIndex=" + targetIndex + ", isHomeMove=" + isHomeMove + '}';
 | 
					        return "MoveMessage{" + "pieceUUID=" + piece.getUuid() + ", targetIndex=" + targetIndex + ", isHomeMove=" + isHomeMove + '}';
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,7 +1,9 @@
 | 
				
			|||||||
package pp.mdga.message.server;
 | 
					package pp.mdga.message.server;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.jme3.network.serializing.Serializable;
 | 
					import com.jme3.network.serializing.Serializable;
 | 
				
			||||||
 | 
					import pp.mdga.game.Piece;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.io.PipedOutputStream;
 | 
				
			||||||
import java.util.ArrayList;
 | 
					import java.util.ArrayList;
 | 
				
			||||||
import java.util.List;
 | 
					import java.util.List;
 | 
				
			||||||
import java.util.UUID;
 | 
					import java.util.UUID;
 | 
				
			||||||
@@ -14,12 +16,12 @@ public class PossiblePieceMessage extends ServerMessage {
 | 
				
			|||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * The list of possible own pieces
 | 
					     * The list of possible own pieces
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private final List<UUID> possibleOwnPieces;
 | 
					    private final List<Piece> possibleOwnPieces;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * The list of possible enemy pieces
 | 
					     * The list of possible enemy pieces
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private final List<UUID> possibleEnemyPieces;
 | 
					    private final List<Piece> possibleEnemyPieces;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Constructor for PossiblePiece
 | 
					     * Constructor for PossiblePiece
 | 
				
			||||||
@@ -37,7 +39,7 @@ public PossiblePieceMessage() {
 | 
				
			|||||||
     * @param possibleEnemyPieces the list of possible enemy pieces
 | 
					     * @param possibleEnemyPieces the list of possible enemy pieces
 | 
				
			||||||
     * @return the swapped possible pieces
 | 
					     * @return the swapped possible pieces
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public static PossiblePieceMessage swapPossiblePieces(ArrayList<UUID> possibleOwnPieces, ArrayList<UUID> possibleEnemyPieces) {
 | 
					    public static PossiblePieceMessage swapPossiblePieces(List<Piece> possibleOwnPieces, List<Piece> possibleEnemyPieces) {
 | 
				
			||||||
        PossiblePieceMessage possiblePieceMessage = new PossiblePieceMessage();
 | 
					        PossiblePieceMessage possiblePieceMessage = new PossiblePieceMessage();
 | 
				
			||||||
        possiblePieceMessage.possibleOwnPieces.addAll(possibleOwnPieces);
 | 
					        possiblePieceMessage.possibleOwnPieces.addAll(possibleOwnPieces);
 | 
				
			||||||
        possiblePieceMessage.possibleEnemyPieces.addAll(possibleEnemyPieces);
 | 
					        possiblePieceMessage.possibleEnemyPieces.addAll(possibleEnemyPieces);
 | 
				
			||||||
@@ -50,7 +52,7 @@ public static PossiblePieceMessage swapPossiblePieces(ArrayList<UUID> possibleOw
 | 
				
			|||||||
     * @param possibleOwnPieces the list of possible own pieces
 | 
					     * @param possibleOwnPieces the list of possible own pieces
 | 
				
			||||||
     * @return the possible pieces for the shield
 | 
					     * @return the possible pieces for the shield
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public static PossiblePieceMessage shieldPossiblePieces(ArrayList<UUID> possibleOwnPieces) {
 | 
					    public static PossiblePieceMessage shieldPossiblePieces(List<Piece> possibleOwnPieces) {
 | 
				
			||||||
        PossiblePieceMessage possiblePieceMessage = new PossiblePieceMessage();
 | 
					        PossiblePieceMessage possiblePieceMessage = new PossiblePieceMessage();
 | 
				
			||||||
        possiblePieceMessage.possibleOwnPieces.addAll(possibleOwnPieces);
 | 
					        possiblePieceMessage.possibleOwnPieces.addAll(possibleOwnPieces);
 | 
				
			||||||
        return possiblePieceMessage;
 | 
					        return possiblePieceMessage;
 | 
				
			||||||
@@ -61,7 +63,7 @@ public static PossiblePieceMessage shieldPossiblePieces(ArrayList<UUID> possible
 | 
				
			|||||||
     *
 | 
					     *
 | 
				
			||||||
     * @param piece the piece to add
 | 
					     * @param piece the piece to add
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public void addOwnPossiblePiece(UUID piece) {
 | 
					    public void addOwnPossiblePiece(Piece piece) {
 | 
				
			||||||
        this.possibleOwnPieces.add(piece);
 | 
					        this.possibleOwnPieces.add(piece);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -70,7 +72,7 @@ public void addOwnPossiblePiece(UUID piece) {
 | 
				
			|||||||
     *
 | 
					     *
 | 
				
			||||||
     * @param piece the piece to add
 | 
					     * @param piece the piece to add
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public void addEnemyPossiblePiece(UUID piece) {
 | 
					    public void addEnemyPossiblePiece(Piece piece) {
 | 
				
			||||||
        this.possibleEnemyPieces.add(piece);
 | 
					        this.possibleEnemyPieces.add(piece);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -79,7 +81,7 @@ public void addEnemyPossiblePiece(UUID piece) {
 | 
				
			|||||||
     *
 | 
					     *
 | 
				
			||||||
     * @return the list of possible pieces
 | 
					     * @return the list of possible pieces
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public List<UUID> getOwnPossiblePieces() {
 | 
					    public List<Piece> getOwnPossiblePieces() {
 | 
				
			||||||
        return possibleOwnPieces;
 | 
					        return possibleOwnPieces;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -88,7 +90,7 @@ public List<UUID> getOwnPossiblePieces() {
 | 
				
			|||||||
     *
 | 
					     *
 | 
				
			||||||
     * @return the list of possible enemy pieces
 | 
					     * @return the list of possible enemy pieces
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public List<UUID> getEnemyPossiblePieces() {
 | 
					    public List<Piece> getEnemyPossiblePieces() {
 | 
				
			||||||
        return possibleEnemyPieces;
 | 
					        return possibleEnemyPieces;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||