removed unused imports and reformatted the code for code style

This commit is contained in:
Daniel Grigencha
2024-12-11 05:34:34 +01:00
parent d8816be811
commit aa44b84648
155 changed files with 1662 additions and 3882 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1,21 +0,0 @@
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x000070ba272e8104, pid=54211, tid=54346
#
# JRE version: OpenJDK Runtime Environment Temurin-20.0.2+9 (20.0.2+9) (build 20.0.2+9)
# Java VM: OpenJDK 64-Bit Server VM Temurin-20.0.2+9 (20.0.2+9, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V [libjvm.so+0xee8104] SystemDictionary::find_or_define_helper(Symbol*, Handle, InstanceKlass*, JavaThread*)+0x304
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/lib/systemd/systemd-coredump %P %u %g %s %t %c %h" (or dumping to /home/cedric/ProgProjekt/Gruppe-01/Projekte/mdga/client/core.54211)
#
# If you would like to submit a bug report, please visit:
# https://github.com/adoptium/adoptium-support/issues
#
--------------- S U M M A R Y ------------
Command Line: -Ddebugger.agent.enable.coroutines=true -Djava.util.logging.config.file=logging.properties -Dkotlinx.coroutines.debug.enable.creation.stack.trace=false -Dkotlinx.coroutines.debug.enable.flows.stack.trace=true -Dkotlinx.coroutines.debug.enable.mutable.state.flows.stack.trace=true -agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=127.0.0.1:40559 -javaagent:/usr/share/idea/plugins/java/lib/rt/debugger-agent.jar -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -ea pp.mdga.client.MdgaApp
Host: AMD Ryzen 5 8640HS w/ Radeon 760M Graphics, 12 cores, 14G,

View File

@@ -1,171 +0,0 @@
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007fc14e0eef41, pid=60653, tid=60689
#
# JRE version: OpenJDK Runtime Environment (21.0.5+11) (build 21.0.5+11)
# Java VM: OpenJDK 64-Bit Server VM (21.0.5+11, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# C [libgallium-24.2.8-arch1.1.so+0x8eef41]
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/lib/systemd/systemd-coredump %P %u %g %s %t %c %h" (or dumping to /home/cedric/ProgProjekt/Gruppe-01/Projekte/mdga/client/core.60653)
#
# If you would like to submit a bug report, please visit:
# https://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
--------------- S U M M A R Y ------------
Command Line: -Ddebugger.agent.enable.coroutines=true -Djava.util.logging.config.file=logging.properties -Dkotlinx.coroutines.debug.enable.creation.stack.trace=false -Dkotlinx.coroutines.debug.enable.flows.stack.trace=true -Dkotlinx.coroutines.debug.enable.mutable.state.flows.stack.trace=true -agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=127.0.0.1:39131 -javaagent:/usr/share/idea/plugins/java/lib/rt/debugger-agent.jar -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -ea pp.mdga.client.MdgaApp
Host: AMD Ryzen 5 8640HS w/ Radeon 760M Graphics, 12 cores, 14G, Manjaro Linux
Time: Sun Dec 8 18:11:23 2024 CET elapsed time: 295.650309 seconds (0d 0h 4m 55s)
--------------- T H R E A D ---------------
Current thread (0x00007fc17ca803b0): JavaThread "jME3 Main" [_thread_in_native, id=60689, stack(0x00007fc159425000,0x00007fc159525000) (1024K)]
Stack: [0x00007fc159425000,0x00007fc159525000], sp=0x00007fc159522300, free space=1012k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [libgallium-24.2.8-arch1.1.so+0x8eef41]
C [libgallium-24.2.8-arch1.1.so+0xf4a849]
C [libgallium-24.2.8-arch1.1.so+0x6ccb71]
C [libgallium-24.2.8-arch1.1.so+0x6c58ae]
C [libgallium-24.2.8-arch1.1.so+0x6c6013]
C [libgallium-24.2.8-arch1.1.so+0x6cddf8]
C [libgallium-24.2.8-arch1.1.so+0x141327]
C [libgallium-24.2.8-arch1.1.so+0x5fc8b]
C [libGLX_mesa.so.0+0x4f2e0]
C [libGLX_mesa.so.0+0x40496]
C [libGLX_mesa.so.0+0x2efa5]
J 2042 org.lwjgl.system.JNI.invokePV(JJ)V (0 bytes) @ 0x00007fc16c1abb6f [0x00007fc16c1abaa0+0x00000000000000cf]
J 4039 c1 org.lwjgl.glfw.GLFW.glfwSwapBuffers(J)V (21 bytes) @ 0x00007fc164d8684c [0x00007fc164d86760+0x00000000000000ec]
J 3912 c1 com.jme3.system.lwjgl.LwjglWindow.runLoop()V (177 bytes) @ 0x00007fc164d44b34 [0x00007fc164d442c0+0x0000000000000874]
j com.jme3.system.lwjgl.LwjglWindow.run()V+54
j java.lang.Thread.runWith(Ljava/lang/Object;Ljava/lang/Runnable;)V+5 java.base@21.0.5
j java.lang.Thread.run()V+19 java.base@21.0.5
v ~StubRoutines::call_stub 0x00007fc16bb37cc6
V [libjvm.so+0x6d0894]
V [libjvm.so+0x6d14fd]
V [libjvm.so+0x79a7be]
V [libjvm.so+0x6cac55]
V [libjvm.so+0x9d62c1]
C [libc.so.6+0x9439d]
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
J 2042 org.lwjgl.system.JNI.invokePV(JJ)V (0 bytes) @ 0x00007fc16c1abafc [0x00007fc16c1abaa0+0x000000000000005c]
J 4039 c1 org.lwjgl.glfw.GLFW.glfwSwapBuffers(J)V (21 bytes) @ 0x00007fc164d8684c [0x00007fc164d86760+0x00000000000000ec]
J 3912 c1 com.jme3.system.lwjgl.LwjglWindow.runLoop()V (177 bytes) @ 0x00007fc164d44b34 [0x00007fc164d442c0+0x0000000000000874]
j com.jme3.system.lwjgl.LwjglWindow.run()V+54
j java.lang.Thread.runWith(Ljava/lang/Object;Ljava/lang/Runnable;)V+5 java.base@21.0.5
j java.lang.Thread.run()V+19 java.base@21.0.5
v ~StubRoutines::call_stub 0x00007fc16bb37cc6
siginfo: si_signo: 11 (SIGSEGV), si_code: 1 (SEGV_MAPERR), si_addr: 0x00000000000000c9
Registers:
RAX=0x0000000000000000, RBX=0x00007fc09825b2a0, RCX=0x0000000000000006, RDX=0x0000000028200000
RSP=0x00007fc159522300, RBP=0x00007fc159522310, RSI=0x00007fc0998d3604, RDI=0x00007fc09825b7a0
R8 =0x0000000000000006, R9 =0x00000000aa959a6a, R10=0x0000000000000263, R11=0x00007fc099bc36c0
R12=0x00007fc0998d35e0, R13=0x000000058bc5f100, R14=0x000000058bc5f140, R15=0x0000000000000040
RIP=0x00007fc14e0eef41, EFLAGS=0x0000000000010202, CSGSFS=0x002b000000000033, ERR=0x0000000000000004
TRAPNO=0x000000000000000e
Register to memory mapping:
RAX=0x0 is null
RBX=0x00007fc09825b2a0 points into unknown readable memory: 0x00007fc098239c40 | 40 9c 23 98 c0 7f 00 00
RCX=0x0000000000000006 is an unknown value
RDX=0x0000000028200000 is an unknown value
RSP=0x00007fc159522300 is pointing into the stack for thread: 0x00007fc17ca803b0
RBP=0x00007fc159522310 is pointing into the stack for thread: 0x00007fc17ca803b0
RSI=0x00007fc0998d3604 points into unknown readable memory: 00 00 00 00
RDI=0x00007fc09825b7a0 points into unknown readable memory: 0x00001c7c00000265 | 65 02 00 00 7c 1c 00 00
R8 =0x0000000000000006 is an unknown value
R9 =0x00000000aa959a6a is an unknown value
R10=0x0000000000000263 is an unknown value
R11=0x00007fc099bc36c0 points into unknown readable memory: 0x00007fc14e121570 | 70 15 12 4e c1 7f 00 00
R12=0x00007fc0998d35e0 points into unknown readable memory: 0x0000000000000000 | 00 00 00 00 00 00 00 00
R13=0x000000058bc5f100 is an unknown value
R14=0x000000058bc5f140 is an unknown value
R15=0x0000000000000040 is an unknown value
Top of Stack: (sp=0x00007fc159522300)
0x00007fc159522300: 00007fc09825b2a0 ffffffffffffffff
0x00007fc159522310: 00007fc1595223d0 00007fc14e74a849
0x00007fc159522320: 0000000000000000 00000000cc0016c8
0x00007fc159522330: 00007fc09920b000 00007fc100000004
0x00007fc159522340: 00007fc100000001 00007fc100000000
0x00007fc159522350: ffff800100000002 00007fc09825b7a0
0x00007fc159522360: 00007fc1595223e0 0000000100000b02
0x00007fc159522370: 0000000000000000 00007fc0983eca88
0x00007fc159522380: 00007fc100000000 00007fc099e33780
0x00007fc159522390: 00007fc159523170 b36c5690f9bb0900
0x00007fc1595223a0: 00007fc15951fd20 00007fc0983eca80
0x00007fc1595223b0: 00007fc09825b2a0 00007fc0983edb60
0x00007fc1595223c0: 00007fc098415b10 00007fc0983ec850
0x00007fc1595223d0: 00007fc159523280 00007fc14deccb71
0x00007fc1595223e0: 00000bdc00000000 00007fc100000000
0x00007fc1595223f0: 00007fc159523290 00007fc159523294
0x00007fc159522400: 00007fc159523320 00007fc159523324
0x00007fc159522410: 00007fc1595231b0 00007fc1595231b4
0x00007fc159522420: 00007fc159522860 00007fc164c8401c
0x00007fc159522430: 00007fc159523310 00007fc159523314
0x00007fc159522440: 00007fc1595232a0 00007fc1595232a4
0x00007fc159522450: 00007fc159522860 00007fc159523334
0x00007fc159522460: 00007fc159523400 00007fc159523404
0x00007fc159522470: 00007fc1595232d0 00007fc1595232d4
0x00007fc159522480: 00007fc16bc61f10 00007fc0c80123d0
0x00007fc159522490: 00007fc1595231f0 00007fc1595231f4
0x00007fc1595224a0: 00007fc1595223e0 00000000e31c914f
0x00007fc1595224b0: 00007fc159523350 00007fc159523354
0x00007fc1595224c0: 00007fc1595232e0 00007fc1595232e4
0x00007fc1595224d0: 00007f0000000000 00000000e3193478
0x00007fc1595224e0: 00007fc159523440 00007fc159523444
0x00007fc1595224f0: 00007fc159523310 00007fc159523314
Instructions: (pc=0x00007fc14e0eef41)
0x00007fc14e0eee41: 0f 1e fa 55 48 83 c6 24 48 89 e5 41 55 41 54 53
0x00007fc14e0eee51: 48 89 fb 48 83 ec 08 8b 97 00 05 00 00 44 0f b7
0x00007fc14e0eee61: 6e f0 48 8b 87 08 05 00 00 49 89 d4 45 01 ec 48
0x00007fc14e0eee71: 8d 3c 90 42 8d 14 ad 00 00 00 00 ff 15 ee 7e c3
0x00007fc14e0eee81: 01 44 89 a3 00 05 00 00 48 83 c4 08 5b 41 5c 41
0x00007fc14e0eee91: 5d 5d c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 f3
0x00007fc14e0eeea1: 0f 1e fa 55 48 89 e5 41 57 41 56 41 55 41 54 41
0x00007fc14e0eeeb1: 89 f4 53 48 89 fb 48 83 ec 08 4e 8b b4 e7 88 09
0x00007fc14e0eeec1: 00 00 8b 97 00 05 00 00 48 8b 87 08 05 00 00 45
0x00007fc14e0eeed1: 0f b7 7e 14 49 89 d5 49 8d 76 24 48 8d 3c 90 45
0x00007fc14e0eeee1: 01 fd 42 8d 14 bd 00 00 00 00 ff 15 7f 7e c3 01
0x00007fc14e0eeef1: 44 89 ab 00 05 00 00 4e 89 b4 e3 d8 09 00 00 48
0x00007fc14e0eef01: 83 c4 08 5b 41 5c 41 5d 41 5e 41 5f 5d c3 90 f3
0x00007fc14e0eef11: 0f 1e fa 55 89 f0 48 89 e5 41 54 53 4c 8b a4 c7
0x00007fc14e0eef21: 88 09 00 00 48 89 fb e8 73 ff ff ff 49 8b 84 24
0x00007fc14e0eef31: 80 01 00 00 ba 00 00 20 28 48 8d bb 00 05 00 00
0x00007fc14e0eef41: 0f b6 88 c9 00 00 00 48 8b b0 b0 00 00 00 48 8b
0x00007fc14e0eef51: 83 f0 04 00 00 ff 90 00 01 00 00 49 8b 04 24 48
0x00007fc14e0eef61: 85 c0 74 13 48 89 df be ff ff ff ff 5b 41 5c 5d
0x00007fc14e0eef71: ff e0 0f 1f 44 00 00 5b 41 5c 5d c3 0f 1f 00 f3
0x00007fc14e0eef81: 0f 1e fa 66 0f ef c0 31 c9 ba 01 00 00 00 0f 11
0x00007fc14e0eef91: 87 d8 09 00 00 0f 11 87 e8 09 00 00 0f 11 87 f8
0x00007fc14e0eefa1: 09 00 00 0f 11 87 08 0a 00 00 0f 11 87 18 0a 00
0x00007fc14e0eefb1: 00 66 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 48
0x00007fc14e0eefc1: 83 bc cf 88 09 00 00 00 74 0d 48 89 d0 48 d3 e0
0x00007fc14e0eefd1: 48 09 87 80 09 00 00 48 83 c1 01 48 83 f9 0a 75
0x00007fc14e0eefe1: de c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 f3
0x00007fc14e0eeff1: 0f 1e fa 55 48 89 e5 41 56 41 89 d6 41 55 41 89
0x00007fc14e0ef001: f5 8d 34 b5 28 00 00 00 41 54 49 89 fc bf 01 00
0x00007fc14e0ef011: 00 00 53 ff 15 7e 89 c3 01 48 89 c3 48 85 c0 74
0x00007fc14e0ef021: 2a 66 44 89 68 1a 41 0f b6 ce 48 8d 78 08 41 0f
0x00007fc14e0ef031: b6 94 24 97 08 00 00 49 8d b4 24 90 02 00 00 c0
Stack slot to memory mapping:
stack at sp + 0 slots: 0x00007fc09825b2a0 points into unknown readable memory: 0x00007fc098239c40 | 40 9c 23 98 c0 7f 00 00
stack at sp + 1 slots: 0xffffffffffffffff is an unknown value
stack at sp + 2 slots: 0x00007fc1595223d0 is pointing into the stack for thread: 0x00007fc17ca803b0
stack at sp + 3 slots: 0x00007fc14e74a849: <offset 0x0000000000f4a849> in /usr/lib/libgallium-24.2.8-arch1.1.so at 0x00007fc14d800000
stack at sp + 4 slots: 0x0 is null
stack at sp + 5 slots:

View File

