diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/InputSynchronizer.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/InputSynchronizer.java index 4a70c368..281c126e 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/InputSynchronizer.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/InputSynchronizer.java @@ -12,10 +12,7 @@ import com.jme3.renderer.Camera; import com.jme3.scene.Node; import com.jme3.scene.control.AbstractControl; -import pp.mdga.client.board.NodeControl; -import pp.mdga.client.board.OutlineControl; import pp.mdga.client.board.OutlineOEControl; -import pp.mdga.client.board.PieceControl; import pp.mdga.client.gui.CardControl; import pp.mdga.client.gui.DiceControl; import pp.mdga.client.view.GameView; @@ -148,8 +145,8 @@ public void onAction(String name, boolean isPressed, float tpf) { if (p == null) { p = UUID.randomUUID(); gameView.getBoardHandler().addPlayer(Color.AIRFORCE, List.of(p, UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID())); - gameView.getBoardHandler().movePieceStartAnim(p, 0); - gameView.getBoardHandler().outlineMove(List.of(p), List.of(2), List.of(false)); + gameView.getBoardHandler().movePieceStart(p, 0); + gameView.getBoardHandler().setSelectableMove(List.of(p), List.of(2), List.of(false)); //gameView.getBoardHandler().movePieceAnim(p,0, 8); } else { gameView.getBoardHandler().throwPiece(p, Color.ARMY); diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/NotificationSynchronizer.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/NotificationSynchronizer.java index 61c5de81..3f4cca69 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/NotificationSynchronizer.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/NotificationSynchronizer.java @@ -198,7 +198,7 @@ private void handleGame(Notification notification) { guiHandler.drawCard(n.getColor()); delay = STANDARD_DELAY; } else if (notification instanceof HomeMoveNotification home) { - boardHandler.movePieceHomeAnim(home.getPieceId(), home.getHomeIndex()); + boardHandler.movePieceHome(home.getPieceId(), home.getHomeIndex()); guiHandler.hideText(); waitForAnimation = true; } else if (notification instanceof InterruptNotification notification1) { @@ -206,11 +206,11 @@ private void handleGame(Notification notification) { } else if (notification instanceof MovePieceNotification n) { if (n.isMoveStart()) { //StartMove - boardHandler.movePieceStartAnim(n.getPiece(), n.getMoveIndex()); + boardHandler.movePieceStart(n.getPiece(), n.getMoveIndex()); waitForAnimation = true; } else { //InfieldMove - boardHandler.movePieceAnim(n.getPiece(), n.getStartIndex(), n.getMoveIndex()); + boardHandler.movePiece(n.getPiece(), n.getStartIndex(), n.getMoveIndex()); waitForAnimation = true; } guiHandler.hideText(); @@ -262,18 +262,18 @@ public void run() { app.afterGameCleanup(); app.enter(MdgaState.MAIN); } else if (notification instanceof SwapPieceNotification n) { - boardHandler.swapPieceAnim(n.getFirstPiece(), n.getSecondPiece()); + boardHandler.swapPieces(n.getFirstPiece(), n.getSecondPiece()); guiHandler.swap(); } else if (notification instanceof WaitMoveNotification) { //nothing } else if (notification instanceof SelectableMoveNotification n) { - boardHandler.outlineMove(n.getPieces(), n.getMoveIndices(), n.getHomeMoves()); + boardHandler.setSelectableMove(n.getPieces(), n.getMoveIndices(), n.getHomeMoves()); modelSynchronizer.setSwap(false); } else if (notification instanceof SelectableSwapNotification n) { - boardHandler.outlineSwap(n.getOwnPieces(), n.getEnemyPieces()); + boardHandler.setSelectableSwap(n.getOwnPieces(), n.getEnemyPieces()); modelSynchronizer.setSwap(true); } else if (notification instanceof SelectableShieldNotification n) { - boardHandler.outlineShield(n.getPieces()); + boardHandler.setSelectableShield(n.getPieces()); modelSynchronizer.setSwap(false); } else if (notification instanceof TurboActiveNotification) { //nothing diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/board/BoardHandler.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/board/BoardHandler.java index 034504b4..065c3019 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/board/BoardHandler.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/board/BoardHandler.java @@ -15,7 +15,6 @@ import pp.mdga.client.animation.*; import pp.mdga.client.gui.DiceControl; import pp.mdga.game.Color; -import pp.mdga.game.Piece; import java.util.*; @@ -226,7 +225,7 @@ private Spatial createModel(Asset asset, Vector3f pos, float rot) { * @param y The y-coordinate on the grid * @return The corresponding world position */ - public static Vector3f gridToWorld(int x, int y) { + private static Vector3f gridToWorld(int x, int y) { return new Vector3f(GRID_SIZE * x, GRID_SIZE * y, GRID_ELEVATION); } @@ -367,7 +366,7 @@ private Vector3f getWaitingPos(Color color) { * @param vectors The list of vectors. * @return The mean position as a Vector3f. */ - public static Vector3f getMeanPosition(List vectors) { + private static Vector3f getMeanPosition(List vectors) { if (vectors.isEmpty()) return new Vector3f(0, 0, 0); Vector3f sum = new Vector3f(0, 0, 0); @@ -425,7 +424,7 @@ public void addPlayer(Color color, List uuid) { * @param index the index of the home node to move the piece to * @throws RuntimeException if the UUID is not mapped to a color or if the home nodes are not properly defined */ - private void moveHomePiece(UUID uuid, int index) { + private void executeHomeMove(UUID uuid, int index) { Color color = pieceColor.get(uuid); if (color == null) throw new RuntimeException("uuid is not mapped to a color"); @@ -455,7 +454,7 @@ private void moveHomePiece(UUID uuid, int index) { * @throws RuntimeException if the UUID is not mapped to a color or the piece control is not found * @throws IllegalArgumentException if the node index is invalid */ - private void movePieceStart(UUID uuid, int nodeIndex) { + private void executeStartMove(UUID uuid, int nodeIndex) { // Farbe des Pieces abrufen Color color = pieceColor.get(uuid); @@ -486,7 +485,7 @@ private void movePieceStart(UUID uuid, int nodeIndex) { * @param curIndex the current index of the piece * @param moveIndex the target index of the move */ - private void movePiece(UUID uuid, int curIndex, int moveIndex) { + private void executeMove(UUID uuid, int curIndex, int moveIndex) { movePieceRek(uuid, curIndex, moveIndex); app.getModelSynchronize().animationEnd(); @@ -566,7 +565,7 @@ public void suppressShield(UUID uuid) { * @param loc2 the original location of the second piece * @param rot2 the original rotation of the second piece */ - private void swapPieces(PieceControl p1, PieceControl p2, Vector3f loc1, float rot1, Vector3f loc2, float rot2) { + private void executeSwap(PieceControl p1, PieceControl p2, Vector3f loc1, float rot1, Vector3f loc2, float rot2) { p1.setLocation(loc2); p2.setLocation(loc1); @@ -584,7 +583,7 @@ private void swapPieces(PieceControl p1, PieceControl p2, Vector3f loc1, float r * @param homeMoves the list indicating whether the move is a home move * @throws RuntimeException if the sizes of the input lists do not match */ - public void outlineMove(List pieces, List moveIndexe, List homeMoves) { + public void setSelectableMove(List pieces, List moveIndexe, List homeMoves) { if (pieces.size() != moveIndexe.size() || pieces.size() != homeMoves.size()) throw new RuntimeException("arrays are not the same size"); @@ -618,7 +617,7 @@ public void outlineMove(List pieces, List moveIndexe, List ownPieces, List enemyPieces) { + public void setSelectableSwap(List ownPieces, List enemyPieces) { selectableEnemyPieces.clear(); selectableOwnPieces.clear(); @@ -642,7 +641,7 @@ public void outlineSwap(List ownPieces, List enemyPieces) { * * @param pieces the list of UUIDs representing the pieces to be shielded */ - public void outlineShield(List pieces) { + public void setSelectableShield(List pieces) { selectableOwnPieces.clear(); selectableEnemyPieces.clear(); selectedOwnPiece = null; @@ -779,12 +778,12 @@ private K getKeyByValue(Map map, V value) { * @param curIndex the current index of the piece * @param moveIndex the target index to animate the piece to */ - public void movePieceAnim(UUID uuid, int curIndex, int moveIndex) { + public void movePiece(UUID uuid, int curIndex, int moveIndex) { pieces.get(uuid).getSpatial().addControl(new MoveControl( infield.get(curIndex).getLocation(), infield.get(moveIndex).getLocation(), - () -> movePiece(uuid, curIndex, moveIndex))); + () -> executeMove(uuid, curIndex, moveIndex))); } /** @@ -793,11 +792,11 @@ public void movePieceAnim(UUID uuid, int curIndex, int moveIndex) { * @param uuid the UUID of the piece to animate * @param homeIndex the index of the home node to move the piece to */ - public void movePieceHomeAnim(UUID uuid, int homeIndex) { + public void movePieceHome(UUID uuid, int homeIndex) { pieces.get(uuid).getSpatial().addControl(new MoveControl( pieces.get(uuid).getLocation(), homeNodesMap.get(pieceColor.get(uuid)).get(homeIndex).getLocation(), - () -> moveHomePiece(uuid, homeIndex))); + () -> executeHomeMove(uuid, homeIndex))); } /** @@ -806,11 +805,11 @@ public void movePieceHomeAnim(UUID uuid, int homeIndex) { * @param uuid the UUID of the piece to animate * @param moveIndex the target index to animate the piece to */ - public void movePieceStartAnim(UUID uuid, int moveIndex) { + public void movePieceStart(UUID uuid, int moveIndex) { pieces.get(uuid).getSpatial().addControl(new MoveControl( pieces.get(uuid).getLocation(), infield.get(moveIndex).getLocation(), - () -> movePieceStart(uuid, moveIndex) + () -> executeStartMove(uuid, moveIndex) )); } @@ -819,7 +818,7 @@ public void movePieceStartAnim(UUID uuid, int moveIndex) { * * @param uuid the UUID of the piece to animate */ - public void throwPieceAnim(UUID uuid) { + private void throwPieceAnim(UUID uuid) { pieces.get(uuid).getSpatial().addControl(new MoveControl( pieces.get(uuid).getLocation(), getNextWaitingNode(pieceColor.get(uuid)).getLocation(), () -> throwPiece(uuid)) @@ -873,7 +872,7 @@ private void throwShell(UUID uuid) { * @param piece1 the UUID of the first piece * @param piece2 the UUID of the second piece */ - public void swapPieceAnim(UUID piece1, UUID piece2) { + public void swapPieces(UUID piece1, UUID piece2) { PieceControl piece1Control = pieces.get(piece1); PieceControl piece2Control = pieces.get(piece2); @@ -891,7 +890,7 @@ public void swapPieceAnim(UUID piece1, UUID piece2) { piece2Control.getSpatial().addControl(new MoveControl( piece2Control.getLocation().clone(), piece1Control.getLocation().clone(), - () -> swapPieces(piece1Control, piece2Control, loc1, rot1, loc2, rot2) + () -> executeSwap(piece1Control, piece2Control, loc1, rot1, loc2, rot2) )); } diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/board/NodeControl.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/board/NodeControl.java index c710d776..a57ac682 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/board/NodeControl.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/board/NodeControl.java @@ -1,9 +1,9 @@ package pp.mdga.client.board; -import com.jme3.math.ColorRGBA; import com.jme3.math.Vector3f; import com.jme3.post.FilterPostProcessor; import pp.mdga.client.MdgaApp; +import pp.mdga.client.outline.OutlineControl; /** * A control that adds highlighting functionality to a node in the game. diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/board/OutlineOEControl.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/board/OutlineOEControl.java index 6cfed979..bf1fb25b 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/board/OutlineOEControl.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/board/OutlineOEControl.java @@ -4,12 +4,13 @@ import com.jme3.post.FilterPostProcessor; import com.jme3.renderer.Camera; import pp.mdga.client.MdgaApp; +import pp.mdga.client.outline.OutlineControl; /** * OutlineOEControl class extends OutlineControl to manage outline colors and widths * for own and enemy objects, including hover and select states. */ -public class OutlineOEControl extends OutlineControl{ +public class OutlineOEControl extends OutlineControl { private static final ColorRGBA OUTLINE_OWN_COLOR = ColorRGBA.White; private static final ColorRGBA OUTLINE_ENEMY_COLOR = ColorRGBA.Red; private static final ColorRGBA OUTLINE_OWN_HOVER_COLOR = ColorRGBA.Yellow; diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/board/PieceControl.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/board/PieceControl.java index 1ba43cf6..db2eb8ac 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/board/PieceControl.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/board/PieceControl.java @@ -13,6 +13,7 @@ import com.jme3.scene.Spatial; import pp.mdga.client.Asset; import pp.mdga.client.MdgaApp; +import pp.mdga.client.outline.OutlineControl; /** * A control that manages the behavior and properties of a game piece, such as its rotation, diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/gui/CardControl.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/gui/CardControl.java index 808f9b8b..c3ae7c46 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/gui/CardControl.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/gui/CardControl.java @@ -11,7 +11,7 @@ import com.jme3.scene.Node; import com.jme3.scene.shape.Sphere; import pp.mdga.client.MdgaApp; -import pp.mdga.client.board.OutlineControl; +import pp.mdga.client.outline.OutlineControl; /** * CardControl class extends OutlineControl to manage the visual representation diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/board/OutlineControl.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/outline/OutlineControl.java similarity index 92% rename from Projekte/mdga/client/src/main/java/pp/mdga/client/board/OutlineControl.java rename to Projekte/mdga/client/src/main/java/pp/mdga/client/outline/OutlineControl.java index b2a210c4..48b627ca 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/board/OutlineControl.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/outline/OutlineControl.java @@ -1,11 +1,10 @@ -package pp.mdga.client.board; +package pp.mdga.client.outline; import com.jme3.math.ColorRGBA; import com.jme3.post.FilterPostProcessor; import com.jme3.renderer.Camera; import pp.mdga.client.InitControl; import pp.mdga.client.MdgaApp; -import pp.mdga.client.outline.SelectObjectOutliner; /** * A control that provides outline functionality to a spatial object. @@ -50,16 +49,6 @@ public OutlineControl(MdgaApp app, FilterPostProcessor fpp, Camera cam, selectObjectOutliner = new SelectObjectOutliner(fpp, app.getRenderManager(), app.getAssetManager(), cam, app); } - - /** - * Applies an outline to the spatial object with the given color. - * - * @param color The {@link ColorRGBA} representing the color of the outline. - */ -// public void outline(ColorRGBA color) { -// selectObjectOutliner.select(spatial, color); -// } - /** * Applies an outline to the spatial object with the given color and width. *