@@ -45,8 +45,7 @@ public enum Asset {
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
;
shell;
private final String modelPath;
private final String diffPath;
@@ -83,7 +82,8 @@ public enum Asset {
Asset(String modelPath) {
String folderFileName = "./" + ROOT + name() + "/" + name();
this.modelPath = modelPath;
this.diffPath = folderFileName + "_diff.png";;
this.diffPath = folderFileName + "_diff.png";
;
this.size = 1f;
}
@@ -106,7 +106,7 @@ public enum Asset {
* @param diffPath Path to the diffuse texture file.
* @param size Scaling factor for the asset.
*/
Asset(String modelPath, String diffPath, float size){
Asset(String modelPath, String diffPath, float size) {
this.modelPath = modelPath;
this.diffPath = diffPath;
this.size = size;

View File

@@ -12,19 +12,13 @@
import com.jme3.renderer.Camera;
import com.jme3.scene.Node;
import com.jme3.scene.control.AbstractControl;
import com.jme3.scene.control.Control;
import pp.mdga.client.board.NodeControl;
import pp.mdga.client.board.OutlineControl;
import pp.mdga.client.board.PieceControl;
import pp.mdga.client.gui.CardControl;
import pp.mdga.client.gui.DiceControl;
import pp.mdga.client.view.GameView;
import pp.mdga.game.BonusCard;
import pp.mdga.game.Color;
import pp.mdga.game.Piece;
import pp.mdga.notification.FinishNotification;
import pp.mdga.notification.MovePieceNotification;
import pp.mdga.notification.SelectableCardsNotification;
import java.util.List;
import java.util.UUID;
@@ -61,13 +55,13 @@ public class InputSynchronizer {
}
public void update(float tpf) {
if(isRotateLeft && isRotateRight) {
if (isRotateLeft && isRotateRight) {
return;
}
if(isRotateLeft) {
if (isRotateLeft) {
rotationAngle += 180 * tpf;
}
if(isRotateRight) {
if (isRotateRight) {
rotationAngle -= 180 * tpf;
}
}
@@ -94,6 +88,7 @@ private void setupInput() {
inputManager.addListener(actionListener, "Settings", "Forward", "RotateRightMouse", "Click", "Left", "Right", "Test");
inputManager.addListener(analogListener, "MouseLeft", "MouseRight", "MouseScrollUp", "MouseScrollDown");
}
UUID p = null;
/**
* Handles action-based input events such as key presses and mouse clicks.
@@ -110,8 +105,8 @@ public void onAction(String name, boolean isPressed, float tpf) {
if (name.equals("RotateRightMouse")) {
rightMousePressed = isPressed;
}
if(name.equals("Click") && isPressed) {
if(!clickAllowed) {
if (name.equals("Click") && isPressed) {
if (!clickAllowed) {
return;
}
@@ -120,23 +115,20 @@ public void onAction(String name, boolean isPressed, float tpf) {
CardControl cardLayerSelect = checkHover(gameView.getGuiHandler().getCardLayerCamera(), gameView.getGuiHandler().getCardLayerRootNode(), CardControl.class);
OutlineControl boardSelect = checkHover(app.getCamera(), app.getRootNode(), OutlineControl.class);
if(diceSelect != null) {
if (diceSelect != null) {
app.getModelSynchronize().rolledDice();
}
else if(cardLayerSelect != null) {
} else if (cardLayerSelect != null) {
//cardSelect
if(cardLayerSelect.isSelectable()) gameView.getGuiHandler().selectCard(cardLayerSelect);
}
else if(boardSelect != null) {
if (cardLayerSelect.isSelectable()) gameView.getGuiHandler().selectCard(cardLayerSelect);
} else if (boardSelect != null) {
//boardSelect
if(boardSelect instanceof PieceControl pieceControl){
if(pieceControl.isSelectable()) gameView.getBoardHandler().pieceSelect(pieceControl);
if (boardSelect instanceof PieceControl pieceControl) {
if (pieceControl.isSelectable()) gameView.getBoardHandler().pieceSelect(pieceControl);
}
if(boardSelect instanceof NodeControl nodeControl){
if (boardSelect instanceof NodeControl nodeControl) {
//
}
}
else {
} else {
//both null
}
}
@@ -149,14 +141,14 @@ else if(boardSelect != null) {
if (name.equals("Right")) {
isRotateRight = !isRotateRight;
}
if(name.equals("Test2") &&isPressed){
if(app.getView() instanceof GameView gameView){
if (name.equals("Test2") && isPressed) {
if (app.getView() instanceof GameView gameView) {
if(p == null) {
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().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().movePieceAnim(p,0, 8);
} else {
gameView.getBoardHandler().throwPiece(p, Color.ARMY);
@@ -177,7 +169,6 @@ else if(boardSelect != null) {
//gameView.getGuiHandler().playCardOwn(BonusCard.SHIELD);
}
}
}
@@ -191,17 +182,13 @@ else if(boardSelect != null) {
public void onAnalog(String name, float value, float tpf) {
if (name.equals("MouseLeft") && rightMousePressed) {
rotationAngle -= value * 360f;
}
else if (name.equals("MouseRight") && rightMousePressed) {
} else if (name.equals("MouseRight") && rightMousePressed) {
rotationAngle += value * 360f;
}
else if (name.equals("MouseScrollUp")) {
} else if (name.equals("MouseScrollUp")) {
scrollValue = Math.max(1, scrollValue - 5);
}
else if (name.equals("MouseScrollDown")) {
} else if (name.equals("MouseScrollDown")) {
scrollValue = Math.min(100, scrollValue + 5);
}
else if (name.equals("MouseLeft") || name.equals("MouseRight") || name.equals("MouseVertical")){
} else if (name.equals("MouseLeft") || name.equals("MouseRight") || name.equals("MouseVertical")) {
hoverPiece();
hoverCard();
}
@@ -212,12 +199,13 @@ else if (name.equals("MouseLeft") || name.equals("MouseRight") || name.equals("M
* Detects the hovered piece and updates its hover state.
*/
private <T extends AbstractControl> T checkHover(Camera cam, Node root, Class<T> controlType) {
if(cam == null || root == null || controlType == null) return null;
if (cam == null || root == null || controlType == null) return null;
CollisionResults results = new CollisionResults();
Ray ray = new Ray(cam.getLocation(), getMousePos(cam).subtract(cam.getLocation()).normalize());
root.collideWith(ray, results);
for(CollisionResult collisionResult : results){
if(collisionResult.getGeometry().getControl(controlType) != null) return collisionResult.getGeometry().getControl(controlType);
for (CollisionResult collisionResult : results) {
if (collisionResult.getGeometry().getControl(controlType) != null)
return collisionResult.getGeometry().getControl(controlType);
}
return null;
}
@@ -226,16 +214,16 @@ private <T extends AbstractControl> T checkHover(Camera cam, Node root, Class<T>
* Detects the hovered card and updates its hover state.
*/
private <T extends AbstractControl> T checkHoverOrtho(Camera cam, Node root, Class<T> controlType) {
if(cam == null || root == null || controlType == null) return null;
if (cam == null || root == null || controlType == null) return null;
CollisionResults results = new CollisionResults();
Vector3f mousePos = getMousePos(cam);
mousePos.setZ(cam.getLocation().getZ());
Ray ray = new Ray(mousePos, getMousePos(cam).subtract(mousePos).normalize());
root.collideWith(ray, results);
if (results.size() > 0) {
for(CollisionResult res : results ){
for (CollisionResult res : results) {
T control = res.getGeometry().getControl(controlType);
if(control != null) return control;
if (control != null) return control;
}
}
return null;
@@ -297,9 +285,9 @@ private PieceControl checkPiece() {
*/
private CardControl checkCard(GameView gameView) {
return checkHoverOrtho(
gameView.getGuiHandler().getCardLayerCamera(),
gameView.getGuiHandler().getCardLayerRootNode(),
CardControl.class
gameView.getGuiHandler().getCardLayerCamera(),
gameView.getGuiHandler().getCardLayerRootNode(),
CardControl.class
);
}
@@ -344,7 +332,7 @@ public float getRotation() {
return (rotationAngle / 2) % 360;
}
public void setRotation(float rotationAngle){
public void setRotation(float rotationAngle) {
this.rotationAngle = rotationAngle;
}

View File

@@ -1,20 +1,14 @@
package pp.mdga.client;
import com.jme3.app.SimpleApplication;
import com.simsilica.lemur.GuiGlobals;
import com.sun.tools.javac.Main;
import pp.mdga.client.acoustic.AcousticHandler;
import com.jme3.system.AppSettings;
import com.simsilica.lemur.GuiGlobals;
import pp.mdga.client.acoustic.AcousticHandler;
import pp.mdga.client.animation.TimerManager;
import pp.mdga.client.dialog.JoinDialog;
import pp.mdga.client.view.*;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Objects;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.prefs.Preferences;
@@ -27,40 +21,64 @@ public class MdgaApp extends SimpleApplication {
private static Preferences prefs = Preferences.userNodeForPackage(JoinDialog.class);
/** Handles acoustic effects and state-based sounds. */
/**
* Handles acoustic effects and state-based sounds.
*/
private AcousticHandler acousticHandler;
/** Synchronizes notifications throughout the application. */
/**
* Synchronizes notifications throughout the application.
*/
private NotificationSynchronizer notificationSynchronizer;
/** Manages input events and synchronization. */
/**
* Manages input events and synchronization.
*/
private InputSynchronizer inputSynchronizer;
/** Synchronizes game models. */
/**
* Synchronizes game models.
*/
private ModelSynchronizer modelSynchronizer;
/** The currently active view in the application. */
/**
* The currently active view in the application.
*/
private MdgaView view = null;
/** The current state of the application. */
/**
* The current state of the application.
*/
private MdgaState state = null;
/** Scale for rendering images. */
/**
* Scale for rendering images.
*/
private final float imageScale = prefs.getInt("scale", 1);
/** The main menu view. */
/**
* The main menu view.
*/
private MainView mainView;
/** The lobby view. */
/**
* The lobby view.
*/
private LobbyView lobbyView;
/** The game view. */
/**
* The game view.
*/
private GameView gameView;
/** The ceremony view. */
/**
* The ceremony view.
*/
private CeremonyView ceremonyView;
/** The client game logic. */
/**
* The client game logic.
*/
private final ClientGameLogic clientGameLogic;
private ExecutorService executor;
@@ -87,7 +105,7 @@ public static void main(String[] args) {
AppSettings settings = new AppSettings(true);
settings.setSamples(128);
if(prefs.getBoolean("fullscreen", false)) {
if (prefs.getBoolean("fullscreen", false)) {
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
int screenWidth = (int) screenSize.getWidth();
int screenHeight = (int) screenSize.getHeight();
@@ -270,12 +288,12 @@ public ExecutorService getExecutor() {
return this.executor;
}
public ServerConnection getNetworkSupport(){
public ServerConnection getNetworkSupport() {
return networkConnection;
}
public void updateResolution(int width, int height, float imageFactor, boolean isFullscreen) {
if(isFullscreen) {
if (isFullscreen) {
int baseWidth = 1280;
int baseHeight = 720;
float baseAspectRatio = (float) baseWidth / baseHeight;
@@ -306,7 +324,7 @@ public static void restartApp() {
String className = System.getProperty("sun.java.command");
ProcessBuilder builder = new ProcessBuilder(
javaBin, "-cp", classPath, className
javaBin, "-cp", classPath, className
);
builder.start();
@@ -326,7 +344,7 @@ public void afterGameCleanup() {
ceremonyView.afterGameCleanup();
}
public GameView getGameView(){
public GameView getGameView() {
return gameView;
}

View File

@@ -14,7 +14,7 @@ public class ModelSynchronizer {
private UUID a;
private UUID b;
private BonusCard card;
private BonusCard card;
private boolean swap;
ModelSynchronizer(MdgaApp app) {
@@ -23,15 +23,15 @@ public class ModelSynchronizer {
}
public void animationEnd() {
if(app.getNotificationSynchronizer().waitForAnimation) {
if (app.getNotificationSynchronizer().waitForAnimation) {
app.getNotificationSynchronizer().waitForAnimation = false;
} else {
app.getGameLogic().selectAnimationEnd();
}
}
public void select(UUID a, UUID b){
if(swap) selectSwap(a,b);
public void select(UUID a, UUID b) {
if (swap) selectSwap(a, b);
else selectPiece(a);
}
@@ -42,7 +42,7 @@ public void selectSwap(UUID a, UUID b) {
this.b = b;
GameView gameView = (GameView) app.getView();
if(a != null && b != null) {
if (a != null && b != null) {
gameView.needConfirm();
} else {
gameView.noConfirm();
@@ -56,7 +56,7 @@ public void selectPiece(UUID piece) {
this.a = piece;
GameView gameView = (GameView) app.getView();
if(piece != null) {
if (piece != null) {
gameView.needConfirm();
} else {
gameView.noConfirm();
@@ -71,7 +71,7 @@ public void selectCard(BonusCard card) {
GameView gameView = (GameView) app.getView();
if(card != null) {
if (card != null) {
gameView.needConfirm();
} else {
gameView.showNoPower();
@@ -85,7 +85,7 @@ public void confirm() {
gameView.getGuiHandler().hideText();
if(a != null && b != null) {
if (a != null && b != null) {
app.getGameLogic().selectPiece(a);
app.getGameLogic().selectPiece(b);
gameView.getBoardHandler().clearSelectable();
@@ -144,7 +144,7 @@ public void enter(MdgaState state) {
//app.enter(state);
}
public void setSwap(boolean swap){
public void setSwap(boolean swap) {
this.swap = swap;
}

View File

@@ -33,13 +33,13 @@ public class NotificationSynchronizer {
public void update() {
while (timer.getTimeInSeconds() >= delay) {
if(waitForAnimation) {
if (waitForAnimation) {
return;
}
Notification n = app.getGameLogic().getNotification();
if(n == null) {
if (n == null) {
return;
}
@@ -48,12 +48,12 @@ public void update() {
timer.reset();
delay = 0;
if(n instanceof InfoNotification infoNotification) {
if (n instanceof InfoNotification infoNotification) {
app.getView().showInfo(infoNotification.getMessage(), infoNotification.isError());
return;
}
if(n != null) {
if (n != null) {
switch (app.getState()) {
case MAIN:
handleMain(n);
@@ -71,7 +71,7 @@ public void update() {
throw new RuntimeException("no notification expected: " + n.getClass().getName());
}
if(0 == MdgaApp.DEBUG_MULTIPLIER) {
if (0 == MdgaApp.DEBUG_MULTIPLIER) {
delay = 0;
}
}
@@ -84,7 +84,7 @@ private void handleMain(Notification notification) {
} else if (notification instanceof StartDialogNotification) {
//nothing
} else {
throw new RuntimeException("notification not expected in main: "+ notification.getClass().getName());
throw new RuntimeException("notification not expected in main: " + notification.getClass().getName());
}
}
@@ -98,7 +98,7 @@ private void handleLobby(Notification notification) {
app.enter(MdgaState.MAIN);
} else if (notification instanceof TskUnselectNotification n) {
lobbyView.setTaken(n.getColor(), false, false, null);
} else if(notification instanceof LobbyReadyNotification lobbyReadyNotification) {
} else if (notification instanceof LobbyReadyNotification lobbyReadyNotification) {
lobbyView.setReady(lobbyReadyNotification.getColor(), lobbyReadyNotification.isReady());
} else if (notification instanceof GameNotification n) {
app.getGameView().setOwnColor(n.getOwnColor());
@@ -119,7 +119,7 @@ private void handleGame(Notification notification) {
guiHandler.addCardOwn(n.getBonusCard());
app.getAcousticHandler().playSound(MdgaSound.BONUS);
delay = STANDARD_DELAY;
} else if(notification instanceof RankingResponceNotification n) {
} else if (notification instanceof RankingResponceNotification n) {
guiHandler.hideText();
n.getRankingResults().forEach((c, i) -> {
guiHandler.rollRankingResult(c, i);
@@ -129,7 +129,7 @@ private void handleGame(Notification notification) {
guiHandler.hideText();
boardHandler.hideDice();
gameView.getGuiHandler().setActivePlayer(n.getColor());
if(n.getColor() != ownColor) boardHandler.showDice(n.getColor());
if (n.getColor() != ownColor) boardHandler.showDice(n.getColor());
app.getAcousticHandler().playSound(MdgaSound.UI90);
delay = STANDARD_DELAY;
} else if (notification instanceof CeremonyNotification ceremonyNotification) {
@@ -138,11 +138,11 @@ private void handleGame(Notification notification) {
int size = ceremonyNotification.getNames().size();
if (ceremonyNotification.getPiecesThrown().size() != size ||
ceremonyNotification.getPiecesLost().size() != size ||
ceremonyNotification.getBonusCardsPlayed().size() != size ||
ceremonyNotification.getSixes().size() != size ||
ceremonyNotification.getNodesMoved().size() != size ||
ceremonyNotification.getBonusNodes().size() != size) {
ceremonyNotification.getPiecesLost().size() != size ||
ceremonyNotification.getBonusCardsPlayed().size() != size ||
ceremonyNotification.getSixes().size() != size ||
ceremonyNotification.getNodesMoved().size() != size ||
ceremonyNotification.getBonusNodes().size() != size) {
throw new IllegalArgumentException("All data lists in CeremonyNotification must have the same size.");
}
@@ -173,12 +173,11 @@ private void handleGame(Notification notification) {
} else if (notification instanceof InterruptNotification notification1) {
gameView.enterInterrupt(notification1.getColor());
} else if (notification instanceof MovePieceNotification n) {
if(n.isMoveStart()) {
if (n.isMoveStart()) {
//StartMove
boardHandler.movePieceStartAnim(n.getPiece(), n.getMoveIndex());
waitForAnimation = true;
}
else {
} else {
//InfieldMove
boardHandler.movePieceAnim(n.getPiece(), n.getStartIndex(), n.getMoveIndex());
waitForAnimation = true;
@@ -190,15 +189,15 @@ private void handleGame(Notification notification) {
} else if (notification instanceof RemoveShieldNotification n) {
boardHandler.unshieldPiece(n.getPieceUuid());
} else if (notification instanceof PlayCardNotification n) {
if(n.getCard() == BonusCard.TURBO) {
if (n.getCard() == BonusCard.TURBO) {
app.getAcousticHandler().playSound(MdgaSound.TURBO);
guiHandler.turbo();
} else if(n.getCard() == BonusCard.SHIELD) {
} else if (n.getCard() == BonusCard.SHIELD) {
app.getAcousticHandler().playSound(MdgaSound.SHIELD);
} else if(n.getCard() == BonusCard.SWAP) {
} else if (n.getCard() == BonusCard.SWAP) {
app.getAcousticHandler().playSound(MdgaSound.SWAP);
}
if(n.getColor() == ownColor) guiHandler.playCardOwn(n.getCard());
if (n.getColor() == ownColor) guiHandler.playCardOwn(n.getCard());
else guiHandler.playCardEnemy(n.getColor(), n.getCard());
new Timer().schedule(new TimerTask() {
@@ -208,17 +207,16 @@ public void run() {
}
}, 2200 * MdgaApp.DEBUG_MULTIPLIER);
} else if (notification instanceof PlayerInGameNotification n) {
boardHandler.addPlayer(n.getColor(),n.getPiecesList());
guiHandler.addPlayer(n.getColor(),n.getName());
boardHandler.addPlayer(n.getColor(), n.getPiecesList());
guiHandler.addPlayer(n.getColor(), n.getName());
} else if (notification instanceof ResumeNotification) {
gameView.leaveInterrupt();
} else if (notification instanceof RollDiceNotification n) {
gameView.getGuiHandler().hideText();
if(n.getColor() == ownColor){
if (n.getColor() == ownColor) {
guiHandler.rollDice(n.getEyes(), n.isTurbo() ? n.getMultiplier() : -1);
waitForAnimation = true;
}
else {
} else {
if (n.isTurbo()) guiHandler.showRolledDiceMult(n.getEyes(), n.getMultiplier(), n.getColor());
else guiHandler.showRolledDice(n.getEyes(), n.getColor());
}
@@ -243,12 +241,12 @@ public void run() {
} else if (notification instanceof SelectableSwapNotification n) {
boardHandler.outlineSwap(n.getOwnPieces(), n.getEnemyPieces());
modelSynchronizer.setSwap(true);
} else if (notification instanceof SelectableShieldNotification n) {
} else if (notification instanceof SelectableShieldNotification n) {
boardHandler.outlineShield(n.getPieces());
modelSynchronizer.setSwap(false);
} else if (notification instanceof TurboActiveNotification){
} else if (notification instanceof TurboActiveNotification) {
//nothing
} else if (notification instanceof FinishNotification n){
} else if (notification instanceof FinishNotification n) {
guiHandler.finish(n.getColorFinished());
} else {
throw new RuntimeException("notification not expected in game: " + notification.getClass().getName());

View File

@@ -3,14 +3,15 @@
import com.jme3.math.Vector3f;
public class Util {
private 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.
* @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) {
@@ -23,7 +24,7 @@ public static float linInt(float start, float end, float t) {
* @param p1 The initial point.
* @param p2 The middle point.
* @param p3 The final point.
* @param t The interpolation parameter (0 <= t <= 1).
* @param t The interpolation parameter (0 <= t <= 1).
* @return The interpolated point.
*/
public static Vector3f quadInt(Vector3f p1, Vector3f p2, Vector3f p3, float t) {
@@ -41,7 +42,7 @@ public static Vector3f quadInt(Vector3f p1, Vector3f p2, Vector3f p3, float t) {
* @param x The interpolation parameter (0 <= x <= 1).
* @return The adjusted interpolation value.
*/
public static float easeInOut(float x){
public static float easeInOut(float x) {
return x < 0.5 ? 4 * x * x * x : (float) (1 - Math.pow(-2 * x + 2, 3) / 2);
}
}

View File

@@ -4,7 +4,10 @@
import pp.mdga.client.MdgaApp;
import pp.mdga.client.MdgaState;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.Random;
import java.util.prefs.Preferences;
public class AcousticHandler {
@@ -226,20 +229,20 @@ private float lerp(float start, float end, float t) {
/**
* Updates the state of audio playback, handling track transitions and volume adjustments.
*
* <p>
* This method ensures smooth transitions between tracks using fade-in and fade-out effects.
* It also handles cases where no track is playing, starting a scheduled track immediately at full volume.
* The method prioritizes the latest scheduled track if multiple scheduling occurs quickly.
*
* <p>
* Behavior:
* 1. If nothing is scheduled and no track is playing, it exits early.
* 2. If a scheduled track exists and no track is playing, the scheduled track starts immediately at full volume.
* 3. If a scheduled track exists while a track is playing, it initiates a fade-out for the currently playing track
* and prepares for the new track to fade in.
* and prepares for the new track to fade in.
* 4. If a track transition is in progress (fading), it processes the fade-out and fade-in states.
* If a new track is scheduled during this process, it interrupts the current transition and prioritizes the new track.
* If a new track is scheduled during this process, it interrupts the current transition and prioritizes the new track.
* 5. If no fading is needed and a track is playing, it ensures the track's volume is updated.
*
* <p>
* Special cases:
* - If no track is playing and a new track is scheduled, it starts the track immediately without fading.
* - If a new track is scheduled during fading, it resets the transition to prioritize the new track.
@@ -291,23 +294,23 @@ private void updateVolumeAndTrack() {
/**
* Manages the fading process during audio track transitions.
*
* <p>
* This method handles the fade-out of the currently playing (old) track, manages any pause between the fade-out
* and fade-in, and initiates the fade-in for the new track if applicable. It ensures smooth transitions between
* tracks while maintaining the correct volume adjustments.
*
* <p>
* Behavior:
* 1. **Outfade:** Gradually decreases the volume of the `old` track over the duration of `FADE_DURATION`.
* Once the outfade completes, the `old` track is paused and cleared.
* Once the outfade completes, the `old` track is paused and cleared.
* 2. **Pause Handling:** Waits for a defined pause (if applicable) before initiating the infade for the next track.
* 3. **Infade:** If a `scheduled` track exists and the outfade and pause are complete, it begins playing
* the new track (`playing`) and initiates the infade process.
*
* the new track (`playing`) and initiates the infade process.
* <p>
* Key Details:
* - The outfade volume adjustment is interpolated linearly from full volume to zero using the `lerp` function.
* - The pause duration is retrieved from the scheduled track if it is specified.
* - If a new track is scheduled during the fade process, it is handled by external logic to prioritize transitions.
*
* <p>
* Preconditions:
* - `fading` is expected to be `true` when this method is called.
* - The method is invoked as part of the `updateVolumeAndTrack` process.
@@ -343,23 +346,23 @@ private void handleFadeProcess() {
/**
* Manages the fade-in process for the currently playing track.
*
* <p>
* This method gradually increases the volume of the `playing` track from zero to full volume
* over the duration of `CROSSFADE_DURATION`. It ensures a smooth transition into the new track.
*
* <p>
* Behavior:
* 1. If no track is set as `playing`, the method exits early, as there is nothing to fade in.
* 2. Linearly interpolates the volume of the `playing` track from 0.0 to 1.0 based on the elapsed
* `infadeTime` and the specified `CROSSFADE_DURATION`.
* `infadeTime` and the specified `CROSSFADE_DURATION`.
* 3. Once the fade-in is complete (when `infadeTime` exceeds `CROSSFADE_DURATION`), the method:
* - Marks the fade process (`fading`) as complete.
* - Ensures the `playing` track is updated to its full volume.
*
* - Marks the fade process (`fading`) as complete.
* - Ensures the `playing` track is updated to its full volume.
* <p>
* Key Details:
* - Uses the `lerp` function to calculate the volume level for the `playing` track during the fade-in.
* - Ensures the volume is always a value between 0.0 and 1.0.
* - The `infadeTime` parameter should be relative to the start of the fade-in process.
*
* <p>
* Preconditions:
* - The `playing` track must be initialized and actively fading in for this method to have an effect.
* - The method is invoked as part of the `updateVolumeAndTrack` process.
@@ -402,7 +405,7 @@ private void addGameTracks() {
* a new track will be scheduled to play. If the list of game tracks is empty, it will be refreshed.
*/
private void updateGameTracks() {
if(null == playing) {
if (null == playing) {
return;
}

View File

@@ -4,4 +4,5 @@
* A record that encapsulates a sound asset along with its playback settings:
* the relative volume (subVolume) and a delay before it starts playing.
*/
record SoundAssetDelayVolume(SoundAsset asset, float subVolume, float delay) {}
record SoundAssetDelayVolume(SoundAsset asset, float subVolume, float delay) {
}

View File

@@ -5,14 +5,12 @@
public class ActionControl extends InitControl {
private final Runnable runnable;
public ActionControl(Runnable runnable){
public ActionControl(Runnable runnable) {
this.runnable = runnable;
}
protected void action(){
if(null != runnable) {
protected void action() {
if (null != runnable) {
runnable.run();
}
}

View File

@@ -47,13 +47,13 @@ public Explosion(MdgaApp app, Node rootNode, Vector3f location) {
* Configures the fire and smoke emitters with appearance, behavior, and lifespan.
*/
private void initializeEmitter() {
fire = new ParticleEmitter("Effect", Type.Triangle,50);
fire = new ParticleEmitter("Effect", Type.Triangle, 50);
fire.setMaterial(mat);
fire.setImagesX(2);
fire.setImagesY(2);
fire.setStartColor(ColorRGBA.Yellow);
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.setStartSize(0.7f);
fire.setEndSize(1.8f);
@@ -64,13 +64,13 @@ private void initializeEmitter() {
fire.setLocalTranslation(location);
smoke = new ParticleEmitter("Effect2", Type.Triangle,40);
smoke = new ParticleEmitter("Effect2", Type.Triangle, 40);
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.7f));
smoke.getParticleInfluencer().setInitialVelocity(new Vector3f(0.0f, 0.0f, 0.7f));
smoke.getParticleInfluencer().setVelocityVariation(0.5f);
smoke.setStartSize(0.8f);
smoke.setEndSize(1.5f);
@@ -109,7 +109,8 @@ protected void controlUpdate(float tpf) {
}
@Override
protected void controlRender(com.jme3.renderer.RenderManager rm, com.jme3.renderer.ViewPort vp) {}
protected void controlRender(com.jme3.renderer.RenderManager rm, com.jme3.renderer.ViewPort vp) {
}
});
rootNode.attachChild(smoke);
@@ -127,7 +128,8 @@ protected void controlUpdate(float tpf) {
}
@Override
protected void controlRender(com.jme3.renderer.RenderManager rm, com.jme3.renderer.ViewPort vp) {}
protected void controlRender(com.jme3.renderer.RenderManager rm, com.jme3.renderer.ViewPort vp) {
}
});
}
}

View File

@@ -1,10 +1,9 @@
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 com.jme3.renderer.queue.RenderQueue;
import com.jme3.scene.Geometry;
import static pp.mdga.client.Util.linInt;

View File

@@ -12,10 +12,6 @@
import pp.mdga.client.Asset;
import pp.mdga.client.MdgaApp;
import pp.mdga.client.acoustic.MdgaSound;
import pp.mdga.client.board.BoardHandler;
import pp.mdga.client.view.GameView;
import java.util.UUID;
/**
* The {@code JetAnimation} class handles the animation of a jet model in a 3D environment.
@@ -38,10 +34,10 @@ public class JetAnimation {
/**
* Constructor for the {@code JetAnimation} class.
*
* @param app The main application managing the jet animation.
* @param rootNode The root node to which the jet model will be attached.
* @param targetPoint The target point where the explosion will occur.
* @param curveHeight The height of the curve for the jet's flight path.
* @param app The main application managing the jet animation.
* @param rootNode The root node to which the jet model will be attached.
* @param targetPoint The target point where the explosion will occur.
* @param curveHeight The height of the curve for the jet's flight path.
* @param animationDuration The total duration of the jet animation.
*/
public JetAnimation(MdgaApp app, Node rootNode, Vector3f targetPoint, float curveHeight, float animationDuration, Runnable actionAfter) {
@@ -88,7 +84,8 @@ private void spawnJet() {
rootNode.attachChild(jetModel);
}
/**actionAfter
/**
* actionAfter
* Animates the jet along a Bezier curve path, triggers the explosion effect at the appropriate time,
* and performs cleanup operations after the animation completes.
*/
@@ -106,7 +103,7 @@ protected void controlUpdate(float tpf) {
elapsedTime += tpf;
float progress = elapsedTime / animationDuration;
if(elapsedTime > 4.2f) {
if (elapsedTime > 4.2f) {
explosion.trigger();
}
@@ -127,11 +124,12 @@ protected void controlUpdate(float tpf) {
}
@Override
protected void controlRender(RenderManager rm, ViewPort vp) {}
protected void controlRender(RenderManager rm, ViewPort vp) {
}
});
}
private void endAnim(){
private void endAnim() {
actionAfter.run();
}

View File

@@ -6,11 +6,11 @@
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.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class MatrixAnimation extends ActionControl {
private MdgaApp app;
@@ -23,7 +23,7 @@ public class MatrixAnimation extends ActionControl {
private float timeElapsed = 0f;
private enum MatrixState{
private enum MatrixState {
RADAR_ON,
RADAR_OFF,
MATRIX_ON,
@@ -32,7 +32,7 @@ private enum MatrixState{
private MatrixState state;
public MatrixAnimation(MdgaApp app, Vector3f radarPos, Runnable runnable){
public MatrixAnimation(MdgaApp app, Vector3f radarPos, Runnable runnable) {
super(runnable);
this.app = app;
this.radarPos = radarPos;
@@ -48,15 +48,14 @@ protected void initSpatial() {
@Override
protected void controlUpdate(float tpf) {
if(!init) return;
if (!init) return;
timeElapsed += tpf;
switch(state){
switch (state) {
case RADAR_ON -> {
if(timeElapsed >= 2f){
if (timeElapsed >= 2f) {
state = MatrixState.RADAR_OFF;
timeElapsed = 0;
radarEmitter.setParticlesPerSec(0);
@@ -68,7 +67,7 @@ protected void controlUpdate(float tpf) {
}
}
case RADAR_OFF -> {
if(timeElapsed >= 0.1f){
if (timeElapsed >= 0.1f) {
state = MatrixState.MATRIX_ON;
timeElapsed = 0;
matrix();
@@ -76,12 +75,12 @@ protected void controlUpdate(float tpf) {
}
case MATRIX_ON -> {
if(timeElapsed >= 3f){
if (timeElapsed >= 3f) {
state = MatrixState.MATRIX_OFF;
timeElapsed = 0;
turnOff();
app.getTimerManager().addTask(3f, () -> app.enqueue(() -> {
for (ParticleEmitter particleEmitter : activeEmitter){
for (ParticleEmitter particleEmitter : activeEmitter) {
app.getRootNode().detachChild(particleEmitter);
}
System.out.println("delete particle");
@@ -90,7 +89,7 @@ protected void controlUpdate(float tpf) {
}
}
case MATRIX_OFF -> {
if(timeElapsed >= 0.5f){
if (timeElapsed >= 0.5f) {
init = false;
spatial.removeControl(this);
action();
@@ -99,13 +98,13 @@ protected void controlUpdate(float tpf) {
}
}
private void turnOff(){
for (ParticleEmitter particleEmitter : activeEmitter){
private void turnOff() {
for (ParticleEmitter particleEmitter : activeEmitter) {
particleEmitter.setParticlesPerSec(0f);
}
}
private void radar(){
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);
@@ -123,26 +122,26 @@ private void radar(){
float life = 2.6f;
emitter.setLowLife(life);
emitter.setHighLife(life);
emitter.setLocalTranslation(radarPos.add(new Vector3f(0,0,5)));
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 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){
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"));
@@ -160,7 +159,7 @@ private void particleStream(ColorRGBA start, ColorRGBA end, float speedVar, Vect
matrix.setGravity(0, 0, 2f);
matrix.setLowLife(3f);
matrix.setHighLife(3f);
matrix.setLocalTranslation(spatial.getLocalTranslation().add(pos).add(new Vector3f(0,0,15)));
matrix.setLocalTranslation(spatial.getLocalTranslation().add(pos).add(new Vector3f(0, 0, 15)));
matrix.setParticlesPerSec(spawnVar);
app.getRootNode().attachChild(matrix);
activeEmitter.add(matrix);
@@ -178,7 +177,7 @@ public static Vector3f getRandomPosition() {
float x = radius * (float) Math.cos(angle);
float y = radius * (float) Math.sin(angle);
return new Vector3f(x,y,0);
return new Vector3f(x, y, 0);
}
public static float getRandomFloat(float start, float end) {

View File

@@ -17,8 +17,6 @@
import pp.mdga.client.acoustic.MdgaSound;
import pp.mdga.client.board.BoardHandler;
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.
@@ -42,9 +40,9 @@ public class MissileAnimation {
/**
* Constructor for the {@code MissileAnimation} class.
*
* @param app The main application managing the missile animation.
* @param rootNode The root node to which the missile model will be attached.
* @param target The target point where the missile will explode.
* @param app The main application managing the missile animation.
* @param rootNode The root node to which the missile model will be attached.
* @param target The target point where the missile will explode.
* @param flightTime The total flight time of the missile.
*/
public MissileAnimation(MdgaApp app, Node rootNode, Vector3f target, float flightTime, Runnable actionAfter) {
@@ -64,13 +62,13 @@ public MissileAnimation(MdgaApp app, Node rootNode, Vector3f target, float fligh
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 = 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().setInitialVelocity(new Vector3f(0.0f, 0.0f, 0.0f));
smoke.getParticleInfluencer().setVelocityVariation(0.1f);
smoke.setStartSize(0.8f);
smoke.setEndSize(1.5f);
@@ -120,7 +118,7 @@ private void animateMissile() {
@Override
protected void controlUpdate(float tpf) {
if(elapsedTime > 6) {
if (elapsedTime > 6) {
endAnim();
rootNode.detachChild(missileNode);
this.spatial.removeControl(this);
@@ -150,8 +148,8 @@ protected void controlUpdate(float tpf) {
missileNode.setLocalTranslation(currentPosition);
Vector3f direction = computeParabolicPath(start, target, progress + 0.01f)
.subtract(currentPosition)
.normalizeLocal();
.subtract(currentPosition)
.normalizeLocal();
missileModel.lookAt(currentPosition.add(direction), Vector3f.UNIT_Y);
missileModel.rotate(0, FastMath.HALF_PI, 0);
}
@@ -162,16 +160,16 @@ protected void controlRender(RenderManager rm, ViewPort vp) {
});
}
private void endAnim(){
private void endAnim() {
actionAfter.run();
}
/**
* Computes a position along a parabolic path at a given progress value {@code t}.
*
* @param start The starting point of the missile's flight.
* @param start The starting point of the missile's flight.
* @param target The target point of the missile's flight.
* @param t The progress value (0.0 to 1.0) along the flight path.
* @param t The progress value (0.0 to 1.0) along the flight path.
* @return The interpolated position along the parabolic path.
*/
private Vector3f computeParabolicPath(Vector3f start, Vector3f target, float t) {

View File

@@ -2,7 +2,8 @@
import com.jme3.math.Vector3f;
import static pp.mdga.client.Util.*;
import static pp.mdga.client.Util.easeInOut;
import static pp.mdga.client.Util.quadInt;
/**
* A control that smoothly moves a spatial from an initial position to an end position
@@ -28,15 +29,15 @@ public class MoveControl extends ActionControl {
* Creates a new MoveControl with specified initial and end positions, and an action to run after the movement.
* The movement follows a path with a midpoint at a fixed height.
*
* @param initPos The starting position of the spatial.
* @param endPos The target position of the spatial.
* @param initPos The starting position of the spatial.
* @param endPos The target position of the spatial.
* @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){
public MoveControl(Vector3f initPos, Vector3f endPos, Runnable actionAfter, float height, float duration, boolean easing) {
super(actionAfter);
moving = false;
this.initPos = initPos;
@@ -70,7 +71,7 @@ protected void initSpatial() {
*/
@Override
protected void controlUpdate(float tpf) {
if(!moving) return;
if (!moving) return;
timer += tpf;
float t = timer / duration;
@@ -78,22 +79,20 @@ protected void controlUpdate(float tpf) {
float interpolated = easing ? easeInOut(t) : t;
spatial.setLocalTranslation(quadInt(initPos,middlePos,endPos, interpolated));
spatial.setLocalTranslation(quadInt(initPos, middlePos, endPos, interpolated));
if(t >= 1) end();
if (t >= 1) end();
}
/**
* Ends the movement by stopping the interpolation, running the action after the movement,
* and removing this control from the spatial.
*/
private void end(){
private void end() {
moving = false;
spatial.removeControl(this);
action();
}
}

View File

@@ -3,17 +3,12 @@
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;
@@ -22,7 +17,6 @@
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;
@@ -30,7 +24,7 @@ public class ShellAnimation extends ActionControl {
private TankTopControl tankTopControl;
private MdgaApp app;
public ShellAnimation(TankTopControl tankTopControl, MdgaApp app, Runnable actionAfter){
public ShellAnimation(TankTopControl tankTopControl, MdgaApp app, Runnable actionAfter) {
super(actionAfter);
this.tankTopControl = tankTopControl;
this.app = app;
@@ -44,14 +38,14 @@ protected void initSpatial() {
app.getRootNode().attachChild(createShell());
}
private Vector3f getShootPos(){
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(){
private void shoot() {
app.getAcousticHandler().playSound(MdgaSound.TANK_SHOOT);
Vector3f shootPos = getShootPos();
createEffect(
@@ -71,7 +65,7 @@ private void shoot(){
0.3f, 0.8f,
10,
0.1f, 0.35f,
new ColorRGBA(0.5f,0.5f,0.5f,0.5f),
new ColorRGBA(0.5f, 0.5f, 0.5f, 0.5f),
ColorRGBA.Black
);
@@ -80,7 +74,7 @@ private void shoot(){
shell.addControl(new ShellControl(this::hitExplosion, shootPos, spatial.getLocalTranslation(), FLYING_HEIGHT, FLYING_DURATION, app.getAssetManager()));
}
private Spatial createShell(){
private Spatial createShell() {
Spatial model = app.getAssetManager().loadModel(Asset.shell.getModelPath());
model.scale(.16f);
model.setLocalTranslation(tankTopControl.getSpatial().getLocalTranslation());
@@ -90,21 +84,21 @@ private Spatial createShell(){
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
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);
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);
ColorRGBA color = ColorRGBA.fromRGBA255(143, 117, 0, 255);
mat.setColor("Diffuse", color);
mat.setColor("Ambient", color);
model.setMaterial(mat);
return model;
}
private void hitExplosion(){
private void hitExplosion() {
app.getAcousticHandler().playSound(MdgaSound.TANK_EXPLOSION);
createEffect(
spatial.getLocalTranslation().setZ(1),
@@ -130,7 +124,7 @@ private void createEffect(Vector3f shootPos,
float startSize, float endSize,
float velocity,
float lowLife, float highLife,
ColorRGBA start, ColorRGBA end){
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");

View File

@@ -7,7 +7,6 @@
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;
@@ -18,7 +17,7 @@ public class ShellControl extends ActionControl {
private ParticleEmitter emitter;
private AssetManager assetManager;
public ShellControl(Runnable runnable, Vector3f shootPos, Vector3f endPos, float height, float duration, AssetManager assetManager){
public ShellControl(Runnable runnable, Vector3f shootPos, Vector3f endPos, float height, float duration, AssetManager assetManager) {
super(runnable);
this.shootPos = shootPos;
this.endPos = endPos;
@@ -32,7 +31,7 @@ protected void initSpatial() {
spatial.addControl(new MoveControl(
shootPos,
endPos,
()->{
() -> {
emitter.killAllParticles();
emitter.setParticlesPerSec(0);
emitter.removeFromParent();
@@ -80,7 +79,7 @@ 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);
spatial.rotate(FastMath.HALF_PI, 0, 0);
}
oldPos = spatial.getLocalTranslation().clone();

View File

@@ -43,11 +43,11 @@ public Smoke(MdgaApp app, Node rootNode, Vector3f location) {
* Configures the fire and smoke emitters with appearance, behavior, and lifespan.
*/
private void initializeEmitter() {
fire = new ParticleEmitter("Effect", ParticleMesh.Type.Triangle,50);
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().setInitialVelocity(new Vector3f(0.2f, 0.2f, 4f));
fire.getParticleInfluencer().setVelocityVariation(0.4f);
fire.setStartSize(0.7f);
fire.setEndSize(3.8f);
@@ -58,13 +58,13 @@ private void initializeEmitter() {
fire.setLocalTranslation(location);
smoke = new ParticleEmitter("Effect2", ParticleMesh.Type.Triangle,40);
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().setInitialVelocity(new Vector3f(0.0f, 0.0f, 2f));
smoke.getParticleInfluencer().setVelocityVariation(0.5f);
smoke.setStartSize(0.5f);
smoke.setEndSize(1.5f);
@@ -103,7 +103,8 @@ protected void controlUpdate(float tpf) {
}
@Override
protected void controlRender(com.jme3.renderer.RenderManager rm, com.jme3.renderer.ViewPort vp) {}
protected void controlRender(com.jme3.renderer.RenderManager rm, com.jme3.renderer.ViewPort vp) {
}
});
rootNode.attachChild(smoke);
@@ -121,7 +122,8 @@ protected void controlUpdate(float tpf) {
}
@Override
protected void controlRender(com.jme3.renderer.RenderManager rm, com.jme3.renderer.ViewPort vp) {}
protected void controlRender(com.jme3.renderer.RenderManager rm, com.jme3.renderer.ViewPort vp) {
}
});
}
}

View File

@@ -172,8 +172,8 @@ public void turbo() {
* Performs linear interpolation between two values.
*
* @param start The starting value.
* @param end The target value.
* @param t The interpolation parameter (0 <= t <= 1).
* @param end The target value.
* @param t The interpolation parameter (0 <= t <= 1).
* @return The interpolated value.
*/
private static float lerp(float start, float end, float t) {

View File

@@ -17,8 +17,8 @@ public class ZoomControl extends InitControl {
private float zoomFactor = 1f;
/**
* Constructs a new ZoomControl with the default zoom speed.
*/
* Constructs a new ZoomControl with the default zoom speed.
*/
public ZoomControl() {
}
@@ -78,8 +78,8 @@ private void end() {
* Performs linear interpolation between two values.
*
* @param start The starting value.
* @param end The target value.
* @param t The interpolation parameter (0 <= t <= 1).
* @param end The target value.
* @param t The interpolation parameter (0 <= t <= 1).
* @return The interpolated value.
*/
private static float lerp(float start, float end, float t) {

View File

@@ -5,4 +5,5 @@
/**
* Record for holding Asset information
*/
record AssetOnMap(Asset asset, int x, int y, float rot) {}
record AssetOnMap(Asset asset, int x, int y, float rot) {
}

View File

@@ -2,7 +2,6 @@
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.post.FilterPostProcessor;
@@ -66,13 +65,13 @@ public class BoardHandler {
/**
* Creates a new BoardHandler.
*
* @param app The main application instance
* @param app The main application instance
* @param rootNode The root node where the board will be attached
* @param fpp The post-processor for effects like shadows or filters
* @param fpp The post-processor for effects like shadows or filters
* @throws RuntimeException if the app is null
*/
public BoardHandler(MdgaApp app, Node rootNode, FilterPostProcessor fpp) {
if(app == null) throw new RuntimeException("app is null");
if (app == null) throw new RuntimeException("app is null");
this.app = app;
this.fpp = fpp;
@@ -99,7 +98,7 @@ public void init() {
/**
* Shuts down the board handler by detaching all board-related nodes and clearing selected pieces.
*/
public void shutdown(){
public void shutdown() {
clearSelectable();
isInitialised = false;
rootNode.detachChild(rootNodeBoard);
@@ -108,7 +107,7 @@ public void shutdown(){
/**
* Adds an asset to the map of player assets, ensuring that the player does not have too many assets.
*
* @param col The color of the player
* @param col The color of the player
* @param assetOnMap The asset to be added
* @throws RuntimeException if there are too many assets for the player
*/
@@ -129,7 +128,7 @@ private void initMap() {
waitingPiecesMap = new HashMap<>();
pieceColor = new HashMap<>();
diceControl = new DiceControl(app.getAssetManager());
diceControl.create(new Vector3f(0,0,0), 0.7f, true);
diceControl.create(new Vector3f(0, 0, 0), 0.7f, true);
waitingNodes = new HashMap<>();
waitingNodes.put(Color.AIRFORCE, new HashMap<>());
waitingNodes.put(Color.ARMY, new HashMap<>());
@@ -146,7 +145,7 @@ private void initMap() {
case cir -> addFigureToPlayerMap(assetToColor(Asset.cir), assetOnMap);
case marine -> addFigureToPlayerMap(assetToColor(Asset.marine), assetOnMap);
case node_normal, node_bonus, node_start ->
infield.add(displayAndControl(assetOnMap, new NodeControl(app, fpp)));
infield.add(displayAndControl(assetOnMap, new NodeControl(app, fpp)));
case node_home_black -> addHomeNode(homeNodesMap, Color.AIRFORCE, assetOnMap);
case node_home_blue -> addHomeNode(homeNodesMap, Color.NAVY, assetOnMap);
case node_home_green -> addHomeNode(homeNodesMap, Color.ARMY, assetOnMap);
@@ -194,8 +193,8 @@ private Color assetToColor(Asset asset) {
* Creates a 3D model of an asset and adds it to the board.
*
* @param asset The asset to be displayed
* @param pos The position of the asset on the board
* @param rot The rotation of the asset
* @param pos The position of the asset on the board
* @param rot The rotation of the asset
* @return The Spatial representation of the asset
*/
private Spatial createModel(Asset asset, Vector3f pos, float rot) {
@@ -262,19 +261,19 @@ private <T extends AbstractControl> T displayAndControl(AssetOnMap assetOnMap, T
* @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());
}
/**
* 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.
* @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)));
if (homeNodes.size() > 4) throw new RuntimeException("too many homeNodes for " + color);
}
@@ -290,19 +289,19 @@ private float getRotationMove(Vector3f prev, Vector3f next) {
Vector3f direction = next.subtract(prev).normalizeLocal();
//I had to reverse dir.y, because then it worked.
float newRot = (float) Math.toDegrees(Math.atan2(direction.x, -direction.y));
if(newRot < 0) newRot += 360;
if (newRot < 0) newRot += 360;
return newRot;
}
/**
* Recursively moves a piece from its current index to the destination index,
* to keep track of the piece rotation.
*
* @param uuid The UUID of the piece to move.
* @param curIndex The current index of the piece.
* @param moveIndex The target index to move the piece to.
* Recursively moves a piece from its current index to the destination index,
* to keep track of the piece rotation.
*
* @param uuid The UUID of the piece to move.
* @param curIndex The current index of the piece.
* @param moveIndex The target index to move the piece to.
*/
private void movePieceRek(UUID uuid, int curIndex, int moveIndex){
private void movePieceRek(UUID uuid, int curIndex, int moveIndex) {
if (curIndex == moveIndex) return;
int nextIndex = (curIndex + 1) % infield.size();
@@ -311,7 +310,7 @@ private void movePieceRek(UUID uuid, int curIndex, int moveIndex){
NodeControl nodeCur = infield.get(curIndex);
NodeControl nodeMove = infield.get(nextIndex);
pieceControl.setRotation(getRotationMove(nodeCur.getLocation(),nodeMove.getLocation()));
pieceControl.setRotation(getRotationMove(nodeCur.getLocation(), nodeMove.getLocation()));
movePieceToNode(pieceControl, nodeMove);
@@ -329,7 +328,7 @@ private void movePieceRek(UUID uuid, int curIndex, int moveIndex){
* @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.add(item);
map.put(key, list);
@@ -345,7 +344,7 @@ private <T, E> List<T> addItemToMapList(Map<E,List<T>> map, E key, T item){
* @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.remove(item);
map.put(key, list);
@@ -357,7 +356,7 @@ private <T, E> void removeItemFromMapList(Map<E,List<T>> map, E key, T item){
* @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());
}
@@ -381,20 +380,22 @@ public static Vector3f getMeanPosition(List<Vector3f> vectors) {
* Adds a player to the game by associating a color and a list of UUIDs to corresponding assets and waiting nodes.
*
* @param color the color of the player
* @param uuid the list of UUIDs representing the player's assets
* @param uuid the list of UUIDs representing the player's assets
* @throws RuntimeException if the number of assets or waiting nodes does not match the provided UUIDs
*/
public void addPlayer(Color color, List<UUID> uuid) {
List<AssetOnMap> playerAssets = colorAssetsMap.get(color);
if (playerAssets == null) throw new RuntimeException("Assets for Player color are not defined");
if (uuid.size() != playerAssets.size()) throw new RuntimeException("UUID array and playerAssets are not the same size");
if (uuid.size() != playerAssets.size())
throw new RuntimeException("UUID array and playerAssets are not the same size");
List<NodeControl> waitNodes = waitingNodesMap.get(color);
if (waitNodes.size() != playerAssets.size()) throw new RuntimeException("waitNodes size does not match playerAssets size");
if (waitNodes.size() != playerAssets.size())
throw new RuntimeException("waitNodes size does not match playerAssets size");
for (int i = 0; i < playerAssets.size(); i++){
for (int i = 0; i < playerAssets.size(); i++) {
AssetOnMap assetOnMap = playerAssets.get(i);
UUID pieceUuid = uuid.get(i);
@@ -419,18 +420,18 @@ public void addPlayer(Color color, List<UUID> uuid) {
/**
* Moves a piece to its corresponding home node based on the given index.
*
* @param uuid the UUID of the piece to move
* @param uuid the UUID of the piece to move
* @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 moveHomePiece(UUID uuid, int index) {
Color color = pieceColor.get(uuid);
if(color == null) throw new RuntimeException("uuid is not mapped to a color");
if (color == null) throw new RuntimeException("uuid is not mapped to a color");
List<NodeControl> homeNodes = homeNodesMap.get(color);
if(homeNodesMap.size() != 4) throw new RuntimeException("HomeNodes for" + color + " are not properly defined");
if (homeNodesMap.size() != 4) throw new RuntimeException("HomeNodes for" + color + " are not properly defined");
PieceControl pieceControl = pieces.get(uuid);
NodeControl nodeControl = homeNodes.get(index);
@@ -438,7 +439,7 @@ private void moveHomePiece(UUID uuid, int index){
//rotate piece in direction of homeNodes
NodeControl firstHomeNode = homeNodes.get(0);
NodeControl lastHomeNode = homeNodes.get(homeNodes.size()-1);
NodeControl lastHomeNode = homeNodes.get(homeNodes.size() - 1);
pieceControl.setRotation(getRotationMove(firstHomeNode.getLocation(), lastHomeNode.getLocation()));
app.getModelSynchronize().animationEnd();
@@ -448,12 +449,12 @@ private void moveHomePiece(UUID uuid, int index){
/**
* Starts the movement of a piece to a target node based on the given index.
*
* @param uuid the UUID of the piece to move
* @param uuid the UUID of the piece to move
* @param nodeIndex the index of the target node to move the piece to
* @throws RuntimeException if the UUID is not mapped to a color or the piece control is not found
* @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 movePieceStart(UUID uuid, int nodeIndex) {
// Farbe des Pieces abrufen
Color color = pieceColor.get(uuid);
@@ -480,11 +481,11 @@ private void movePieceStart(UUID uuid, int nodeIndex){
/**
* Moves a piece from its current position to the target position based on the given indexes.
*
* @param uuid the UUID of the piece to move
* @param curIndex the current index of the piece
* @param uuid the UUID of the piece to move
* @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 movePiece(UUID uuid, int curIndex, int moveIndex) {
movePieceRek(uuid, curIndex, moveIndex);
app.getModelSynchronize().animationEnd();
@@ -497,7 +498,7 @@ private void movePiece(UUID uuid, int curIndex, int moveIndex){
* @param uuid the UUID of the piece to throw
* @throws RuntimeException if the UUID is not mapped to a color or if no available waiting nodes are found
*/
private void throwPiece(UUID uuid){
private void throwPiece(UUID uuid) {
// Farbe des Pieces abrufen
Color color = pieceColor.get(uuid);
@@ -531,7 +532,7 @@ private void throwPiece(UUID uuid){
*
* @param uuid the UUID of the piece to shield
*/
public void shieldPiece(UUID uuid){
public void shieldPiece(UUID uuid) {
pieces.get(uuid).activateShield();
}
@@ -540,7 +541,7 @@ public void shieldPiece(UUID uuid){
*
* @param uuid the UUID of the piece to unshield
*/
public void unshieldPiece(UUID uuid){
public void unshieldPiece(UUID uuid) {
pieces.get(uuid).deactivateShield();
}
@@ -549,7 +550,7 @@ public void unshieldPiece(UUID uuid){
*
* @param uuid the UUID of the piece to suppress the shield
*/
public void suppressShield(UUID uuid){
public void suppressShield(UUID uuid) {
pieces.get(uuid).suppressShield();
}
@@ -557,14 +558,14 @@ public void suppressShield(UUID uuid){
/**
* Swaps the positions and rotations of two pieces.
*
* @param p1 the first piece to swap
* @param p2 the second piece to swap
* @param p1 the first piece to swap
* @param p2 the second piece to swap
* @param loc1 the original location of the first piece
* @param rot1 the original rotation of the first piece
* @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 swapPieces(PieceControl p1, PieceControl p2, Vector3f loc1, float rot1, Vector3f loc2, float rot2) {
p1.setLocation(loc2);
p2.setLocation(loc1);
@@ -577,13 +578,14 @@ private void swapPieces(PieceControl p1, PieceControl p2, Vector3f loc1, float r
/**
* Outlines the possible move nodes for a list of pieces based on the move indices and whether it's a home move.
*
* @param pieces the list of UUIDs representing the pieces to outline
* @param pieces the list of UUIDs representing the pieces to outline
* @param moveIndexe the list of indices for the target move nodes
* @param homeMoves the list indicating whether the move is a home move
* @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<UUID> pieces, List<Integer> moveIndexe, List<Boolean> homeMoves) {
if(pieces.size() != moveIndexe.size() || pieces.size() != homeMoves.size()) throw new RuntimeException("arrays are not the same size");
if (pieces.size() != moveIndexe.size() || pieces.size() != homeMoves.size())
throw new RuntimeException("arrays are not the same size");
selectableEnemyPieces.clear();
selectableOwnPieces.clear();
@@ -598,8 +600,7 @@ public void outlineMove(List<UUID> pieces, List<Integer> moveIndexe, List<Boolea
if (homeMoves.get(i)) {
Color color = pieceColor.get(uuid);
nodeControl = homeNodesMap.get(color).get(moveIndexe.get(i));
}
else {
} else {
nodeControl = infield.get(moveIndexe.get(i));
}
nodeControl.highlight();
@@ -615,24 +616,24 @@ public void outlineMove(List<UUID> pieces, List<Integer> moveIndexe, List<Boolea
/**
* Outlines the pieces that can be swapped based on the provided own and enemy pieces.
*
* @param ownPieces the list of UUIDs representing the player's pieces
* @param ownPieces the list of UUIDs representing the player's pieces
* @param enemyPieces the list of UUIDs representing the enemy's pieces
*/
public void outlineSwap(List<UUID> ownPieces, List<UUID> enemyPieces){
public void outlineSwap(List<UUID> ownPieces, List<UUID> enemyPieces) {
selectableEnemyPieces.clear();
selectableOwnPieces.clear();
selectedOwnPiece = null;
selectedEnemyPiece = null;
for(UUID uuid : ownPieces) {
for (UUID uuid : ownPieces) {
PieceControl p = pieces.get(uuid);
p.highlight(false);
p.setHoverable(true);
p.setSelectable(true);
selectableOwnPieces.add(p);
}
for(UUID uuid : enemyPieces) {
for (UUID uuid : enemyPieces) {
PieceControl p = pieces.get(uuid);
p.highlight(true);
p.setHoverable(true);
@@ -646,13 +647,13 @@ public void outlineSwap(List<UUID> ownPieces, List<UUID> enemyPieces){
*
* @param pieces the list of UUIDs representing the pieces to be shielded
*/
public void outlineShield(List<UUID> pieces){
public void outlineShield(List<UUID> pieces) {
selectableOwnPieces.clear();
selectableEnemyPieces.clear();
selectedOwnPiece = null;
selectedEnemyPiece = null;
for (UUID uuid : pieces){
for (UUID uuid : pieces) {
PieceControl p = this.pieces.get(uuid);
p.highlight(false);
p.setHoverable(true);
@@ -668,69 +669,65 @@ public void outlineShield(List<UUID> pieces){
*/
public void pieceSelect(PieceControl pieceSelected) {
boolean isSelected = pieceSelected.isSelected();
if(selectableOwnPieces.contains(pieceSelected)){
for(PieceControl p : selectableOwnPieces) {
if (selectableOwnPieces.contains(pieceSelected)) {
for (PieceControl p : selectableOwnPieces) {
p.unSelect();
if(selectedPieceNodeMap.get(p) != null) selectedPieceNodeMap.get(p).unSelect();
if (selectedPieceNodeMap.get(p) != null) selectedPieceNodeMap.get(p).unSelect();
}
if (!isSelected) {
pieceSelected.select();
if(selectedPieceNodeMap.get(pieceSelected) != null) selectedPieceNodeMap.get(pieceSelected).select();
if (selectedPieceNodeMap.get(pieceSelected) != null) selectedPieceNodeMap.get(pieceSelected).select();
selectedOwnPiece = pieceSelected;
}
else {
} else {
pieceSelected.unSelect();
if(selectedPieceNodeMap.get(pieceSelected) != null) selectedPieceNodeMap.get(pieceSelected).unSelect();
if (selectedPieceNodeMap.get(pieceSelected) != null) selectedPieceNodeMap.get(pieceSelected).unSelect();
selectedOwnPiece = null;
}
}
else if(selectableEnemyPieces.contains(pieceSelected)) {
for(PieceControl p : selectableEnemyPieces) {
} else if (selectableEnemyPieces.contains(pieceSelected)) {
for (PieceControl p : selectableEnemyPieces) {
p.unSelect();
}
if (!isSelected) {
pieceSelected.select();
selectedEnemyPiece = pieceSelected;
}
else {
} else {
pieceSelected.unSelect();
selectedEnemyPiece = null;
}
}
else throw new RuntimeException("pieceSelected is not in own/enemySelectablePieces");
} else throw new RuntimeException("pieceSelected is not in own/enemySelectablePieces");
app.getModelSynchronize().select(getKeyByValue(pieces, selectedOwnPiece), getKeyByValue(pieces, selectedEnemyPiece));
}
public void pieceHoverOn(PieceControl hoverPiece){
public void pieceHoverOn(PieceControl hoverPiece) {
hoverPiece.hover();
if(selectedPieceNodeMap.get(hoverPiece) != null) selectedPieceNodeMap.get(hoverPiece).hover();
if (selectedPieceNodeMap.get(hoverPiece) != null) selectedPieceNodeMap.get(hoverPiece).hover();
}
public void pieceHoverOff(PieceControl hoverPiece){
public void pieceHoverOff(PieceControl hoverPiece) {
hoverPiece.hoverOff();
if(selectedPieceNodeMap.get(hoverPiece) != null) selectedPieceNodeMap.get(hoverPiece).hoverOff();
if (selectedPieceNodeMap.get(hoverPiece) != null) selectedPieceNodeMap.get(hoverPiece).hoverOff();
}
/**
* Clears all highlighted, selectable, and selected pieces and nodes.
*/
public void clearSelectable(){
for(PieceControl p : selectableEnemyPieces) {
public void clearSelectable() {
for (PieceControl p : selectableEnemyPieces) {
p.unSelect();
p.unHighlight();
p.setSelectable(false);
p.setHoverable(false);
if(selectedPieceNodeMap.get(p) != null) selectedPieceNodeMap.get(p).unSelect();
if(selectedPieceNodeMap.get(p) != null) selectedPieceNodeMap.get(p).unHighlight();
if (selectedPieceNodeMap.get(p) != null) selectedPieceNodeMap.get(p).unSelect();
if (selectedPieceNodeMap.get(p) != null) selectedPieceNodeMap.get(p).unHighlight();
}
for(PieceControl p : selectableOwnPieces) {
for (PieceControl p : selectableOwnPieces) {
p.unSelect();
p.unHighlight();
p.setSelectable(false);
p.setHoverable(false);
}
for(NodeControl n : outlineNodes){
for (NodeControl n : outlineNodes) {
n.deOutline();
}
outlineNodes.clear();
@@ -746,16 +743,16 @@ public void clearSelectable(){
*
* @param color the color of the player whose dice should be displayed
*/
public void showDice(Color color){
public void showDice(Color color) {
rootNodeBoard.attachChild(diceControl.getSpatial());
diceControl.setPos(getWaitingPos(color).add(new Vector3f(0,0,4)));
diceControl.setPos(getWaitingPos(color).add(new Vector3f(0, 0, 4)));
diceControl.spin();
}
/**
* Hides the dice from the view.
*/
public void hideDice(){
public void hideDice() {
diceControl.hide();
}
@@ -771,42 +768,42 @@ private <K, V> K getKeyByValue(Map<K, V> map, V value) {
/**
* Animates the movement of a piece from its current index to a target index.
*
* @param uuid the UUID of the piece to animate
* @param curIndex the current index of the piece
* @param uuid the UUID of the piece to animate
* @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 movePieceAnim(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)));
infield.get(curIndex).getLocation(),
infield.get(moveIndex).getLocation(),
() -> movePiece(uuid, curIndex, moveIndex)));
}
/**
* Animates the movement of a piece to its home position based on the given home index.
*
* @param uuid the UUID of the piece to animate
* @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 movePieceHomeAnim(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)));
pieces.get(uuid).getLocation(),
homeNodesMap.get(pieceColor.get(uuid)).get(homeIndex).getLocation(),
() -> moveHomePiece(uuid, homeIndex)));
}
/**
* Animates the start of the movement of a piece to a target index.
*
* @param uuid the UUID of the piece to animate
* @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 movePieceStartAnim(UUID uuid, int moveIndex) {
pieces.get(uuid).getSpatial().addControl(new MoveControl(
pieces.get(uuid).getLocation(),
infield.get(moveIndex).getLocation(),
()->movePieceStart(uuid, moveIndex)
pieces.get(uuid).getLocation(),
infield.get(moveIndex).getLocation(),
() -> movePieceStart(uuid, moveIndex)
));
}
@@ -815,15 +812,15 @@ public void movePieceStartAnim(UUID uuid, int moveIndex){
*
* @param uuid the UUID of the piece to animate
*/
public void throwPieceAnim(UUID uuid){
public void throwPieceAnim(UUID uuid) {
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){
switch(throwColor){
public void throwPiece(UUID uuid, Color throwColor) {
switch (throwColor) {
case ARMY -> throwShell(uuid);
case NAVY -> throwMissile(uuid);
case CYBER -> throwMatrix(uuid);
@@ -840,14 +837,14 @@ public void throwPiece(UUID uuid, Color throwColor){
private void throwBomb(UUID uuid) {
Vector3f targetPoint = pieces.get(uuid).getLocation();
JetAnimation anim = new JetAnimation(app, rootNode, targetPoint, 40, 6, ()->throwPieceAnim(uuid));
JetAnimation anim = new JetAnimation(app, rootNode, targetPoint, 40, 6, () -> throwPieceAnim(uuid));
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 MatrixAnimation(app, radarPos, () -> {
throwPieceAnim(uuid);
}));
}
@@ -855,12 +852,12 @@ private void throwMatrix(UUID uuid) {
private void throwMissile(UUID uuid) {
Vector3f targetPoint = pieces.get(uuid).getLocation();
MissileAnimation anim = new MissileAnimation(app, rootNode, targetPoint, 2f, ()->throwPieceAnim(uuid));
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)));
pieces.get(uuid).getSpatial().addControl(new ShellAnimation(tankTop, app, () -> throwPieceAnim(uuid)));
}
/**
@@ -869,7 +866,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 swapPieceAnim(UUID piece1, UUID piece2) {
PieceControl piece1Control = pieces.get(piece1);
PieceControl piece2Control = pieces.get(piece2);
@@ -879,14 +876,15 @@ public void swapPieceAnim(UUID piece1, UUID piece2){
float rot2 = piece2Control.getRotation();
piece1Control.getSpatial().addControl(new MoveControl(
piece1Control.getLocation().clone(),
piece2Control.getLocation().clone(),
()->{}
piece1Control.getLocation().clone(),
piece2Control.getLocation().clone(),
() -> {
}
));
piece2Control.getSpatial().addControl(new MoveControl(
piece2Control.getLocation().clone(),
piece1Control.getLocation().clone(),
()->swapPieces(piece1Control,piece2Control,loc1,rot1,loc2,rot2)
piece2Control.getLocation().clone(),
piece1Control.getLocation().clone(),
() -> swapPieces(piece1Control, piece2Control, loc1, rot1, loc2, rot2)
));
}

View File

@@ -73,7 +73,7 @@ public CameraHandler(MdgaApp app, FilterPostProcessor fpp) {
// ssaoFilter = new SSAOFilter();
fxaaFilter = new FXAAFilter();
sky = SkyFactory.createSky(app.getAssetManager(), "Images/sky/sky.dds", EnvMapType.EquirectMap).rotate(FastMath.HALF_PI*1,0,FastMath.HALF_PI*0.2f);
sky = SkyFactory.createSky(app.getAssetManager(), "Images/sky/sky.dds", EnvMapType.EquirectMap).rotate(FastMath.HALF_PI * 1, 0, FastMath.HALF_PI * 0.2f);
}
@@ -94,7 +94,7 @@ public void init(Color ownColor) {
init = true;
initRot = true;
this.ownColor = ownColor;
app.getInputSynchronize().setRotation(getInitAngleByColor(ownColor)*2);
app.getInputSynchronize().setRotation(getInitAngleByColor(ownColor) * 2);
}
/**
@@ -120,11 +120,11 @@ public void shutdown() {
* Updates the camera position and rotation based on user input (scroll and rotation).
* Adjusts the vertical angle and radius based on zoom and rotation values.
*
* @param scroll The scroll input, determining zoom level.
* @param scroll The scroll input, determining zoom level.
* @param rotation The rotation input, determining camera orientation.
*/
public void update(float scroll, float rotation) {
if(!init) return;
if (!init) return;
float scrollValue = Math.max(0, Math.min(scroll, 100));
float rotationValue = rotation % 360;
@@ -162,8 +162,8 @@ public void update(float scroll, float rotation) {
* @param color The color used to determine the camera angle.
* @return The camera angle in degrees.
*/
private float getAngleByColor(Color color){
return switch (color){
private float getAngleByColor(Color color) {
return switch (color) {
case ARMY -> 0;
case AIRFORCE -> 90;
case NAVY -> 270;
@@ -178,7 +178,7 @@ private float getAngleByColor(Color color){
* @param color The color used to determine the camera angle.
* @return The initial camera angle in degrees.
*/
private float getInitAngleByColor(Color color){
private float getInitAngleByColor(Color color) {
return (getAngleByColor(color) + 180) % 360;
}

View File

@@ -28,15 +28,15 @@ private MapLoader() {
*
* @param mapName The name of the map file to load. The file is expected to be located in the resources directory.
* @return A list of {@link AssetOnMap} objects representing the assets placed on the map.
* @throws IOException If an error occurs while reading the map file.
* @throws IOException If an error occurs while reading the map file.
* @throws IllegalArgumentException If the map file contains invalid data.
*/
public static List<AssetOnMap> loadMap(String mapName) {
List<AssetOnMap> assetsOnMap = new ArrayList<>();
try (
InputStream inputStream = MapLoader.class.getClassLoader().getResourceAsStream(mapName);
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))
InputStream inputStream = MapLoader.class.getClassLoader().getResourceAsStream(mapName);
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))
) {
while (true) {
@@ -65,11 +65,9 @@ public static List<AssetOnMap> loadMap(String mapName) {
Asset asset = getLoadedAsset(assetName);
assetsOnMap.add(new AssetOnMap(asset, x, y, rot));
}
}
catch (IOException e) {
} catch (IOException e) {
e.printStackTrace();
}
catch (IllegalArgumentException e) {
} catch (IllegalArgumentException e) {
e.printStackTrace();
}

View File

@@ -3,9 +3,6 @@
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.post.FilterPostProcessor;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.scene.control.AbstractControl;
import pp.mdga.client.MdgaApp;
/**
@@ -40,38 +37,38 @@ public NodeControl(MdgaApp app, FilterPostProcessor fpp) {
*
* @return The {@link Vector3f} representing the node's location.
*/
public Vector3f getLocation(){
public Vector3f getLocation() {
return this.getSpatial().getLocalTranslation();
}
public void highlight(){
public void highlight() {
highlight = true;
super.outline(OUTLINE_HIGHLIGHT_COLOR, OUTLINE_HIGHLIGHT_WIDTH);
}
public void unHighlight(){
public void unHighlight() {
highlight = false;
deOutline();
}
public void select(){
public void select() {
select = true;
super.outline(OUTLINE_SELECT_COLOR, OUTLINE_SELECT_WIDTH);
}
public void unSelect(){
public void unSelect() {
select = false;
if(highlight) highlight();
if (highlight) highlight();
else deOutline();
}
public void hover(){
public void hover() {
super.outline(OUTLINE_HOVER_COLOR, OUTLINE_HOVER_WIDTH);
}
public void hoverOff(){
if(select) select();
else if(highlight) highlight();
public void hoverOff() {
if (select) select();
else if (highlight) highlight();
else deOutline();
}
}

View File

@@ -3,8 +3,8 @@
import com.jme3.math.ColorRGBA;
import com.jme3.post.FilterPostProcessor;
import com.jme3.renderer.Camera;
import pp.mdga.client.MdgaApp;
import pp.mdga.client.InitControl;
import pp.mdga.client.MdgaApp;
import pp.mdga.client.outline.SelectObjectOutliner;
/**
@@ -13,7 +13,9 @@
* object, allowing it to be highlighted or deselected.
*/
public class OutlineControl extends InitControl {
/** The {@link SelectObjectOutliner} responsible for managing the outline effect. */
/**
* The {@link SelectObjectOutliner} responsible for managing the outline effect.
*/
private final SelectObjectOutliner outlineOwn;
private static final int THICKNESS_DEFAULT = 6;
private MdgaApp app;
@@ -24,7 +26,7 @@ public class OutlineControl extends InitControl {
* @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;
outlineOwn = new SelectObjectOutliner(THICKNESS_DEFAULT, fpp, app.getRenderManager(), app.getAssetManager(), app.getCamera(), app);
}
@@ -36,7 +38,7 @@ public OutlineControl(MdgaApp app, FilterPostProcessor fpp){
* @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;
outlineOwn = new SelectObjectOutliner(THICKNESS_DEFAULT, fpp, app.getRenderManager(), app.getAssetManager(), cam, app);
}
@@ -49,7 +51,7 @@ public OutlineControl(MdgaApp app, FilterPostProcessor fpp, Camera cam){
* @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;
outlineOwn = new SelectObjectOutliner(thickness, fpp, app.getRenderManager(), app.getAssetManager(), cam, app);
}
@@ -59,7 +61,7 @@ public OutlineControl(MdgaApp app, FilterPostProcessor fpp, Camera cam, int thic
*
* @param color The {@link ColorRGBA} representing the color of the outline.
*/
public void outline(ColorRGBA color){
public void outline(ColorRGBA color) {
outlineOwn.select(spatial, color);
}
@@ -69,7 +71,7 @@ public void outline(ColorRGBA color){
* @param color The {@link ColorRGBA} representing the color of the outline.
* @param width The width of the outline.
*/
public void outline(ColorRGBA color, int width){
public void outline(ColorRGBA color, int width) {
deOutline();
outlineOwn.select(spatial, color, width);
}
@@ -77,7 +79,7 @@ public void outline(ColorRGBA color, int width){
/**
* Removes the outline effect from the spatial object.
*/
public void deOutline(){
public void deOutline() {
outlineOwn.deselect(spatial);
}

View File

@@ -55,10 +55,10 @@ public class PieceControl extends OutlineControl {
*
* @param initRotation The initial rotation of the piece in degrees.
* @param assetManager The {@link AssetManager} used for loading models and materials.
* @param app The {@link MdgaApp} instance to use for the application context.
* @param fpp The {@link FilterPostProcessor} to apply post-processing effects.
* @param app The {@link MdgaApp} instance to use for the application context.
* @param fpp The {@link FilterPostProcessor} to apply post-processing effects.
*/
public PieceControl(float initRotation, AssetManager assetManager, MdgaApp app, FilterPostProcessor fpp){
public PieceControl(float initRotation, AssetManager assetManager, MdgaApp app, FilterPostProcessor fpp) {
super(app, fpp);
this.parentNode = new Node();
this.initRotation = initRotation;
@@ -79,7 +79,7 @@ public PieceControl(float initRotation, AssetManager assetManager, MdgaApp app,
* @return The rotation of the piece in degrees.
*/
public float getRotation() {
return (float) Math.toDegrees(spatial.getLocalRotation().toAngleAxis(new Vector3f(0,0,1)));
return (float) Math.toDegrees(spatial.getLocalRotation().toAngleAxis(new Vector3f(0, 0, 1)));
}
/**
@@ -87,11 +87,11 @@ public float getRotation() {
*
* @param rot The rotation in degrees to set.
*/
public void setRotation(float rot){
if(rot < 0) rot =- 360;
public void setRotation(float rot) {
if (rot < 0) rot = -360;
Quaternion quaternion = new Quaternion();
quaternion.fromAngleAxis((float) Math.toRadians(rot), new Vector3f(0,0,1));
quaternion.fromAngleAxis((float) Math.toRadians(rot), new Vector3f(0, 0, 1));
spatial.setLocalRotation(quaternion);
}
@@ -100,7 +100,7 @@ public void setRotation(float rot){
*
* @return The location of the piece as a {@link Vector3f}.
*/
public Vector3f getLocation(){
public Vector3f getLocation() {
return spatial.getLocalTranslation();
}
@@ -111,9 +111,9 @@ public Vector3f getLocation(){
*/
@Override
protected void controlUpdate(float delta) {
if(shieldRing != null){
if (shieldRing != null) {
shieldRing.rotate(0, 0, delta * SHIELD_SPEED);
shieldRing.setLocalTranslation(spatial.getLocalTranslation().add(new Vector3f(0,0,SHIELD_Z)));
shieldRing.setLocalTranslation(spatial.getLocalTranslation().add(new Vector3f(0, 0, SHIELD_Z)));
}
}
@@ -122,7 +122,7 @@ protected void controlUpdate(float delta) {
*
* @param loc The location to set as a {@link Vector3f}.
*/
public void setLocation(Vector3f loc){
public void setLocation(Vector3f loc) {
this.spatial.setLocalTranslation(loc);
}
@@ -131,7 +131,7 @@ public void setLocation(Vector3f loc){
* This also moves the spatial to a new parent node for organizational purposes.
*/
@Override
public void initSpatial(){
public void initSpatial() {
setRotation(this.initRotation);
Node oldParent = spatial.getParent();
@@ -149,14 +149,14 @@ public void rotateInit() {
* Activates the shield around the piece.
* This adds a visual shield effect in the form of a rotating ring.
*/
public void activateShield(){
if(shieldRing != null){
public void activateShield() {
if (shieldRing != null) {
deactivateShield();
}
shieldRing = assetManager.loadModel(Asset.shieldRing.getModelPath());
shieldRing.scale(1f);
shieldRing.rotate((float) Math.toRadians(0), 0, (float) Math.toRadians(0));
shieldRing.setLocalTranslation(spatial.getLocalTranslation().add(new Vector3f(0,0,SHIELD_Z)));
shieldRing.setLocalTranslation(spatial.getLocalTranslation().add(new Vector3f(0, 0, SHIELD_Z)));
shieldRing.setQueueBucket(RenderQueue.Bucket.Transparent); // Render in the transparent bucket
@@ -170,7 +170,7 @@ public void activateShield(){
* Deactivates the shield by removing the shield ring from the scene.
*/
public void deactivateShield(){
public void deactivateShield() {
parentNode.detachChild(shieldRing);
shieldRing = null;
}
@@ -178,16 +178,16 @@ public void deactivateShield(){
/**
* Suppresses the shield, changing its color to a suppressed state.
*/
public void suppressShield(){
assert(shieldRing != null) : "PieceControl: shieldRing is not set";
public void suppressShield() {
assert (shieldRing != null) : "PieceControl: shieldRing is not set";
shieldMat.setColor("Color", SHIELD_SUPPRESSED_COLOR);
}
public void setMaterial(Material mat){
public void setMaterial(Material mat) {
spatial.setMaterial(mat);
}
public Material getMaterial(){
public Material getMaterial() {
return ((Geometry) getSpatial()).getMaterial();
}
@@ -205,7 +205,7 @@ public void highlight(boolean enemy) {
/**
* Removes the highlight effect from the piece.
*/
public void unHighlight(){
public void unHighlight() {
highlight = false;
deOutline();
}
@@ -213,19 +213,19 @@ public void unHighlight(){
/**
* Applies a hover effect on the piece if it is hoverable.
*/
public void hover(){
if(!hoverable) return;
public void hover() {
if (!hoverable) return;
super.outline(enemy ? OUTLINE_ENEMY_HOVER_COLOR : OUTLINE_OWN_HOVER_COLOR, OUTLINE_HOVER_WIDTH);
}
/**
* Removes the hover effect from the piece.
*/
public void hoverOff(){
if(!hoverable) return;
public void hoverOff() {
if (!hoverable) return;
if(select) select();
else if(highlight) highlight(enemy);
if (select) select();
else if (highlight) highlight(enemy);
else deOutline();
}
@@ -233,9 +233,9 @@ public void hoverOff(){
* Deselects the piece and removes the selection outline. If the piece was highlighted,
* it will be re-highlighted. Otherwise, the outline is removed.
*/
public void unSelect(){
public void unSelect() {
select = false;
if(highlight) highlight(enemy);
if (highlight) highlight(enemy);
else deOutline();
}
@@ -243,8 +243,8 @@ public void unSelect(){
* Selects the piece and applies the selection outline. If the piece is an enemy, it will
* be outlined with the enemy selection color; otherwise, the own selection color will be used.
*/
public void select(){
if(!selectable) return;
public void select() {
if (!selectable) return;
select = true;
super.outline(enemy ? OUTLINE_ENEMY_SELECT_COLOR : OUTLINE_OWN_SELECT_COLOR, OUTLINE_SELECT_WIDTH);
}
@@ -254,7 +254,7 @@ public void select(){
*
* @param selectable True if the piece can be selected, false otherwise.
*/
public void setSelectable(boolean selectable){
public void setSelectable(boolean selectable) {
this.selectable = selectable;
}
@@ -263,7 +263,9 @@ public void setSelectable(boolean selectable){
*
* @return True if the piece is selected, false otherwise.
*/
public boolean isSelected() { return select; }
public boolean isSelected() {
return select;
}
/**
* Checks if the piece is selectable.

View File

@@ -37,9 +37,9 @@ protected void controlUpdate(float tpf) {
// Apply the interpolated rotation to the spatial
spatial.setLocalRotation(interpolatedRotation);
if(t >= 1){
if (t >= 1) {
rotating = false;
if(actionAfter != null) actionAfter.run();
if (actionAfter != null) actionAfter.run();
}
}
@@ -62,7 +62,7 @@ public void rotate(Vector3f enemyPos, Runnable actionAfter) {
this.actionAfter = actionAfter; // Store the action to execute after rotation
}
private float getEnemyAngle(Vector3f enemyPos){
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

View File

@@ -115,7 +115,7 @@ public abstract class AbstractButton {
* Constructs an AbstractButton instance with the specified application context and scene node.
* Initializes the button's visual elements and font.
*
* @param app the application instance for accessing resources
* @param app the application instance for accessing resources
* @param node the node in the scene graph to which the button is attached
*/
public AbstractButton(MdgaApp app, Node node) {

View File

@@ -3,7 +3,6 @@
import com.jme3.math.Vector2f;
import com.jme3.scene.Node;
import pp.mdga.client.MdgaApp;
import com.jme3.ui.Picture;
/**
* Represents a specific implementation of a clickable button positioned on the left side.

View File

@@ -69,15 +69,16 @@ public enum Pos {
* Constructs a CeremonyButton with specified attributes such as type, position, and label.
* The button supports both 2D and 3D components for UI and visual effects.
*
* @param app the application instance for accessing resources and settings
* @param node the node in the scene graph to which the button belongs
* @param app the application instance for accessing resources and settings
* @param node the node in the scene graph to which the button belongs
* @param node3d the node for 3D scene components associated with this button
* @param tsk the type/color associated with the button
* @param pos the position of the button in the ceremony layout
* @param name the label or name displayed on the button
* @param tsk the type/color associated with the button
* @param pos the position of the button in the ceremony layout
* @param name the label or name displayed on the button
*/
public CeremonyButton(MdgaApp app, Node node, Node node3d, Color tsk, Pos pos, String name) {
super(app, node, () -> {}, "", new Vector2f(WIDTH, 7), new Vector2f(0, 0));
super(app, node, () -> {
}, "", new Vector2f(WIDTH, 7), new Vector2f(0, 0));
this.node3d = node3d;
@@ -217,9 +218,9 @@ public void update(float tpf) {
}
model.setLocalRotation(new Quaternion().fromAngles(
(float) Math.toRadians(90),
(float) Math.toRadians(rot),
(float) Math.toRadians(180)
(float) Math.toRadians(90),
(float) Math.toRadians(rot),
(float) Math.toRadians(180)
));
}
@@ -236,9 +237,9 @@ private void createModel(Asset asset, Vector3f pos) {
model = app.getAssetManager().loadModel(modelName);
model.scale(asset.getSize() / 2);
model.rotate(
(float) Math.toRadians(90),
(float) Math.toRadians(rot),
(float) Math.toRadians(180)
(float) Math.toRadians(90),
(float) Math.toRadians(rot),
(float) Math.toRadians(180)
);
model.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);

View File

@@ -41,12 +41,12 @@ public abstract class ClickButton extends AbstractButton {
/**
* Constructs a ClickButton with the specified properties.
*
* @param app the application instance for accessing resources
* @param node the node in the scene graph to which the button belongs
* @param app the application instance for accessing resources
* @param node the node in the scene graph to which the button belongs
* @param action the action to execute on button click
* @param label the text label displayed on the button
* @param size the size of the button
* @param pos the position of the button in relative units
* @param label the text label displayed on the button
* @param size the size of the button
* @param pos the position of the button in relative units
*/
ClickButton(MdgaApp app, Node node, Runnable action, String label, Vector2f size, Vector2f pos) {
super(app, node);
@@ -203,9 +203,9 @@ protected void setImageRelative(Picture picture) {
picture.setHeight(instance.getPreferredSize().y + larger);
picture.setLocalTranslation(
instance.getLocalTranslation().x - larger / 2,
(instance.getLocalTranslation().y - picture.getHeight()) + larger / 2,
instance.getLocalTranslation().z + 0.01f
instance.getLocalTranslation().x - larger / 2,
(instance.getLocalTranslation().y - picture.getHeight()) + larger / 2,
instance.getLocalTranslation().z + 0.01f
);
}
}

View File

@@ -38,7 +38,8 @@ public class LabelButton extends ClickButton {
* @param isButton whether this component acts as a button or a simple label
*/
public LabelButton(MdgaApp app, Node node, String label, Vector2f size, Vector2f pos, boolean isButton) {
super(app, node, () -> {}, label, size, pos);
super(app, node, () -> {
}, label, size, pos);
this.isButton = isButton;

View File

@@ -1,17 +1,13 @@
package pp.mdga.client.button;
import com.jme3.light.AmbientLight;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector2f;
import com.jme3.math.Vector3f;
import com.jme3.renderer.queue.RenderQueue;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.scene.shape.Quad;
import com.jme3.texture.Texture;
import com.simsilica.lemur.component.QuadBackgroundComponent;
import pp.mdga.client.Asset;
import pp.mdga.client.MdgaApp;
@@ -101,11 +97,11 @@ public enum Taken {
/**
* Constructs a LobbyButton with specified properties, including a 3D model and label.
*
* @param app the application instance for accessing resources
* @param node the node in the scene graph to which the button belongs
* @param node3d the node for 3D scene components associated with this button
* @param action the action to execute when the button is clicked
* @param tsk the type or category of the button (e.g., CYBER, AIRFORCE)
* @param app the application instance for accessing resources
* @param node the node in the scene graph to which the button belongs
* @param node3d the node for 3D scene components associated with this button
* @param action the action to execute when the button is clicked
* @param tsk the type or category of the button (e.g., CYBER, AIRFORCE)
*/
public LobbyButton(MdgaApp app, Node node, Node node3d, Runnable action, Color tsk) {
super(app, node, action, "", new Vector2f(WIDTH, 7), new Vector2f(0, 0));
@@ -261,9 +257,9 @@ public void update(float tpf) {
}
model.setLocalRotation(new Quaternion().fromAngles(
(float) Math.toRadians(90),
(float) Math.toRadians(rot),
(float) Math.toRadians(180)
(float) Math.toRadians(90),
(float) Math.toRadians(rot),
(float) Math.toRadians(180)
));
}
@@ -280,9 +276,9 @@ private void createModel(Asset asset, Vector3f pos) {
model = app.getAssetManager().loadModel(modelName);
model.scale(asset.getSize() / 2);
model.rotate(
(float) Math.toRadians(90),
(float) Math.toRadians(rot),
(float) Math.toRadians(180)
(float) Math.toRadians(90),
(float) Math.toRadians(rot),
(float) Math.toRadians(180)
);
model.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);

View File

@@ -13,10 +13,10 @@ public class MenuButton extends ClickButton {
/**
* Constructs a MenuButton with specified properties.
*
* @param app the application instance for accessing resources
* @param node the node in the scene graph to which the button belongs
* @param action the action to execute when the button is clicked
* @param label the text label displayed on the button
* @param app the application instance for accessing resources
* @param node the node in the scene graph to which the button belongs
* @param action the action to execute when the button is clicked
* @param label the text label displayed on the button
*/
public MenuButton(MdgaApp app, Node node, Runnable action, String label) {
super(app, node, action, label, new Vector2f(5.5f, 2), new Vector2f(0, 0));

View File

@@ -2,8 +2,6 @@
import com.jme3.math.Vector2f;
import com.jme3.scene.Node;
import com.simsilica.lemur.HAlignment;
import com.simsilica.lemur.VAlignment;
import com.simsilica.lemur.component.IconComponent;
import pp.mdga.client.MdgaApp;

View File

@@ -91,7 +91,7 @@ protected void onHide() {
* This method is called continuously while the dialog is active.
*/
public void update() {
if(!active) {
if (!active) {
return;
}

View File

@@ -88,7 +88,7 @@ public void addStatisticsRow(String name, int v1, int v2, int v3, int v4, int v5
int j = 0;
for (LabelButton b : row) {
if(j > 0) {
if (j > 0) {
b.setColor(colorText, colorButton);
}

View File

@@ -1,7 +1,6 @@
package pp.mdga.client.dialog;
import com.jme3.scene.Node;
import com.simsilica.lemur.Container;
import pp.mdga.client.MdgaApp;
/**

View File

@@ -16,7 +16,7 @@
* 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 ButtonRight hostButton;

View File

@@ -3,11 +3,9 @@
import com.jme3.math.Vector2f;
import com.jme3.scene.Node;
import pp.mdga.client.MdgaApp;
import pp.mdga.client.button.AbstractButton;
import pp.mdga.client.button.ButtonRight;
import pp.mdga.client.button.LabelButton;
import pp.mdga.client.button.MenuButton;
import pp.mdga.client.view.MdgaView;
import pp.mdga.game.Color;
/**
@@ -39,7 +37,7 @@ public InterruptDialog(MdgaApp app, Node node) {
@Override
protected void onShow() {
if(app.getGameLogic().isHost()) {
if (app.getGameLogic().isHost()) {
forceButton.show();
}

View File

@@ -4,7 +4,6 @@
import com.jme3.scene.Node;
import pp.mdga.client.MdgaApp;
import pp.mdga.client.NetworkSupport;
import pp.mdga.client.acoustic.AcousticHandler;
import pp.mdga.client.button.ButtonLeft;
import pp.mdga.client.button.ButtonRight;
import pp.mdga.client.button.InputButton;

View File

@@ -25,9 +25,9 @@ public abstract class NetworkDialog extends Dialog {
/**
* 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.
* @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) {
super(app, node);

View File

@@ -3,9 +3,7 @@
import com.jme3.math.Vector2f;
import com.jme3.scene.Node;
import pp.mdga.client.MdgaApp;
import pp.mdga.client.button.InputButton;
import pp.mdga.client.button.MenuButton;
import pp.mdga.client.view.MainView;
import pp.mdga.client.view.MdgaView;
/**

View File

@@ -1,18 +1,13 @@
package pp.mdga.client.dialog;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector2f;
import com.jme3.math.Vector3f;
import com.jme3.scene.Node;
import com.simsilica.lemur.Container;
import com.simsilica.lemur.component.QuadBackgroundComponent;
import pp.mdga.client.MdgaApp;
import pp.mdga.client.button.InputButton;
import pp.mdga.client.button.MenuButton;
import pp.mdga.client.view.MainView;
import java.util.Random;
import java.util.random.RandomGenerator;
/**
* The {@code StartDialog} class represents the initial dialog in the application,
@@ -75,8 +70,7 @@ protected void onShow() {
* Called when the dialog is hidden. Hides the name input field and all buttons.
*/
@Override
protected void onHide ()
{
protected void onHide() {
nameInput.hide();
hostButton.hide();
@@ -101,210 +95,210 @@ public String getName() {
if (name == null || name.trim().isEmpty()) {
String[] names = {
"PixelPirat",
"NoobJäger",
"LagMeister",
"KnopfDrücker",
"SpawnCamper",
"AFKHeld",
"RageQuitter",
"GameOverPro",
"Checkpoint",
"RespawnHeld",
"Teebeutel",
"GlitchHexer",
"QuickScope",
"LootSammler",
"EpicLauch",
"KartoffelPro",
"StilleKlinge",
"TastenHeld",
"PixelKrieger",
"HacknSlash",
"JoystickJoe",
"SpawnFalle",
"OneHitWanda",
"CamperKing",
"GameGenie",
"HighPing",
"CheesePro",
"Speedy",
"GigaGamer",
"LevelNoob",
"SkillTobi",
"HeadshotMax",
"PentaPaul",
"CritKarl",
"ManaLeerer",
"Nachlader",
"ClutchKönig",
"FriendlyFe",
"ZonenHeld",
"SchleichKatze",
"ShotgunPro",
"SniperUdo",
"BossHunter",
"HeldenNoob",
"KillFranz",
"FragKarl",
"TeamNiete",
"LootPaul",
"UltraNoob",
"ProfiScout",
"PunkteKlaus",
"KrüppelKill",
"PixelNinja",
"NoobCrusher",
"LagBoss",
"SpawnKing",
"AFKSlayer",
"RespawnPro",
"Killjoy",
"GameBreaker",
"FastFingers",
"LootKing",
"QuickFlick",
"SilentShot",
"HackGod",
"GlitchHero",
"SpeedyBot",
"AimWizard",
"FragMaster",
"OneTapPro",
"KnifeLord",
"MetaHunter",
"PingWarrior",
"KeyBash",
"ClutchPro",
"ScopeBot",
"TrollMage",
"PowerLooter",
"TankHero",
"CampLord",
"SmurfSlayer",
"SkillThief",
"SniperGod",
"LevelHack",
"GhostAim",
"BossTamer",
"ShotgunJoe",
"AimRider",
"KillCount",
"PixelManiac",
"TrollOver",
"SneakPro",
"ReloadKing",
"SpawnTrap",
"LagLover",
"MetaHater",
"BoomMaker",
"WipeLord",
"CarryPro",
"ProBaiter",
"GameWarden",
"KartoffelKönig",
"SaufenderWolf",
"WurstGriller",
"Flitzekacke",
"BratwurstBub",
"Hoppeldoppels",
"BananenMensch",
"KlopapierGuru",
"SchnitzelKing",
"NerdNomade",
"Dönertänzer",
"GlitzerGurke",
"SchinkenShrek",
"KäseKalle",
"SchokoSchnecke",
"KeksKämpfer",
"QuarkPiraten",
"Müslimonster",
"KnuddelNase",
"FantaFighter",
"SchnapsSaurier",
"Wackelpudding",
"ZitronenZock",
"FettWurst",
"PlüschPanda",
"Zuckerschnur",
"FluffiKopf",
"DonutDöner",
"VollpfostenX",
"Waschlappen",
"Witzepumper",
"ToastTraum",
"FroschFighter",
"KrümelTiger",
"RegenWolke",
"PuddingPower",
"KoffeinKrieger",
"SpeckSchlumpf",
"SuperSuppe",
"BierBärchen",
"FischBär",
"Flauschi",
"Schokomonster",
"ChaosKäse",
"FlitzLappen",
"WurstWombat",
"KrümelMensch",
"PuddingBär",
"ZickZack",
"Schwabel",
"Fluffi",
"RülpsFrosch",
"PommesPapa",
"QuarkBär",
"KnusperKönig",
"ToastBrot",
"Ploppster",
"Schleimschwein",
"Äpfelchen",
"Knallbonbon",
"KaffeeKopf",
"WackelWurst",
"RennKeks",
"BröselBub",
"ZockerBrot",
"BierWurm",
"StinkFlummi",
"SchlumpfKing",
"PurzelBär",
"FlinkFluff",
"PloppPudel",
"Schnorchel",
"FliegenKopf",
"PixelPommes",
"SchwipsWürst",
"WutzBär",
"KnuddelKeks",
"FantaFlumm",
"ZockerKäse",
"LachHäufchen",
"GurkenGuru",
"PonySchnitzel",
"NudelNinja",
"VulkanKeks",
"WasserToast",
"MenschSalat",
"KampfKohl",
"SockenZirkus",
"SchwimmBärchen",
"TanzenderPudel",
"PizzamarktMensch",
"ZahnarztZocker",
"RollerRudi",
"PupsPilot",
"WitzigeZwiebel",
"Pillenschlucker",
"ZwiebelReiter",
"HüpfenderKaktus",
"AsteroidenAlf",
"ChaosKarotte",
"WolkenFurz",
"Krümelmonster",
"WackelBiene",
"PixelPirat",
"NoobJäger",
"LagMeister",
"KnopfDrücker",
"SpawnCamper",
"AFKHeld",
"RageQuitter",
"GameOverPro",
"Checkpoint",
"RespawnHeld",
"Teebeutel",
"GlitchHexer",
"QuickScope",
"LootSammler",
"EpicLauch",
"KartoffelPro",
"StilleKlinge",
"TastenHeld",
"PixelKrieger",
"HacknSlash",
"JoystickJoe",
"SpawnFalle",
"OneHitWanda",
"CamperKing",
"GameGenie",
"HighPing",
"CheesePro",
"Speedy",
"GigaGamer",
"LevelNoob",
"SkillTobi",
"HeadshotMax",
"PentaPaul",
"CritKarl",
"ManaLeerer",
"Nachlader",
"ClutchKönig",
"FriendlyFe",
"ZonenHeld",
"SchleichKatze",
"ShotgunPro",
"SniperUdo",
"BossHunter",
"HeldenNoob",
"KillFranz",
"FragKarl",
"TeamNiete",
"LootPaul",
"UltraNoob",
"ProfiScout",
"PunkteKlaus",
"KrüppelKill",
"PixelNinja",
"NoobCrusher",
"LagBoss",
"SpawnKing",
"AFKSlayer",
"RespawnPro",
"Killjoy",
"GameBreaker",
"FastFingers",
"LootKing",
"QuickFlick",
"SilentShot",
"HackGod",
"GlitchHero",
"SpeedyBot",
"AimWizard",
"FragMaster",
"OneTapPro",
"KnifeLord",
"MetaHunter",
"PingWarrior",
"KeyBash",
"ClutchPro",
"ScopeBot",
"TrollMage",
"PowerLooter",
"TankHero",
"CampLord",
"SmurfSlayer",
"SkillThief",
"SniperGod",
"LevelHack",
"GhostAim",
"BossTamer",
"ShotgunJoe",
"AimRider",
"KillCount",
"PixelManiac",
"TrollOver",
"SneakPro",
"ReloadKing",
"SpawnTrap",
"LagLover",
"MetaHater",
"BoomMaker",
"WipeLord",
"CarryPro",
"ProBaiter",
"GameWarden",
"KartoffelKönig",
"SaufenderWolf",
"WurstGriller",
"Flitzekacke",
"BratwurstBub",
"Hoppeldoppels",
"BananenMensch",
"KlopapierGuru",
"SchnitzelKing",
"NerdNomade",
"Dönertänzer",
"GlitzerGurke",
"SchinkenShrek",
"KäseKalle",
"SchokoSchnecke",
"KeksKämpfer",
"QuarkPiraten",
"Müslimonster",
"KnuddelNase",
"FantaFighter",
"SchnapsSaurier",
"Wackelpudding",
"ZitronenZock",
"FettWurst",
"PlüschPanda",
"Zuckerschnur",
"FluffiKopf",
"DonutDöner",
"VollpfostenX",
"Waschlappen",
"Witzepumper",
"ToastTraum",
"FroschFighter",
"KrümelTiger",
"RegenWolke",
"PuddingPower",
"KoffeinKrieger",
"SpeckSchlumpf",
"SuperSuppe",
"BierBärchen",
"FischBär",
"Flauschi",
"Schokomonster",
"ChaosKäse",
"FlitzLappen",
"WurstWombat",
"KrümelMensch",
"PuddingBär",
"ZickZack",
"Schwabel",
"Fluffi",
"RülpsFrosch",
"PommesPapa",
"QuarkBär",
"KnusperKönig",
"ToastBrot",
"Ploppster",
"Schleimschwein",
"Äpfelchen",
"Knallbonbon",
"KaffeeKopf",
"WackelWurst",
"RennKeks",
"BröselBub",
"ZockerBrot",
"BierWurm",
"StinkFlummi",
"SchlumpfKing",
"PurzelBär",
"FlinkFluff",
"PloppPudel",
"Schnorchel",
"FliegenKopf",
"PixelPommes",
"SchwipsWürst",
"WutzBär",
"KnuddelKeks",
"FantaFlumm",
"ZockerKäse",
"LachHäufchen",
"GurkenGuru",
"PonySchnitzel",
"NudelNinja",
"VulkanKeks",
"WasserToast",
"MenschSalat",
"KampfKohl",
"SockenZirkus",
"SchwimmBärchen",
"TanzenderPudel",
"PizzamarktMensch",
"ZahnarztZocker",
"RollerRudi",
"PupsPilot",
"WitzigeZwiebel",
"Pillenschlucker",
"ZwiebelReiter",
"HüpfenderKaktus",
"AsteroidenAlf",
"ChaosKarotte",
"WolkenFurz",
"Krümelmonster",
"WackelBiene",
};
Random random = new Random();

View File

@@ -3,7 +3,6 @@
import com.jme3.math.Vector2f;
import com.jme3.scene.Node;
import pp.mdga.client.MdgaApp;
import pp.mdga.client.button.AbstractButton;
import pp.mdga.client.button.ButtonLeft;
import pp.mdga.client.button.ButtonRight;
import pp.mdga.client.button.MenuButton;
@@ -122,7 +121,7 @@ protected void onHide() {
* Updates the dialog's state. This method can be used for periodic updates while the dialog is active.
*/
public void update() {
if(!active) {
if (!active) {
return;
}
}
@@ -130,13 +129,13 @@ public void update() {
/**
* 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.
* @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) {
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();
}

View File

@@ -14,7 +14,7 @@
* 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 BitmapFont font;
private AppSettings appSettings;
@@ -29,7 +29,7 @@ class ActionTextHandler {
* @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");
guiNode.attachChild(root);
@@ -50,12 +50,12 @@ class ActionTextHandler {
* @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) {
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");
Node textNode = new Node("TextWithSpacing");
Node center = new Node();
float xOffset = 0;
for(int i = 0; i < textArr.length; i++){
for (int i = 0; i < textArr.length; i++) {
String text = textArr[i];
ColorRGBA color = colorArr[i];
for (char c : text.toCharArray()) {
@@ -63,14 +63,14 @@ private Node createTextWithSpacing(String[] textArr, float spacing, float size,
letter.setColor(color);
letter.setSize(size);
letter.setText(Character.toString(c));
letter.setLocalTranslation(xOffset, letter.getHeight()/2, 0);
letter.setLocalTranslation(xOffset, letter.getHeight() / 2, 0);
center.attachChild(letter);
xOffset += letter.getLineWidth() + spacing;
}
}
center.setLocalTranslation(new Vector3f(-xOffset/2,0,0));
center.setLocalTranslation(new Vector3f(-xOffset / 2, 0, 0));
textNode.attachChild(center);
return textNode;
}
@@ -96,8 +96,8 @@ private Node createTextWithSpacing(String text, float spacing, float size, Color
* @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){
return new Vector3f(pos.x+width/2, pos.y+height/2,0);
private Vector3f center(float width, float height, Vector3f pos) {
return new Vector3f(pos.x + width / 2, pos.y + height / 2, 0);
}
/**
@@ -110,7 +110,7 @@ private Vector3f center(float width, float height, Vector3f pos){
* @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);
}
@@ -124,9 +124,9 @@ private Node createTopText(String name, float spacing, float size, ColorRGBA col
* @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);
text.setLocalTranslation(0, (appSettings.getHeight()/2f)*0.8f-top,0);
text.setLocalTranslation(0, (appSettings.getHeight() / 2f) * 0.8f - top, 0);
root.attachChild(text);
return text;
}
@@ -139,7 +139,7 @@ private Node createTopText(String[] name, float spacing, float size, ColorRGBA c
* @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);
}
@@ -149,8 +149,8 @@ private Vector3f centerText(float width, float height, Vector3f pos){
* @param name The name of the active player.
* @param color The color representing the player's team.
*/
void activePlayer(String name, Color color){
createTopText(new String[]{name," ist dran"}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl());
void activePlayer(String name, Color color) {
createTopText(new String[]{name, " ist dran"}, 10, 90, new ColorRGBA[]{playerColorToColorRGBA(color), ColorRGBA.White}, 0).addControl(new ZoomControl());
}
/**
@@ -158,8 +158,8 @@ void activePlayer(String name, Color color){
*
* @param color The color representing the player's team.
*/
void ownActive(Color color){
createTopText(new String[]{"Du"," bist dran"}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl());
void ownActive(Color color) {
createTopText(new String[]{"Du", " bist dran"}, 10, 90, new ColorRGBA[]{playerColorToColorRGBA(color), ColorRGBA.White}, 0).addControl(new ZoomControl());
}
/**
@@ -169,8 +169,8 @@ void ownActive(Color color){
* @param name The name of the player.
* @param color The color representing the player's team.
*/
void diceNum(int diceNum, String name, Color color){
createTopText(new String[]{name," würfelt:"}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0);
void diceNum(int diceNum, String name, Color color) {
createTopText(new String[]{name, " würfelt:"}, 10, 90, new ColorRGBA[]{playerColorToColorRGBA(color), ColorRGBA.White}, 0);
createTopText(String.valueOf(diceNum), 10, 100, ColorRGBA.White, 100);
@@ -184,10 +184,10 @@ void diceNum(int diceNum, String name, Color color){
* @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){
createTopText(new String[]{name," würfelt:"}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0);
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[]{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);
}
/**
@@ -195,7 +195,7 @@ void diceNumMult(int diceNum,int mult, String name, Color color){
*
* @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);
}
@@ -205,8 +205,8 @@ void ownDice(int diceNum){
* @param diceNum The number rolled on the dice.
* @param mult The multiplier applied to the dice result.
*/
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);
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);
}
/**
@@ -215,8 +215,8 @@ void ownDiceMult(int diceNum, int mult){
* @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){
createTopText(new String[]{name," erhält eine Bonuskarte"}, 7,70, new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl());
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());
}
/**
@@ -224,8 +224,8 @@ void drawCard(String name, Color color){
*
* @param color The color representing the player's team.
*/
void drawCardOwn(Color color){
createTopText(new String[]{"Du"," erhälst eine Bonuskarte"}, 5,70, new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl());
void drawCardOwn(Color color) {
createTopText(new String[]{"Du", " erhälst eine Bonuskarte"}, 5, 70, new ColorRGBA[]{playerColorToColorRGBA(color), ColorRGBA.White}, 0).addControl(new ZoomControl());
}
/**
@@ -234,8 +234,8 @@ void drawCardOwn(Color color){
* @param name The name of the player who finished.
* @param color The color representing the player's team.
*/
void finishText(String name, Color color){
createTopText(new String[]{name," ist fertig!"}, 7,70, new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl());
void finishText(String name, Color color) {
createTopText(new String[]{name, " ist fertig!"}, 7, 70, new ColorRGBA[]{playerColorToColorRGBA(color), ColorRGBA.White}, 0).addControl(new ZoomControl());
}
/**
@@ -243,8 +243,8 @@ void finishText(String name, Color color){
*
* @param color The color representing the player's team.
*/
void finishTextOwn(Color color){
createTopText(new String[]{"Du", " bist fertig!"}, 7,70, new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl());
void finishTextOwn(Color color) {
createTopText(new String[]{"Du", " bist fertig!"}, 7, 70, new ColorRGBA[]{playerColorToColorRGBA(color), ColorRGBA.White}, 0).addControl(new ZoomControl());
}
/**
@@ -254,8 +254,8 @@ void finishTextOwn(Color color){
* @return The corresponding {@code ColorRGBA}.
* @throws RuntimeException if the color is invalid.
*/
private ColorRGBA playerColorToColorRGBA(Color color){
return switch (color){
private ColorRGBA playerColorToColorRGBA(Color color) {
return switch (color) {
case ARMY -> ColorRGBA.Green;
case NAVY -> ColorRGBA.Blue;
case CYBER -> ColorRGBA.Orange;
@@ -267,9 +267,9 @@ private ColorRGBA playerColorToColorRGBA(Color color){
/**
* Hides all text messages displayed by the handler and resets the ranking counter.
*/
void hide(){
ranking = 0;
root.detachAllChildren();
void hide() {
ranking = 0;
root.detachAllChildren();
}
/**
@@ -279,8 +279,8 @@ void hide(){
* @param color The color representing the player's team.
* @param eye The dice roll result.
*/
void rollRankingResult(String name, Color color, int eye){
createTopText(new String[]{name,": "+eye}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, paddingRanked*ranking);
void rollRankingResult(String name, Color color, int eye) {
createTopText(new String[]{name, ": " + eye}, 10, 90, new ColorRGBA[]{playerColorToColorRGBA(color), ColorRGBA.White}, paddingRanked * ranking);
ranking++;
}
@@ -290,15 +290,15 @@ void rollRankingResult(String name, Color color, int eye){
* @param color The color representing the player's team.
* @param eye The dice roll result.
*/
void rollRankingResultOwn(Color color, int eye){
createTopText(new String[]{"Du",": "+eye}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, paddingRanked*ranking);
ranking++;
}
void rollRankingResultOwn(Color color, int eye) {
createTopText(new String[]{"Du", ": " + eye}, 10, 90, new ColorRGBA[]{playerColorToColorRGBA(color), ColorRGBA.White}, paddingRanked * ranking);
ranking++;
}
/**
* Displays a message prompting the player to roll the dice.
*/
void diceNow(){
createTopText("Klicke zum Würfeln", 5, 80, ColorRGBA.White, 0);
}
void diceNow() {
createTopText("Klicke zum Würfeln", 5, 80, ColorRGBA.White, 0);
}
}

View File

@@ -7,19 +7,12 @@
import com.jme3.math.Vector3f;
import com.jme3.post.FilterPostProcessor;
import com.jme3.renderer.Camera;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.control.AbstractControl;
import com.jme3.scene.shape.Box;
import com.jme3.scene.shape.Cylinder;
import com.jme3.scene.shape.Sphere;
import pp.mdga.client.MdgaApp;
import pp.mdga.client.board.OutlineControl;
import java.awt.*;
public class CardControl extends OutlineControl {
private static final ColorRGBA OUTLINE_COLOR = ColorRGBA.Yellow;
@@ -42,20 +35,20 @@ public class CardControl extends OutlineControl {
private Node root;
private BitmapText num;
public CardControl(MdgaApp app, FilterPostProcessor fpp, Camera cam, Node root){
public CardControl(MdgaApp app, FilterPostProcessor fpp, Camera cam, Node root) {
super(app, fpp, cam, OUTLINE_THICKNESS);
this.root = root;
Node rootNum = createNum();
rootNum.setLocalTranslation(new Vector3f(0.35f,0.8f,0));
rootNum.setLocalTranslation(new Vector3f(0.35f, 0.8f, 0));
root.attachChild(rootNum);
}
private Node createNum(){
private Node createNum() {
Node rootNum = new Node("root Num");
Geometry circle = new Geometry("circle", new Sphere(20,20,1));
circle.setLocalTranslation(new Vector3f(0.03f,0.01f,1));
Geometry circle = new Geometry("circle", new Sphere(20, 20, 1));
circle.setLocalTranslation(new Vector3f(0.03f, 0.01f, 1));
circle.setLocalScale(0.2f);
Material mat = new Material(getApp().getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", ColorRGBA.Black);
@@ -72,7 +65,7 @@ private Node createNum(){
return rootNum;
}
public void setNumCard(int num){
public void setNumCard(int num) {
this.num.setText(String.valueOf(num));
}
@@ -81,14 +74,14 @@ public Node getRoot() {
}
@Override
public void initSpatial(){
public void initSpatial() {
}
public void outline(){
public void outline() {
super.outline(OUTLINE_COLOR);
}
private final static Vector3f HIGHLIGHT_Y = new Vector3f(0,0.4f,0);
private final static Vector3f HIGHLIGHT_Y = new Vector3f(0, 0.4f, 0);
public void setHighlight() {
this.highlight = true;
@@ -100,39 +93,39 @@ public void highlight() {
super.outline(HIGHLIGHT_COLOR, HIGHLIGHT_WIDTH);
}
public void unHighlight(){
public void unHighlight() {
highlight = false;
root.setLocalTranslation(root.getLocalTranslation().subtract(HIGHLIGHT_Y));
deOutline();
}
public void hover(){
if(!hoverable) return;
public void hover() {
if (!hoverable) return;
super.outline(HOVER_COLOR, HOVER_WIDTH);
}
public void hoverOff(){
if(!hoverable) return;
public void hoverOff() {
if (!hoverable) return;
if(select) select();
else if(highlight) highlight();
if (select) select();
else if (highlight) highlight();
else deOutline();
}
public void select(){
if(!selectable) return;
public void select() {
if (!selectable) return;
select = true;
super.outline(SELECT_COLOR, SELECT_WIDTH);
}
public void unSelect(){
if(!selectable) return;
public void unSelect() {
if (!selectable) return;
select = false;
if(highlight) highlight();
if (highlight) highlight();
else deOutline();
}
public void setSelectable(boolean selectable){
public void setSelectable(boolean selectable) {
this.selectable = selectable;
}

View File

@@ -19,7 +19,8 @@
import com.jme3.texture.Image;
import com.jme3.texture.Texture2D;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
public class CardLayer extends AbstractAppState {
@@ -115,7 +116,7 @@ public void update(float tpf) {
}
public void addSpatial(Spatial card) {
if(root == null) cardBuffer.add(card);
if (root == null) cardBuffer.add(card);
else root.attachChild(card);
}

View File

@@ -66,7 +66,7 @@ public void rollDice(int rollNum, Runnable actionAfter) {
}
public void showDice() {
if(show) return;
if (show) return;
show = true;
cardLayer.addSpatial(diceControl.getSpatial());
diceControl.spin();
@@ -90,11 +90,11 @@ public void addCard(BonusCard card) {
updateCard();
}
public void removeCard(BonusCard card){
if(bonusCardControlMap.containsKey(card)){
public void removeCard(BonusCard card) {
if (bonusCardControlMap.containsKey(card)) {
bonusCardIntegerMap.put(card, bonusCardIntegerMap.get(card) - 1);
if(bonusCardIntegerMap.get(card) <= 0){
if (bonusCardIntegerMap.get(card) <= 0) {
bonusCardIntegerMap.remove(card);
cardOrder.remove(card);
}
@@ -113,14 +113,14 @@ public void clearSelectableCards() {
cardSelect = null;
}
private void updateCard(){
for(BonusCard card : bonusCardControlMap.keySet()){
private void updateCard() {
for (BonusCard card : bonusCardControlMap.keySet()) {
CardControl control = bonusCardControlMap.get(card);
cardLayer.deleteSpatial(control.getRoot());
}
bonusCardControlMap.clear();
for(int i = 0; i < cardOrder.size(); i++){
for (int i = 0; i < cardOrder.size(); i++) {
BonusCard card = cardOrder.get(i);
CardControl control = createCard(bonusToAsset(card), nextPos(i));
control.setNumCard(bonusCardIntegerMap.get(card));
@@ -159,19 +159,19 @@ public Camera getCardLayerCamera() {
return cardLayerCamera;
}
public void shield(){
public void shield() {
SymbolControl control = createSymbol(Asset.shieldSymbol);
cardLayer.addSpatial(control.getSpatial());
control.shield();
}
public void swap(){
public void swap() {
SymbolControl control = createSymbol(Asset.swapSymbol);
cardLayer.addSpatial(control.getSpatial());
control.swap();
}
public void turbo(){
public void turbo() {
SymbolControl control = createSymbol(Asset.turboSymbol);
cardLayer.addSpatial(control.getSpatial());
control.turbo();
@@ -218,7 +218,7 @@ public void test() {
addCard(BonusCard.SWAP);
}
private CardControl createCard(Asset card, Vector3f pos){
private CardControl createCard(Asset card, Vector3f pos) {
Node rootCard = new Node("Root Card");
Spatial spatial = app.getAssetManager().loadModel(card.getModelPath());
rootCard.attachChild(spatial);
@@ -227,26 +227,26 @@ private CardControl createCard(Asset card, Vector3f pos){
spatial.setMaterial(mat);
spatial.setLocalScale(1f);
rootCard.setLocalTranslation(pos);
spatial.rotate((float)Math.toRadians(90), (float)Math.toRadians(180), (float)Math.toRadians(180));
spatial.rotate((float) Math.toRadians(90), (float) Math.toRadians(180), (float) Math.toRadians(180));
spatial.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
CardControl control = new CardControl(app, fpp, cardLayer.getOverlayCam(), rootCard);
spatial.addControl(control);
return control;
}
private SymbolControl createSymbol(Asset asset){
private SymbolControl createSymbol(Asset asset) {
Spatial spatial = app.getAssetManager().loadModel(asset.getModelPath());
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
mat.setTexture("ColorMap", app.getAssetManager().loadTexture(asset.getDiffPath()));
spatial.setMaterial(mat);
spatial.setLocalScale(1f);
spatial.rotate((float)Math.toRadians(90), (float)Math.toRadians(180), (float)Math.toRadians(180));
spatial.rotate((float) Math.toRadians(90), (float) Math.toRadians(180), (float) Math.toRadians(180));
SymbolControl control = new SymbolControl();
spatial.addControl(control);
return control;
}
public CardLayer getCardLayer(){
public CardLayer getCardLayer() {
return cardLayer;
}
}

View File

@@ -13,8 +13,6 @@
import pp.mdga.client.Asset;
import pp.mdga.client.MdgaApp;
import java.util.Random;
import static com.jme3.material.Materials.LIGHTING;
import static com.jme3.material.Materials.UNSHADED;
@@ -33,7 +31,7 @@ public class DiceControl extends AbstractControl {
private final AssetManager assetManager;
private Runnable actionAfter;
public DiceControl(AssetManager assetManager){
public DiceControl(AssetManager assetManager) {
this.assetManager = assetManager;
}
@@ -42,7 +40,7 @@ public DiceControl(AssetManager assetManager){
protected void controlUpdate(float tpf) {
float clampedTpf = Math.min(tpf, 0.05f); // Max 50 ms per frame
if (isRolling) {
if(!slerp) {
if (!slerp) {
// Apply rotational velocity to the dice
spinWithAngularVelocity(clampedTpf);
@@ -55,8 +53,7 @@ protected void controlUpdate(float tpf) {
if (angularVelocity.lengthSquared() <= 3f || MdgaApp.DEBUG_MULTIPLIER == 0) {
slerp = true;
}
}
else {
} else {
timeElapsed += clampedTpf * rollDuration;
@@ -66,18 +63,18 @@ protected void controlUpdate(float tpf) {
spatial.setLocalRotation(interpolated);
// Stop rolling once duration is complete
if (timeElapsed >= 1.0f * MdgaApp.DEBUG_MULTIPLIER) {
if (timeElapsed >= 1.0f * MdgaApp.DEBUG_MULTIPLIER) {
isRolling = false;
slerp = false;
actionAfter.run();
}
}
} else if(spin){
} else if (spin) {
spinWithAngularVelocity(clampedTpf);
}
}
private void spinWithAngularVelocity(float tpf){
private void spinWithAngularVelocity(float tpf) {
Quaternion currentRotation = spatial.getLocalRotation();
Quaternion deltaRotation = new Quaternion();
deltaRotation.fromAngles(
@@ -100,9 +97,9 @@ public void rollDice(int diceNum, Runnable actionAfter) {
timeElapsed = 0;
this.actionAfter = actionAfter;
angularVelocity.set(
FastMath.nextRandomInt(ANGULAR_MIN,ANGULAR_MAX),
FastMath.nextRandomInt(ANGULAR_MIN,ANGULAR_MAX),
FastMath.nextRandomInt(ANGULAR_MIN,ANGULAR_MAX)
FastMath.nextRandomInt(ANGULAR_MIN, ANGULAR_MAX),
FastMath.nextRandomInt(ANGULAR_MIN, ANGULAR_MAX),
FastMath.nextRandomInt(ANGULAR_MIN, ANGULAR_MAX)
);
targetRotation = getRotationForDiceNum(diceNum);
@@ -136,38 +133,37 @@ public void randomRotation() {
spatial.setLocalRotation(randomRotation);
}
public void spin(){
angularVelocity.set(ANGULAR_SPIN,ANGULAR_SPIN,ANGULAR_SPIN);
public void spin() {
angularVelocity.set(ANGULAR_SPIN, ANGULAR_SPIN, ANGULAR_SPIN);
spin = true;
}
public void hide(){
public void hide() {
spatial.removeFromParent();
spin = false;
isRolling = false;
slerp = false;
}
public void create(Vector3f pos, float scale, boolean shadow){
public void create(Vector3f pos, float scale, boolean shadow) {
Spatial spatial = assetManager.loadModel(Asset.dice.getModelPath());
Material mat;
if(shadow){
if (shadow) {
mat = new Material(assetManager, LIGHTING);
mat.setTexture("DiffuseMap", assetManager.loadTexture(Asset.dice.getDiffPath()));
spatial.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
}
else{
} else {
mat = new Material(assetManager, UNSHADED);
mat.setTexture("ColorMap", assetManager.loadTexture(Asset.dice.getDiffPath()));
}
spatial.setMaterial(mat);
spatial.setLocalScale(scale);
spatial.setLocalTranslation(pos);
spatial.rotate((float)Math.toRadians(90), (float)Math.toRadians(180), (float)Math.toRadians(180));
spatial.rotate((float) Math.toRadians(90), (float) Math.toRadians(180), (float) Math.toRadians(180));
spatial.addControl(this);
}
public void setPos(Vector3f pos){
public void setPos(Vector3f pos) {
spatial.setLocalTranslation(pos);
}

View File

@@ -6,8 +6,8 @@
import com.jme3.texture.Image;
import com.jme3.texture.Texture2D;
import pp.mdga.client.MdgaApp;
import pp.mdga.game.Color;
import pp.mdga.game.BonusCard;
import pp.mdga.game.Color;
import java.util.List;
@@ -47,8 +47,8 @@ public void shutdown() {
}
public void rollDice(int rollNum, int mult) {
cardLayerHandler.rollDice(rollNum, ()->{
if(mult == -1) actionTextHandler.ownDice(rollNum);
cardLayerHandler.rollDice(rollNum, () -> {
if (mult == -1) actionTextHandler.ownDice(rollNum);
else actionTextHandler.ownDiceMult(rollNum, mult);
hideDice();
app.getModelSynchronize().animationEnd();
@@ -58,7 +58,7 @@ public void rollDice(int rollNum, int mult) {
public void showRolledDiceMult(int rollNum, int mult, Color color) {
String name = playerNameHandler.getName(color);
if(mult == -1) actionTextHandler.diceNum(rollNum, name, color);
if (mult == -1) actionTextHandler.diceNum(rollNum, name, color);
else actionTextHandler.diceNumMult(rollNum, mult, name, color);
}
@@ -82,7 +82,7 @@ public void addCardOwn(BonusCard card) {
actionTextHandler.drawCardOwn(ownColor);
}
public void playCardOwn(BonusCard card){
public void playCardOwn(BonusCard card) {
getEffectByCard(card);
cardLayerHandler.removeCard(card);
playerNameHandler.removeCard(ownColor);
@@ -93,8 +93,8 @@ public void playCardEnemy(Color color, BonusCard card) {
playerNameHandler.removeCard(color);
}
private void getEffectByCard(BonusCard bonus){
switch(bonus){
private void getEffectByCard(BonusCard bonus) {
switch (bonus) {
case SWAP -> swap();
case TURBO -> turbo();
case SHIELD -> shield();
@@ -118,7 +118,7 @@ public Camera getCardLayerCamera() {
return cardLayerHandler.getCardLayerCamera();
}
public Node getCardLayerRootNode(){
public Node getCardLayerRootNode() {
return cardLayerHandler.getCardLayer().getRootNode();
}
@@ -133,19 +133,19 @@ public void setActivePlayer(Color color) {
else actionTextHandler.activePlayer(playerNameHandler.getName(color), color);
}
public void shield(){
public void shield() {
cardLayerHandler.shield();
}
public void swap(){
public void swap() {
cardLayerHandler.swap();
}
public void turbo(){
public void turbo() {
cardLayerHandler.turbo();
}
public void hideText(){
public void hideText() {
actionTextHandler.hide();
}
@@ -156,17 +156,15 @@ public void drawCard(Color color) {
playerNameHandler.addCard(color);
}
public void finish(Color color){
if(ownColor == color) actionTextHandler.finishTextOwn(color);
public void finish(Color color) {
if (ownColor == color) actionTextHandler.finishTextOwn(color);
else actionTextHandler.finishText(playerNameHandler.getName(color), color);
}
public void rollRankingResult(Color color, int eye){
if(ownColor == color) actionTextHandler.rollRankingResultOwn(color, eye);
public void rollRankingResult(Color color, int eye) {
if (ownColor == color) actionTextHandler.rollRankingResultOwn(color, eye);
else actionTextHandler.rollRankingResult(playerNameHandler.getName(color), color, eye);
}
}

View File

@@ -4,19 +4,16 @@
import com.jme3.font.BitmapFont;
import com.jme3.font.BitmapText;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.system.AppSettings;
import com.jme3.ui.Picture;
import pp.mdga.game.BonusCard;
import pp.mdga.game.Color;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;
public class PlayerNameHandler {
private final BitmapFont playerFont;
@@ -40,7 +37,7 @@ public class PlayerNameHandler {
private final Node guiNode;
public PlayerNameHandler(Node guiNode, AssetManager assetManager, AppSettings appSettings){
public PlayerNameHandler(Node guiNode, AssetManager assetManager, AppSettings appSettings) {
this.guiNode = guiNode;
playerFont = assetManager.loadFont("Fonts/Gunplay.fnt");
@@ -60,35 +57,35 @@ public void hide() {
guiNode.detachChild(playerNameNode);
}
private void drawPlayers(){
private void drawPlayers() {
playerNameNode.detachAllChildren();
for(int i = 0; i < playerOrder.size(); i++) {
for (int i = 0; i < playerOrder.size(); i++) {
Color color = playerOrder.get(i);
if(!colorNameMap.containsKey(color)) throw new RuntimeException(color + " isn't mapped to a name");
if (!colorNameMap.containsKey(color)) throw new RuntimeException(color + " isn't mapped to a name");
Node nameParent = new Node("nameParent");
nameParent.attachChild(createColor(color));
BitmapText name = createName(colorNameMap.get(color), i == 0, color == ownColor);
nameParent.attachChild(name);
if(colorCardMap.getOrDefault(color, 0) > 0){
if (colorCardMap.getOrDefault(color, 0) > 0) {
Picture pic = createHandCard(name.getLineWidth());
nameParent.attachChild(pic);
nameParent.attachChild(createCardNum(colorCardMap.get(color), pic.getWidth(), pic.getLocalTranslation().getX()));
}
nameParent.setLocalTranslation(50,appSettings.getWindowHeight()-PADDING_TOP- MARGIN_NAMES *i,0);
nameParent.setLocalTranslation(50, appSettings.getWindowHeight() - PADDING_TOP - MARGIN_NAMES * i, 0);
playerNameNode.attachChild(nameParent);
}
}
private Spatial createCardNum(int num, float lastWidth, float lastX ) {
private Spatial createCardNum(int num, float lastWidth, float lastX) {
BitmapText hudText = new BitmapText(playerFont);
//renderedSize = 45
hudText.setSize(TEXT_SIZE);
hudText.setColor(NORMAL_COLOR);
hudText.setText(String.valueOf(num));
hudText.setLocalTranslation(lastX + lastWidth + 20,hudText.getHeight()/2, 0);
hudText.setLocalTranslation(lastX + lastWidth + 20, hudText.getHeight() / 2, 0);
return hudText;
}
@@ -97,17 +94,17 @@ private Picture createHandCard(float width) {
pic.setImage(assetManager, "./Images/handcard.png", true);
pic.setWidth(IMAGE_SIZE);
pic.setHeight(IMAGE_SIZE);
pic.setPosition(-pic.getWidth()/2 + width + PADDING_LEFT * 2 ,-pic.getHeight()/2);
pic.setPosition(-pic.getWidth() / 2 + width + PADDING_LEFT * 2, -pic.getHeight() / 2);
return pic;
}
private String imagePath(Color color){
private String imagePath(Color color) {
String root = "./Images/name_pictures/";
return switch(color){
case ARMY -> root+"HEER_IMAGE.png";
case NAVY -> root+"MARINE_IMAGE.png";
case CYBER -> root+"CIR_IMAGE.png";
case AIRFORCE -> root+"LW_IMAGE.png";
return switch (color) {
case ARMY -> root + "HEER_IMAGE.png";
case NAVY -> root + "MARINE_IMAGE.png";
case CYBER -> root + "CIR_IMAGE.png";
case AIRFORCE -> root + "LW_IMAGE.png";
default -> throw new RuntimeException("None is not valid");
};
}
@@ -117,31 +114,30 @@ private Spatial createColor(Color color) {
pic.setImage(assetManager, imagePath(color), true);
pic.setWidth(IMAGE_SIZE);
pic.setHeight(IMAGE_SIZE);
pic.setPosition(-pic.getWidth()/2,-pic.getHeight()/2);
pic.setPosition(-pic.getWidth() / 2, -pic.getHeight() / 2);
return pic;
}
private BitmapText createName(String name, boolean first, boolean own){
private BitmapText createName(String name, boolean first, boolean own) {
BitmapText hudText = new BitmapText(playerFont);
//renderedSize = 45
hudText.setSize(TEXT_SIZE);
hudText.setColor(first ? ACTIVE_COLOR : own ? OWN_COLOR : NORMAL_COLOR);
hudText.setText(own ? name + " (Du)" : name);
hudText.setLocalTranslation(PADDING_LEFT,hudText.getHeight()/2, 0);
hudText.setLocalTranslation(PADDING_LEFT, hudText.getHeight() / 2, 0);
return hudText;
}
public void addPlayer(Color color, String name, boolean own){
if(own) ownColor = color;
public void addPlayer(Color color, String name, boolean own) {
if (own) ownColor = color;
colorNameMap.put(color, name);
playerOrder.add(color);
drawPlayers();
}
public void setActivePlayer(Color color) {
if(playerOrder.get(0) == color) return;
if (playerOrder.get(0) == color) return;
Color oldFirst = playerOrder.remove(0);
playerOrder.remove(color);
playerOrder.add(0, color);
@@ -150,20 +146,20 @@ public void setActivePlayer(Color color) {
drawPlayers();
}
public String getName(Color color){
if(!colorNameMap.containsKey(color)) throw new RuntimeException("color is not in colorNameMap");
public String getName(Color color) {
if (!colorNameMap.containsKey(color)) throw new RuntimeException("color is not in colorNameMap");
return colorNameMap.get(color);
}
public void addCard(Color color){
public void addCard(Color color) {
colorCardMap.put(color, colorCardMap.getOrDefault(color, 0) + 1);
drawPlayers();
}
public void removeCard(Color color){
if(colorCardMap.containsKey(color)){
public void removeCard(Color color) {
if (colorCardMap.containsKey(color)) {
colorCardMap.put(color, colorCardMap.getOrDefault(color, 0) - 1);
if(colorCardMap.get(color) <= 0) colorCardMap.remove(color);
if (colorCardMap.get(color) <= 0) colorCardMap.remove(color);
}
drawPlayers();
}

View File

@@ -13,67 +13,67 @@
public class OutlineFilter extends Filter {
private OutlinePreFilter outlinePreFilter;
private ColorRGBA outlineColor = new ColorRGBA(0, 1, 0, 1);
private float outlineWidth = 1;
private OutlinePreFilter outlinePreFilter;
private ColorRGBA outlineColor = new ColorRGBA(0, 1, 0, 1);
private float outlineWidth = 1;
public OutlineFilter(OutlinePreFilter outlinePreFilter) {
super("OutlineFilter");
this.outlinePreFilter = outlinePreFilter;
}
public OutlineFilter(OutlinePreFilter outlinePreFilter) {
super("OutlineFilter");
this.outlinePreFilter = outlinePreFilter;
}
@Override
protected void initFilter(AssetManager assetManager, RenderManager renderManager, ViewPort vp, int w, int h) {
MaterialDef matDef = (MaterialDef) assetManager.loadAsset("MatDefs/SelectObjectOutliner/Outline.j3md");
material = new Material(matDef);
material.setVector2("Resolution", new Vector2f(w, h));
material.setColor("OutlineColor", outlineColor);
material.setFloat("OutlineWidth", outlineWidth);
}
@Override
protected void initFilter(AssetManager assetManager, RenderManager renderManager, ViewPort vp, int w, int h) {
MaterialDef matDef = (MaterialDef) assetManager.loadAsset("MatDefs/SelectObjectOutliner/Outline.j3md");
material = new Material(matDef);
material.setVector2("Resolution", new Vector2f(w, h));
material.setColor("OutlineColor", outlineColor);
material.setFloat("OutlineWidth", outlineWidth);
}
@Override
protected void preFrame(float tpf) {
super.preFrame(tpf);
material.setTexture("OutlineDepthTexture", outlinePreFilter.getOutlineTexture());
@Override
protected void preFrame(float tpf) {
super.preFrame(tpf);
material.setTexture("OutlineDepthTexture", outlinePreFilter.getOutlineTexture());
// System.out.println("OutlineFilter.preFrame()");
}
}
@Override
protected void postFrame(RenderManager renderManager, ViewPort viewPort, FrameBuffer prevFilterBuffer, FrameBuffer sceneBuffer) {
super.postFrame(renderManager, viewPort, prevFilterBuffer, sceneBuffer);
@Override
protected void postFrame(RenderManager renderManager, ViewPort viewPort, FrameBuffer prevFilterBuffer, FrameBuffer sceneBuffer) {
super.postFrame(renderManager, viewPort, prevFilterBuffer, sceneBuffer);
// material.setTexture("OutlineDepthTexture", outlinePreFilter.getDefaultPassDepthTexture());
// System.out.println("OutlineFilter.postFrame()");
}
}
@Override
protected Material getMaterial() {
return material;
}
@Override
protected Material getMaterial() {
return material;
}
public ColorRGBA getOutlineColor() {
return outlineColor;
}
public ColorRGBA getOutlineColor() {
return outlineColor;
}
public void setOutlineColor(ColorRGBA outlineColor) {
this.outlineColor = outlineColor;
if (material != null) {
material.setColor("OutlineColor", outlineColor);
}
}
public void setOutlineColor(ColorRGBA outlineColor) {
this.outlineColor = outlineColor;
if (material != null) {
material.setColor("OutlineColor", outlineColor);
}
}
public float getOutlineWidth() {
return outlineWidth;
}
public float getOutlineWidth() {
return outlineWidth;
}
public void setOutlineWidth(float outlineWidth) {
this.outlineWidth = outlineWidth;
if (material != null) {
material.setFloat("OutlineWidth", outlineWidth);
}
}
public void setOutlineWidth(float outlineWidth) {
this.outlineWidth = outlineWidth;
if (material != null) {
material.setFloat("OutlineWidth", outlineWidth);
}
}
public OutlinePreFilter getOutlinePreFilter() {
return outlinePreFilter;
}
public OutlinePreFilter getOutlinePreFilter() {
return outlinePreFilter;
}
}

View File

@@ -14,54 +14,54 @@
public class OutlinePreFilter extends Filter {
private Pass normalPass;
private RenderManager renderManager;
private Pass normalPass;
private RenderManager renderManager;
/**
* Creates a OutlinePreFilter
*/
public OutlinePreFilter() {
super("OutlinePreFilter");
}
/**
* Creates a OutlinePreFilter
*/
public OutlinePreFilter() {
super("OutlinePreFilter");
}
@Override
protected boolean isRequiresDepthTexture() {
return true;
}
@Override
protected boolean isRequiresDepthTexture() {
return true;
}
@Override
protected void postQueue(RenderQueue queue) {
Renderer r = renderManager.getRenderer();
r.setFrameBuffer(normalPass.getRenderFrameBuffer());
renderManager.getRenderer().clearBuffers(true, true, false);
}
@Override
protected void postQueue(RenderQueue queue) {
Renderer r = renderManager.getRenderer();
r.setFrameBuffer(normalPass.getRenderFrameBuffer());
renderManager.getRenderer().clearBuffers(true, true, false);
}
@Override
protected void postFrame(RenderManager renderManager, ViewPort viewPort, FrameBuffer prevFilterBuffer, FrameBuffer sceneBuffer) {
super.postFrame(renderManager, viewPort, prevFilterBuffer, sceneBuffer);
@Override
protected void postFrame(RenderManager renderManager, ViewPort viewPort, FrameBuffer prevFilterBuffer, FrameBuffer sceneBuffer) {
super.postFrame(renderManager, viewPort, prevFilterBuffer, sceneBuffer);
}
}
@Override
protected Material getMaterial() {
return material;
}
@Override
protected Material getMaterial() {
return material;
}
public Texture getOutlineTexture() {
return normalPass.getRenderedTexture();
}
public Texture getOutlineTexture() {
return normalPass.getRenderedTexture();
}
@Override
protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
this.renderManager = renderManager;
normalPass = new Pass();
normalPass.init(renderManager.getRenderer(), w, h, Format.RGBA8, Format.Depth);
material = new Material(manager, "MatDefs/SelectObjectOutliner/OutlinePre.j3md");
}
@Override
protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
this.renderManager = renderManager;
normalPass = new Pass();
normalPass.init(renderManager.getRenderer(), w, h, Format.RGBA8, Format.Depth);
material = new Material(manager, "MatDefs/SelectObjectOutliner/OutlinePre.j3md");
}
@Override
protected void cleanUpFilter(Renderer r) {
normalPass.cleanup(r);
}
@Override
protected void cleanUpFilter(Renderer r) {
normalPass.cleanup(r);
}
}

View File

@@ -3,7 +3,6 @@
import com.jme3.asset.AssetManager;
import com.jme3.math.ColorRGBA;
import com.jme3.post.FilterPostProcessor;
import com.jme3.post.filters.FXAAFilter;
import com.jme3.renderer.Camera;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
@@ -19,7 +18,7 @@ public class SelectObjectOutliner {
private final int width;
private boolean selected;
private ViewPort outlineViewport = null;
// private OutlineFilter outlineFilter = null;
// private OutlineFilter outlineFilter = null;
private OutlineProFilter outlineFilter = null;
private final MdgaApp app;
@@ -34,49 +33,49 @@ public SelectObjectOutliner(int width, FilterPostProcessor fpp, RenderManager re
}
public void deselect(Spatial model) {
if(selected){
if (selected) {
selected = false;
hideOutlineFilterEffect(model);
}
}
public void select(Spatial model, ColorRGBA color) {
if(!selected){
if (!selected) {
selected = true;
showOutlineFilterEffect(model, width, color);
}
}
public void select(Spatial model, ColorRGBA color, int width) {
if(!selected){
if (!selected) {
selected = true;
showOutlineFilterEffect(model, width, color);
}
}
private void hideOutlineFilterEffect(Spatial model) {
outlineFilter.setEnabled(false);
outlineFilter.getOutlinePreFilter().setEnabled(false);
fpp.removeFilter(outlineFilter);
outlineViewport.detachScene(model);
outlineViewport.clearProcessors();
renderManager.removePreView(outlineViewport);
outlineViewport = null;
outlineFilter.setEnabled(false);
outlineFilter.getOutlinePreFilter().setEnabled(false);
fpp.removeFilter(outlineFilter);
outlineViewport.detachScene(model);
outlineViewport.clearProcessors();
renderManager.removePreView(outlineViewport);
outlineViewport = null;
}
private void showOutlineFilterEffect(Spatial model, int width, ColorRGBA color) {
outlineViewport = renderManager.createPreView("outlineViewport", cam);
FilterPostProcessor outlineFpp = new FilterPostProcessor(assetManager);
outlineViewport = renderManager.createPreView("outlineViewport", cam);
FilterPostProcessor outlineFpp = new FilterPostProcessor(assetManager);
OutlinePreFilter outlinePreFilter = new OutlinePreFilter();
outlineFpp.addFilter(outlinePreFilter);
outlineViewport.attachScene(model);
outlineViewport.addProcessor(outlineFpp);
OutlinePreFilter outlinePreFilter = new OutlinePreFilter();
outlineFpp.addFilter(outlinePreFilter);
outlineViewport.attachScene(model);
outlineViewport.addProcessor(outlineFpp);
outlineFilter = new OutlineProFilter(outlinePreFilter);
outlineFilter.setOutlineColor(color);
outlineFilter.setOutlineWidth(width);
outlineFilter = new OutlineProFilter(outlinePreFilter);
outlineFilter.setOutlineColor(color);
outlineFilter.setOutlineWidth(width);
fpp.addFilter(outlineFilter);
fpp.addFilter(outlineFilter);
}
}

View File

@@ -283,11 +283,10 @@ public void send(int id, ServerMessage message) {
return;
}
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);
}
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
}
/**

View File

@@ -1,32 +1,29 @@
package pp.mdga.client.server;
import com.jme3.network.serializing.Serializer;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.UUID;
import com.jme3.network.serializing.Serializer;
public class UUIDSerializer extends Serializer
{
public class UUIDSerializer extends Serializer {
@Override
public <T> T readObject(ByteBuffer data, Class<T> c) throws IOException
{
byte[] uuid = new byte[36];
data.get(uuid);
public <T> T readObject(ByteBuffer data, Class<T> c) throws IOException {
byte[] uuid = new byte[36];
data.get(uuid);
if(uuid.equals(new UUID(1, 1))) {
return null;
} else {
return (T) UUID.fromString(new String(uuid));
if (uuid.equals(new UUID(1, 1))) {
return null;
} else {
return (T) UUID.fromString(new String(uuid));
}
}
}
@Override
public void writeObject(ByteBuffer buffer, Object object) throws IOException
{
public void writeObject(ByteBuffer buffer, Object object) throws IOException {
UUID uuid = (UUID) object;
if(uuid != null) {
if (uuid != null) {
buffer.put(uuid.toString().getBytes());
} else {
buffer.put(new UUID(1, 1).toString().getBytes());

View File

@@ -103,7 +103,7 @@ public void onLeave() {
backButton.hide();
continueButton.hide();
if(null != background) {
if (null != background) {
guiNode.detachChild(background);
}
@@ -118,7 +118,7 @@ public void onLeave() {
@Override
protected void onEnterOverlay(Overlay overlay) {
if(rootNode.hasChild(podest)) {
if (rootNode.hasChild(podest)) {
rootNode.detachChild(podest);
}
}
@@ -157,7 +157,7 @@ private void statistics() {
private void enterSub(SubState state) {
this.state = state;
if(rootNode.hasChild(podest)) {
if (rootNode.hasChild(podest)) {
rootNode.detachChild(podest);
}
@@ -205,7 +205,7 @@ public void addCeremonyParticipant(Color color, int pos, String name) {
ceremonyButtons.add(button);
if(state.equals(SubState.AWARD_CEREMONY)) {
if (state.equals(SubState.AWARD_CEREMONY)) {
button.hide();
button.show();
}

View File

@@ -2,10 +2,10 @@
import com.jme3.post.FilterPostProcessor;
import com.jme3.scene.Node;
import pp.mdga.client.MdgaApp;
import pp.mdga.client.acoustic.MdgaSound;
import pp.mdga.client.board.BoardHandler;
import pp.mdga.client.board.CameraHandler;
import pp.mdga.client.MdgaApp;
import pp.mdga.client.button.ButtonLeft;
import pp.mdga.client.button.ButtonRight;
import pp.mdga.client.dialog.InterruptDialog;
@@ -84,14 +84,14 @@ public void onUpdate(float tpf) {
@Override
protected void onEnterOverlay(Overlay overlay) {
if(overlay == Overlay.SETTINGS) {
if (overlay == Overlay.SETTINGS) {
leaveButton.show();
}
}
@Override
protected void onLeaveOverlay(Overlay overlay) {
if(overlay == Overlay.SETTINGS) {
if (overlay == Overlay.SETTINGS) {
leaveButton.hide();
}
}
@@ -101,7 +101,7 @@ private void leaveGame() {
}
public BoardHandler getBoardHandler() {
return boardHandler;
return boardHandler;
}
public GuiHandler getGuiHandler() {

View File

@@ -5,21 +5,15 @@
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.Camera;
import com.jme3.scene.Geometry;
import com.jme3.scene.Spatial;
import com.jme3.scene.shape.Quad;
import com.jme3.texture.Texture;
import com.jme3.util.SkyFactory;
import pp.mdga.client.MdgaApp;
import pp.mdga.client.acoustic.MdgaSound;
import pp.mdga.client.button.ButtonLeft;
import pp.mdga.client.button.ButtonRight;
import pp.mdga.client.button.LobbyButton;
import pp.mdga.client.button.SettingsButton;
import pp.mdga.game.Color;
import pp.mdga.message.client.StartGameMessage;
import pp.mdga.notification.GameNotification;
public class LobbyView extends MdgaView {
private Geometry background;
@@ -64,7 +58,7 @@ public void onEnter() {
leaveButton.show();
readyButton.show();
if(app.getGameLogic().isHost()) {
if (app.getGameLogic().isHost()) {
startButton.show();
}
@@ -114,10 +108,10 @@ public void onLeave() {
app.getCamera().setParallelProjection(false);
app.getCamera().setFrustumPerspective(
45.0f,
(float) app.getCamera().getWidth() / app.getCamera().getHeight(),
0.1f,
1000.0f
45.0f,
(float) app.getCamera().getWidth() / app.getCamera().getHeight(),
0.1f,
1000.0f
);
app.getCamera().setLocation(new Vector3f(0, 0, 10));
@@ -150,23 +144,22 @@ protected void onEnterOverlay(Overlay overlay) {
}
@Override
protected void onLeaveOverlay(Overlay overlay)
{
protected void onLeaveOverlay(Overlay overlay) {
}
public void setTaken(Color color, boolean isTaken, boolean isSelf, String name) {
LobbyButton.Taken taken;
if(isTaken) {
if(isSelf) {
if (isTaken) {
if (isSelf) {
own = color;
taken = LobbyButton.Taken.SELF;
} else {
taken = LobbyButton.Taken.OTHER;
}
} else {
if(isSelf) {
if (isSelf) {
own = null;
}
@@ -204,10 +197,10 @@ public void setReady(Color color, boolean isReady) {
this.isReady = isReady;
}
if(!isReady) {
if (!isReady) {
app.getAcousticHandler().playSound(MdgaSound.NOT_READY);
} else {
if(button.getTaken() != LobbyButton.Taken.SELF) {
if (button.getTaken() != LobbyButton.Taken.SELF) {
app.getAcousticHandler().playSound(MdgaSound.OTHER_READY);
}
}
@@ -231,7 +224,7 @@ private void toggleTsk(Color color) {
break;
}
if(isReady) {
if (isReady) {
setReady(own, false);
}
@@ -249,12 +242,12 @@ private void toggleTsk(Color color) {
}
public void ready() {
if(own == null) {
if (own == null) {
app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT);
return;
}
if(!isReady) {
if (!isReady) {
app.getAcousticHandler().playSound(MdgaSound.SELF_READY);
}

View File

@@ -98,7 +98,7 @@ private void tryHost() {
try {
port = Integer.parseInt(text);
if(port >= 1 && port <= 65535) {
if (port >= 1 && port <= 65535) {
app.getModelSynchronize().setName(startDialog.getName());
hostDialog.hostServer();
try {
@@ -148,10 +148,10 @@ private void tryJoin() {
private boolean isValidIpAddress(String ip) {
String ipRegex =
"^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\." +
"(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\." +
"(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\." +
"(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)$";
"^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\." +
"(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\." +
"(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\." +
"(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)$";
return ip != null && ip.matches(ipRegex);
}
@@ -159,7 +159,7 @@ private boolean isValidIpAddress(String ip) {
private void enterSub(SubState state) {
this.state = state;
if(null != background) {
if (null != background) {
rootNode.detachChild(background);
}
@@ -198,7 +198,7 @@ public void forward(boolean host) {
tryJoin();
break;
case MAIN:
if(host) {
if (host) {
enterSub(SubState.HOST);
//TODO playSound
} else {

View File

@@ -11,7 +11,9 @@
import com.jme3.texture.Texture;
import pp.mdga.client.MdgaApp;
import pp.mdga.client.acoustic.MdgaSound;
import pp.mdga.client.button.*;
import pp.mdga.client.button.AbstractButton;
import pp.mdga.client.button.LabelButton;
import pp.mdga.client.button.SettingsButton;
import pp.mdga.client.dialog.AudioSettingsDialog;
import pp.mdga.client.dialog.SettingsDialog;
import pp.mdga.client.dialog.VideoSettingsDialog;
@@ -196,9 +198,9 @@ public void pressForward() {
}
if (this instanceof GameView gameView) {
if(gameView.needConfirm) {
if (gameView.needConfirm) {
app.getModelSynchronize().confirm();
} else if(gameView.needNoPower) {
} else if (gameView.needNoPower) {
app.getModelSynchronize().confirm();
} else {
app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT);
@@ -213,7 +215,7 @@ public void pressForward() {
public void showInfo(String error, boolean isError) {
infoTimer.reset();
if(null != infoLabel) {
if (null != infoLabel) {
infoLabel.hide();
}
@@ -221,7 +223,7 @@ public void showInfo(String error, boolean isError) {
ColorRGBA color;
if(isError) {
if (isError) {
color = ColorRGBA.Red.clone();
} else {
color = ColorRGBA.Green.clone();