Compare commits
51 Commits
dev/server
...
dev/test
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ee70699150 | ||
|
|
9ef897f873 | ||
|
|
ba9a60a58a | ||
|
|
2434ede556 | ||
|
|
50ac201277 | ||
|
|
bd55a1f08d | ||
|
|
db95a44915 | ||
|
|
cfd16973f5 | ||
|
|
af38224483 | ||
|
|
9b9b5e6781 | ||
|
|
0f2766918b | ||
|
|
314019a632 | ||
|
|
798b6ebe1d | ||
|
|
2cb8e512e6 | ||
|
|
5e61727bec | ||
|
|
470607af5c | ||
|
|
435919306a | ||
|
|
f63e94cf24 | ||
|
|
0aeb02a5f2 | ||
|
|
5240150ec2 | ||
|
|
7bf41bc358 | ||
|
|
48923cddd6 | ||
|
|
a1934e30cb | ||
|
|
9718ad111f | ||
|
|
6370ec15c2 | ||
|
|
1c826bcec0 | ||
|
|
bd9d8c688d | ||
|
|
a1bd8007de | ||
|
|
55ef5438d2 | ||
|
|
d7b0ac92b8 | ||
|
|
0d043e4bb4 | ||
|
|
27de0ccece | ||
|
|
8d49528a92 | ||
|
|
8b1868e03b | ||
|
|
56f32c5c0b | ||
|
|
c41848b061 | ||
|
|
0fd190419d | ||
|
|
838beee345 | ||
|
|
c6462a50ca | ||
|
|
d0361b2759 | ||
|
|
eff011f69f | ||
|
|
fad853b34a | ||
|
|
4a89c4fa65 | ||
|
|
6d58ceee3d | ||
|
|
ecf1cc6e9a | ||
|
|
dd836aa6b9 | ||
|
|
b3504925a5 | ||
|
|
8a5ebfd9d2 | ||
|
|
a3a155a7e3 | ||
|
|
5ef07e35d1 | ||
|
|
ef3193cd68 |
2
.gitignore
vendored
@@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
.run/
|
|
||||||
.gradle
|
.gradle
|
||||||
build/
|
build/
|
||||||
#!gradle/wrapper/gradle-wrapper.jar
|
#!gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package pp.battleship.game.client;
|
||||||
|
|
||||||
|
public class AnimationState {
|
||||||
|
}
|
||||||
@@ -28,23 +28,17 @@ public enum Asset {
|
|||||||
ship(0.8f),
|
ship(0.8f),
|
||||||
smallTent,
|
smallTent,
|
||||||
tank,
|
tank,
|
||||||
world("Models/world/world_export_newTex.obj", "Models/world/world_diff.png",1.2f),
|
world(1.2f),
|
||||||
shieldRing("Models/shieldRing/shieldRing.j3o", null),
|
shieldRing("Models/shieldRing/shieldRing.j3o", null),
|
||||||
treeSmall(1.2f),
|
treeSmall,
|
||||||
treeBig(1.2f),
|
treeBig,
|
||||||
turboCard,
|
turboCard,
|
||||||
turboSymbol("Models/turboCard/turboSymbol.j3o", "Models/turboCard/turboCard_diff.png"),
|
turboSymbol("Models/turboCard/turboSymbol.j3o", "Models/turboCard/turboCard_diff.j3o"),
|
||||||
swapCard,
|
swapCard,
|
||||||
swapSymbol("Models/swapCard/swapSymbol.j3o", "Models/swapCard/swapCard_diff.png"),
|
swapSymbol("Models/swapCard/swapSymbol.j3o", "Models/swapCard/swapCard_diff.j3o"),
|
||||||
shieldCard,
|
shieldCard,
|
||||||
shieldSymbol("Models/shieldCard/shieldSymbol.j3o", "Models/shieldCard/shieldCard_diff.png"),
|
shieldSymbol("Models/shieldCard/shieldSymbol.j3o", "Models/shieldCard/shieldCard_diff.j3o"),
|
||||||
dice,
|
dice
|
||||||
missile("Models/missile/AVMT300.obj", "Models/missile/texture.jpg", 0.1f),
|
|
||||||
tankShoot("Models/tank/tank_shoot_bot.obj", "Models/tank/tank_diff.png"),
|
|
||||||
tankShootTop("Models/tank/tank_shoot_top.obj", "Models/tank/tank_diff.png"),
|
|
||||||
treesSmallBackground("Models/treeSmall/small_trees_background.obj", "Models/treeSmall/treeSmall_diff.png", 1.2f),
|
|
||||||
treesBigBackground("Models/treeBig/big_trees_background.obj", "Models/treeBig/treeBig_diff.png", 1.2f),
|
|
||||||
shell
|
|
||||||
;
|
;
|
||||||
|
|
||||||
private final String modelPath;
|
private final String modelPath;
|
||||||
|
|||||||
@@ -27,7 +27,6 @@
|
|||||||
import pp.mdga.notification.SelectableCardsNotification;
|
import pp.mdga.notification.SelectableCardsNotification;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class InputSynchronizer {
|
public class InputSynchronizer {
|
||||||
|
|
||||||
@@ -40,11 +39,6 @@ public class InputSynchronizer {
|
|||||||
private CardControl hoverCard;
|
private CardControl hoverCard;
|
||||||
private PieceControl hoverPiece;
|
private PieceControl hoverPiece;
|
||||||
|
|
||||||
private boolean clickAllowed = true;
|
|
||||||
|
|
||||||
private boolean isRotateLeft = false;
|
|
||||||
private boolean isRotateRight = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor initializes the InputSynchronizer with the application context.
|
* Constructor initializes the InputSynchronizer with the application context.
|
||||||
* Sets up input mappings and listeners for user interactions.
|
* Sets up input mappings and listeners for user interactions.
|
||||||
@@ -60,18 +54,6 @@ public class InputSynchronizer {
|
|||||||
setupInput();
|
setupInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(float tpf) {
|
|
||||||
if(isRotateLeft && isRotateRight) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(isRotateLeft) {
|
|
||||||
rotationAngle += 180 * tpf;
|
|
||||||
}
|
|
||||||
if(isRotateRight) {
|
|
||||||
rotationAngle -= 180 * tpf;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configures input mappings for various actions and binds them to listeners.
|
* Configures input mappings for various actions and binds them to listeners.
|
||||||
*/
|
*/
|
||||||
@@ -79,22 +61,22 @@ private void setupInput() {
|
|||||||
inputManager.addMapping("Settings", new KeyTrigger(KeyInput.KEY_ESCAPE));
|
inputManager.addMapping("Settings", new KeyTrigger(KeyInput.KEY_ESCAPE));
|
||||||
inputManager.addMapping("Forward", new KeyTrigger(KeyInput.KEY_RETURN));
|
inputManager.addMapping("Forward", new KeyTrigger(KeyInput.KEY_RETURN));
|
||||||
|
|
||||||
inputManager.addMapping("Left", new KeyTrigger(KeyInput.KEY_Q));
|
|
||||||
inputManager.addMapping("Right", new KeyTrigger(KeyInput.KEY_E));
|
|
||||||
|
|
||||||
inputManager.addMapping("RotateRightMouse", new MouseButtonTrigger(MouseInput.BUTTON_RIGHT));
|
inputManager.addMapping("RotateRightMouse", new MouseButtonTrigger(MouseInput.BUTTON_RIGHT));
|
||||||
inputManager.addMapping("MouseLeft", new MouseAxisTrigger(MouseInput.AXIS_X, false)); // Left movement
|
inputManager.addMapping("MouseLeft", new MouseAxisTrigger(MouseInput.AXIS_X, false)); // Left movement
|
||||||
inputManager.addMapping("MouseRight", new MouseAxisTrigger(MouseInput.AXIS_X, true)); // Right movement
|
inputManager.addMapping("MouseRight", new MouseAxisTrigger(MouseInput.AXIS_X, true)); // Right movement
|
||||||
|
inputManager.addMapping("MouseVertical", new MouseAxisTrigger(MouseInput.AXIS_Y, false), new MouseAxisTrigger(MouseInput.AXIS_Y, true)); //Mouse Up Down movement
|
||||||
inputManager.addMapping("MouseScrollUp", new MouseAxisTrigger(MouseInput.AXIS_WHEEL, false)); // Scroll up
|
inputManager.addMapping("MouseScrollUp", new MouseAxisTrigger(MouseInput.AXIS_WHEEL, false)); // Scroll up
|
||||||
inputManager.addMapping("MouseScrollDown", new MouseAxisTrigger(MouseInput.AXIS_WHEEL, true)); // Scroll down
|
inputManager.addMapping("MouseScrollDown", new MouseAxisTrigger(MouseInput.AXIS_WHEEL, true)); // Scroll down
|
||||||
inputManager.addMapping("Test", new KeyTrigger(KeyInput.KEY_J));
|
inputManager.addMapping("Test", new KeyTrigger(KeyInput.KEY_J));
|
||||||
inputManager.addMapping("Click", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
|
inputManager.addMapping("Click", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
|
||||||
|
|
||||||
|
|
||||||
inputManager.addListener(actionListener, "Settings", "Forward", "RotateRightMouse", "Click", "Left", "Right", "Test");
|
inputManager.addListener(actionListener, "Settings", "Forward", "RotateRightMouse", "Click", "Test");
|
||||||
inputManager.addListener(analogListener, "MouseLeft", "MouseRight", "MouseScrollUp", "MouseScrollDown");
|
inputManager.addListener(analogListener, "MouseLeft", "MouseRight", "MouseScrollUp", "MouseScrollDown");
|
||||||
}
|
}
|
||||||
UUID p = null;
|
|
||||||
|
private boolean test = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles action-based input events such as key presses and mouse clicks.
|
* Handles action-based input events such as key presses and mouse clicks.
|
||||||
*/
|
*/
|
||||||
@@ -111,10 +93,6 @@ public void onAction(String name, boolean isPressed, float tpf) {
|
|||||||
rightMousePressed = isPressed;
|
rightMousePressed = isPressed;
|
||||||
}
|
}
|
||||||
if(name.equals("Click") && isPressed) {
|
if(name.equals("Click") && isPressed) {
|
||||||
if(!clickAllowed) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (app.getView() instanceof GameView gameView) {
|
if (app.getView() instanceof GameView gameView) {
|
||||||
DiceControl diceSelect = checkHover(gameView.getGuiHandler().getCardLayerCamera(), gameView.getGuiHandler().getCardLayerRootNode(), DiceControl.class);
|
DiceControl diceSelect = checkHover(gameView.getGuiHandler().getCardLayerCamera(), gameView.getGuiHandler().getCardLayerRootNode(), DiceControl.class);
|
||||||
CardControl cardLayerSelect = checkHover(gameView.getGuiHandler().getCardLayerCamera(), gameView.getGuiHandler().getCardLayerRootNode(), CardControl.class);
|
CardControl cardLayerSelect = checkHover(gameView.getGuiHandler().getCardLayerCamera(), gameView.getGuiHandler().getCardLayerRootNode(), CardControl.class);
|
||||||
@@ -143,40 +121,13 @@ else if(boardSelect != null) {
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if (name.equals("Left")) {
|
if(name.equals("Test") &&isPressed){
|
||||||
isRotateLeft = !isRotateLeft;
|
|
||||||
}
|
|
||||||
if (name.equals("Right")) {
|
|
||||||
isRotateRight = !isRotateRight;
|
|
||||||
}
|
|
||||||
if(name.equals("Test2") &&isPressed){
|
|
||||||
if(app.getView() instanceof GameView gameView){
|
if(app.getView() instanceof GameView gameView){
|
||||||
|
|
||||||
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().movePieceAnim(p,0, 8);
|
|
||||||
} else {
|
|
||||||
gameView.getBoardHandler().throwPiece(p, Color.NAVY);
|
|
||||||
//gameView.getBoardHandler().movePieceStartAnim(p,0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// gameView.getGuiHandler().rollRankingResult(Color.AIRFORCE, 1);
|
// gameView.getGuiHandler().rollRankingResult(Color.AIRFORCE, 1);
|
||||||
// gameView.getGuiHandler().rollRankingResult(Color.ARMY, 2);
|
// gameView.getGuiHandler().rollRankingResult(Color.ARMY, 2);
|
||||||
// gameView.getGuiHandler().rollRankingResult(Color.NAVY, 3);
|
// gameView.getGuiHandler().rollRankingResult(Color.NAVY, 3);
|
||||||
// gameView.getGuiHandler().rollRankingResult(Color.CYBER, 4);
|
// gameView.getGuiHandler().rollRankingResult(Color.CYBER, 4);
|
||||||
// gameView.getGuiHandler().showDice();
|
gameView.getGuiHandler().showDice();
|
||||||
// UUID p1 = UUID.randomUUID();
|
|
||||||
|
|
||||||
// gameView.getBoardHandler().addPlayer(Color.AIRFORCE,List.of(p1,UUID.randomUUID(),UUID.randomUUID(),UUID.randomUUID()));
|
|
||||||
// gameView.getBoardHandler().movePieceStartAnim(p1,0);
|
|
||||||
//gameView.getGuiHandler().drawCard(Color.ARMY);
|
|
||||||
//gameView.getGuiHandler().addCardOwn(BonusCard.SHIELD);
|
|
||||||
//gameView.getGuiHandler().playCardOwn(BonusCard.SHIELD);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -351,12 +302,4 @@ public void setRotation(float rotationAngle){
|
|||||||
public int getScroll() {
|
public int getScroll() {
|
||||||
return scrollValue;
|
return scrollValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setClickAllowed(boolean allowed) {
|
|
||||||
clickAllowed = allowed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isClickAllowed() {
|
|
||||||
return clickAllowed;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,13 @@
|
|||||||
package pp.mdga.client;
|
package pp.mdga.client;
|
||||||
|
|
||||||
import com.jme3.app.SimpleApplication;
|
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.jme3.system.AppSettings;
|
||||||
|
import com.simsilica.lemur.GuiGlobals;
|
||||||
|
import pp.mdga.client.acoustic.AcousticHandler;
|
||||||
import pp.mdga.client.dialog.JoinDialog;
|
import pp.mdga.client.dialog.JoinDialog;
|
||||||
import pp.mdga.client.view.*;
|
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.io.IOException;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.prefs.Preferences;
|
import java.util.prefs.Preferences;
|
||||||
@@ -45,19 +39,19 @@ public class MdgaApp extends SimpleApplication {
|
|||||||
private MdgaState state = null;
|
private MdgaState state = null;
|
||||||
|
|
||||||
/** Scale for rendering images. */
|
/** Scale for rendering images. */
|
||||||
private final float imageScale = prefs.getInt("scale", 1);
|
private float imageScale = prefs.getInt("scale", 1);
|
||||||
|
|
||||||
/** The main menu view. */
|
/** The main menu view. */
|
||||||
private MainView mainView;
|
private MdgaView mainView;
|
||||||
|
|
||||||
/** The lobby view. */
|
/** The lobby view. */
|
||||||
private LobbyView lobbyView;
|
private MdgaView lobbyView;
|
||||||
|
|
||||||
/** The game view. */
|
/** The game view. */
|
||||||
private GameView gameView;
|
private MdgaView gameView;
|
||||||
|
|
||||||
/** The ceremony view. */
|
/** The ceremony view. */
|
||||||
private CeremonyView ceremonyView;
|
private MdgaView ceremonyView;
|
||||||
|
|
||||||
/** The client game logic. */
|
/** The client game logic. */
|
||||||
private final ClientGameLogic clientGameLogic;
|
private final ClientGameLogic clientGameLogic;
|
||||||
@@ -66,7 +60,7 @@ public class MdgaApp extends SimpleApplication {
|
|||||||
|
|
||||||
private ServerConnection networkConnection;
|
private ServerConnection networkConnection;
|
||||||
|
|
||||||
public MdgaApp() {
|
private MdgaApp() {
|
||||||
networkConnection = new NetworkSupport(this);
|
networkConnection = new NetworkSupport(this);
|
||||||
this.clientGameLogic = new ClientGameLogic(networkConnection);
|
this.clientGameLogic = new ClientGameLogic(networkConnection);
|
||||||
}
|
}
|
||||||
@@ -80,30 +74,15 @@ public MdgaApp() {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
AppSettings settings = new AppSettings(true);
|
AppSettings settings = new AppSettings(true);
|
||||||
settings.setSamples(128);
|
settings.setSamples(128);
|
||||||
|
settings.setWidth(prefs.getInt("width", 1280));
|
||||||
if(prefs.getBoolean("fullscreen", false)) {
|
settings.setHeight(prefs.getInt("height", 720));
|
||||||
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
|
||||||
int screenWidth = (int) screenSize.getWidth();
|
|
||||||
int screenHeight = (int) screenSize.getHeight();
|
|
||||||
|
|
||||||
settings.setResolution(screenWidth, screenHeight);
|
|
||||||
|
|
||||||
settings.setFullscreen(true);
|
|
||||||
} else {
|
|
||||||
settings.setWidth(prefs.getInt("width", 1280));
|
|
||||||
settings.setHeight(prefs.getInt("height", 720));
|
|
||||||
}
|
|
||||||
|
|
||||||
settings.setCenterWindow(true);
|
settings.setCenterWindow(true);
|
||||||
settings.setVSync(false);
|
settings.setVSync(false);
|
||||||
settings.setTitle("MDGA");
|
|
||||||
settings.setVSync(true);
|
|
||||||
MdgaApp app = new MdgaApp();
|
MdgaApp app = new MdgaApp();
|
||||||
app.setSettings(settings);
|
app.setSettings(settings);
|
||||||
app.setShowSettings(false);
|
app.setShowSettings(false);
|
||||||
app.setPauseOnLostFocus(false);
|
app.setPauseOnLostFocus(false);
|
||||||
app.setDisplayStatView(false);
|
|
||||||
|
|
||||||
app.start();
|
app.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,7 +120,6 @@ public void simpleUpdate(float tpf) {
|
|||||||
view.update(tpf);
|
view.update(tpf);
|
||||||
acousticHandler.update();
|
acousticHandler.update();
|
||||||
notificationSynchronizer.update();
|
notificationSynchronizer.update();
|
||||||
inputSynchronizer.update(tpf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -267,60 +245,30 @@ public ServerConnection getNetworkSupport(){
|
|||||||
return networkConnection;
|
return networkConnection;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateResolution(int width, int height, float imageFactor, boolean isFullscreen) {
|
public void updateResolution(int width, int height, float imageFactor) {
|
||||||
if(isFullscreen) {
|
prefs.putInt("width", width);
|
||||||
int baseWidth = 1280;
|
prefs.putInt("height", height);
|
||||||
int baseHeight = 720;
|
prefs.putFloat("scale", imageFactor);
|
||||||
float baseAspectRatio = (float) baseWidth / baseHeight;
|
|
||||||
float newAspectRatio = (float) width / height;
|
|
||||||
|
|
||||||
float scaleFactor = Math.max((float) width / baseWidth, (float) height / baseHeight);
|
|
||||||
|
|
||||||
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
|
||||||
int screenWidth = (int) screenSize.getWidth();
|
|
||||||
int screenHeight = (int) screenSize.getHeight();
|
|
||||||
settings.setResolution(screenWidth, screenHeight);
|
|
||||||
settings.setFullscreen(true);
|
|
||||||
|
|
||||||
prefs.putFloat("scale", scaleFactor);
|
|
||||||
prefs.putBoolean("fullscreen", true);
|
|
||||||
} else {
|
|
||||||
prefs.putInt("width", width);
|
|
||||||
prefs.putInt("height", height);
|
|
||||||
prefs.putFloat("scale", imageFactor);
|
|
||||||
prefs.putBoolean("fullscreen", false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void restartApp() {
|
|
||||||
try {
|
try {
|
||||||
String javaBin = System.getProperty("java.home") + "/bin/java";
|
restartApp();
|
||||||
String classPath = System.getProperty("java.class.path");
|
|
||||||
String className = System.getProperty("sun.java.command");
|
|
||||||
|
|
||||||
ProcessBuilder builder = new ProcessBuilder(
|
|
||||||
javaBin, "-cp", classPath, className
|
|
||||||
);
|
|
||||||
|
|
||||||
builder.start();
|
|
||||||
|
|
||||||
System.exit(0);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException("restart failed");
|
//nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void afterGameCleanup() {
|
public static void restartApp() throws IOException {
|
||||||
MainView main = (MainView) mainView;
|
String javaBin = System.getProperty("java.home") + "/bin/java";
|
||||||
|
String classPath = System.getProperty("java.class.path");
|
||||||
|
String className = System.getProperty("sun.java.command");
|
||||||
|
|
||||||
main.getJoinDialog().disconnect();
|
ProcessBuilder builder = new ProcessBuilder(
|
||||||
main.getHostDialog().shutdownServer();
|
javaBin, "-cp", classPath, className
|
||||||
|
);
|
||||||
|
|
||||||
ceremonyView.afterGameCleanup();
|
builder.start();
|
||||||
}
|
|
||||||
|
|
||||||
public GameView getGameView(){
|
System.exit(0);
|
||||||
return gameView;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,16 @@
|
|||||||
package pp.mdga.client;
|
package pp.mdga.client;
|
||||||
|
|
||||||
|
import pp.mdga.client.acoustic.MdgaSound;
|
||||||
|
import pp.mdga.client.server.MdgaServer;
|
||||||
|
import pp.mdga.client.view.CeremonyView;
|
||||||
import pp.mdga.client.view.GameView;
|
import pp.mdga.client.view.GameView;
|
||||||
|
import pp.mdga.client.view.LobbyView;
|
||||||
import pp.mdga.game.BonusCard;
|
import pp.mdga.game.BonusCard;
|
||||||
import pp.mdga.game.Color;
|
import pp.mdga.game.Color;
|
||||||
|
import pp.mdga.message.client.LobbyReadyMessage;
|
||||||
|
import pp.mdga.notification.AcquireCardNotification;
|
||||||
|
import pp.mdga.notification.DrawCardNotification;
|
||||||
|
import pp.mdga.notification.TskSelectNotification;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@@ -66,11 +74,10 @@ public void selectCard(BonusCard card) {
|
|||||||
this.card = card;
|
this.card = card;
|
||||||
|
|
||||||
GameView gameView = (GameView) app.getView();
|
GameView gameView = (GameView) app.getView();
|
||||||
|
|
||||||
if(card != null) {
|
if(card != null) {
|
||||||
gameView.needConfirm();
|
gameView.needConfirm();
|
||||||
} else {
|
} else {
|
||||||
gameView.showNoPower();
|
gameView.noConfirm();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,19 +87,20 @@ public void confirm() {
|
|||||||
GameView gameView = (GameView) app.getView();
|
GameView gameView = (GameView) app.getView();
|
||||||
|
|
||||||
if(a != null && b != null) {
|
if(a != null && b != null) {
|
||||||
app.getGameLogic().selectPiece(a);
|
selectPiece(a);
|
||||||
app.getGameLogic().selectPiece(b);
|
selectPiece(b);
|
||||||
gameView.getBoardHandler().clearSelectable();
|
gameView.getBoardHandler().clearSelectable();
|
||||||
} else if (a != null) {
|
} else if (a != null) {
|
||||||
app.getGameLogic().selectPiece(a);
|
selectPiece(a);
|
||||||
gameView.getBoardHandler().clearSelectable();
|
gameView.getBoardHandler().clearSelectable();
|
||||||
} else {
|
} else if (card != null){
|
||||||
app.getGameLogic().selectCard(card);
|
selectCard(card);
|
||||||
gameView.getGuiHandler().clearSelectableCards();
|
gameView.getGuiHandler().clearSelectableCards();
|
||||||
|
} else {
|
||||||
|
throw new RuntimeException("nothing to confirm");
|
||||||
}
|
}
|
||||||
|
|
||||||
gameView.noConfirm();
|
gameView.noConfirm();
|
||||||
gameView.hideNoPower();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectTsk(Color color) {
|
public void selectTsk(Color color) {
|
||||||
@@ -137,8 +145,4 @@ public void enter(MdgaState state) {
|
|||||||
public void setSwap(boolean swap){
|
public void setSwap(boolean swap){
|
||||||
this.swap = swap;
|
this.swap = swap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void force() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package pp.mdga.client;
|
package pp.mdga.client;
|
||||||
|
|
||||||
import com.jme3.system.NanoTimer;
|
|
||||||
import pp.mdga.client.acoustic.MdgaSound;
|
|
||||||
import pp.mdga.client.board.BoardHandler;
|
import pp.mdga.client.board.BoardHandler;
|
||||||
import pp.mdga.client.gui.GuiHandler;
|
import pp.mdga.client.gui.GuiHandler;
|
||||||
import pp.mdga.client.view.CeremonyView;
|
import pp.mdga.client.view.CeremonyView;
|
||||||
@@ -17,48 +15,34 @@ public class NotificationSynchronizer {
|
|||||||
|
|
||||||
private ArrayList<Notification> notifications = new ArrayList<>();
|
private ArrayList<Notification> notifications = new ArrayList<>();
|
||||||
|
|
||||||
private NanoTimer timer = new NanoTimer();
|
|
||||||
private float delay = 0;
|
|
||||||
|
|
||||||
private static final float STANDARD_DELAY = 2.5f;
|
|
||||||
|
|
||||||
NotificationSynchronizer(MdgaApp app) {
|
NotificationSynchronizer(MdgaApp app) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addTestNotification(Notification n) {
|
||||||
|
notifications.add(n);
|
||||||
|
handleGame(n);
|
||||||
|
}
|
||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
while (timer.getTimeInSeconds() >= delay) {
|
Notification n = app.getGameLogic().getNotification();
|
||||||
Notification n = app.getGameLogic().getNotification();
|
|
||||||
|
|
||||||
if(n == null) {
|
if(n != null) {
|
||||||
return;
|
switch (app.getState()) {
|
||||||
}
|
case MAIN:
|
||||||
|
handleMain(n);
|
||||||
timer.reset();
|
break;
|
||||||
delay = 0;
|
case LOBBY:
|
||||||
|
handleLobby(n);
|
||||||
if(n instanceof InfoNotification infoNotification) {
|
break;
|
||||||
app.getView().showInfo(infoNotification.getMessage(), infoNotification.isError());
|
case GAME:
|
||||||
return;
|
handleGame(n);
|
||||||
}
|
break;
|
||||||
|
case CEREMONY:
|
||||||
if(n != null) {
|
handleCeremony(n);
|
||||||
switch (app.getState()) {
|
break;
|
||||||
case MAIN:
|
case NONE:
|
||||||
handleMain(n);
|
throw new RuntimeException("no notification expected: " + n.toString());
|
||||||
break;
|
|
||||||
case LOBBY:
|
|
||||||
handleLobby(n);
|
|
||||||
break;
|
|
||||||
case GAME:
|
|
||||||
handleGame(n);
|
|
||||||
break;
|
|
||||||
case CEREMONY:
|
|
||||||
handleCeremony(n);
|
|
||||||
break;
|
|
||||||
case NONE:
|
|
||||||
throw new RuntimeException("no notification expected: " + n.getClass().getName());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -66,10 +50,8 @@ public void update() {
|
|||||||
private void handleMain(Notification notification) {
|
private void handleMain(Notification notification) {
|
||||||
if (notification instanceof LobbyDialogNotification) {
|
if (notification instanceof LobbyDialogNotification) {
|
||||||
app.enter(MdgaState.LOBBY);
|
app.enter(MdgaState.LOBBY);
|
||||||
} else if (notification instanceof StartDialogNotification) {
|
|
||||||
//nothing
|
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("notification not expected in main: "+ notification.getClass().getName());
|
throw new RuntimeException("notification not expected: ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,17 +61,16 @@ private void handleLobby(Notification notification) {
|
|||||||
if (notification instanceof TskSelectNotification n) {
|
if (notification instanceof TskSelectNotification n) {
|
||||||
lobbyView.setTaken(n.getColor(), true, n.isSelf(), n.getName());
|
lobbyView.setTaken(n.getColor(), true, n.isSelf(), n.getName());
|
||||||
} else if (notification instanceof StartDialogNotification) {
|
} else if (notification instanceof StartDialogNotification) {
|
||||||
app.afterGameCleanup();
|
|
||||||
app.enter(MdgaState.MAIN);
|
app.enter(MdgaState.MAIN);
|
||||||
} else if (notification instanceof TskUnselectNotification n) {
|
} else if (notification instanceof TskUnselectNotification n) {
|
||||||
lobbyView.setTaken(n.getColor(), false, false, null);
|
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());
|
lobbyView.setReady(lobbyReadyNotification.getColor(), lobbyReadyNotification.isReady());
|
||||||
} else if (notification instanceof GameNotification n) {
|
} else if (notification instanceof GameNotification n) {
|
||||||
app.getGameView().setOwnColor(n.getOwnColor());
|
|
||||||
app.enter(MdgaState.GAME);
|
app.enter(MdgaState.GAME);
|
||||||
|
((GameView) app.getView()).setOwnColor(n.getOwnColor());
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("notification not expected in lobby: " + notification.getClass().getName());
|
throw new RuntimeException("notification not expected: " + notification.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,14 +81,10 @@ private void handleGame(Notification notification) {
|
|||||||
ModelSynchronizer modelSynchronizer = app.getModelSynchronize();
|
ModelSynchronizer modelSynchronizer = app.getModelSynchronize();
|
||||||
|
|
||||||
if (notification instanceof AcquireCardNotification n) {
|
if (notification instanceof AcquireCardNotification n) {
|
||||||
guiHandler.addCardOwn(n.getBonusCard());
|
guiHandler.addCard(n.getBonusCard());
|
||||||
app.getAcousticHandler().playSound(MdgaSound.BONUS);
|
|
||||||
delay = STANDARD_DELAY;
|
|
||||||
} else if (notification instanceof ActivePlayerNotification n) {
|
} else if (notification instanceof ActivePlayerNotification n) {
|
||||||
gameView.getGuiHandler().setActivePlayer(n.getColor());
|
gameView.getGuiHandler().setActivePlayer(n.getColor());
|
||||||
boardHandler.showDice(n.getColor());
|
boardHandler.showDice(n.getColor());
|
||||||
app.getAcousticHandler().playSound(MdgaSound.UI90);
|
|
||||||
delay = STANDARD_DELAY;
|
|
||||||
} else if (notification instanceof CeremonyNotification ceremonyNotification) {
|
} else if (notification instanceof CeremonyNotification ceremonyNotification) {
|
||||||
app.enter(MdgaState.CEREMONY);
|
app.enter(MdgaState.CEREMONY);
|
||||||
CeremonyView ceremonyView = (CeremonyView) app.getView();
|
CeremonyView ceremonyView = (CeremonyView) app.getView();
|
||||||
@@ -142,8 +119,8 @@ private void handleGame(Notification notification) {
|
|||||||
} else if (notification instanceof HomeMoveNotification home) {
|
} else if (notification instanceof HomeMoveNotification home) {
|
||||||
boardHandler.movePieceHomeAnim(home.getPieceId(), home.getHomeIndex());
|
boardHandler.movePieceHomeAnim(home.getPieceId(), home.getHomeIndex());
|
||||||
guiHandler.hideText();
|
guiHandler.hideText();
|
||||||
} else if (notification instanceof InterruptNotification notification1) {
|
} else if (notification instanceof InterruptNotification) {
|
||||||
gameView.enterInterrupt(notification1.getColor());
|
app.enter(MdgaState.LOBBY);
|
||||||
} else if (notification instanceof MovePieceNotification n) {
|
} else if (notification instanceof MovePieceNotification n) {
|
||||||
if(n.isMoveStart()) {
|
if(n.isMoveStart()) {
|
||||||
//StartMove
|
//StartMove
|
||||||
@@ -155,17 +132,21 @@ private void handleGame(Notification notification) {
|
|||||||
}
|
}
|
||||||
guiHandler.hideText();
|
guiHandler.hideText();
|
||||||
} else if (notification instanceof ThrowPieceNotification n) {
|
} else if (notification instanceof ThrowPieceNotification n) {
|
||||||
boardHandler.throwPiece(n.getPieceId(), n.getThrowColor());
|
boardHandler.throwPieceAnim(n.getPieceId());
|
||||||
} else if (notification instanceof NoShieldNotification n) {
|
} else if (notification instanceof NoShieldNotification n) {
|
||||||
boardHandler.unshieldPiece(n.getPieceId());
|
boardHandler.unshieldPiece(n.getPieceId());
|
||||||
} else if (notification instanceof PlayCardNotification n) {
|
} else if (notification instanceof PlayCardNotification n) {
|
||||||
if(n.getColor() == gameView.getOwnColor()) guiHandler.playCardOwn(n.getCard());
|
switch(n.getCard()){
|
||||||
else guiHandler.playCardEnemy(n.getColor(), n.getCard());
|
case SWAP -> guiHandler.swap();
|
||||||
|
case TURBO -> guiHandler.turbo();
|
||||||
|
case SHIELD -> guiHandler.shield();
|
||||||
|
default -> throw new RuntimeException("invalid card");
|
||||||
|
}
|
||||||
} else if (notification instanceof PlayerInGameNotification n) {
|
} else if (notification instanceof PlayerInGameNotification n) {
|
||||||
boardHandler.addPlayer(n.getColor(),n.getPiecesList());
|
boardHandler.addPlayer(n.getColor(),n.getPiecesList());
|
||||||
guiHandler.addPlayer(n.getColor(),n.getName());
|
guiHandler.addPlayer(n.getColor(),n.getName());
|
||||||
} else if (notification instanceof ResumeNotification) {
|
} else if (notification instanceof ResumeNotification) {
|
||||||
gameView.leaveInterrupt();
|
//TODO
|
||||||
} else if (notification instanceof RollDiceNotification n) {
|
} else if (notification instanceof RollDiceNotification n) {
|
||||||
gameView.getGuiHandler().hideText();
|
gameView.getGuiHandler().hideText();
|
||||||
if(n.getColor() == gameView.getOwnColor()){
|
if(n.getColor() == gameView.getOwnColor()){
|
||||||
@@ -176,16 +157,13 @@ private void handleGame(Notification notification) {
|
|||||||
if (n.isTurbo()) guiHandler.showRolledDiceMult(n.getEyes(), n.getMultiplier(), n.getColor());
|
if (n.isTurbo()) guiHandler.showRolledDiceMult(n.getEyes(), n.getMultiplier(), n.getColor());
|
||||||
else guiHandler.showRolledDice(n.getEyes(), n.getColor());
|
else guiHandler.showRolledDice(n.getEyes(), n.getColor());
|
||||||
}
|
}
|
||||||
delay = 7;
|
|
||||||
} else if (notification instanceof SelectableCardsNotification n) {
|
} else if (notification instanceof SelectableCardsNotification n) {
|
||||||
guiHandler.setSelectableCards(n.getCards());
|
guiHandler.setSelectableCards(n.getCards());
|
||||||
gameView.showNoPower();
|
|
||||||
} else if (notification instanceof ShieldActiveNotification n) {
|
} else if (notification instanceof ShieldActiveNotification n) {
|
||||||
boardHandler.shieldPiece(n.getPieceId());
|
boardHandler.shieldPiece(n.getPieceId());
|
||||||
} else if (notification instanceof ShieldSuppressedNotification n) {
|
} else if (notification instanceof ShieldSuppressedNotification n) {
|
||||||
boardHandler.suppressShield(n.getPieceId());
|
boardHandler.suppressShield(n.getPieceId());
|
||||||
} else if (notification instanceof StartDialogNotification) {
|
} else if (notification instanceof StartDialogNotification) {
|
||||||
app.afterGameCleanup();
|
|
||||||
app.enter(MdgaState.MAIN);
|
app.enter(MdgaState.MAIN);
|
||||||
} else if (notification instanceof SwapPieceNotification n) {
|
} else if (notification instanceof SwapPieceNotification n) {
|
||||||
// boardHandler.swapPieces(n.getFirstPiece(), n.getSecondPiece());
|
// boardHandler.swapPieces(n.getFirstPiece(), n.getSecondPiece());
|
||||||
@@ -206,16 +184,15 @@ private void handleGame(Notification notification) {
|
|||||||
} else if (notification instanceof FinishNotification n){
|
} else if (notification instanceof FinishNotification n){
|
||||||
guiHandler.finish(n.getColorFinished());
|
guiHandler.finish(n.getColorFinished());
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("notification not expected in game: " + notification.getClass().getName());
|
throw new RuntimeException("notification not expected: " + notification.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleCeremony(Notification notification) {
|
private void handleCeremony(Notification notification) {
|
||||||
if (notification instanceof StartDialogNotification) {
|
if (notification instanceof StartDialogNotification) {
|
||||||
app.afterGameCleanup();
|
|
||||||
app.enter(MdgaState.MAIN);
|
app.enter(MdgaState.MAIN);
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("notification not expected in ceremony: " + notification.getClass().getName());
|
throw new RuntimeException("notification not expected: " + notification.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,47 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
import com.jme3.math.Vector3f;
|
|
||||||
|
|
||||||
public class Util {
|
|
||||||
private Util(){}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Performs linear interpolation between two values.
|
|
||||||
*
|
|
||||||
* @param start The starting value.
|
|
||||||
* @param end The ending value.
|
|
||||||
* @param t A parameter between 0 and 1 representing the interpolation progress.
|
|
||||||
* @return The interpolated value.
|
|
||||||
*/
|
|
||||||
public static float linInt(float start, float end, float t) {
|
|
||||||
return start + t * (end - start);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Performs quadratic interpolation between three points.
|
|
||||||
*
|
|
||||||
* @param p1 The initial point.
|
|
||||||
* @param p2 The middle point.
|
|
||||||
* @param p3 The final point.
|
|
||||||
* @param t The interpolation parameter (0 <= t <= 1).
|
|
||||||
* @return The interpolated point.
|
|
||||||
*/
|
|
||||||
public static Vector3f quadInt(Vector3f p1, Vector3f p2, Vector3f p3, float t) {
|
|
||||||
// Quadratic interpolation: (1-t)^2 * p1 + 2 * (1-t) * t * p2 + t^2 * p3
|
|
||||||
float oneMinusT = 1 - t;
|
|
||||||
return p1.mult(oneMinusT * oneMinusT)
|
|
||||||
.add(p2.mult(2 * oneMinusT * t))
|
|
||||||
.add(p3.mult(t * t));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A smooth ease-in-out function for interpolation.
|
|
||||||
* It accelerates and decelerates the interpolation for a smoother effect.
|
|
||||||
*
|
|
||||||
* @param x The interpolation parameter (0 <= x <= 1).
|
|
||||||
* @return The adjusted interpolation value.
|
|
||||||
*/
|
|
||||||
public static float easeInOut(float x){
|
|
||||||
return x < 0.5 ? 4 * x * x * x : (float) (1 - Math.pow(-2 * x + 2, 3) / 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -18,14 +18,12 @@ public class AcousticHandler {
|
|||||||
|
|
||||||
private boolean fading = false; // Indicates if a fade is in progress
|
private boolean fading = false; // Indicates if a fade is in progress
|
||||||
private NanoTimer fadeTimer = new NanoTimer(); // Timer to track fade progress
|
private NanoTimer fadeTimer = new NanoTimer(); // Timer to track fade progress
|
||||||
private static final float FADE_DURATION = 2.0f; // Duration for outfade
|
private static final float FADE_DURATION = 3.0f; // Duration for outfade
|
||||||
private static final float CROSSFADE_DURATION = 1.5f; // Duration for infade
|
private static final float CROSSFADE_DURATION = 1.5f; // Duration for infade
|
||||||
private GameMusic playing = null; // Currently playing track
|
private GameMusic playing = null; // Currently playing track
|
||||||
private GameMusic scheduled = null; // Scheduled track to play next
|
private GameMusic scheduled = null; // Scheduled track to play next
|
||||||
private GameMusic old = null; // Old track being faded out
|
private GameMusic old = null; // Old track being faded out
|
||||||
|
|
||||||
private GameMusic birds;
|
|
||||||
|
|
||||||
private float mainVolume = 0.0f;
|
private float mainVolume = 0.0f;
|
||||||
private float musicVolume = 1.0f;
|
private float musicVolume = 1.0f;
|
||||||
private float soundVolume = 1.0f;
|
private float soundVolume = 1.0f;
|
||||||
@@ -40,8 +38,6 @@ public AcousticHandler(MdgaApp app) {
|
|||||||
mainVolume = prefs.getFloat("mainVolume", 1.0f);
|
mainVolume = prefs.getFloat("mainVolume", 1.0f);
|
||||||
musicVolume = prefs.getFloat("musicVolume", 1.0f);
|
musicVolume = prefs.getFloat("musicVolume", 1.0f);
|
||||||
soundVolume = prefs.getFloat("soundVolume", 1.0f);
|
soundVolume = prefs.getFloat("soundVolume", 1.0f);
|
||||||
|
|
||||||
birds = new GameMusic(app, MusicAsset.BIRDS, getSoundVolumeTotal(), MusicAsset.BIRDS.getSubVolume(), MusicAsset.BIRDS.getLoop(), 0.0f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -64,8 +60,6 @@ public void update() {
|
|||||||
iterator.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
birds.update(Math.min(getSoundVolumeTotal(), getMusicVolumeTotal() > 0 ? 0 : 1));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -115,38 +109,6 @@ public void playSound(MdgaSound sound) {
|
|||||||
case LEAVE:
|
case LEAVE:
|
||||||
assets.add(new SoundAssetDelayVolume(SoundAsset.UI_SOUND2, 0.6f, 0.0f));
|
assets.add(new SoundAssetDelayVolume(SoundAsset.UI_SOUND2, 0.6f, 0.0f));
|
||||||
break;
|
break;
|
||||||
case JET:
|
|
||||||
assets.add(new SoundAssetDelayVolume(SoundAsset.JET, 1.0f, 0.0f));
|
|
||||||
break;
|
|
||||||
case EXPLOSION:
|
|
||||||
assets.add(new SoundAssetDelayVolume(SoundAsset.EXPLOSION_1, 1.0f, 0f));
|
|
||||||
assets.add(new SoundAssetDelayVolume(SoundAsset.EXPLOSION_2, 1.0f, 0f));
|
|
||||||
assets.add(new SoundAssetDelayVolume(SoundAsset.THUNDER, 1.0f, 0f));
|
|
||||||
break;
|
|
||||||
case LOSE:
|
|
||||||
assets.add(new SoundAssetDelayVolume(SoundAsset.LOSE, 1.0f, 0.0f));
|
|
||||||
break;
|
|
||||||
case BONUS:
|
|
||||||
assets.add(new SoundAssetDelayVolume(SoundAsset.BONUS, 1.0f, 0.0f));
|
|
||||||
break;
|
|
||||||
case UI90:
|
|
||||||
assets.add(new SoundAssetDelayVolume(SoundAsset.UI90, 1.0f, 0.0f));
|
|
||||||
break;
|
|
||||||
case MISSILE:
|
|
||||||
assets.add(new SoundAssetDelayVolume(SoundAsset.MISSILE, 1.0f, 0.0f));
|
|
||||||
break;
|
|
||||||
case MATRIX:
|
|
||||||
assets.add(new SoundAssetDelayVolume(SoundAsset.MATRIX, 1.0f, 0.0f));
|
|
||||||
break;
|
|
||||||
case TURRET_ROTATE:
|
|
||||||
assets.add(new SoundAssetDelayVolume(SoundAsset.TURRET_ROTATE, 0.7f, 0f));
|
|
||||||
break;
|
|
||||||
case TANK_SHOOT:
|
|
||||||
assets.add(new SoundAssetDelayVolume(SoundAsset.TANK_SHOOT, 0.7f, 0f));
|
|
||||||
break;
|
|
||||||
case TANK_EXPLOSION:
|
|
||||||
assets.add(new SoundAssetDelayVolume(SoundAsset.EXPLOSION_1, 1.0f, 0f));
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -168,10 +130,6 @@ public void playState(MdgaState state) {
|
|||||||
}
|
}
|
||||||
MusicAsset asset = null;
|
MusicAsset asset = null;
|
||||||
|
|
||||||
birds.pause();
|
|
||||||
|
|
||||||
float pause = 0.0f;
|
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case MAIN:
|
case MAIN:
|
||||||
playGame = false;
|
playGame = false;
|
||||||
@@ -182,12 +140,10 @@ public void playState(MdgaState state) {
|
|||||||
asset = MusicAsset.LOBBY;
|
asset = MusicAsset.LOBBY;
|
||||||
break;
|
break;
|
||||||
case GAME:
|
case GAME:
|
||||||
birds.play();
|
|
||||||
addGameTracks();
|
addGameTracks();
|
||||||
playGame = true;
|
playGame = true;
|
||||||
assert (!gameTracks.isEmpty()) : "no more game music available";
|
assert (!gameTracks.isEmpty()) : "no more game music available";
|
||||||
asset = gameTracks.remove(0);
|
asset = gameTracks.remove(0);
|
||||||
pause = 2.0f;
|
|
||||||
break;
|
break;
|
||||||
case CEREMONY:
|
case CEREMONY:
|
||||||
playGame = false;
|
playGame = false;
|
||||||
@@ -199,7 +155,7 @@ public void playState(MdgaState state) {
|
|||||||
|
|
||||||
assert (null != asset) : "music sceduling went wrong";
|
assert (null != asset) : "music sceduling went wrong";
|
||||||
|
|
||||||
scheduled = new GameMusic(app, asset, getMusicVolumeTotal(), asset.getSubVolume(), asset.getLoop(), pause);
|
scheduled = new GameMusic(app, asset, getMusicVolumeTotal(), asset.getSubVolume(), asset.getLoop(), 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -475,7 +431,7 @@ public void setSoundVolume(float soundVolume) {
|
|||||||
*/
|
*/
|
||||||
float getMusicVolumeTotal() {
|
float getMusicVolumeTotal() {
|
||||||
|
|
||||||
return getMusicVolume() * getMainVolume() / 2;
|
return getMusicVolume() * getMainVolume();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -31,14 +31,4 @@ public enum MdgaSound {
|
|||||||
OTHER_CONNECTED,
|
OTHER_CONNECTED,
|
||||||
NOT_READY,
|
NOT_READY,
|
||||||
LEAVE,
|
LEAVE,
|
||||||
JET,
|
|
||||||
EXPLOSION,
|
|
||||||
LOSE,
|
|
||||||
BONUS,
|
|
||||||
UI90,
|
|
||||||
MISSILE,
|
|
||||||
MATRIX,
|
|
||||||
TURRET_ROTATE,
|
|
||||||
TANK_SHOOT,
|
|
||||||
TANK_EXPLOSION
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,13 +10,12 @@ enum MusicAsset {
|
|||||||
MAIN_MENU("Spaceship.wav", true, 1.0f),
|
MAIN_MENU("Spaceship.wav", true, 1.0f),
|
||||||
LOBBY("DeadPlanet.wav", true, 1.0f),
|
LOBBY("DeadPlanet.wav", true, 1.0f),
|
||||||
CEREMONY("80s,Disco,Life.wav", true, 1.0f),
|
CEREMONY("80s,Disco,Life.wav", true, 1.0f),
|
||||||
GAME_1("NeonRoadTrip.wav", 0.5f),
|
GAME_1("NeonRoadTrip.wav", 1.0f),
|
||||||
GAME_2("NoPressureTrance.wav", 0.5f),
|
GAME_2("NoPressureTrance.wav", 1.0f),
|
||||||
GAME_3("TheSynthRave.wav", 0.5f),
|
GAME_3("TheSynthRave.wav", 1.0f),
|
||||||
GAME_4("LaserParty.wav", 0.5f),
|
GAME_4("LaserParty.wav", 1.0f),
|
||||||
GAME_5("RetroNoir.wav", 0.5f),
|
GAME_5("RetroNoir.wav", 1.0f),
|
||||||
GAME_6("SpaceInvaders.wav", 0.5f),
|
GAME_6("SpaceInvaders.wav", 1.0f);
|
||||||
BIRDS("nature-ambience.ogg", true, 1.0f);
|
|
||||||
|
|
||||||
private final String path;
|
private final String path;
|
||||||
private final boolean loop;
|
private final boolean loop;
|
||||||
|
|||||||
@@ -28,20 +28,7 @@ enum SoundAsset {
|
|||||||
POWERUP("powerup.wav"),
|
POWERUP("powerup.wav"),
|
||||||
ROBOT_READY("robotReady.wav"),
|
ROBOT_READY("robotReady.wav"),
|
||||||
UNIT_READY("unitReady.wav"),
|
UNIT_READY("unitReady.wav"),
|
||||||
JET("jet-overhead.wav"),
|
CONNECTED("connected.wav");
|
||||||
EXPLOSION_1("exp.ogg"),
|
|
||||||
EXPLOSION_2("exp2.ogg"),
|
|
||||||
THUNDER("thunder.ogg"),
|
|
||||||
UI90("ui90.ogg"),
|
|
||||||
BONUS("bonus.ogg"),
|
|
||||||
LOSE("lose.ogg"),
|
|
||||||
MISSILE("missile.ogg"),
|
|
||||||
MATRIX("matrix.wav"),
|
|
||||||
CONNECTED("connected.wav"),
|
|
||||||
TURRET_ROTATE("turret_rotate.ogg"),
|
|
||||||
TANK_SHOOT("tank_shoot.ogg")
|
|
||||||
;
|
|
||||||
|
|
||||||
|
|
||||||
private final String path;
|
private final String path;
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
package pp.mdga.client.animation;
|
|
||||||
|
|
||||||
import pp.mdga.client.InitControl;
|
|
||||||
|
|
||||||
public class ActionControl extends InitControl {
|
|
||||||
private final Runnable runnable;
|
|
||||||
|
|
||||||
public ActionControl(Runnable runnable){
|
|
||||||
this.runnable = runnable;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected void action(){
|
|
||||||
if(runnable == null) throw new RuntimeException("runnable is null");
|
|
||||||
else runnable.run();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,131 +0,0 @@
|
|||||||
package pp.mdga.client.animation;
|
|
||||||
|
|
||||||
import com.jme3.effect.ParticleEmitter;
|
|
||||||
import com.jme3.effect.ParticleMesh.Type;
|
|
||||||
import com.jme3.material.Material;
|
|
||||||
import com.jme3.math.ColorRGBA;
|
|
||||||
import com.jme3.math.Vector3f;
|
|
||||||
import com.jme3.scene.Node;
|
|
||||||
import com.jme3.scene.control.AbstractControl;
|
|
||||||
import pp.mdga.client.MdgaApp;
|
|
||||||
import pp.mdga.client.acoustic.MdgaSound;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@code Explosion} class represents an explosion effect in a 3D environment.
|
|
||||||
* It manages the creation, configuration, and triggering of particle emitters for fire and smoke effects.
|
|
||||||
*/
|
|
||||||
public class Explosion {
|
|
||||||
|
|
||||||
private final Node rootNode;
|
|
||||||
private final MdgaApp app;
|
|
||||||
private final Vector3f location;
|
|
||||||
private ParticleEmitter fire;
|
|
||||||
private ParticleEmitter smoke;
|
|
||||||
|
|
||||||
private boolean triggered = false;
|
|
||||||
|
|
||||||
private final Material mat;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for the {@code Explosion} class.
|
|
||||||
*
|
|
||||||
* @param app The main application managing the explosion.
|
|
||||||
* @param rootNode The root node to which the explosion effects will be attached.
|
|
||||||
* @param location The location of the explosion in world coordinates.
|
|
||||||
*/
|
|
||||||
public Explosion(MdgaApp app, Node rootNode, Vector3f location) {
|
|
||||||
this.app = app;
|
|
||||||
this.rootNode = rootNode;
|
|
||||||
this.location = location;
|
|
||||||
|
|
||||||
this.mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes the particle emitters for the explosion effect.
|
|
||||||
* Configures the fire and smoke emitters with appearance, behavior, and lifespan.
|
|
||||||
*/
|
|
||||||
private void initializeEmitter() {
|
|
||||||
fire = new ParticleEmitter("Effect", Type.Triangle,50);
|
|
||||||
fire.setMaterial(mat);
|
|
||||||
fire.setStartColor(ColorRGBA.Yellow);
|
|
||||||
fire.setEndColor(ColorRGBA.Red);
|
|
||||||
fire.getParticleInfluencer().setInitialVelocity(new Vector3f(0.2f,0.2f,4f));
|
|
||||||
fire.getParticleInfluencer().setVelocityVariation(0.4f);
|
|
||||||
fire.setStartSize(0.1f);
|
|
||||||
fire.setEndSize(0.8f);
|
|
||||||
fire.setGravity(0, 0, -0.1f);
|
|
||||||
fire.setLowLife(0.5f);
|
|
||||||
fire.setHighLife(2.2f);
|
|
||||||
fire.setParticlesPerSec(0);
|
|
||||||
|
|
||||||
fire.setLocalTranslation(location);
|
|
||||||
|
|
||||||
smoke = new ParticleEmitter("Effect2", 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,0.7f));
|
|
||||||
smoke.getParticleInfluencer().setVelocityVariation(0.5f);
|
|
||||||
smoke.setStartSize(0.2f);
|
|
||||||
smoke.setEndSize(0.5f);
|
|
||||||
smoke.setGravity(0, 0, -0.3f);
|
|
||||||
smoke.setLowLife(1.2f);
|
|
||||||
smoke.setHighLife(5.5f);
|
|
||||||
smoke.setParticlesPerSec(0);
|
|
||||||
|
|
||||||
smoke.setLocalTranslation(location);
|
|
||||||
|
|
||||||
app.getAcousticHandler().playSound(MdgaSound.EXPLOSION);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Triggers the explosion effect by attaching and activating the particle emitters for fire and smoke.
|
|
||||||
* Both emitters are automatically detached after a predefined duration.
|
|
||||||
*/
|
|
||||||
public void trigger() {
|
|
||||||
if (!triggered) {
|
|
||||||
triggered = true;
|
|
||||||
initializeEmitter();
|
|
||||||
}
|
|
||||||
|
|
||||||
rootNode.attachChild(fire);
|
|
||||||
fire.emitAllParticles();
|
|
||||||
fire.addControl(new AbstractControl() {
|
|
||||||
private float elapsedTime = 0;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void controlUpdate(float tpf) {
|
|
||||||
elapsedTime += tpf;
|
|
||||||
if (elapsedTime > 10f) {
|
|
||||||
rootNode.detachChild(fire);
|
|
||||||
fire.removeControl(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void controlRender(com.jme3.renderer.RenderManager rm, com.jme3.renderer.ViewPort vp) {}
|
|
||||||
});
|
|
||||||
|
|
||||||
rootNode.attachChild(smoke);
|
|
||||||
smoke.emitAllParticles();
|
|
||||||
smoke.addControl(new AbstractControl() {
|
|
||||||
private float elapsedTime = 0;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void controlUpdate(float tpf) {
|
|
||||||
elapsedTime += tpf;
|
|
||||||
if (elapsedTime > 10f) {
|
|
||||||
rootNode.detachChild(smoke);
|
|
||||||
smoke.removeControl(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void controlRender(com.jme3.renderer.RenderManager rm, com.jme3.renderer.ViewPort vp) {}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
package pp.mdga.client.animation;
|
|
||||||
|
|
||||||
import com.jme3.renderer.queue.RenderQueue;
|
|
||||||
import com.jme3.scene.Geometry;
|
|
||||||
import com.jme3.material.Material;
|
|
||||||
import com.jme3.math.ColorRGBA;
|
|
||||||
import pp.mdga.client.InitControl;
|
|
||||||
|
|
||||||
import static pp.mdga.client.Util.linInt;
|
|
||||||
|
|
||||||
public class FadeControl extends ActionControl {
|
|
||||||
private float duration; // Duration of the fade effect
|
|
||||||
private float timeElapsed = 0;
|
|
||||||
private boolean init = false;
|
|
||||||
private float startAlpha;
|
|
||||||
private float endAlpha;
|
|
||||||
|
|
||||||
public FadeControl(float duration, float startAlpha, float endAlpha, Runnable actionAfter) {
|
|
||||||
super(actionAfter);
|
|
||||||
this.duration = duration;
|
|
||||||
this.startAlpha = startAlpha;
|
|
||||||
this.endAlpha = endAlpha;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FadeControl(float duration, float startAlpha, float endAlpha) {
|
|
||||||
this(duration, startAlpha, endAlpha, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void initSpatial() {
|
|
||||||
init = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void controlUpdate(float tpf) {
|
|
||||||
if (!init) return;
|
|
||||||
|
|
||||||
timeElapsed += tpf;
|
|
||||||
float t = timeElapsed / duration; // Calculate progress (0 to 1)
|
|
||||||
|
|
||||||
if (t >= 1) {
|
|
||||||
// Fade complete
|
|
||||||
t = 1;
|
|
||||||
init = false;
|
|
||||||
spatial.removeControl(this);
|
|
||||||
action();
|
|
||||||
}
|
|
||||||
|
|
||||||
float alpha = linInt(startAlpha, endAlpha, t); // Interpolate alpha
|
|
||||||
|
|
||||||
// Update the material's alpha
|
|
||||||
if (spatial instanceof Geometry geometry) {
|
|
||||||
Material mat = geometry.getMaterial();
|
|
||||||
if (mat != null) {
|
|
||||||
ColorRGBA diffuse = (ColorRGBA) mat.getParam("Diffuse").getValue();
|
|
||||||
mat.setColor("Diffuse", new ColorRGBA(diffuse.r, diffuse.g, diffuse.b, alpha));
|
|
||||||
|
|
||||||
ColorRGBA ambient = (ColorRGBA) mat.getParam("Ambient").getValue();
|
|
||||||
mat.setColor("Ambient", new ColorRGBA(ambient.r, ambient.g, ambient.b, alpha));
|
|
||||||
|
|
||||||
// Disable shadows when the object is nearly invisible
|
|
||||||
if (alpha <= 0.1f) {
|
|
||||||
geometry.setShadowMode(RenderQueue.ShadowMode.Off);
|
|
||||||
} else {
|
|
||||||
geometry.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
|
|
||||||
}
|
|
||||||
} else throw new RuntimeException("Material is null");
|
|
||||||
} else throw new RuntimeException("Spatial is not instance of Geometry");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,201 +0,0 @@
|
|||||||
package pp.mdga.client.animation;
|
|
||||||
|
|
||||||
import com.jme3.material.Material;
|
|
||||||
import com.jme3.math.FastMath;
|
|
||||||
import com.jme3.math.Vector3f;
|
|
||||||
import com.jme3.renderer.RenderManager;
|
|
||||||
import com.jme3.renderer.ViewPort;
|
|
||||||
import com.jme3.renderer.queue.RenderQueue;
|
|
||||||
import com.jme3.scene.Node;
|
|
||||||
import com.jme3.scene.Spatial;
|
|
||||||
import com.jme3.scene.control.AbstractControl;
|
|
||||||
import pp.mdga.client.Asset;
|
|
||||||
import pp.mdga.client.MdgaApp;
|
|
||||||
import pp.mdga.client.acoustic.MdgaSound;
|
|
||||||
import pp.mdga.client.board.BoardHandler;
|
|
||||||
import pp.mdga.client.view.GameView;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@code JetAnimation} class handles the animation of a jet model in a 3D environment.
|
|
||||||
* It creates a jet model, animates its movement along a curved path, triggers an explosion at a target point,
|
|
||||||
* and performs additional actions upon animation completion.
|
|
||||||
*/
|
|
||||||
public class JetAnimation {
|
|
||||||
|
|
||||||
private final MdgaApp app;
|
|
||||||
private final Node rootNode;
|
|
||||||
private Spatial jetModel;
|
|
||||||
private final Vector3f spawnPoint;
|
|
||||||
private final Vector3f nodePoint;
|
|
||||||
private final Vector3f despawnPoint;
|
|
||||||
private final float curveHeight;
|
|
||||||
private final float animationDuration;
|
|
||||||
private Explosion explosion;
|
|
||||||
private final UUID id;
|
|
||||||
private Runnable actionAfter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 uuid A unique identifier for the animation.
|
|
||||||
* @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, UUID uuid, Vector3f targetPoint, float curveHeight, float animationDuration, Runnable actionAfter) {
|
|
||||||
Vector3f spawnPoint = targetPoint.add(170, 50, 50);
|
|
||||||
|
|
||||||
Vector3f controlPoint = targetPoint.add(new Vector3f(0, 0, -45));
|
|
||||||
|
|
||||||
Vector3f despawnPoint = targetPoint.add(-100, -100, 40);
|
|
||||||
|
|
||||||
this.app = app;
|
|
||||||
this.rootNode = rootNode;
|
|
||||||
this.spawnPoint = spawnPoint;
|
|
||||||
this.nodePoint = controlPoint;
|
|
||||||
this.despawnPoint = despawnPoint;
|
|
||||||
this.curveHeight = curveHeight;
|
|
||||||
this.animationDuration = animationDuration;
|
|
||||||
|
|
||||||
id = uuid;
|
|
||||||
|
|
||||||
explosion = new Explosion(app, rootNode, nodePoint);
|
|
||||||
this.actionAfter = actionAfter;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Starts the jet animation by spawning the jet model and initiating its movement along the predefined path.
|
|
||||||
*/
|
|
||||||
public void start() {
|
|
||||||
app.getAcousticHandler().playSound(MdgaSound.JET);
|
|
||||||
spawnJet();
|
|
||||||
animateJet();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Spawns the jet model at the designated spawn point, applying material, scaling, and rotation.
|
|
||||||
*/
|
|
||||||
private void spawnJet() {
|
|
||||||
jetModel = app.getAssetManager().loadModel(Asset.jet.getModelPath());
|
|
||||||
jetModel.setLocalTranslation(spawnPoint);
|
|
||||||
jetModel.scale(Asset.jet.getSize());
|
|
||||||
jetModel.rotate(FastMath.HALF_PI, 0, 0);
|
|
||||||
jetModel.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
|
|
||||||
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
|
|
||||||
mat.setTexture("DiffuseMap", app.getAssetManager().loadTexture(Asset.jet.getDiffPath()));
|
|
||||||
jetModel.setMaterial(mat);
|
|
||||||
|
|
||||||
rootNode.attachChild(jetModel);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Animates the jet along a Bezier curve path, triggers the explosion effect at the appropriate time,
|
|
||||||
* and performs cleanup operations after the animation completes.
|
|
||||||
*/
|
|
||||||
private void animateJet() {
|
|
||||||
Vector3f controlPoint1 = spawnPoint.add(0, curveHeight, 0);
|
|
||||||
Vector3f controlPoint2 = nodePoint.add(0, curveHeight, 0);
|
|
||||||
|
|
||||||
BezierCurve3f curve = new BezierCurve3f(spawnPoint, controlPoint1, controlPoint2, despawnPoint);
|
|
||||||
|
|
||||||
app.getRootNode().addControl(new AbstractControl() {
|
|
||||||
private float elapsedTime = 0;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void controlUpdate(float tpf) {
|
|
||||||
elapsedTime += tpf;
|
|
||||||
float progress = elapsedTime / animationDuration;
|
|
||||||
|
|
||||||
if(elapsedTime > 4.2f) {
|
|
||||||
explosion.trigger();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (progress > 1) {
|
|
||||||
rootNode.detachChild(jetModel);
|
|
||||||
this.spatial.removeControl(this);
|
|
||||||
} else {
|
|
||||||
Vector3f currentPos = curve.interpolate(progress);
|
|
||||||
Vector3f direction = curve.interpolateDerivative(progress).normalizeLocal();
|
|
||||||
jetModel.setLocalTranslation(currentPos);
|
|
||||||
jetModel.lookAt(currentPos.add(direction), Vector3f.UNIT_Z);
|
|
||||||
jetModel.rotate(-FastMath.HALF_PI, 0, (float) Math.toRadians(-25));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (elapsedTime > 6.0f) {
|
|
||||||
endAnim();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void controlRender(RenderManager rm, ViewPort vp) {}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void endAnim(){
|
|
||||||
actionAfter.run();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@code BezierCurve3f} class represents a 3D cubic Bezier curve.
|
|
||||||
* It provides methods to interpolate positions and derivatives along the curve.
|
|
||||||
*/
|
|
||||||
private static class BezierCurve3f {
|
|
||||||
private final Vector3f p0, p1, p2, p3;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for the {@code BezierCurve3f} class.
|
|
||||||
*
|
|
||||||
* @param p0 The starting point of the curve.
|
|
||||||
* @param p1 The first control point influencing the curve's shape.
|
|
||||||
* @param p2 The second control point influencing the curve's shape.
|
|
||||||
* @param p3 The endpoint of the curve.
|
|
||||||
*/
|
|
||||||
public BezierCurve3f(Vector3f p0, Vector3f p1, Vector3f p2, Vector3f p3) {
|
|
||||||
this.p0 = p0;
|
|
||||||
this.p1 = p1;
|
|
||||||
this.p2 = p2;
|
|
||||||
this.p3 = p3;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Interpolates a position along the curve at a given progress value {@code t}.
|
|
||||||
*
|
|
||||||
* @param t The progress value (0.0 to 1.0) along the curve.
|
|
||||||
* @return The interpolated position on the curve.
|
|
||||||
*/
|
|
||||||
public Vector3f interpolate(float t) {
|
|
||||||
float u = 1 - t;
|
|
||||||
float tt = t * t;
|
|
||||||
float uu = u * u;
|
|
||||||
float uuu = uu * u;
|
|
||||||
float ttt = tt * t;
|
|
||||||
|
|
||||||
Vector3f point = p0.mult(uuu);
|
|
||||||
point = point.add(p1.mult(3 * uu * t));
|
|
||||||
point = point.add(p2.mult(3 * u * tt));
|
|
||||||
point = point.add(p3.mult(ttt));
|
|
||||||
return point;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Computes the derivative at a given progress value {@code t}, representing the direction along the curve.
|
|
||||||
*
|
|
||||||
* @param t The progress value (0.0 to 1.0) along the curve.
|
|
||||||
* @return The derivative (direction vector) at the specified progress.
|
|
||||||
*/
|
|
||||||
public Vector3f interpolateDerivative(float t) {
|
|
||||||
float u = 1 - t;
|
|
||||||
float tt = t * t;
|
|
||||||
|
|
||||||
Vector3f derivative = p0.mult(-3 * u * u);
|
|
||||||
derivative = derivative.add(p1.mult(3 * u * u - 6 * u * t));
|
|
||||||
derivative = derivative.add(p2.mult(6 * u * t - 3 * tt));
|
|
||||||
derivative = derivative.add(p3.mult(3 * tt));
|
|
||||||
return derivative;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,200 +0,0 @@
|
|||||||
package pp.mdga.client.animation;
|
|
||||||
|
|
||||||
import com.jme3.effect.ParticleEmitter;
|
|
||||||
import com.jme3.effect.ParticleMesh.Type;
|
|
||||||
import com.jme3.material.Material;
|
|
||||||
import com.jme3.material.RenderState;
|
|
||||||
import com.jme3.math.ColorRGBA;
|
|
||||||
import com.jme3.math.Vector3f;
|
|
||||||
import pp.mdga.client.InitControl;
|
|
||||||
import pp.mdga.client.MdgaApp;
|
|
||||||
import pp.mdga.client.acoustic.MdgaSound;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class MatrixAnimation extends ActionControl {
|
|
||||||
private MdgaApp app;
|
|
||||||
private static final Random RANDOM = new Random();
|
|
||||||
private Vector3f radarPos;
|
|
||||||
private Runnable runnable;
|
|
||||||
private boolean init = false;
|
|
||||||
private List<ParticleEmitter> activeEmitter = new ArrayList<>();
|
|
||||||
private ParticleEmitter radarEmitter = null;
|
|
||||||
private float timeElapsed = 0f;
|
|
||||||
|
|
||||||
private enum MatrixState{
|
|
||||||
RADAR_ON,
|
|
||||||
RADAR_OFF,
|
|
||||||
MATRIX_ON,
|
|
||||||
MATRIX_OFF
|
|
||||||
}
|
|
||||||
|
|
||||||
private MatrixState state;
|
|
||||||
public MatrixAnimation(MdgaApp app, Vector3f radarPos, Runnable runnable){
|
|
||||||
super(runnable);
|
|
||||||
this.app = app;
|
|
||||||
this.radarPos = radarPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void initSpatial() {
|
|
||||||
state = MatrixState.RADAR_ON;
|
|
||||||
timeElapsed = 0;
|
|
||||||
init = true;
|
|
||||||
radar();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void controlUpdate(float tpf) {
|
|
||||||
if(!init) return;
|
|
||||||
|
|
||||||
timeElapsed += tpf;
|
|
||||||
|
|
||||||
switch(state){
|
|
||||||
case RADAR_ON -> {
|
|
||||||
if(timeElapsed >= 2f){
|
|
||||||
state = MatrixState.RADAR_OFF;
|
|
||||||
timeElapsed = 0;
|
|
||||||
radarEmitter.setParticlesPerSec(0);
|
|
||||||
new Timer().schedule(new TimerTask() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
app.getRootNode().detachChild(radarEmitter);
|
|
||||||
}
|
|
||||||
}, 3000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case RADAR_OFF -> {
|
|
||||||
if(timeElapsed >= 0.1f){
|
|
||||||
state = MatrixState.MATRIX_ON;
|
|
||||||
timeElapsed = 0;
|
|
||||||
matrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
case MATRIX_ON -> {
|
|
||||||
if(timeElapsed >= 3f){
|
|
||||||
state = MatrixState.MATRIX_OFF;
|
|
||||||
timeElapsed = 0;
|
|
||||||
turnOff();
|
|
||||||
new Timer().schedule(new TimerTask() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
for (ParticleEmitter particleEmitter : activeEmitter){
|
|
||||||
app.getRootNode().detachChild(particleEmitter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 3000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case MATRIX_OFF -> {
|
|
||||||
if(timeElapsed >= 0.5f){
|
|
||||||
init = false;
|
|
||||||
spatial.removeControl(this);
|
|
||||||
action();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void turnOff(){
|
|
||||||
for (ParticleEmitter particleEmitter : activeEmitter){
|
|
||||||
particleEmitter.setParticlesPerSec(0f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void radar(){
|
|
||||||
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md");
|
|
||||||
mat.setTexture("Texture", app.getAssetManager().loadTexture("Images/particle/radar_beam.png"));
|
|
||||||
ParticleEmitter emitter = new ParticleEmitter("Effect", Type.Triangle, 50);
|
|
||||||
emitter.setMaterial(mat);
|
|
||||||
emitter.setImagesX(1); // columns
|
|
||||||
emitter.setImagesY(1); // rows
|
|
||||||
emitter.setSelectRandomImage(true);
|
|
||||||
emitter.setStartColor(ColorRGBA.White);
|
|
||||||
emitter.setEndColor(ColorRGBA.Black);
|
|
||||||
emitter.getParticleInfluencer().setInitialVelocity(new Vector3f(0f, 0f, 2));
|
|
||||||
emitter.getParticleInfluencer().setVelocityVariation(0f);
|
|
||||||
emitter.setStartSize(0.1f);
|
|
||||||
emitter.setEndSize(10);
|
|
||||||
emitter.setGravity(0, 0, 0);
|
|
||||||
float life = 2.6f;
|
|
||||||
emitter.setLowLife(life);
|
|
||||||
emitter.setHighLife(life);
|
|
||||||
emitter.setLocalTranslation(radarPos.add(new Vector3f(0,0,5)));
|
|
||||||
emitter.setParticlesPerSec(1.8f);
|
|
||||||
app.getRootNode().attachChild(emitter);
|
|
||||||
radarEmitter = emitter;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void matrix(){
|
|
||||||
for(int i = 0; i < 5; i++){
|
|
||||||
particleStream(
|
|
||||||
generateMatrixColor(),
|
|
||||||
generateMatrixColor(),
|
|
||||||
getRandomFloat(0,1f),
|
|
||||||
getRandomPosition(),
|
|
||||||
getRandomFloat(1,2)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void particleStream(ColorRGBA start, ColorRGBA end, float speedVar, Vector3f pos, float spawnVar){
|
|
||||||
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md");
|
|
||||||
mat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
|
|
||||||
mat.setTexture("Texture", app.getAssetManager().loadTexture("Images/particle/particle_cir.png"));
|
|
||||||
ParticleEmitter matrix = new ParticleEmitter("Effect", Type.Triangle, 50);
|
|
||||||
matrix.setMaterial(mat);
|
|
||||||
matrix.setImagesX(2); // columns
|
|
||||||
matrix.setImagesY(1); // rows
|
|
||||||
matrix.setSelectRandomImage(true);
|
|
||||||
matrix.setStartColor(start);
|
|
||||||
matrix.setEndColor(end);
|
|
||||||
matrix.getParticleInfluencer().setInitialVelocity(new Vector3f(0f, 0f, -6f - speedVar));
|
|
||||||
matrix.getParticleInfluencer().setVelocityVariation(0f);
|
|
||||||
matrix.setStartSize(0.4f);
|
|
||||||
matrix.setEndSize(0.6f);
|
|
||||||
matrix.setGravity(0, 0, 2f);
|
|
||||||
matrix.setLowLife(3f);
|
|
||||||
matrix.setHighLife(3f);
|
|
||||||
matrix.setLocalTranslation(spatial.getLocalTranslation().add(pos).add(new Vector3f(0,0,15)));
|
|
||||||
matrix.setParticlesPerSec(spawnVar);
|
|
||||||
app.getRootNode().attachChild(matrix);
|
|
||||||
activeEmitter.add(matrix);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Vector3f getRandomPosition() {
|
|
||||||
// Generate a random angle in radians (0 to 2π)
|
|
||||||
float angle = (float) (2 * Math.PI * RANDOM.nextDouble());
|
|
||||||
|
|
||||||
// Generate a random radius with uniform distribution
|
|
||||||
float radius = (float) Math.sqrt(RANDOM.nextDouble());
|
|
||||||
radius *= 1f;
|
|
||||||
|
|
||||||
// Convert polar coordinates to Cartesian
|
|
||||||
float x = radius * (float) Math.cos(angle);
|
|
||||||
float y = radius * (float) Math.sin(angle);
|
|
||||||
|
|
||||||
return new Vector3f(x,y,0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static float getRandomFloat(float start, float end) {
|
|
||||||
if (start > end) {
|
|
||||||
throw new IllegalArgumentException("Start must be less than or equal to end.");
|
|
||||||
}
|
|
||||||
return start + RANDOM.nextFloat() * (end - start);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ColorRGBA generateMatrixColor() {
|
|
||||||
// Red is dominant
|
|
||||||
float red = 0.8f + RANDOM.nextFloat() * 0.2f; // Red channel: 0.8 to 1.0
|
|
||||||
// Green is moderately high
|
|
||||||
float green = 0.4f + RANDOM.nextFloat() * 0.3f; // Green channel: 0.4 to 0.7
|
|
||||||
// Blue is minimal
|
|
||||||
float blue = RANDOM.nextFloat() * 0.2f; // Blue channel: 0.0 to 0.2
|
|
||||||
float alpha = 1.0f; // Fully opaque
|
|
||||||
|
|
||||||
return new ColorRGBA(red, green, blue, alpha);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,141 +0,0 @@
|
|||||||
package pp.mdga.client.animation;
|
|
||||||
|
|
||||||
import com.jme3.material.Material;
|
|
||||||
import com.jme3.math.FastMath;
|
|
||||||
import com.jme3.math.Vector3f;
|
|
||||||
import com.jme3.renderer.RenderManager;
|
|
||||||
import com.jme3.renderer.ViewPort;
|
|
||||||
import com.jme3.renderer.queue.RenderQueue;
|
|
||||||
import com.jme3.scene.Node;
|
|
||||||
import com.jme3.scene.Spatial;
|
|
||||||
import com.jme3.scene.control.AbstractControl;
|
|
||||||
import pp.mdga.client.Asset;
|
|
||||||
import pp.mdga.client.MdgaApp;
|
|
||||||
import pp.mdga.client.acoustic.MdgaSound;
|
|
||||||
import pp.mdga.client.board.BoardHandler;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@code MissileAnimation} class handles the animation of a missile moving along a parabolic path
|
|
||||||
* towards a target point in a 3D environment. It also triggers an explosion at the target upon impact.
|
|
||||||
*/
|
|
||||||
public class MissileAnimation {
|
|
||||||
|
|
||||||
private final Node rootNode;
|
|
||||||
private final MdgaApp app;
|
|
||||||
private final Vector3f start;
|
|
||||||
private final Vector3f target;
|
|
||||||
private final float flightTime;
|
|
||||||
private Explosion explosion;
|
|
||||||
private Spatial missileModel;
|
|
||||||
|
|
||||||
private UUID id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 uuid A unique identifier for the missile animation.
|
|
||||||
* @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, UUID uuid, Vector3f target, float flightTime) {
|
|
||||||
this.app = app;
|
|
||||||
this.rootNode = rootNode;
|
|
||||||
this.flightTime = flightTime;
|
|
||||||
|
|
||||||
explosion = new Explosion(app, rootNode, target);
|
|
||||||
id = uuid;
|
|
||||||
|
|
||||||
this.target = target.add(new Vector3f(1.5f, -1, 0));
|
|
||||||
|
|
||||||
|
|
||||||
start = BoardHandler.gridToWorld(12, 0);
|
|
||||||
start.add(new Vector3f(0, 0, 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Starts the missile animation by loading the missile model and initiating its parabolic movement.
|
|
||||||
*/
|
|
||||||
public void start() {
|
|
||||||
Smoke s = new Smoke(app, rootNode, start);
|
|
||||||
s.trigger();
|
|
||||||
loadMissile();
|
|
||||||
app.getAcousticHandler().playSound(MdgaSound.MISSILE);
|
|
||||||
animateMissile();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads the missile model into the scene, applies scaling, material, and sets its initial position.
|
|
||||||
*/
|
|
||||||
private void loadMissile() {
|
|
||||||
missileModel = app.getAssetManager().loadModel(Asset.missile.getModelPath());
|
|
||||||
missileModel.scale(Asset.missile.getSize());
|
|
||||||
missileModel.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
|
|
||||||
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
|
|
||||||
mat.setTexture("DiffuseMap", app.getAssetManager().loadTexture(Asset.missile.getDiffPath()));
|
|
||||||
missileModel.setMaterial(mat);
|
|
||||||
missileModel.setLocalTranslation(start);
|
|
||||||
rootNode.attachChild(missileModel);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Animates the missile along a parabolic path, triggers the explosion near the target,
|
|
||||||
* and removes the missile model after the animation completes.
|
|
||||||
*/
|
|
||||||
private void animateMissile() {
|
|
||||||
missileModel.addControl(new AbstractControl() {
|
|
||||||
private float elapsedTime = 0;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void controlUpdate(float tpf) {
|
|
||||||
elapsedTime += tpf;
|
|
||||||
float progress = elapsedTime / flightTime;
|
|
||||||
|
|
||||||
if (progress >= 0.95f) {
|
|
||||||
explosion.trigger();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (progress >= 1) {
|
|
||||||
explosion.trigger();
|
|
||||||
|
|
||||||
rootNode.detachChild(missileModel);
|
|
||||||
this.spatial.removeControl(this);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector3f currentPosition = computeParabolicPath(start, target, progress);
|
|
||||||
missileModel.setLocalTranslation(currentPosition);
|
|
||||||
|
|
||||||
Vector3f direction = computeParabolicPath(start, target, progress + 0.01f)
|
|
||||||
.subtract(currentPosition)
|
|
||||||
.normalizeLocal();
|
|
||||||
missileModel.lookAt(currentPosition.add(direction), Vector3f.UNIT_Y);
|
|
||||||
missileModel.rotate(0, FastMath.HALF_PI, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void controlRender(RenderManager rm, ViewPort vp) {
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 target The target point of the missile's flight.
|
|
||||||
* @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) {
|
|
||||||
Vector3f midPoint = start.add(target).multLocal(0.5f);
|
|
||||||
midPoint.addLocal(0, 0, 20);
|
|
||||||
|
|
||||||
Vector3f startToMid = FastMath.interpolateLinear(t, start, midPoint);
|
|
||||||
Vector3f midToTarget = FastMath.interpolateLinear(t, midPoint, target);
|
|
||||||
return FastMath.interpolateLinear(t, startToMid, midToTarget);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
package pp.mdga.client.animation;
|
package pp.mdga.client.animation;
|
||||||
|
|
||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
|
import pp.mdga.client.InitControl;
|
||||||
import static pp.mdga.client.Util.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A control that smoothly moves a spatial from an initial position to an end position
|
* A control that smoothly moves a spatial from an initial position to an end position
|
||||||
@@ -13,16 +12,16 @@
|
|||||||
* an ease-in-out curve to create a smooth start and stop effect.
|
* an ease-in-out curve to create a smooth start and stop effect.
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public class MoveControl extends ActionControl {
|
public class MoveControl extends InitControl {
|
||||||
|
|
||||||
private boolean moving;
|
private boolean moving;
|
||||||
private final Vector3f initPos;
|
private final Vector3f initPos;
|
||||||
private final Vector3f endPos;
|
private final Vector3f endPos;
|
||||||
private final Vector3f middlePos;
|
private final Vector3f middlePos;
|
||||||
private final float height;
|
private final static float HEIGHT = 2;
|
||||||
private final float duration;
|
private final static float MOVE_SPEED = 1f;
|
||||||
private float timer = 0;
|
private float progress = 0;
|
||||||
private boolean easing;
|
private final Runnable actionAfter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new MoveControl with specified initial and end positions, and an action to run after the movement.
|
* Creates a new MoveControl with specified initial and end positions, and an action to run after the movement.
|
||||||
@@ -33,22 +32,15 @@ public class MoveControl extends ActionControl {
|
|||||||
* @param actionAfter A Runnable that will be executed after the movement finishes.
|
* @param actionAfter A Runnable that will be executed after the movement finishes.
|
||||||
*/
|
*/
|
||||||
public MoveControl(Vector3f initPos, Vector3f endPos, Runnable actionAfter){
|
public MoveControl(Vector3f initPos, Vector3f endPos, Runnable actionAfter){
|
||||||
this(initPos, endPos, actionAfter, 2, 1, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MoveControl(Vector3f initPos, Vector3f endPos, Runnable actionAfter, float height, float duration, boolean easing){
|
|
||||||
super(actionAfter);
|
|
||||||
moving = false;
|
moving = false;
|
||||||
this.initPos = initPos;
|
this.initPos = initPos;
|
||||||
this.endPos = endPos;
|
this.endPos = endPos;
|
||||||
this.height = height;
|
|
||||||
this.duration = duration;
|
|
||||||
this.easing = easing;
|
|
||||||
middlePos = new Vector3f(
|
middlePos = new Vector3f(
|
||||||
(initPos.x + endPos.x) / 2,
|
(initPos.x + endPos.x) / 2,
|
||||||
(initPos.y + endPos.y) / 2,
|
(initPos.y + endPos.y) / 2,
|
||||||
height
|
HEIGHT
|
||||||
);
|
);
|
||||||
|
this.actionAfter = actionAfter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -58,7 +50,7 @@ public MoveControl(Vector3f initPos, Vector3f endPos, Runnable actionAfter, floa
|
|||||||
@Override
|
@Override
|
||||||
protected void initSpatial() {
|
protected void initSpatial() {
|
||||||
moving = true;
|
moving = true;
|
||||||
timer = 0;
|
progress = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -71,16 +63,10 @@ protected void initSpatial() {
|
|||||||
@Override
|
@Override
|
||||||
protected void controlUpdate(float tpf) {
|
protected void controlUpdate(float tpf) {
|
||||||
if(!moving) return;
|
if(!moving) return;
|
||||||
timer += tpf;
|
progress += tpf * MOVE_SPEED;
|
||||||
|
if(progress > 1) progress = 1;
|
||||||
float t = timer / duration;
|
spatial.setLocalTranslation(quadInt(initPos,middlePos,endPos, easeInOut(progress)));
|
||||||
if (t >= 1) t = 1;
|
if(progress == 1) end();
|
||||||
|
|
||||||
float interpolated = easing ? easeInOut(t) : t;
|
|
||||||
|
|
||||||
spatial.setLocalTranslation(quadInt(initPos,middlePos,endPos, interpolated));
|
|
||||||
|
|
||||||
if(t >= 1) end();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -89,11 +75,35 @@ protected void controlUpdate(float tpf) {
|
|||||||
*/
|
*/
|
||||||
private void end(){
|
private void end(){
|
||||||
moving = false;
|
moving = false;
|
||||||
|
actionAfter.run();
|
||||||
spatial.removeControl(this);
|
spatial.removeControl(this);
|
||||||
action();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Performs quadratic interpolation between three points.
|
||||||
|
*
|
||||||
|
* @param p1 The initial point.
|
||||||
|
* @param p2 The middle point.
|
||||||
|
* @param p3 The final point.
|
||||||
|
* @param t The interpolation parameter (0 <= t <= 1).
|
||||||
|
* @return The interpolated point.
|
||||||
|
*/
|
||||||
|
private Vector3f quadInt(Vector3f p1, Vector3f p2, Vector3f p3, float t) {
|
||||||
|
// Quadratic interpolation: (1-t)^2 * p1 + 2 * (1-t) * t * p2 + t^2 * p3
|
||||||
|
float oneMinusT = 1 - t;
|
||||||
|
return p1.mult(oneMinusT * oneMinusT)
|
||||||
|
.add(p2.mult(2 * oneMinusT * t))
|
||||||
|
.add(p3.mult(t * t));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A smooth ease-in-out function for interpolation.
|
||||||
|
* It accelerates and decelerates the interpolation for a smoother effect.
|
||||||
|
*
|
||||||
|
* @param x The interpolation parameter (0 <= x <= 1).
|
||||||
|
* @return The adjusted interpolation value.
|
||||||
|
*/
|
||||||
|
private float easeInOut(float x){
|
||||||
|
return x < 0.5 ? 4 * x * x * x : (float) (1 - Math.pow(-2 * x + 2, 3) / 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,167 +0,0 @@
|
|||||||
package pp.mdga.client.animation;
|
|
||||||
|
|
||||||
import com.jme3.effect.ParticleEmitter;
|
|
||||||
import com.jme3.effect.ParticleMesh;
|
|
||||||
import com.jme3.material.Material;
|
|
||||||
import com.jme3.material.RenderState;
|
|
||||||
import com.jme3.math.ColorRGBA;
|
|
||||||
import com.jme3.math.FastMath;
|
|
||||||
import com.jme3.math.Quaternion;
|
|
||||||
import com.jme3.math.Vector3f;
|
|
||||||
import com.jme3.renderer.queue.RenderQueue;
|
|
||||||
import com.jme3.scene.Geometry;
|
|
||||||
import com.jme3.scene.Spatial;
|
|
||||||
import com.jme3.scene.shape.Box;
|
|
||||||
import pp.mdga.client.Asset;
|
|
||||||
import pp.mdga.client.InitControl;
|
|
||||||
import pp.mdga.client.MdgaApp;
|
|
||||||
import pp.mdga.client.acoustic.MdgaSound;
|
|
||||||
import pp.mdga.client.board.TankTopControl;
|
|
||||||
|
|
||||||
import java.util.Timer;
|
|
||||||
import java.util.TimerTask;
|
|
||||||
|
|
||||||
import static com.jme3.material.Materials.LIGHTING;
|
|
||||||
import static com.jme3.material.Materials.UNSHADED;
|
|
||||||
|
|
||||||
public class ShellAnimation extends ActionControl {
|
|
||||||
private static final float FLYING_DURATION = 1.25f;
|
|
||||||
private static final float FLYING_HEIGHT = 12f;
|
|
||||||
private TankTopControl tankTopControl;
|
|
||||||
private MdgaApp app;
|
|
||||||
|
|
||||||
public ShellAnimation(TankTopControl tankTopControl, MdgaApp app, Runnable actionAfter){
|
|
||||||
super(actionAfter);
|
|
||||||
this.tankTopControl = tankTopControl;
|
|
||||||
this.app = app;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void initSpatial() {
|
|
||||||
tankTopControl.rotate(spatial.getLocalTranslation(), this::shoot);
|
|
||||||
app.getAcousticHandler().playSound(MdgaSound.TURRET_ROTATE);
|
|
||||||
app.getRootNode().attachChild(createShell());
|
|
||||||
}
|
|
||||||
|
|
||||||
private Vector3f getShootPos(){
|
|
||||||
Vector3f localOffset = new Vector3f(0, -5.4f, 2.9f);
|
|
||||||
Quaternion turretRotation = tankTopControl.getSpatial().getLocalRotation();
|
|
||||||
Vector3f transformedOffset = turretRotation.mult(localOffset);
|
|
||||||
return tankTopControl.getSpatial().getLocalTranslation().add(transformedOffset);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void shoot(){
|
|
||||||
app.getAcousticHandler().playSound(MdgaSound.TANK_SHOOT);
|
|
||||||
Vector3f shootPos = getShootPos();
|
|
||||||
createEffect(
|
|
||||||
shootPos,
|
|
||||||
"Images/particle/flame.png",
|
|
||||||
2, 2,
|
|
||||||
1, 3,
|
|
||||||
1f,
|
|
||||||
0.3f, 0.7f,
|
|
||||||
new ColorRGBA(1f, 0.8f, 0.4f, 0.5f),
|
|
||||||
new ColorRGBA(1f, 0f, 0f, 0f)
|
|
||||||
);
|
|
||||||
createEffect(
|
|
||||||
shootPos,
|
|
||||||
"Images/particle/vapor_cloud.png",
|
|
||||||
3, 3,
|
|
||||||
0.3f, 0.8f,
|
|
||||||
10,
|
|
||||||
0.1f, 0.35f,
|
|
||||||
new ColorRGBA(0.5f,0.5f,0.5f,0.5f),
|
|
||||||
ColorRGBA.Black
|
|
||||||
);
|
|
||||||
|
|
||||||
Spatial shell = createShell();
|
|
||||||
app.getRootNode().attachChild(shell);
|
|
||||||
shell.addControl(new ShellControl(this::hitExplosion, shootPos, spatial.getLocalTranslation(), FLYING_HEIGHT, FLYING_DURATION, app.getAssetManager()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private Spatial createShell(){
|
|
||||||
Spatial model = app.getAssetManager().loadModel(Asset.shell.getModelPath());
|
|
||||||
model.scale(.16f);
|
|
||||||
model.setLocalTranslation(tankTopControl.getSpatial().getLocalTranslation());
|
|
||||||
|
|
||||||
Vector3f shootPos = tankTopControl.getSpatial().getLocalTranslation();
|
|
||||||
Vector3f targetPos = spatial.getLocalTranslation();
|
|
||||||
Vector3f direction = targetPos.subtract(shootPos).normalize();
|
|
||||||
|
|
||||||
Quaternion rotation = new Quaternion();
|
|
||||||
rotation.lookAt(direction, new Vector3f(1,0,0)); // Assuming UNIT_Y is the up vector
|
|
||||||
|
|
||||||
model.setLocalRotation(rotation);
|
|
||||||
model.rotate(FastMath.HALF_PI,0,0);
|
|
||||||
|
|
||||||
Material mat = new Material(app.getAssetManager(), LIGHTING);
|
|
||||||
mat.setBoolean("UseMaterialColors", true);
|
|
||||||
ColorRGBA color = ColorRGBA.fromRGBA255(143,117,0,255);
|
|
||||||
mat.setColor("Diffuse", color);
|
|
||||||
mat.setColor("Ambient", color);
|
|
||||||
model.setMaterial(mat);
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void hitExplosion(){
|
|
||||||
app.getAcousticHandler().playSound(MdgaSound.TANK_EXPLOSION);
|
|
||||||
createEffect(
|
|
||||||
spatial.getLocalTranslation().setZ(1),
|
|
||||||
"Images/particle/flame.png",
|
|
||||||
2, 2,
|
|
||||||
1, 5,
|
|
||||||
2f,
|
|
||||||
0.3f, 0.7f,
|
|
||||||
new ColorRGBA(1f, 0.8f, 0.4f, 0.5f),
|
|
||||||
new ColorRGBA(1f, 0f, 0f, 0f)
|
|
||||||
);
|
|
||||||
new Timer().schedule(new TimerTask() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
action();
|
|
||||||
}
|
|
||||||
}, 800);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createEffect(Vector3f shootPos,
|
|
||||||
String image,
|
|
||||||
int x, int y,
|
|
||||||
float startSize, float endSize,
|
|
||||||
float velocity,
|
|
||||||
float lowLife, float highLife,
|
|
||||||
ColorRGBA start, ColorRGBA end){
|
|
||||||
// Create a particle emitter for the explosion
|
|
||||||
ParticleEmitter explosionEmitter = new ParticleEmitter("Explosion", ParticleMesh.Type.Triangle, 100);
|
|
||||||
Material explosionMat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md");
|
|
||||||
explosionMat.setTexture("Texture", app.getAssetManager().loadTexture(image));
|
|
||||||
explosionEmitter.setMaterial(explosionMat);
|
|
||||||
|
|
||||||
// Particle properties
|
|
||||||
explosionEmitter.setImagesX(x); // Columns in the texture
|
|
||||||
explosionEmitter.setImagesY(y); // Rows in the texture
|
|
||||||
explosionEmitter.setSelectRandomImage(true); // Randomize images for variety
|
|
||||||
|
|
||||||
explosionEmitter.setStartColor(start); // Bright yellowish orange
|
|
||||||
explosionEmitter.setEndColor(end); // Fade to transparent red
|
|
||||||
|
|
||||||
explosionEmitter.setStartSize(startSize); // Initial size
|
|
||||||
explosionEmitter.setEndSize(endSize); // Final size
|
|
||||||
explosionEmitter.setLowLife(lowLife); // Minimum lifetime of particles
|
|
||||||
explosionEmitter.setHighLife(highLife); // Maximum lifetime of particles
|
|
||||||
explosionEmitter.setGravity(0, 0, 1); // Gravity to pull particles down
|
|
||||||
explosionEmitter.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 0, velocity));
|
|
||||||
explosionEmitter.getParticleInfluencer().setVelocityVariation(1f); // Adds randomness to the initial velocity
|
|
||||||
explosionEmitter.setFacingVelocity(true); // Particles face their velocity direction
|
|
||||||
explosionEmitter.setLocalTranslation(shootPos);
|
|
||||||
explosionEmitter.setParticlesPerSec(0);
|
|
||||||
explosionEmitter.emitAllParticles();
|
|
||||||
app.getRootNode().attachChild(explosionEmitter);
|
|
||||||
new Timer().schedule(new TimerTask() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
app.getRootNode().detachChild(explosionEmitter);
|
|
||||||
}
|
|
||||||
}, 1000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
package pp.mdga.client.animation;
|
|
||||||
|
|
||||||
import com.jme3.asset.AssetManager;
|
|
||||||
import com.jme3.effect.ParticleEmitter;
|
|
||||||
import com.jme3.effect.ParticleMesh;
|
|
||||||
import com.jme3.material.Material;
|
|
||||||
import com.jme3.math.ColorRGBA;
|
|
||||||
import com.jme3.math.FastMath;
|
|
||||||
import com.jme3.math.Vector3f;
|
|
||||||
import pp.mdga.client.InitControl;
|
|
||||||
|
|
||||||
public class ShellControl extends ActionControl {
|
|
||||||
private final Vector3f shootPos;
|
|
||||||
private final Vector3f endPos;
|
|
||||||
private final float height;
|
|
||||||
private final float duration;
|
|
||||||
private Vector3f oldPos;
|
|
||||||
private ParticleEmitter emitter;
|
|
||||||
private AssetManager assetManager;
|
|
||||||
|
|
||||||
public ShellControl(Runnable runnable, Vector3f shootPos, Vector3f endPos, float height, float duration, AssetManager assetManager){
|
|
||||||
super(runnable);
|
|
||||||
this.shootPos = shootPos;
|
|
||||||
this.endPos = endPos;
|
|
||||||
this.height = height;
|
|
||||||
this.duration = duration;
|
|
||||||
this.assetManager = assetManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void initSpatial() {
|
|
||||||
spatial.addControl(new MoveControl(
|
|
||||||
shootPos,
|
|
||||||
endPos,
|
|
||||||
()->{
|
|
||||||
emitter.killAllParticles();
|
|
||||||
emitter.setParticlesPerSec(0);
|
|
||||||
emitter.removeFromParent();
|
|
||||||
spatial.removeControl(this);
|
|
||||||
spatial.removeFromParent();
|
|
||||||
action();
|
|
||||||
},
|
|
||||||
height,
|
|
||||||
duration,
|
|
||||||
false
|
|
||||||
));
|
|
||||||
oldPos = spatial.getLocalTranslation().clone();
|
|
||||||
createEmitter();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createEmitter() {
|
|
||||||
emitter = new ParticleEmitter("ShellTrail", ParticleMesh.Type.Triangle, 200);
|
|
||||||
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
|
|
||||||
mat.setTexture("Texture", assetManager.loadTexture("Images/particle/line.png")); // Nutze eine schmale, linienartige Textur
|
|
||||||
emitter.setMaterial(mat);
|
|
||||||
|
|
||||||
// Comic-Style Farben
|
|
||||||
emitter.setStartColor(new ColorRGBA(1f, 1f, 1f, 1f)); // Reinweiß
|
|
||||||
emitter.setEndColor(new ColorRGBA(1f, 1f, 1f, 0f)); // Transparent
|
|
||||||
|
|
||||||
// Partikelgröße und Lebensdauer
|
|
||||||
emitter.setStartSize(0.15f); // Startgröße
|
|
||||||
emitter.setEndSize(0.1f); // Endgröße
|
|
||||||
emitter.setLowLife(0.14f); // Sehr kurze Lebensdauer
|
|
||||||
emitter.setHighLife(0.14f);
|
|
||||||
|
|
||||||
emitter.setGravity(0, 0, 0); // Keine Gravitation
|
|
||||||
emitter.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 0, 0));
|
|
||||||
emitter.getParticleInfluencer().setVelocityVariation(0f); // Kein Variationsspielraum
|
|
||||||
|
|
||||||
// Hohe Dichte für eine glatte Spur
|
|
||||||
emitter.setParticlesPerSec(500);
|
|
||||||
|
|
||||||
// Zur Shell hinzufügen
|
|
||||||
spatial.getParent().attachChild(emitter);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void controlUpdate(float tpf) {
|
|
||||||
Vector3f direction = spatial.getLocalTranslation().subtract(oldPos).normalize();
|
|
||||||
if (direction.lengthSquared() > 0) {
|
|
||||||
spatial.getLocalRotation().lookAt(direction, Vector3f.UNIT_X);
|
|
||||||
spatial.rotate(FastMath.HALF_PI,0,0);
|
|
||||||
}
|
|
||||||
oldPos = spatial.getLocalTranslation().clone();
|
|
||||||
|
|
||||||
emitter.setLocalTranslation(spatial.getLocalTranslation().clone());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,126 +0,0 @@
|
|||||||
package pp.mdga.client.animation;
|
|
||||||
|
|
||||||
import com.jme3.effect.ParticleEmitter;
|
|
||||||
import com.jme3.effect.ParticleMesh;
|
|
||||||
import com.jme3.material.Material;
|
|
||||||
import com.jme3.math.ColorRGBA;
|
|
||||||
import com.jme3.math.Vector3f;
|
|
||||||
import com.jme3.scene.Node;
|
|
||||||
import com.jme3.scene.control.AbstractControl;
|
|
||||||
import pp.mdga.client.MdgaApp;
|
|
||||||
import pp.mdga.client.acoustic.MdgaSound;
|
|
||||||
|
|
||||||
public class Smoke {
|
|
||||||
|
|
||||||
private final Node rootNode;
|
|
||||||
private final MdgaApp app;
|
|
||||||
private final Vector3f location;
|
|
||||||
private ParticleEmitter fire;
|
|
||||||
private ParticleEmitter smoke;
|
|
||||||
|
|
||||||
private boolean triggered = false;
|
|
||||||
|
|
||||||
private final Material mat;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for the {@code Explosion} class.
|
|
||||||
*
|
|
||||||
* @param app The main application managing the explosion.
|
|
||||||
* @param rootNode The root node to which the explosion effects will be attached.
|
|
||||||
* @param location The location of the explosion in world coordinates.
|
|
||||||
*/
|
|
||||||
public Smoke(MdgaApp app, Node rootNode, Vector3f location) {
|
|
||||||
this.app = app;
|
|
||||||
this.rootNode = rootNode;
|
|
||||||
this.location = location;
|
|
||||||
|
|
||||||
this.mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes the particle emitters for the explosion effect.
|
|
||||||
* Configures the fire and smoke emitters with appearance, behavior, and lifespan.
|
|
||||||
*/
|
|
||||||
private void initializeEmitter() {
|
|
||||||
fire = new ParticleEmitter("Effect", ParticleMesh.Type.Triangle,50);
|
|
||||||
fire.setMaterial(mat);
|
|
||||||
fire.setStartColor(ColorRGBA.DarkGray);
|
|
||||||
fire.setEndColor(ColorRGBA.DarkGray);
|
|
||||||
fire.getParticleInfluencer().setInitialVelocity(new Vector3f(0.2f,0.2f,8f));
|
|
||||||
fire.getParticleInfluencer().setVelocityVariation(0.4f);
|
|
||||||
fire.setStartSize(0.1f);
|
|
||||||
fire.setEndSize(0.8f);
|
|
||||||
fire.setGravity(0, 0, -0.1f);
|
|
||||||
fire.setLowLife(0.5f);
|
|
||||||
fire.setHighLife(1.2f);
|
|
||||||
fire.setParticlesPerSec(0);
|
|
||||||
|
|
||||||
fire.setLocalTranslation(location);
|
|
||||||
|
|
||||||
smoke = new ParticleEmitter("Effect2", ParticleMesh.Type.Triangle,40);
|
|
||||||
smoke.setMaterial(mat);
|
|
||||||
smoke.setImagesX(2);
|
|
||||||
smoke.setImagesY(2);
|
|
||||||
smoke.setStartColor(ColorRGBA.DarkGray);
|
|
||||||
smoke.setEndColor(new ColorRGBA(0.05f, 0.05f, 0.05f, 1));
|
|
||||||
smoke.getParticleInfluencer().setInitialVelocity(new Vector3f(0.0f,0.0f,2f));
|
|
||||||
smoke.getParticleInfluencer().setVelocityVariation(0.5f);
|
|
||||||
smoke.setStartSize(0.2f);
|
|
||||||
smoke.setEndSize(0.5f);
|
|
||||||
smoke.setGravity(0, 0, -0.3f);
|
|
||||||
smoke.setLowLife(1.2f);
|
|
||||||
smoke.setHighLife(2.5f);
|
|
||||||
smoke.setParticlesPerSec(0);
|
|
||||||
|
|
||||||
smoke.setLocalTranslation(location);
|
|
||||||
|
|
||||||
app.getAcousticHandler().playSound(MdgaSound.EXPLOSION);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Triggers the explosion effect by attaching and activating the particle emitters for fire and smoke.
|
|
||||||
* Both emitters are automatically detached after a predefined duration.
|
|
||||||
*/
|
|
||||||
public void trigger() {
|
|
||||||
if (!triggered) {
|
|
||||||
triggered = true;
|
|
||||||
initializeEmitter();
|
|
||||||
}
|
|
||||||
|
|
||||||
rootNode.attachChild(fire);
|
|
||||||
fire.emitAllParticles();
|
|
||||||
fire.addControl(new AbstractControl() {
|
|
||||||
private float elapsedTime = 0;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void controlUpdate(float tpf) {
|
|
||||||
elapsedTime += tpf;
|
|
||||||
if (elapsedTime > 10f) {
|
|
||||||
rootNode.detachChild(fire);
|
|
||||||
fire.removeControl(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void controlRender(com.jme3.renderer.RenderManager rm, com.jme3.renderer.ViewPort vp) {}
|
|
||||||
});
|
|
||||||
|
|
||||||
rootNode.attachChild(smoke);
|
|
||||||
smoke.emitAllParticles();
|
|
||||||
smoke.addControl(new AbstractControl() {
|
|
||||||
private float elapsedTime = 0;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void controlUpdate(float tpf) {
|
|
||||||
elapsedTime += tpf;
|
|
||||||
if (elapsedTime > 10f) {
|
|
||||||
rootNode.detachChild(smoke);
|
|
||||||
smoke.removeControl(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void controlRender(com.jme3.renderer.RenderManager rm, com.jme3.renderer.ViewPort vp) {}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +1,6 @@
|
|||||||
package pp.mdga.client.board;
|
package pp.mdga.client.board;
|
||||||
|
|
||||||
import com.jme3.material.Material;
|
import com.jme3.material.Material;
|
||||||
import com.jme3.material.RenderState;
|
|
||||||
import com.jme3.material.RenderState.BlendMode;
|
|
||||||
import com.jme3.math.ColorRGBA;
|
|
||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
import com.jme3.post.FilterPostProcessor;
|
import com.jme3.post.FilterPostProcessor;
|
||||||
import com.jme3.renderer.queue.RenderQueue;
|
import com.jme3.renderer.queue.RenderQueue;
|
||||||
@@ -12,10 +9,10 @@
|
|||||||
import com.jme3.scene.control.AbstractControl;
|
import com.jme3.scene.control.AbstractControl;
|
||||||
import pp.mdga.client.Asset;
|
import pp.mdga.client.Asset;
|
||||||
import pp.mdga.client.MdgaApp;
|
import pp.mdga.client.MdgaApp;
|
||||||
import pp.mdga.client.acoustic.MdgaSound;
|
import pp.mdga.client.animation.MoveControl;
|
||||||
import pp.mdga.client.animation.*;
|
|
||||||
import pp.mdga.client.gui.DiceControl;
|
import pp.mdga.client.gui.DiceControl;
|
||||||
import pp.mdga.game.Color;
|
import pp.mdga.game.Color;
|
||||||
|
import pp.mdga.game.Piece;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@@ -57,10 +54,6 @@ public class BoardHandler {
|
|||||||
private PieceControl selectedOwnPiece;
|
private PieceControl selectedOwnPiece;
|
||||||
private PieceControl selectedEnemyPiece;
|
private PieceControl selectedEnemyPiece;
|
||||||
private DiceControl diceControl;
|
private DiceControl diceControl;
|
||||||
//Radar Position for Matrix animation
|
|
||||||
private Vector3f radarPos;
|
|
||||||
//TankTop for shellAnimation
|
|
||||||
private TankTopControl tankTop;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new BoardHandler.
|
* Creates a new BoardHandler.
|
||||||
@@ -153,24 +146,12 @@ private void initMap() {
|
|||||||
case node_wait_blue -> addHomeNode(waitingNodesMap, Color.NAVY, assetOnMap);
|
case node_wait_blue -> addHomeNode(waitingNodesMap, Color.NAVY, assetOnMap);
|
||||||
case node_wait_green -> addHomeNode(waitingNodesMap, Color.ARMY, assetOnMap);
|
case node_wait_green -> addHomeNode(waitingNodesMap, Color.ARMY, assetOnMap);
|
||||||
case node_wait_yellow -> addHomeNode(waitingNodesMap, Color.CYBER, assetOnMap);
|
case node_wait_yellow -> addHomeNode(waitingNodesMap, Color.CYBER, assetOnMap);
|
||||||
case radar -> addRadar(assetOnMap);
|
|
||||||
case tankShoot -> addTankShoot(assetOnMap);
|
|
||||||
|
|
||||||
default -> displayAsset(assetOnMap);
|
default -> displayAsset(assetOnMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addTankShoot(AssetOnMap assetOnMap) {
|
|
||||||
displayAsset(assetOnMap);
|
|
||||||
tankTop = displayAndControl(new AssetOnMap(Asset.tankShootTop, assetOnMap.x(), assetOnMap.y(), assetOnMap.rot()), new TankTopControl());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addRadar(AssetOnMap assetOnMap) {
|
|
||||||
radarPos = gridToWorld(assetOnMap.x(), assetOnMap.y());
|
|
||||||
displayAsset(assetOnMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts an asset to its corresponding color.
|
* Converts an asset to its corresponding color.
|
||||||
*
|
*
|
||||||
@@ -204,16 +185,11 @@ private Spatial createModel(Asset asset, Vector3f pos, float rot) {
|
|||||||
model.rotate((float) Math.toRadians(0), 0, (float) Math.toRadians(rot));
|
model.rotate((float) Math.toRadians(0), 0, (float) Math.toRadians(rot));
|
||||||
model.setLocalTranslation(pos);
|
model.setLocalTranslation(pos);
|
||||||
model.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
|
model.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
|
||||||
|
|
||||||
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
|
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
|
||||||
mat.setTexture("DiffuseMap", app.getAssetManager().loadTexture(texName));
|
mat.setTexture("DiffuseMap", app.getAssetManager().loadTexture(texName));
|
||||||
mat.setBoolean("UseMaterialColors", true); // Required for Material Colors
|
|
||||||
mat.setColor("Diffuse", new ColorRGBA(1, 1, 1, 1)); // White color with full alpha
|
|
||||||
mat.setColor("Ambient", new ColorRGBA(1, 1, 1, 1)); // Ambient color with full alpha
|
|
||||||
mat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
|
|
||||||
model.setMaterial(mat);
|
model.setMaterial(mat);
|
||||||
|
|
||||||
rootNodeBoard.attachChild(model);
|
rootNodeBoard.attachChild(model);
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,7 +200,7 @@ private Spatial createModel(Asset asset, Vector3f pos, float rot) {
|
|||||||
* @param y The y-coordinate on the grid
|
* @param y The y-coordinate on the grid
|
||||||
* @return The corresponding world position
|
* @return The corresponding world position
|
||||||
*/
|
*/
|
||||||
public static Vector3f gridToWorld(int x, int y) {
|
private static Vector3f gridToWorld(int x, int y) {
|
||||||
return new Vector3f(GRID_SIZE * x, GRID_SIZE * y, GRID_ELEVATION);
|
return new Vector3f(GRID_SIZE * x, GRID_SIZE * y, GRID_ELEVATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,38 +216,16 @@ private Spatial displayAsset(AssetOnMap assetOnMap) {
|
|||||||
return createModel(assetOnMap.asset(), gridToWorld(x, y), assetOnMap.rot());
|
return createModel(assetOnMap.asset(), gridToWorld(x, y), assetOnMap.rot());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a visual representation of an asset to the scene, attaches a control to it, and returns the control.
|
|
||||||
*
|
|
||||||
* @param assetOnMap The asset to be displayed in the 3D environment.
|
|
||||||
* @param control The control to be added to the spatial representing the asset.
|
|
||||||
* @param <T> The type of control, extending {@code AbstractControl}.
|
|
||||||
* @return The control that was added to the spatial.
|
|
||||||
*/
|
|
||||||
private <T extends AbstractControl> T displayAndControl(AssetOnMap assetOnMap, T control) {
|
private <T extends AbstractControl> T displayAndControl(AssetOnMap assetOnMap, T control) {
|
||||||
Spatial spatial = displayAsset(assetOnMap);
|
Spatial spatial = displayAsset(assetOnMap);
|
||||||
spatial.addControl(control);
|
spatial.addControl(control);
|
||||||
return control;
|
return control;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Moves a piece in the 3D environment to the location of a specified node.
|
|
||||||
*
|
|
||||||
* @param pieceControl The control managing the piece to be moved.
|
|
||||||
* @param nodeControl The control managing the target node to which the piece will move.
|
|
||||||
*/
|
|
||||||
private void movePieceToNode(PieceControl pieceControl, NodeControl nodeControl){
|
private void movePieceToNode(PieceControl pieceControl, NodeControl nodeControl){
|
||||||
pieceControl.setLocation(nodeControl.getLocation());
|
pieceControl.setLocation(nodeControl.getLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a home node for a specific player color, attaching it to the map of home nodes.
|
|
||||||
*
|
|
||||||
* @param map The map storing lists of home nodes by player color.
|
|
||||||
* @param color The color associated with the home nodes to be added.
|
|
||||||
* @param assetOnMap The asset representing the home node in the 3D environment.
|
|
||||||
* @throws RuntimeException if more than 4 home nodes are added for a single color.
|
|
||||||
*/
|
|
||||||
private void addHomeNode(Map<Color, List<NodeControl>> map, Color color, AssetOnMap assetOnMap){
|
private void addHomeNode(Map<Color, List<NodeControl>> map, Color color, AssetOnMap assetOnMap){
|
||||||
List<NodeControl> homeNodes = addItemToMapList(map, color, displayAndControl(assetOnMap, new NodeControl(app, fpp)));
|
List<NodeControl> homeNodes = addItemToMapList(map, color, displayAndControl(assetOnMap, new NodeControl(app, fpp)));
|
||||||
if (homeNodes.size() > 4) throw new RuntimeException("too many homeNodes for " + color);
|
if (homeNodes.size() > 4) throw new RuntimeException("too many homeNodes for " + color);
|
||||||
@@ -315,16 +269,6 @@ private void movePieceRek(UUID uuid, int curIndex, int moveIndex){
|
|||||||
movePieceRek(uuid, curIndex, moveIndex);
|
movePieceRek(uuid, curIndex, moveIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds an item to a list in a map. If the key does not exist in the map, a new list is created.
|
|
||||||
*
|
|
||||||
* @param map The map containing lists of items.
|
|
||||||
* @param key The key associated with the list in the map.
|
|
||||||
* @param item The item to be added to the list.
|
|
||||||
* @param <T> The type of items in the list.
|
|
||||||
* @param <E> The type of the key in the map.
|
|
||||||
* @return The updated list associated with the specified key.
|
|
||||||
*/
|
|
||||||
private <T, E> List<T> addItemToMapList(Map<E,List<T>> map, E key, T item){
|
private <T, E> List<T> addItemToMapList(Map<E,List<T>> map, E key, T item){
|
||||||
List<T> list = map.getOrDefault(key, new ArrayList<>());
|
List<T> list = map.getOrDefault(key, new ArrayList<>());
|
||||||
list.add(item);
|
list.add(item);
|
||||||
@@ -332,27 +276,12 @@ private <T, E> List<T> addItemToMapList(Map<E,List<T>> map, E key, T item){
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes an item from a list in a map. If the key does not exist in the map, a new list is created.
|
|
||||||
*
|
|
||||||
* @param map The map containing lists of items.
|
|
||||||
* @param key The key associated with the list in the map.
|
|
||||||
* @param item The item to be removed from the list.
|
|
||||||
* @param <T> The type of items in the list.
|
|
||||||
* @param <E> The type of the key in the map.
|
|
||||||
*/
|
|
||||||
private <T, E> void removeItemFromMapList(Map<E,List<T>> map, E key, T item){
|
private <T, E> void removeItemFromMapList(Map<E,List<T>> map, E key, T item){
|
||||||
List<T> list = map.getOrDefault(key, new ArrayList<>());
|
List<T> list = map.getOrDefault(key, new ArrayList<>());
|
||||||
list.remove(item);
|
list.remove(item);
|
||||||
map.put(key, list);
|
map.put(key, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Calculates the mean position of the waiting nodes for a specific color.
|
|
||||||
*
|
|
||||||
* @param color The color associated with the waiting nodes.
|
|
||||||
* @return The mean position of the waiting nodes as a {@code Vector3f}.
|
|
||||||
*/
|
|
||||||
private Vector3f getWaitingPos(Color color){
|
private Vector3f getWaitingPos(Color color){
|
||||||
return getMeanPosition(waitingNodesMap.get(color).stream().map(NodeControl::getLocation).toList());
|
return getMeanPosition(waitingNodesMap.get(color).stream().map(NodeControl::getLocation).toList());
|
||||||
}
|
}
|
||||||
@@ -514,7 +443,6 @@ private void throwPiece(UUID uuid){
|
|||||||
|
|
||||||
// Synchronisation oder Animation
|
// Synchronisation oder Animation
|
||||||
pieceControl.rotateInit();
|
pieceControl.rotateInit();
|
||||||
app.getAcousticHandler().playSound(MdgaSound.LOSE);
|
|
||||||
app.getModelSynchronize().animationEnd();
|
app.getModelSynchronize().animationEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -792,55 +720,10 @@ public void movePieceStartAnim(UUID uuid, int moveIndex){
|
|||||||
*/
|
*/
|
||||||
public void throwPieceAnim(UUID uuid){
|
public void throwPieceAnim(UUID uuid){
|
||||||
pieces.get(uuid).getSpatial().addControl(new MoveControl(
|
pieces.get(uuid).getSpatial().addControl(new MoveControl(
|
||||||
pieces.get(uuid).getLocation(), getNextWaitingNode(pieceColor.get(uuid)).getLocation(),
|
pieces.get(uuid).getLocation(),
|
||||||
()->throwPiece(uuid))
|
getNextWaitingNode(pieceColor.get(uuid)).getLocation(),
|
||||||
);
|
()->throwPiece(uuid)
|
||||||
}
|
));
|
||||||
|
|
||||||
public void throwPiece(UUID uuid, Color throwColor){
|
|
||||||
switch(throwColor){
|
|
||||||
case ARMY -> throwShell(uuid);
|
|
||||||
case NAVY -> throwMissle(uuid);
|
|
||||||
case CYBER -> throwMatrix(uuid);
|
|
||||||
case AIRFORCE -> throwBomb(uuid);
|
|
||||||
default -> throw new RuntimeException("invalid color");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Animates the throwing of a piece to the next available waiting node.
|
|
||||||
*
|
|
||||||
* @param uuid the UUID of the piece to animate
|
|
||||||
*/
|
|
||||||
private void throwBomb(UUID uuid) {
|
|
||||||
Vector3f targetPoint = pieces.get(uuid).getLocation();
|
|
||||||
|
|
||||||
JetAnimation anim = new JetAnimation(app, rootNode, uuid, 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 FadeControl(1,1,0,
|
|
||||||
() -> {
|
|
||||||
throwPiece(uuid);
|
|
||||||
piece.addControl(new FadeControl(1,0,1));
|
|
||||||
}
|
|
||||||
));
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void throwMissle(UUID uuid) {
|
|
||||||
Vector3f targetPoint = pieces.get(uuid).getLocation();
|
|
||||||
|
|
||||||
MissileAnimation anim = new MissileAnimation(app, rootNode, uuid, targetPoint, 2);
|
|
||||||
anim.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void throwShell(UUID uuid) {
|
|
||||||
pieces.get(uuid).getSpatial().addControl(new ShellAnimation(tankTop, app, ()-> throwPieceAnim(uuid)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -7,8 +7,6 @@
|
|||||||
import com.jme3.math.Quaternion;
|
import com.jme3.math.Quaternion;
|
||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
import com.jme3.post.FilterPostProcessor;
|
import com.jme3.post.FilterPostProcessor;
|
||||||
import com.jme3.post.filters.FXAAFilter;
|
|
||||||
import com.jme3.post.ssao.SSAOFilter;
|
|
||||||
import com.jme3.scene.Spatial;
|
import com.jme3.scene.Spatial;
|
||||||
import com.jme3.shadow.DirectionalLightShadowFilter;
|
import com.jme3.shadow.DirectionalLightShadowFilter;
|
||||||
import com.jme3.shadow.EdgeFilteringMode;
|
import com.jme3.shadow.EdgeFilteringMode;
|
||||||
@@ -39,8 +37,6 @@ public class CameraHandler {
|
|||||||
private Color ownColor;
|
private Color ownColor;
|
||||||
private boolean init;
|
private boolean init;
|
||||||
private boolean initRot;
|
private boolean initRot;
|
||||||
private SSAOFilter ssaoFilter;
|
|
||||||
private FXAAFilter fxaaFilter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for the CameraHandler. Initializes the camera settings and lighting.
|
* Constructor for the CameraHandler. Initializes the camera settings and lighting.
|
||||||
@@ -69,9 +65,6 @@ public CameraHandler(MdgaApp app, FilterPostProcessor fpp) {
|
|||||||
dlsf.setEnabled(true);
|
dlsf.setEnabled(true);
|
||||||
dlsf.setEdgeFilteringMode(EdgeFilteringMode.PCFPOISSON);
|
dlsf.setEdgeFilteringMode(EdgeFilteringMode.PCFPOISSON);
|
||||||
dlsf.setShadowIntensity(0.7f);
|
dlsf.setShadowIntensity(0.7f);
|
||||||
ssaoFilter = new SSAOFilter(6, 10f, 0.33f, 0.61f);
|
|
||||||
// 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);
|
||||||
|
|
||||||
@@ -89,8 +82,6 @@ public void init(Color ownColor) {
|
|||||||
app.getRootNode().addLight(ambient);
|
app.getRootNode().addLight(ambient);
|
||||||
app.getRootNode().attachChild(sky);
|
app.getRootNode().attachChild(sky);
|
||||||
fpp.addFilter(dlsf);
|
fpp.addFilter(dlsf);
|
||||||
fpp.addFilter(ssaoFilter);
|
|
||||||
fpp.addFilter(fxaaFilter);
|
|
||||||
init = true;
|
init = true;
|
||||||
initRot = true;
|
initRot = true;
|
||||||
this.ownColor = ownColor;
|
this.ownColor = ownColor;
|
||||||
|
|||||||
@@ -107,11 +107,8 @@ private static Asset getLoadedAsset(String assetName) {
|
|||||||
case "radar" -> Asset.radar;
|
case "radar" -> Asset.radar;
|
||||||
case "ship" -> Asset.ship;
|
case "ship" -> Asset.ship;
|
||||||
case "tank" -> Asset.tank;
|
case "tank" -> Asset.tank;
|
||||||
case "treeSmall" -> Asset.treeSmall;
|
case "tree_small" -> Asset.treeSmall;
|
||||||
case "treeBig" -> Asset.treeBig;
|
case "tree_big" -> Asset.treeBig;
|
||||||
case "tank_shoot" -> Asset.tankShoot;
|
|
||||||
case "treesBigBackground" -> Asset.treesBigBackground;
|
|
||||||
case "treesSmallBackground" -> Asset.treesSmallBackground;
|
|
||||||
default -> throw new IllegalStateException("Unexpected value: " + assetName);
|
default -> throw new IllegalStateException("Unexpected value: " + assetName);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,37 +18,17 @@ public class OutlineControl extends InitControl {
|
|||||||
private static final int THICKNESS_DEFAULT = 6;
|
private static final int THICKNESS_DEFAULT = 6;
|
||||||
private MdgaApp app;
|
private MdgaApp app;
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs an {@code OutlineControl} with default thickness for the object outline.
|
|
||||||
*
|
|
||||||
* @param app The main application managing the outline control.
|
|
||||||
* @param fpp The {@code FilterPostProcessor} used for post-processing effects.
|
|
||||||
*/
|
|
||||||
public OutlineControl(MdgaApp app, FilterPostProcessor fpp){
|
public OutlineControl(MdgaApp app, FilterPostProcessor fpp){
|
||||||
this.app = app;
|
this.app = app;
|
||||||
outlineOwn = new SelectObjectOutliner(THICKNESS_DEFAULT, fpp, app.getRenderManager(), app.getAssetManager(), app.getCamera(), app);
|
outlineOwn = new SelectObjectOutliner(THICKNESS_DEFAULT, fpp, app.getRenderManager(), app.getAssetManager(), app.getCamera(), app);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs an {@code OutlineControl} with default thickness, allowing a custom camera to be specified.
|
|
||||||
*
|
|
||||||
* @param app The main application managing the outline control.
|
|
||||||
* @param fpp The {@code FilterPostProcessor} used for post-processing effects.
|
|
||||||
* @param cam The camera used for rendering the outlined objects.
|
|
||||||
*/
|
|
||||||
public OutlineControl(MdgaApp app, FilterPostProcessor fpp, Camera cam){
|
public OutlineControl(MdgaApp app, FilterPostProcessor fpp, Camera cam){
|
||||||
this.app = app;
|
this.app = app;
|
||||||
outlineOwn = new SelectObjectOutliner(THICKNESS_DEFAULT, fpp, app.getRenderManager(), app.getAssetManager(), cam, app);
|
outlineOwn = new SelectObjectOutliner(THICKNESS_DEFAULT, fpp, app.getRenderManager(), app.getAssetManager(), cam, app);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs an {@code OutlineControl} with a specified thickness and custom camera.
|
|
||||||
*
|
|
||||||
* @param app The main application managing the outline control.
|
|
||||||
* @param fpp The {@code FilterPostProcessor} used for post-processing effects.
|
|
||||||
* @param cam The camera used for rendering the outlined objects.
|
|
||||||
* @param thickness The thickness of the outline.
|
|
||||||
*/
|
|
||||||
public OutlineControl(MdgaApp app, FilterPostProcessor fpp, Camera cam, int thickness){
|
public OutlineControl(MdgaApp app, FilterPostProcessor fpp, Camera cam, int thickness){
|
||||||
this.app = app;
|
this.app = app;
|
||||||
outlineOwn = new SelectObjectOutliner(thickness, fpp, app.getRenderManager(), app.getAssetManager(), cam, app);
|
outlineOwn = new SelectObjectOutliner(thickness, fpp, app.getRenderManager(), app.getAssetManager(), cam, app);
|
||||||
@@ -81,11 +61,6 @@ public void deOutline(){
|
|||||||
outlineOwn.deselect(spatial);
|
outlineOwn.deselect(spatial);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the instance of the {@code MdgaApp} associated with this control.
|
|
||||||
*
|
|
||||||
* @return The {@code MdgaApp} instance.
|
|
||||||
*/
|
|
||||||
public MdgaApp getApp() {
|
public MdgaApp getApp() {
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ public void initSpatial(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void rotateInit() {
|
public void rotateInit() {
|
||||||
setRotation(initRotation);
|
// rotate(rotation - initRotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -278,5 +278,4 @@ public boolean isSelectable() {
|
|||||||
public void setHoverable(boolean hoverable) {
|
public void setHoverable(boolean hoverable) {
|
||||||
this.hoverable = hoverable;
|
this.hoverable = hoverable;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,105 +0,0 @@
|
|||||||
package pp.mdga.client.board;
|
|
||||||
|
|
||||||
import com.jme3.math.FastMath;
|
|
||||||
import com.jme3.math.Quaternion;
|
|
||||||
import com.jme3.math.Vector3f;
|
|
||||||
import pp.mdga.client.InitControl;
|
|
||||||
|
|
||||||
import static pp.mdga.client.Util.linInt;
|
|
||||||
|
|
||||||
public class TankTopControl extends InitControl {
|
|
||||||
|
|
||||||
private float timer = 0; // Time elapsed
|
|
||||||
private final static float DURATION = 1.5f; // Total rotation duration in seconds
|
|
||||||
private boolean rotating = false; // Flag to track if rotation is active
|
|
||||||
private float startAngle = 0;
|
|
||||||
private float endAngle = 0;
|
|
||||||
private Runnable actionAfter = null;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void controlUpdate(float tpf) {
|
|
||||||
if (!rotating) return;
|
|
||||||
|
|
||||||
// Update the timer
|
|
||||||
timer += tpf;
|
|
||||||
|
|
||||||
// Calculate interpolation factor (0 to 1)
|
|
||||||
float t = timer / DURATION;
|
|
||||||
|
|
||||||
if (t >= 1) t = 1;
|
|
||||||
|
|
||||||
float curAngle = linInt(startAngle, endAngle, t);
|
|
||||||
|
|
||||||
// Interpolate the rotation
|
|
||||||
Quaternion interpolatedRotation = new Quaternion();
|
|
||||||
interpolatedRotation.fromAngleAxis((float) Math.toRadians(curAngle), Vector3f.UNIT_Z);
|
|
||||||
|
|
||||||
// Apply the interpolated rotation to the spatial
|
|
||||||
spatial.setLocalRotation(interpolatedRotation);
|
|
||||||
|
|
||||||
if(t >= 1){
|
|
||||||
rotating = false;
|
|
||||||
if(actionAfter != null) actionAfter.run();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void rotate(Vector3f enemyPos, Runnable actionAfter) {
|
|
||||||
if (spatial == null) throw new RuntimeException("spatial is null");
|
|
||||||
|
|
||||||
startAngle = getOwnAngle();
|
|
||||||
endAngle = getEnemyAngle(enemyPos);
|
|
||||||
|
|
||||||
// Adjust endAngle to ensure the shortest path
|
|
||||||
float deltaAngle = endAngle - startAngle;
|
|
||||||
if (deltaAngle > 180) {
|
|
||||||
endAngle -= 360; // Rotate counterclockwise
|
|
||||||
} else if (deltaAngle < -180) {
|
|
||||||
endAngle += 360; // Rotate clockwise
|
|
||||||
}
|
|
||||||
|
|
||||||
timer = 0;
|
|
||||||
rotating = true;
|
|
||||||
this.actionAfter = actionAfter; // Store the action to execute after rotation
|
|
||||||
}
|
|
||||||
|
|
||||||
private float getEnemyAngle(Vector3f enemyPos){
|
|
||||||
// Direction to the enemy in the XY plane
|
|
||||||
Vector3f direction = enemyPos.subtract(spatial.getLocalTranslation());
|
|
||||||
direction.z = 0; // Project to XY plane
|
|
||||||
direction.normalizeLocal();
|
|
||||||
|
|
||||||
Vector3f reference = Vector3f.UNIT_Y.mult(-1);
|
|
||||||
|
|
||||||
// Calculate the angle between the direction vector and the reference vector
|
|
||||||
float angle = FastMath.acos(reference.dot(direction));
|
|
||||||
|
|
||||||
// Determine rotation direction using the cross product
|
|
||||||
Vector3f cross = reference.cross(direction);
|
|
||||||
if (cross.z < 0) {
|
|
||||||
angle = -angle;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (float) Math.toDegrees(angle); // Return the absolute angle in degrees
|
|
||||||
}
|
|
||||||
|
|
||||||
private float getOwnAngle() {
|
|
||||||
// Tank's forward direction in the XY plane
|
|
||||||
Vector3f forward = spatial.getLocalRotation().mult(Vector3f.UNIT_Y);
|
|
||||||
forward.z = 0; // Project to XY plane
|
|
||||||
forward.normalizeLocal();
|
|
||||||
|
|
||||||
// Reference vector: Positive X-axis
|
|
||||||
Vector3f reference = Vector3f.UNIT_Y;
|
|
||||||
|
|
||||||
// Calculate the angle between the forward vector and the reference vector
|
|
||||||
float angle = FastMath.acos(reference.dot(forward));
|
|
||||||
|
|
||||||
// Determine rotation direction using the cross product
|
|
||||||
Vector3f cross = reference.cross(forward);
|
|
||||||
if (cross.z < 0) { // For Z-up, check the Z component of the cross product
|
|
||||||
angle = -angle;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (float) Math.toDegrees(angle); // Return the absolute angle in radians
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -77,17 +77,12 @@ public SliderButton(MdgaApp app, Node node, String label) {
|
|||||||
QuadBackgroundComponent background = new QuadBackgroundComponent(BUTTON_NORMAL);
|
QuadBackgroundComponent background = new QuadBackgroundComponent(BUTTON_NORMAL);
|
||||||
slider.setBackground(background);
|
slider.setBackground(background);
|
||||||
|
|
||||||
// Set label background
|
|
||||||
QuadBackgroundComponent labelBackground = new QuadBackgroundComponent(BUTTON_NORMAL);
|
|
||||||
this.label.setBackground(labelBackground);
|
|
||||||
|
|
||||||
// Configure the label font
|
// Configure the label font
|
||||||
this.label.setFont(font);
|
this.label.setFont(font);
|
||||||
this.label.setTextHAlignment(HAlignment.Center);
|
|
||||||
|
|
||||||
// Default position and size
|
// Default position and size
|
||||||
pos = new Vector2f(0, 0);
|
pos = new Vector2f(0, 0);
|
||||||
size = new Vector2f(6f, 1);
|
size = new Vector2f(5.5f, 1);
|
||||||
|
|
||||||
// Add label and slider to container
|
// Add label and slider to container
|
||||||
container.addChild(this.label);
|
container.addChild(this.label);
|
||||||
|
|||||||
@@ -7,11 +7,6 @@
|
|||||||
import pp.mdga.client.button.SliderButton;
|
import pp.mdga.client.button.SliderButton;
|
||||||
import pp.mdga.client.view.MdgaView;
|
import pp.mdga.client.view.MdgaView;
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@code AudioSettingsDialog} class represents a dialog for adjusting audio settings in the application.
|
|
||||||
* It provides controls for managing main volume, music volume, and sound effect volume, and includes
|
|
||||||
* a button to return to the previous menu.
|
|
||||||
*/
|
|
||||||
public class AudioSettingsDialog extends Dialog {
|
public class AudioSettingsDialog extends Dialog {
|
||||||
private final MdgaView view;
|
private final MdgaView view;
|
||||||
|
|
||||||
@@ -23,13 +18,6 @@ public class AudioSettingsDialog extends Dialog {
|
|||||||
|
|
||||||
private boolean active = false;
|
private boolean active = false;
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs an {@code AudioSettingsDialog}.
|
|
||||||
*
|
|
||||||
* @param app The main application managing the dialog.
|
|
||||||
* @param node The root node for attaching UI elements.
|
|
||||||
* @param view The current view, used for navigation and interaction with the dialog.
|
|
||||||
*/
|
|
||||||
public AudioSettingsDialog(MdgaApp app, Node node, MdgaView view) {
|
public AudioSettingsDialog(MdgaApp app, Node node, MdgaView view) {
|
||||||
super(app, node);
|
super(app, node);
|
||||||
|
|
||||||
@@ -54,9 +42,6 @@ public AudioSettingsDialog(MdgaApp app, Node node, MdgaView view) {
|
|||||||
backButton.setPos(new Vector2f(0, 1.8f));
|
backButton.setPos(new Vector2f(0, 1.8f));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the dialog is shown. Initializes and displays the volume controls and back button.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected void onShow() {
|
protected void onShow() {
|
||||||
active = true;
|
active = true;
|
||||||
@@ -72,9 +57,6 @@ protected void onShow() {
|
|||||||
soundVolume.show();
|
soundVolume.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the dialog is hidden. Hides all volume controls and the back button.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected void onHide() {
|
protected void onHide() {
|
||||||
active = false;
|
active = false;
|
||||||
@@ -86,10 +68,6 @@ protected void onHide() {
|
|||||||
soundVolume.hide();
|
soundVolume.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the application audio settings based on the current values of the sliders.
|
|
||||||
* This method is called continuously while the dialog is active.
|
|
||||||
*/
|
|
||||||
public void update() {
|
public void update() {
|
||||||
if(!active) {
|
if(!active) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -10,30 +10,17 @@
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@code CeremonyDialog} class displays a dialog containing statistical data in a tabular format.
|
|
||||||
* It allows adding rows of statistics and manages their visibility when shown or hidden.
|
|
||||||
*/
|
|
||||||
public class CeremonyDialog extends Dialog {
|
public class CeremonyDialog extends Dialog {
|
||||||
private ArrayList<ArrayList<LabelButton>> labels;
|
private ArrayList<ArrayList<LabelButton>> labels;
|
||||||
|
|
||||||
float offsetX;
|
float offsetX;
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a {@code CeremonyDialog}.
|
|
||||||
*
|
|
||||||
* @param app The main application managing the dialog.
|
|
||||||
* @param node The root node for attaching UI elements.
|
|
||||||
*/
|
|
||||||
public CeremonyDialog(MdgaApp app, Node node) {
|
public CeremonyDialog(MdgaApp app, Node node) {
|
||||||
super(app, node);
|
super(app, node);
|
||||||
|
|
||||||
prepare();
|
prepare();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the dialog is shown. Makes all label buttons in the table visible.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected void onShow() {
|
protected void onShow() {
|
||||||
for (ArrayList<LabelButton> row : labels) {
|
for (ArrayList<LabelButton> row : labels) {
|
||||||
@@ -43,9 +30,6 @@ protected void onShow() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the dialog is hidden. Hides all label buttons in the table.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected void onHide() {
|
protected void onHide() {
|
||||||
for (ArrayList<LabelButton> row : labels) {
|
for (ArrayList<LabelButton> row : labels) {
|
||||||
@@ -55,17 +39,6 @@ protected void onHide() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a row of statistical data to the dialog.
|
|
||||||
*
|
|
||||||
* @param name The name of the player or category for the row.
|
|
||||||
* @param v1 The value for the first column.
|
|
||||||
* @param v2 The value for the second column.
|
|
||||||
* @param v3 The value for the third column.
|
|
||||||
* @param v4 The value for the fourth column.
|
|
||||||
* @param v5 The value for the fifth column.
|
|
||||||
* @param v6 The value for the sixth column.
|
|
||||||
*/
|
|
||||||
public void addStatisticsRow(String name, int v1, int v2, int v3, int v4, int v5, int v6) {
|
public void addStatisticsRow(String name, int v1, int v2, int v3, int v4, int v5, int v6) {
|
||||||
float offsetYSmall = 0.5f;
|
float offsetYSmall = 0.5f;
|
||||||
|
|
||||||
@@ -103,9 +76,6 @@ public void addStatisticsRow(String name, int v1, int v2, int v3, int v4, int v5
|
|||||||
labels.add(row);
|
labels.add(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Prepares the initial layout of the dialog, including header labels.
|
|
||||||
*/
|
|
||||||
public void prepare() {
|
public void prepare() {
|
||||||
offsetX = 0.5f;
|
offsetX = 0.5f;
|
||||||
|
|
||||||
|
|||||||
@@ -4,53 +4,30 @@
|
|||||||
import com.simsilica.lemur.Container;
|
import com.simsilica.lemur.Container;
|
||||||
import pp.mdga.client.MdgaApp;
|
import pp.mdga.client.MdgaApp;
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@code Dialog} class serves as an abstract base class for dialogs in the application.
|
|
||||||
* It provides functionality for showing and hiding the dialog and defines abstract methods
|
|
||||||
* for custom behavior when the dialog is shown or hidden.
|
|
||||||
*/
|
|
||||||
public abstract class Dialog {
|
public abstract class Dialog {
|
||||||
protected final MdgaApp app;
|
protected final MdgaApp app;
|
||||||
protected final Node node = new Node();
|
protected final Node node = new Node();
|
||||||
|
|
||||||
private final Node root;
|
private final Node root;
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a {@code Dialog}.
|
|
||||||
*
|
|
||||||
* @param app The main application managing the dialog.
|
|
||||||
* @param node The root node to which the dialog's node will be attached.
|
|
||||||
*/
|
|
||||||
Dialog(MdgaApp app, Node node) {
|
Dialog(MdgaApp app, Node node) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
this.root = node;
|
this.root = node;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Shows the dialog by attaching its node to the root node and invoking the {@code onShow} method.
|
|
||||||
*/
|
|
||||||
public void show() {
|
public void show() {
|
||||||
root.attachChild(node);
|
root.attachChild(node);
|
||||||
|
|
||||||
onShow();
|
onShow();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Hides the dialog by detaching its node from the root node and invoking the {@code onHide} method.
|
|
||||||
*/
|
|
||||||
public void hide() {
|
public void hide() {
|
||||||
root.detachChild(node);
|
root.detachChild(node);
|
||||||
|
|
||||||
onHide();
|
onHide();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the dialog is shown. Subclasses must implement this method to define custom behavior.
|
|
||||||
*/
|
|
||||||
protected abstract void onShow();
|
protected abstract void onShow();
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the dialog is hidden. Subclasses must implement this method to define custom behavior.
|
|
||||||
*/
|
|
||||||
protected abstract void onHide();
|
protected abstract void onHide();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,10 +12,6 @@
|
|||||||
|
|
||||||
import java.util.prefs.Preferences;
|
import java.util.prefs.Preferences;
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@code HostDialog} class represents a dialog for hosting a network game session.
|
|
||||||
* It allows users to input a port number, start hosting a server, and navigate back to the previous view.
|
|
||||||
*/
|
|
||||||
public class HostDialog extends NetworkDialog {
|
public class HostDialog extends NetworkDialog {
|
||||||
private InputButton portInput;
|
private InputButton portInput;
|
||||||
|
|
||||||
@@ -26,13 +22,6 @@ public class HostDialog extends NetworkDialog {
|
|||||||
|
|
||||||
private Preferences prefs = Preferences.userNodeForPackage(JoinDialog.class);
|
private Preferences prefs = Preferences.userNodeForPackage(JoinDialog.class);
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a {@code HostDialog}.
|
|
||||||
*
|
|
||||||
* @param app The main application managing the dialog.
|
|
||||||
* @param node The root node for attaching UI elements.
|
|
||||||
* @param view The main view used for navigation and interaction with the dialog.
|
|
||||||
*/
|
|
||||||
public HostDialog(MdgaApp app, Node node, MainView view) {
|
public HostDialog(MdgaApp app, Node node, MainView view) {
|
||||||
super(app, node, (NetworkSupport) app.getNetworkSupport());
|
super(app, node, (NetworkSupport) app.getNetworkSupport());
|
||||||
|
|
||||||
@@ -50,9 +39,6 @@ public HostDialog(MdgaApp app, Node node, MainView view) {
|
|||||||
offset += 1.5f;
|
offset += 1.5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the dialog is shown. Displays all input fields and buttons.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected void onShow() {
|
protected void onShow() {
|
||||||
portInput.show();
|
portInput.show();
|
||||||
@@ -60,9 +46,6 @@ protected void onShow() {
|
|||||||
backButton.show();
|
backButton.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the dialog is hidden. Hides all input fields and buttons.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected void onHide() {
|
protected void onHide() {
|
||||||
portInput.hide();
|
portInput.hide();
|
||||||
@@ -70,44 +53,27 @@ protected void onHide() {
|
|||||||
backButton.hide();
|
backButton.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the state of the port input field.
|
|
||||||
* This method is called periodically to synchronize the dialog state.
|
|
||||||
*/
|
|
||||||
public void update() {
|
public void update() {
|
||||||
portInput.update();
|
portInput.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the currently entered port number, saves it to preferences, and sets it as the active port.
|
|
||||||
*
|
|
||||||
* @return The port number as a string.
|
|
||||||
*/
|
|
||||||
public String getPort() {
|
public String getPort() {
|
||||||
prefs.put("hostPort", portInput.getString());
|
prefs.put("hostPort", portInput.getString());
|
||||||
setPortNumber(Integer.parseInt(portInput.getString()));
|
setPortNumber(Integer.parseInt(portInput.getString()));
|
||||||
return portInput.getString();
|
return portInput.getString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Resets the port input field to its default value and updates preferences accordingly.
|
|
||||||
*/
|
|
||||||
public void resetPort() {
|
public void resetPort() {
|
||||||
portInput.reset();
|
portInput.reset();
|
||||||
prefs.put("hostPort", "11111");
|
prefs.put("hostPort", "11111");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Starts the server to host a network game.
|
|
||||||
*/
|
|
||||||
public void hostServer() {
|
public void hostServer() {
|
||||||
startServer();
|
startServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Connects to the server as a client.
|
|
||||||
*/
|
|
||||||
public void connectServerAsClient() {
|
public void connectServerAsClient() {
|
||||||
connectServer();
|
connectServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,84 +1,4 @@
|
|||||||
package pp.mdga.client.dialog;
|
package pp.mdga.client.dialog;
|
||||||
|
|
||||||
import com.jme3.math.Vector2f;
|
public class InterruptDialog {
|
||||||
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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@code InterruptDialog} class represents a dialog that interrupts the game flow,
|
|
||||||
* providing a message and the option to force an action if the user is a host.
|
|
||||||
*/
|
|
||||||
public class InterruptDialog extends Dialog {
|
|
||||||
private ButtonRight forceButton;
|
|
||||||
|
|
||||||
private LabelButton label;
|
|
||||||
|
|
||||||
private String text = "";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs an {@code InterruptDialog}.
|
|
||||||
*
|
|
||||||
* @param app The main application managing the dialog.
|
|
||||||
* @param node The root node for attaching UI elements.
|
|
||||||
*/
|
|
||||||
public InterruptDialog(MdgaApp app, Node node) {
|
|
||||||
super(app, node);
|
|
||||||
|
|
||||||
forceButton = new ButtonRight(app, node, () -> app.getModelSynchronize().force(), "Erzwingen", 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the dialog is shown. Displays the label and optionally the force button if the user is the host.
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onShow() {
|
|
||||||
if(app.getGameLogic().isHost()) {
|
|
||||||
forceButton.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
label = new LabelButton(app, node, "Warte auf " + text + "...", new Vector2f(5.5f * 1.5f, 2), new Vector2f(0.5f, 0f), false);
|
|
||||||
|
|
||||||
float offset = 2.8f;
|
|
||||||
label.setPos(new Vector2f(0, MenuButton.VERTICAL - offset));
|
|
||||||
|
|
||||||
label.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the dialog is hidden. Hides the label and the force button.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected void onHide() {
|
|
||||||
forceButton.hide();
|
|
||||||
label.hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the displayed text based on the specified color.
|
|
||||||
*
|
|
||||||
* @param color The color used to determine the text (e.g., "Luftwaffe" for AIRFORCE).
|
|
||||||
*/
|
|
||||||
public void setColor(Color color) {
|
|
||||||
switch (color) {
|
|
||||||
case AIRFORCE:
|
|
||||||
text = "Luftwaffe";
|
|
||||||
break;
|
|
||||||
case ARMY:
|
|
||||||
text = "Heer";
|
|
||||||
break;
|
|
||||||
case NAVY:
|
|
||||||
text = "Marine";
|
|
||||||
break;
|
|
||||||
case CYBER:
|
|
||||||
text = "CIR";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,10 +13,6 @@
|
|||||||
|
|
||||||
import java.util.prefs.Preferences;
|
import java.util.prefs.Preferences;
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@code JoinDialog} class represents a dialog for joining a network game.
|
|
||||||
* It allows users to input an IP address and port number, connect to a server, or navigate back to the previous view.
|
|
||||||
*/
|
|
||||||
public class JoinDialog extends NetworkDialog {
|
public class JoinDialog extends NetworkDialog {
|
||||||
private InputButton ipInput;
|
private InputButton ipInput;
|
||||||
private InputButton portInput;
|
private InputButton portInput;
|
||||||
@@ -28,13 +24,6 @@ public class JoinDialog extends NetworkDialog {
|
|||||||
|
|
||||||
private Preferences prefs = Preferences.userNodeForPackage(JoinDialog.class);
|
private Preferences prefs = Preferences.userNodeForPackage(JoinDialog.class);
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a {@code JoinDialog}.
|
|
||||||
*
|
|
||||||
* @param app The main application managing the dialog.
|
|
||||||
* @param node The root node for attaching UI elements.
|
|
||||||
* @param view The main view used for navigation and interaction with the dialog.
|
|
||||||
*/
|
|
||||||
public JoinDialog(MdgaApp app, Node node, MainView view) {
|
public JoinDialog(MdgaApp app, Node node, MainView view) {
|
||||||
super(app, node, (NetworkSupport) app.getNetworkSupport());
|
super(app, node, (NetworkSupport) app.getNetworkSupport());
|
||||||
|
|
||||||
@@ -57,9 +46,6 @@ public JoinDialog(MdgaApp app, Node node, MainView view) {
|
|||||||
offset += 1.5f;
|
offset += 1.5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the dialog is shown. Displays all input fields and buttons.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected void onShow() {
|
protected void onShow() {
|
||||||
ipInput.show();
|
ipInput.show();
|
||||||
@@ -68,9 +54,6 @@ protected void onShow() {
|
|||||||
backButton.show();
|
backButton.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the dialog is hidden. Hides all input fields and buttons.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected void onHide() {
|
protected void onHide() {
|
||||||
ipInput.hide();
|
ipInput.hide();
|
||||||
@@ -79,70 +62,34 @@ protected void onHide() {
|
|||||||
backButton.hide();
|
backButton.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the state of the input fields. This method is called periodically to synchronize the dialog state.
|
|
||||||
*/
|
|
||||||
public void update() {
|
public void update() {
|
||||||
ipInput.update();
|
ipInput.update();
|
||||||
portInput.update();
|
portInput.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the currently entered IP address, saves it to preferences, and sets it as the hostname.
|
|
||||||
*
|
|
||||||
* @return The IP address as a string.
|
|
||||||
*/
|
|
||||||
public String getIpt() {
|
public String getIpt() {
|
||||||
prefs.put("joinIp", ipInput.getString());
|
prefs.put("joinIp", ipInput.getString());
|
||||||
setHostname(ipInput.getString());
|
setHostname(ipInput.getString());
|
||||||
return ipInput.getString();
|
return ipInput.getString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Resets the IP input field to its default value and updates preferences accordingly.
|
|
||||||
*/
|
|
||||||
public void resetIp() {
|
public void resetIp() {
|
||||||
ipInput.reset();
|
ipInput.reset();
|
||||||
prefs.put("joinIp", "");
|
prefs.put("joinIp", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the currently entered port number, saves it to preferences, and sets it as the active port.
|
|
||||||
*
|
|
||||||
* @return The port number as a string.
|
|
||||||
*/
|
|
||||||
public String getPort() {
|
public String getPort() {
|
||||||
prefs.put("joinPort", portInput.getString());
|
prefs.put("joinPort", portInput.getString());
|
||||||
setPortNumber(Integer.parseInt(portInput.getString()));
|
setPortNumber(Integer.parseInt(portInput.getString()));
|
||||||
return portInput.getString();
|
return portInput.getString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Resets the port input field to its default value and updates preferences accordingly.
|
|
||||||
*/
|
|
||||||
public void resetPort() {
|
public void resetPort() {
|
||||||
portInput.reset();
|
portInput.reset();
|
||||||
prefs.put("joinPort", "11111");
|
prefs.put("joinPort", "11111");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Connects to the server using the current IP address and port number.
|
|
||||||
*/
|
|
||||||
public void connectToServer() {
|
public void connectToServer() {
|
||||||
connectServer();
|
connectServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Disconnects from the server if a network connection exists.
|
|
||||||
*/
|
|
||||||
public void disconnect() {
|
|
||||||
NetworkSupport network = getNetwork();
|
|
||||||
if (network != null) {
|
|
||||||
try {
|
|
||||||
network.disconnect();
|
|
||||||
} catch (Exception e) {
|
|
||||||
System.err.println("Error while disconnecting: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,55 +8,27 @@
|
|||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@code NetworkDialog} class serves as an abstract base class for dialogs
|
|
||||||
* that involve network-related functionalities, such as connecting to a server or hosting a game.
|
|
||||||
* It provides methods for initializing, connecting to, and managing a network server.
|
|
||||||
*/
|
|
||||||
public abstract class NetworkDialog extends Dialog {
|
public abstract class NetworkDialog extends Dialog {
|
||||||
|
|
||||||
private NetworkSupport network;
|
private NetworkSupport network;
|
||||||
private String hostname;
|
private String hostname;
|
||||||
private int portNumber;
|
private int portNumber;
|
||||||
private Future<Object> connectionFuture;
|
private Future<Object> connectionFuture;
|
||||||
private MdgaServer serverInstance;
|
|
||||||
private Thread serverThread;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a {@code NetworkDialog}.
|
|
||||||
*
|
|
||||||
* @param app The main application managing the dialog.
|
|
||||||
* @param node The root node for attaching UI elements.
|
|
||||||
* @param network The network support instance for managing network interactions.
|
|
||||||
*/
|
|
||||||
public NetworkDialog(MdgaApp app, Node node, NetworkSupport network) {
|
public NetworkDialog(MdgaApp app, Node node, NetworkSupport network) {
|
||||||
super(app, node);
|
super(app, node);
|
||||||
this.network = network;
|
this.network = network;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the hostname for the network connection.
|
|
||||||
*
|
|
||||||
* @param hostname The hostname or IP address of the server.
|
|
||||||
*/
|
|
||||||
public void setHostname(String hostname) {
|
public void setHostname(String hostname) {
|
||||||
this.hostname = hostname;
|
this.hostname = hostname;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the port number for the network connection.
|
|
||||||
*
|
|
||||||
* @param portNumber The port number to use for the connection.
|
|
||||||
*/
|
|
||||||
public void setPortNumber(int portNumber) {
|
public void setPortNumber(int portNumber) {
|
||||||
this.portNumber = portNumber;
|
this.portNumber = portNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes the network connection using the current hostname and port number.
|
|
||||||
*
|
|
||||||
* @return {@code null} if successful, otherwise throws an exception.
|
|
||||||
*/
|
|
||||||
protected Object initNetwork() {
|
protected Object initNetwork() {
|
||||||
try {
|
try {
|
||||||
this.network.initNetwork(this.hostname, this.portNumber);
|
this.network.initNetwork(this.hostname, this.portNumber);
|
||||||
@@ -66,84 +38,41 @@ protected Object initNetwork() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Starts the process of connecting to a server asynchronously.
|
|
||||||
*/
|
|
||||||
protected void connectServer() {
|
protected void connectServer() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
connectionFuture = this.network.getApp().getExecutor().submit(this::initNetwork);
|
connectionFuture = this.network.getApp().getExecutor().submit(this::initNetwork);
|
||||||
} catch (NumberFormatException var2) {
|
} catch (NumberFormatException var2) {
|
||||||
throw new NumberFormatException("Port must be a number");
|
throw new NumberFormatException("Port must be a number");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Starts hosting a server in a separate thread.
|
|
||||||
*/
|
|
||||||
protected void startServer() {
|
protected void startServer() {
|
||||||
serverThread = new Thread(() -> {
|
(new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
serverInstance = new MdgaServer(portNumber);
|
MdgaServer mdgaServer = new MdgaServer(portNumber);
|
||||||
serverInstance.run();
|
mdgaServer.run();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
serverThread.start();
|
})).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Shuts down the hosted server and cleans up resources.
|
|
||||||
*/
|
|
||||||
public void shutdownServer() {
|
|
||||||
|
|
||||||
try {
|
|
||||||
Thread.sleep(1000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
System.err.println("Thread was interrupted: " + e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (serverInstance != null) {
|
|
||||||
serverInstance.shutdown();
|
|
||||||
serverInstance = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (serverThread != null && serverThread.isAlive()) {
|
|
||||||
serverThread.interrupt();
|
|
||||||
try {
|
|
||||||
serverThread.join();
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
}
|
|
||||||
serverThread = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the state of the connection process.
|
|
||||||
*
|
|
||||||
* @param delta The time elapsed since the last update call.
|
|
||||||
*/
|
|
||||||
public void update(float delta) {
|
public void update(float delta) {
|
||||||
if (this.connectionFuture != null && this.connectionFuture.isDone()) {
|
if (this.connectionFuture != null && this.connectionFuture.isDone()) {
|
||||||
try {
|
try {
|
||||||
this.connectionFuture.get();
|
this.connectionFuture.get();
|
||||||
} catch (ExecutionException ignored) {
|
} catch (ExecutionException ignored) {
|
||||||
// TODO: implement
|
// todo: implement
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public NetworkSupport getNetwork(){
|
||||||
* Retrieves the {@code NetworkSupport} instance associated with this dialog.
|
|
||||||
*
|
|
||||||
* @return The {@code NetworkSupport} instance.
|
|
||||||
*/
|
|
||||||
public NetworkSupport getNetwork() {
|
|
||||||
return network;
|
return network;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,10 +8,6 @@
|
|||||||
import pp.mdga.client.view.MainView;
|
import pp.mdga.client.view.MainView;
|
||||||
import pp.mdga.client.view.MdgaView;
|
import pp.mdga.client.view.MdgaView;
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@code SettingsDialog} class represents a dialog for navigating to various settings sections,
|
|
||||||
* such as video and audio settings, or returning to the previous view.
|
|
||||||
*/
|
|
||||||
public class SettingsDialog extends Dialog {
|
public class SettingsDialog extends Dialog {
|
||||||
private MenuButton videoButton;
|
private MenuButton videoButton;
|
||||||
private MenuButton audioButton;
|
private MenuButton audioButton;
|
||||||
@@ -19,13 +15,6 @@ public class SettingsDialog extends Dialog {
|
|||||||
|
|
||||||
private final MdgaView view;
|
private final MdgaView view;
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a {@code SettingsDialog}.
|
|
||||||
*
|
|
||||||
* @param app The main application managing the dialog.
|
|
||||||
* @param node The root node for attaching UI elements.
|
|
||||||
* @param view The view managing navigation and interaction with the settings dialog.
|
|
||||||
*/
|
|
||||||
public SettingsDialog(MdgaApp app, Node node, MdgaView view) {
|
public SettingsDialog(MdgaApp app, Node node, MdgaView view) {
|
||||||
super(app, node);
|
super(app, node);
|
||||||
|
|
||||||
@@ -45,9 +34,6 @@ public SettingsDialog(MdgaApp app, Node node, MdgaView view) {
|
|||||||
backButton.setPos(new Vector2f(0, 1.8f));
|
backButton.setPos(new Vector2f(0, 1.8f));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the dialog is shown. Displays all buttons for video settings, audio settings, and back navigation.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected void onShow() {
|
protected void onShow() {
|
||||||
videoButton.show();
|
videoButton.show();
|
||||||
@@ -55,9 +41,6 @@ protected void onShow() {
|
|||||||
backButton.show();
|
backButton.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the dialog is hidden. Hides all buttons for video settings, audio settings, and back navigation.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected void onHide() {
|
protected void onHide() {
|
||||||
videoButton.hide();
|
videoButton.hide();
|
||||||
|
|||||||
@@ -14,10 +14,6 @@
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.random.RandomGenerator;
|
import java.util.random.RandomGenerator;
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@code StartDialog} class represents the initial dialog in the application,
|
|
||||||
* allowing the user to input their name, host or join a game, or exit the application.
|
|
||||||
*/
|
|
||||||
public class StartDialog extends Dialog {
|
public class StartDialog extends Dialog {
|
||||||
private InputButton nameInput;
|
private InputButton nameInput;
|
||||||
|
|
||||||
@@ -27,13 +23,6 @@ public class StartDialog extends Dialog {
|
|||||||
|
|
||||||
private final MainView view;
|
private final MainView view;
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a {@code StartDialog}.
|
|
||||||
*
|
|
||||||
* @param app The main application managing the dialog.
|
|
||||||
* @param node The root node for attaching UI elements.
|
|
||||||
* @param view The main view used for navigation and interaction with the dialog.
|
|
||||||
*/
|
|
||||||
public StartDialog(MdgaApp app, Node node, MainView view) {
|
public StartDialog(MdgaApp app, Node node, MainView view) {
|
||||||
super(app, node);
|
super(app, node);
|
||||||
|
|
||||||
@@ -59,9 +48,6 @@ public StartDialog(MdgaApp app, Node node, MainView view) {
|
|||||||
endButton.setPos(new Vector2f(0, 1.8f));
|
endButton.setPos(new Vector2f(0, 1.8f));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the dialog is shown. Displays the name input field and all buttons.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected void onShow() {
|
protected void onShow() {
|
||||||
nameInput.show();
|
nameInput.show();
|
||||||
@@ -71,9 +57,6 @@ protected void onShow() {
|
|||||||
endButton.show();
|
endButton.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the dialog is hidden. Hides the name input field and all buttons.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected void onHide ()
|
protected void onHide ()
|
||||||
{
|
{
|
||||||
@@ -84,18 +67,10 @@ protected void onHide ()
|
|||||||
endButton.hide();
|
endButton.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the state of the name input field. This method is called periodically to synchronize the dialog state.
|
|
||||||
*/
|
|
||||||
public void update() {
|
public void update() {
|
||||||
nameInput.update();
|
nameInput.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the name entered by the user. If no name is provided, a random name is generated.
|
|
||||||
*
|
|
||||||
* @return The user's name or a randomly generated name.
|
|
||||||
*/
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
String name = nameInput.getString();
|
String name = nameInput.getString();
|
||||||
|
|
||||||
@@ -202,109 +177,6 @@ public String getName() {
|
|||||||
"CarryPro",
|
"CarryPro",
|
||||||
"ProBaiter",
|
"ProBaiter",
|
||||||
"GameWarden",
|
"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();
|
Random random = new Random();
|
||||||
|
|||||||
@@ -3,25 +3,13 @@
|
|||||||
import com.jme3.math.Vector2f;
|
import com.jme3.math.Vector2f;
|
||||||
import com.jme3.scene.Node;
|
import com.jme3.scene.Node;
|
||||||
import pp.mdga.client.MdgaApp;
|
import pp.mdga.client.MdgaApp;
|
||||||
import pp.mdga.client.button.AbstractButton;
|
|
||||||
import pp.mdga.client.button.ButtonLeft;
|
import pp.mdga.client.button.ButtonLeft;
|
||||||
import pp.mdga.client.button.ButtonRight;
|
import pp.mdga.client.button.ButtonRight;
|
||||||
import pp.mdga.client.button.MenuButton;
|
import pp.mdga.client.button.MenuButton;
|
||||||
import pp.mdga.client.view.MdgaView;
|
import pp.mdga.client.view.MdgaView;
|
||||||
|
|
||||||
import java.util.prefs.Preferences;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@code VideoSettingsDialog} class represents a dialog for configuring video settings,
|
|
||||||
* such as resolution and fullscreen mode. It also provides an option to restart the application
|
|
||||||
* when certain settings are changed.
|
|
||||||
*/
|
|
||||||
public class VideoSettingsDialog extends Dialog {
|
public class VideoSettingsDialog extends Dialog {
|
||||||
private static Preferences prefs = Preferences.userNodeForPackage(JoinDialog.class);
|
|
||||||
|
|
||||||
private ButtonRight fullscreenButton;
|
|
||||||
private MenuButton backButton;
|
private MenuButton backButton;
|
||||||
private ButtonRight restartButton;
|
|
||||||
|
|
||||||
private ButtonLeft hdButton9;
|
private ButtonLeft hdButton9;
|
||||||
private ButtonLeft fullHdButton9;
|
private ButtonLeft fullHdButton9;
|
||||||
@@ -34,13 +22,6 @@ public class VideoSettingsDialog extends Dialog {
|
|||||||
|
|
||||||
private boolean active = false;
|
private boolean active = false;
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a {@code VideoSettingsDialog}.
|
|
||||||
*
|
|
||||||
* @param app The main application managing the dialog.
|
|
||||||
* @param node The root node for attaching UI elements.
|
|
||||||
* @param view The view managing navigation and interaction with the video settings dialog.
|
|
||||||
*/
|
|
||||||
public VideoSettingsDialog(MdgaApp app, Node node, MdgaView view) {
|
public VideoSettingsDialog(MdgaApp app, Node node, MdgaView view) {
|
||||||
super(app, node);
|
super(app, node);
|
||||||
|
|
||||||
@@ -48,24 +29,20 @@ public VideoSettingsDialog(MdgaApp app, Node node, MdgaView view) {
|
|||||||
|
|
||||||
backButton = new MenuButton(app, node, view::leaveVideoSettings, "Zurück");
|
backButton = new MenuButton(app, node, view::leaveVideoSettings, "Zurück");
|
||||||
|
|
||||||
restartButton = new ButtonRight(app, node, MdgaApp::restartApp, "Neustart", 1);
|
// MenuButton für verschiedene Auflösungen erstellen
|
||||||
|
hdButton9 = new ButtonLeft(app, node, () -> app.updateResolution(1280, 720, 1.0f), "hd 16:9", 10);
|
||||||
fullscreenButton = new ButtonRight(app, node, () -> updateResolution(0, 0, 0, true), "Vollbild", 1);
|
fullHdButton9 = new ButtonLeft(app, node, () -> app.updateResolution(1920, 1080, 2.25f), "full hd 16:9", 10);
|
||||||
|
wqhdButton9 = new ButtonLeft(app, node, () -> app.updateResolution(2560, 1440, 4.0f), "wqhd 16:9", 10);
|
||||||
hdButton9 = new ButtonLeft(app, node, () -> updateResolution(1280, 720, 1.0f, false), "hd 16:9", 10);
|
|
||||||
fullHdButton9 = new ButtonLeft(app, node, () -> updateResolution(1920, 1080, 2.25f, false), "full hd 16:9", 10);
|
|
||||||
wqhdButton9 = new ButtonLeft(app, node, () -> updateResolution(2560, 1440, 4.0f, false), "wqhd 16:9", 10);
|
|
||||||
|
|
||||||
|
|
||||||
hdButton10 = new ButtonRight(app, node, () -> updateResolution(1280, 800, 1.0f, false), "hd 16:10", 10);
|
hdButton10 = new ButtonRight(app, node, () -> app.updateResolution(1280, 800, 1.0f), "hd 16:10", 10);
|
||||||
fullHdButton10 = new ButtonRight(app, node, () -> updateResolution(1920, 1200, 2.25f, false), "full hd 16:10", 10);
|
fullHdButton10 = new ButtonRight(app, node, () -> app.updateResolution(1920, 1200, 2.25f), "full hd 16:10", 10);
|
||||||
wqhdButton10 = new ButtonRight(app, node, () -> updateResolution(2560, 1600, 4.0f, false), "wqhd 16:10", 10);
|
wqhdButton10 = new ButtonRight(app, node, () -> app.updateResolution(2560, 1600, 4.0f), "wqhd 16:10", 10);
|
||||||
|
|
||||||
float offset = 2.8f;
|
float offset = 2.8f;
|
||||||
|
|
||||||
hdButton9.setPos(new Vector2f(hdButton9.getPos().x, MenuButton.VERTICAL - offset));
|
hdButton9.setPos(new Vector2f(hdButton9.getPos().x, MenuButton.VERTICAL - offset));
|
||||||
hdButton10.setPos(new Vector2f(hdButton10.getPos().x, MenuButton.VERTICAL - offset));
|
hdButton10.setPos(new Vector2f(hdButton10.getPos().x, MenuButton.VERTICAL - offset));
|
||||||
fullscreenButton.setPos(new Vector2f(fullscreenButton.getPos().x, MenuButton.VERTICAL - offset));
|
|
||||||
offset += 1.5f;
|
offset += 1.5f;
|
||||||
|
|
||||||
fullHdButton9.setPos(new Vector2f(fullHdButton9.getPos().x, MenuButton.VERTICAL - offset));
|
fullHdButton9.setPos(new Vector2f(fullHdButton9.getPos().x, MenuButton.VERTICAL - offset));
|
||||||
@@ -79,9 +56,6 @@ public VideoSettingsDialog(MdgaApp app, Node node, MdgaView view) {
|
|||||||
backButton.setPos(new Vector2f(0, 1.8f));
|
backButton.setPos(new Vector2f(0, 1.8f));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the dialog is shown. Displays all buttons and marks the dialog as active.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected void onShow() {
|
protected void onShow() {
|
||||||
active = true;
|
active = true;
|
||||||
@@ -94,13 +68,9 @@ protected void onShow() {
|
|||||||
fullHdButton10.show();
|
fullHdButton10.show();
|
||||||
wqhdButton10.show();
|
wqhdButton10.show();
|
||||||
|
|
||||||
fullscreenButton.show();
|
|
||||||
backButton.show();
|
backButton.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the dialog is hidden. Hides all buttons and marks the dialog as inactive.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected void onHide() {
|
protected void onHide() {
|
||||||
active = false;
|
active = false;
|
||||||
@@ -113,33 +83,12 @@ protected void onHide() {
|
|||||||
fullHdButton10.hide();
|
fullHdButton10.hide();
|
||||||
wqhdButton10.hide();
|
wqhdButton10.hide();
|
||||||
|
|
||||||
fullscreenButton.hide();
|
|
||||||
backButton.hide();
|
backButton.hide();
|
||||||
restartButton.hide();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the dialog's state. This method can be used for periodic updates while the dialog is active.
|
|
||||||
*/
|
|
||||||
public void update() {
|
public void update() {
|
||||||
if(!active) {
|
if(!active) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the resolution settings and optionally triggers the restart button if changes are detected.
|
|
||||||
*
|
|
||||||
* @param width The width of the resolution.
|
|
||||||
* @param height The height of the resolution.
|
|
||||||
* @param imageFactor The scaling factor for the resolution.
|
|
||||||
* @param isFullscreen {@code true} if fullscreen mode is enabled, {@code false} otherwise.
|
|
||||||
*/
|
|
||||||
public void updateResolution(int width, int height, float imageFactor, boolean isFullscreen) {
|
|
||||||
if(width != prefs.getInt("width", 1280) || height != prefs.getInt("height", 720) || isFullscreen != prefs.getBoolean("fullscreen", false)) {
|
|
||||||
restartButton.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
app.updateResolution(width, height, imageFactor, isFullscreen);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,25 +10,12 @@
|
|||||||
import pp.mdga.client.animation.ZoomControl;
|
import pp.mdga.client.animation.ZoomControl;
|
||||||
import pp.mdga.game.Color;
|
import pp.mdga.game.Color;
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@code ActionTextHandler} class manages the display of animated and stylized text messages in the game's UI.
|
|
||||||
* It supports dynamic text creation with spacing, color, and effects, such as dice rolls, player actions, and rankings.
|
|
||||||
*/
|
|
||||||
class ActionTextHandler {
|
class ActionTextHandler {
|
||||||
private Node root;
|
private Node root;
|
||||||
private BitmapFont font;
|
private BitmapFont font;
|
||||||
private AppSettings appSettings;
|
private AppSettings appSettings;
|
||||||
private int ranking;
|
private int ranking;
|
||||||
|
|
||||||
float paddingRanked = 100;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs an {@code ActionTextHandler}.
|
|
||||||
*
|
|
||||||
* @param guiNode The GUI node where the text messages will be displayed.
|
|
||||||
* @param assetManager The asset manager used to load fonts and other assets.
|
|
||||||
* @param appSettings The application settings for positioning and sizing.
|
|
||||||
*/
|
|
||||||
ActionTextHandler(Node guiNode, AssetManager assetManager, AppSettings appSettings){
|
ActionTextHandler(Node guiNode, AssetManager assetManager, AppSettings appSettings){
|
||||||
root = new Node("actionTextRoot");
|
root = new Node("actionTextRoot");
|
||||||
guiNode.attachChild(root);
|
guiNode.attachChild(root);
|
||||||
@@ -39,16 +26,6 @@ class ActionTextHandler {
|
|||||||
ranking = 0;
|
ranking = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a {@code Node} containing text with specified spacing, size, and colors for each segment of the text.
|
|
||||||
*
|
|
||||||
* @param textArr An array of strings representing the text to be displayed.
|
|
||||||
* @param spacing The spacing between individual characters.
|
|
||||||
* @param size The size of the text.
|
|
||||||
* @param colorArr An array of {@code ColorRGBA} representing the color for each string in {@code textArr}.
|
|
||||||
* @return A {@code Node} containing the styled text with spacing and color applied.
|
|
||||||
* @throws RuntimeException if the lengths of {@code textArr} and {@code colorArr} do not match.
|
|
||||||
*/
|
|
||||||
private Node createTextWithSpacing(String[] textArr, float spacing, float size, ColorRGBA[] colorArr) {
|
private Node createTextWithSpacing(String[] textArr, float spacing, float size, ColorRGBA[] colorArr) {
|
||||||
if(textArr.length != colorArr.length) throw new RuntimeException("text and color are not the same length");
|
if(textArr.length != colorArr.length) throw new RuntimeException("text and color are not the same length");
|
||||||
|
|
||||||
@@ -75,55 +52,18 @@ private Node createTextWithSpacing(String[] textArr, float spacing, float size,
|
|||||||
return textNode;
|
return textNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a {@code Node} containing text with specified spacing, size, and a single color.
|
|
||||||
*
|
|
||||||
* @param text The text to be displayed.
|
|
||||||
* @param spacing The spacing between individual characters.
|
|
||||||
* @param size The size of the text.
|
|
||||||
* @param color The color of the text.
|
|
||||||
* @return A {@code Node} containing the styled text.
|
|
||||||
*/
|
|
||||||
private Node createTextWithSpacing(String text, float spacing, float size, ColorRGBA color) {
|
private Node createTextWithSpacing(String text, float spacing, float size, ColorRGBA color) {
|
||||||
return createTextWithSpacing(new String[]{text}, spacing, size, new ColorRGBA[]{color});
|
return createTextWithSpacing(new String[]{text}, spacing, size, new ColorRGBA[]{color});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Calculates the center position of a rectangle given its width, height, and an origin position.
|
|
||||||
*
|
|
||||||
* @param width The width of the rectangle.
|
|
||||||
* @param height The height of the rectangle.
|
|
||||||
* @param pos The origin position of the rectangle.
|
|
||||||
* @return A {@code Vector3f} representing the center position.
|
|
||||||
*/
|
|
||||||
private Vector3f center(float width, float height, Vector3f pos){
|
private Vector3f center(float width, float height, Vector3f pos){
|
||||||
return new Vector3f(pos.x+width/2, pos.y+height/2,0);
|
return new Vector3f(pos.x+width/2, pos.y+height/2,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates and positions a single-line text at the top of the screen with a specified vertical offset.
|
|
||||||
*
|
|
||||||
* @param name The text to be displayed.
|
|
||||||
* @param spacing The spacing between individual characters.
|
|
||||||
* @param size The size of the text.
|
|
||||||
* @param color The color of the text.
|
|
||||||
* @param top The vertical offset from the top of the screen.
|
|
||||||
* @return A {@code Node} containing the styled text positioned at the top.
|
|
||||||
*/
|
|
||||||
private Node createTopText(String name, float spacing, float size, ColorRGBA color, float top){
|
private Node createTopText(String name, float spacing, float size, ColorRGBA color, float top){
|
||||||
return createTopText(new String[]{name}, spacing, size, new ColorRGBA[]{color}, top);
|
return createTopText(new String[]{name}, spacing, size, new ColorRGBA[]{color}, top);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates and positions multi-line text at the top of the screen with specified vertical offset, spacing, and colors.
|
|
||||||
*
|
|
||||||
* @param name An array of strings representing the text to be displayed.
|
|
||||||
* @param spacing The spacing between individual characters.
|
|
||||||
* @param size The size of the text.
|
|
||||||
* @param color An array of {@code ColorRGBA} representing the color for each string in {@code name}.
|
|
||||||
* @param top The vertical offset from the top of the screen.
|
|
||||||
* @return A {@code Node} containing the styled text positioned at the top.
|
|
||||||
*/
|
|
||||||
private Node createTopText(String[] name, float spacing, float size, ColorRGBA color[], float top){
|
private Node createTopText(String[] name, float spacing, float size, ColorRGBA color[], float top){
|
||||||
Node text = createTextWithSpacing(name, spacing, size, color);
|
Node text = createTextWithSpacing(name, spacing, size, color);
|
||||||
text.setLocalTranslation(0, (appSettings.getHeight()/2f)*0.8f-top,0);
|
text.setLocalTranslation(0, (appSettings.getHeight()/2f)*0.8f-top,0);
|
||||||
@@ -131,44 +71,18 @@ private Node createTopText(String[] name, float spacing, float size, ColorRGBA c
|
|||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Calculates the center position of a rectangle with negative width offset.
|
|
||||||
*
|
|
||||||
* @param width The negative width of the rectangle.
|
|
||||||
* @param height The height of the rectangle.
|
|
||||||
* @param pos The origin position of the rectangle.
|
|
||||||
* @return A {@code Vector3f} representing the center position.
|
|
||||||
*/
|
|
||||||
private Vector3f centerText(float width, float height, Vector3f pos){
|
private Vector3f centerText(float width, float height, Vector3f pos){
|
||||||
return center(-width, height, pos);
|
return center(-width, height, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Displays a message indicating the active player.
|
|
||||||
*
|
|
||||||
* @param name The name of the active player.
|
|
||||||
* @param color The color representing the player's team.
|
|
||||||
*/
|
|
||||||
void activePlayer(String name, Color color){
|
void activePlayer(String name, Color color){
|
||||||
createTopText(new String[]{name," ist dran"}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl());
|
createTopText(new String[]{name," ist dran"}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Displays a message indicating that the current player is active.
|
|
||||||
*
|
|
||||||
* @param color The color representing the player's team.
|
|
||||||
*/
|
|
||||||
void ownActive(Color color){
|
void ownActive(Color color){
|
||||||
createTopText(new String[]{"Du"," bist dran"}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl());
|
createTopText(new String[]{"Du"," bist dran"}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Displays a dice roll result for a player.
|
|
||||||
*
|
|
||||||
* @param diceNum The number rolled on the dice.
|
|
||||||
* @param name The name of the player.
|
|
||||||
* @param color The color representing the player's team.
|
|
||||||
*/
|
|
||||||
void diceNum(int diceNum, String name, Color color){
|
void diceNum(int diceNum, String name, Color color){
|
||||||
createTopText(new String[]{name," würfelt:"}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0);
|
createTopText(new String[]{name," würfelt:"}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0);
|
||||||
|
|
||||||
@@ -176,84 +90,38 @@ void diceNum(int diceNum, String name, Color color){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Displays a dice roll result with a multiplier for a player.
|
|
||||||
*
|
|
||||||
* @param diceNum The number rolled on the dice.
|
|
||||||
* @param mult The multiplier applied to the dice result.
|
|
||||||
* @param name The name of the player.
|
|
||||||
* @param color The color representing the player's team.
|
|
||||||
*/
|
|
||||||
void diceNumMult(int diceNum,int mult, String name, Color color){
|
void diceNumMult(int diceNum,int mult, String name, Color color){
|
||||||
createTopText(new String[]{name," würfelt:"}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0);
|
createTopText(new String[]{name," würfelt:"}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0);
|
||||||
|
|
||||||
createTopText(new String[]{String.valueOf(diceNum), " x" + mult + " = " + (diceNum*mult)}, 20, 100, new ColorRGBA[]{ColorRGBA.White,ColorRGBA.Red}, 100);
|
createTopText(new String[]{String.valueOf(diceNum), " x" + mult + " = " + (diceNum*mult)}, 20, 100, new ColorRGBA[]{ColorRGBA.White,ColorRGBA.Red}, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Displays the dice roll result for the current player.
|
|
||||||
*
|
|
||||||
* @param diceNum The number rolled on the dice.
|
|
||||||
*/
|
|
||||||
void ownDice(int diceNum){
|
void ownDice(int diceNum){
|
||||||
createTopText(String.valueOf(diceNum), 10, 100, ColorRGBA.White, 0);
|
createTopText(String.valueOf(diceNum), 10, 100, ColorRGBA.White, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Displays the dice roll result with a multiplier for the current player.
|
|
||||||
*
|
|
||||||
* @param diceNum The number rolled on the dice.
|
|
||||||
* @param mult The multiplier applied to the dice result.
|
|
||||||
*/
|
|
||||||
void ownDiceMult(int diceNum, int mult){
|
void ownDiceMult(int diceNum, int mult){
|
||||||
createTopText(new String[]{String.valueOf(diceNum), " x" + mult + " = " + (diceNum*mult)}, 20, 100, new ColorRGBA[]{ColorRGBA.White,ColorRGBA.Red}, 0);
|
createTopText(new String[]{String.valueOf(diceNum), " x" + mult + " = " + (diceNum*mult)}, 20, 100, new ColorRGBA[]{ColorRGBA.White,ColorRGBA.Red}, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Displays a message indicating that a specified player received a bonus card.
|
|
||||||
*
|
|
||||||
* @param name The name of the player who received the bonus card.
|
|
||||||
* @param color The color representing the player's team.
|
|
||||||
*/
|
|
||||||
void drawCard(String name, Color color){
|
void drawCard(String name, Color color){
|
||||||
createTopText(new String[]{name," erhält eine Bonuskarte"}, 7,70, new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl());
|
createTopText(new String[]{name," erhält eine Bonuskarte"}, 7,70, new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Displays a message indicating that the current player received a bonus card.
|
|
||||||
*
|
|
||||||
* @param color The color representing the player's team.
|
|
||||||
*/
|
|
||||||
void drawCardOwn(Color color){
|
void drawCardOwn(Color color){
|
||||||
createTopText(new String[]{"Du"," erhälst eine Bonuskarte"}, 5,70, new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl());
|
createTopText(new String[]{"Du"," erhälst eine Bonuskarte"}, 5,70, new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Displays a message indicating that a specified player has completed their turn or action.
|
|
||||||
*
|
|
||||||
* @param name The name of the player who finished.
|
|
||||||
* @param color The color representing the player's team.
|
|
||||||
*/
|
|
||||||
void finishText(String name, Color color){
|
void finishText(String name, Color color){
|
||||||
createTopText(new String[]{name," ist fertig!"}, 7,70, new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl());
|
createTopText(new String[]{name," ist fertig!"}, 7,70, new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Displays a message indicating that the current player has completed their turn or action.
|
|
||||||
*
|
|
||||||
* @param color The color representing the player's team.
|
|
||||||
*/
|
|
||||||
void finishTextOwn(Color color){
|
void finishTextOwn(Color color){
|
||||||
createTopText(new String[]{"Du", " bist fertig!"}, 7,70, new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl());
|
createTopText(new String[]{"Du", " bist fertig!"}, 7,70, new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a player's team color to a corresponding {@code ColorRGBA}.
|
|
||||||
*
|
|
||||||
* @param color The player's team color.
|
|
||||||
* @return The corresponding {@code ColorRGBA}.
|
|
||||||
* @throws RuntimeException if the color is invalid.
|
|
||||||
*/
|
|
||||||
private ColorRGBA playerColorToColorRGBA(Color color){
|
private ColorRGBA playerColorToColorRGBA(Color color){
|
||||||
return switch (color){
|
return switch (color){
|
||||||
case ARMY -> ColorRGBA.Green;
|
case ARMY -> ColorRGBA.Green;
|
||||||
@@ -264,41 +132,25 @@ private ColorRGBA playerColorToColorRGBA(Color color){
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Hides all text messages displayed by the handler and resets the ranking counter.
|
|
||||||
*/
|
|
||||||
void hide(){
|
void hide(){
|
||||||
ranking = 0;
|
ranking = 0;
|
||||||
root.detachAllChildren();
|
root.detachAllChildren();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
float paddingRanked = 100;
|
||||||
* Displays a ranked dice roll result for a specified player.
|
|
||||||
*
|
|
||||||
* @param name The name of the player.
|
|
||||||
* @param color The color representing the player's team.
|
|
||||||
* @param eye The dice roll result.
|
|
||||||
*/
|
|
||||||
void rollRankingResult(String name, Color color, int eye){
|
void rollRankingResult(String name, Color color, int eye){
|
||||||
createTopText(new String[]{name,": "+eye}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, paddingRanked*ranking);
|
createTopText(new String[]{name,": "+eye}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, paddingRanked*ranking);
|
||||||
ranking++;
|
ranking++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Displays a ranked dice roll result for the current player.
|
|
||||||
*
|
|
||||||
* @param color The color representing the player's team.
|
|
||||||
* @param eye The dice roll result.
|
|
||||||
*/
|
|
||||||
void rollRankingResultOwn(Color color, int eye){
|
void rollRankingResultOwn(Color color, int eye){
|
||||||
createTopText(new String[]{"Du",": "+eye}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, paddingRanked*ranking);
|
createTopText(new String[]{"Du",": "+eye}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, paddingRanked*ranking);
|
||||||
ranking++;
|
ranking++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Displays a message prompting the player to roll the dice.
|
|
||||||
*/
|
|
||||||
void diceNow(){
|
void diceNow(){
|
||||||
createTopText("Klicke zum Würfeln", 5, 80, ColorRGBA.White, 0);
|
createTopText("Klicke zum Würfeln", 5, 80, ColorRGBA.White, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ private Node createNum(){
|
|||||||
Material mat = new Material(getApp().getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
|
Material mat = new Material(getApp().getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
mat.setColor("Color", ColorRGBA.Black);
|
mat.setColor("Color", ColorRGBA.Black);
|
||||||
circle.setMaterial(mat);
|
circle.setMaterial(mat);
|
||||||
// root.attachChild(circle);
|
root.attachChild(circle);
|
||||||
BitmapFont guiFont = getApp().getAssetManager().loadFont("Fonts/Gunplay.fnt");
|
BitmapFont guiFont = getApp().getAssetManager().loadFont("Fonts/Gunplay.fnt");
|
||||||
num = new BitmapText(guiFont);
|
num = new BitmapText(guiFont);
|
||||||
num.setSize(0.3f);
|
num.setSize(0.3f);
|
||||||
|
|||||||
@@ -94,8 +94,7 @@ public void update(float tpf) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addSpatial(Spatial card) {
|
public void addSpatial(Spatial card) {
|
||||||
if(root == null) cardBuffer.add(card);
|
cardBuffer.add(card);
|
||||||
else root.attachChild(card);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteSpatial(Spatial spatial) {
|
public void deleteSpatial(Spatial spatial) {
|
||||||
|
|||||||
@@ -85,19 +85,6 @@ public void addCard(BonusCard card) {
|
|||||||
bonusCardControlMap.get(card).setNumCard(newNum);
|
bonusCardControlMap.get(card).setNumCard(newNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeCard(BonusCard card){
|
|
||||||
if(bonusCardControlMap.containsKey(card)){
|
|
||||||
bonusCardIntegerMap.put(card, bonusCardIntegerMap.get(card) - 1);
|
|
||||||
|
|
||||||
if(bonusCardIntegerMap.get(card) <= 0){
|
|
||||||
cardLayer.deleteSpatial(bonusCardControlMap.get(card).getRoot());
|
|
||||||
bonusCardIntegerMap.remove(card);
|
|
||||||
bonusCardControlMap.remove(card);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clearSelectableCards() {
|
public void clearSelectableCards() {
|
||||||
for (CardControl control : selectableCards) {
|
for (CardControl control : selectableCards) {
|
||||||
control.setSelectable(false);
|
control.setSelectable(false);
|
||||||
@@ -131,8 +118,6 @@ public void selectCard(CardControl cardControl) {
|
|||||||
cardControl.select();
|
cardControl.select();
|
||||||
cardSelect = getKeyByValue(bonusCardControlMap, cardControl);
|
cardSelect = getKeyByValue(bonusCardControlMap, cardControl);
|
||||||
}
|
}
|
||||||
|
|
||||||
app.getModelSynchronize().selectCard(cardSelect);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Camera getCardLayerCamera() {
|
public Camera getCardLayerCamera() {
|
||||||
|
|||||||
@@ -74,31 +74,8 @@ public void hideDice() {
|
|||||||
cardLayerHandler.hideDice();
|
cardLayerHandler.hideDice();
|
||||||
}
|
}
|
||||||
|
|
||||||
//add own handCard
|
public void addCard(BonusCard card) {
|
||||||
public void addCardOwn(BonusCard card) {
|
|
||||||
cardLayerHandler.addCard(card);
|
cardLayerHandler.addCard(card);
|
||||||
playerNameHandler.addCard(ownColor);
|
|
||||||
actionTextHandler.drawCardOwn(ownColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void playCardOwn(BonusCard card){
|
|
||||||
getEffectByCard(card);
|
|
||||||
cardLayerHandler.removeCard(card);
|
|
||||||
playerNameHandler.removeCard(ownColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void playCardEnemy(Color color, BonusCard card) {
|
|
||||||
getEffectByCard(card);
|
|
||||||
playerNameHandler.removeCard(color);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void getEffectByCard(BonusCard bonus){
|
|
||||||
switch(bonus){
|
|
||||||
case SWAP -> swap();
|
|
||||||
case TURBO -> turbo();
|
|
||||||
case SHIELD -> shield();
|
|
||||||
default -> throw new RuntimeException("invalid card");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearSelectableCards() {
|
public void clearSelectableCards() {
|
||||||
@@ -148,11 +125,9 @@ public void hideText(){
|
|||||||
actionTextHandler.hide();
|
actionTextHandler.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
//addCard Enemy (DrawCardNotification)
|
|
||||||
public void drawCard(Color color) {
|
public void drawCard(Color color) {
|
||||||
//Color != ownColor
|
if (ownColor == color) actionTextHandler.drawCardOwn(color);
|
||||||
actionTextHandler.drawCard(playerNameHandler.getName(color), color);
|
else actionTextHandler.drawCard(playerNameHandler.getName(color), color);
|
||||||
playerNameHandler.addCard(color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void finish(Color color){
|
public void finish(Color color){
|
||||||
@@ -166,6 +141,4 @@ public void rollRankingResult(Color color, int eye){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,27 +4,23 @@
|
|||||||
import com.jme3.font.BitmapFont;
|
import com.jme3.font.BitmapFont;
|
||||||
import com.jme3.font.BitmapText;
|
import com.jme3.font.BitmapText;
|
||||||
import com.jme3.math.ColorRGBA;
|
import com.jme3.math.ColorRGBA;
|
||||||
import com.jme3.math.Vector3f;
|
|
||||||
import com.jme3.scene.Node;
|
import com.jme3.scene.Node;
|
||||||
import com.jme3.scene.Spatial;
|
import com.jme3.scene.Spatial;
|
||||||
import com.jme3.system.AppSettings;
|
import com.jme3.system.AppSettings;
|
||||||
import com.jme3.ui.Picture;
|
import com.jme3.ui.Picture;
|
||||||
import pp.mdga.game.BonusCard;
|
|
||||||
import pp.mdga.game.Color;
|
import pp.mdga.game.Color;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
public class PlayerNameHandler {
|
public class PlayerNameHandler {
|
||||||
private final BitmapFont playerFont;
|
private final BitmapFont playerFont;
|
||||||
private final Node playerNameNode;
|
private final Node playerNameNode;
|
||||||
private final List<Color> playerOrder;
|
private final List<Color> playerOrder;
|
||||||
private final Map<Color, String> colorNameMap;
|
private final Map<Color, String> colorNameMap;
|
||||||
private final Map<Color, Integer> colorCardMap;
|
|
||||||
|
|
||||||
private final AppSettings appSettings;
|
private final AppSettings appSettings;
|
||||||
private final AssetManager assetManager;
|
private final AssetManager assetManager;
|
||||||
private Color ownColor;
|
private Color ownColor;
|
||||||
@@ -47,7 +43,6 @@ public PlayerNameHandler(Node guiNode, AssetManager assetManager, AppSettings ap
|
|||||||
playerNameNode = new Node("player name node");
|
playerNameNode = new Node("player name node");
|
||||||
playerOrder = new ArrayList<>();
|
playerOrder = new ArrayList<>();
|
||||||
colorNameMap = new HashMap<>();
|
colorNameMap = new HashMap<>();
|
||||||
colorCardMap = new HashMap<>();
|
|
||||||
this.appSettings = appSettings;
|
this.appSettings = appSettings;
|
||||||
this.assetManager = assetManager;
|
this.assetManager = assetManager;
|
||||||
}
|
}
|
||||||
@@ -69,38 +64,13 @@ private void drawPlayers(){
|
|||||||
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");
|
Node nameParent = new Node("nameParent");
|
||||||
|
nameParent.attachChild(createName(colorNameMap.get(color), i == 0, color == ownColor));
|
||||||
nameParent.attachChild(createColor(color));
|
nameParent.attachChild(createColor(color));
|
||||||
BitmapText name = createName(colorNameMap.get(color), i == 0, color == ownColor);
|
|
||||||
nameParent.attachChild(name);
|
|
||||||
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);
|
playerNameNode.attachChild(nameParent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
|
||||||
return hudText;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Picture createHandCard(float width) {
|
|
||||||
Picture pic = new Picture("HUD Picture");
|
|
||||||
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);
|
|
||||||
return pic;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String imagePath(Color color){
|
private String imagePath(Color color){
|
||||||
String root = "./Images/name_pictures/";
|
String root = "./Images/name_pictures/";
|
||||||
return switch(color){
|
return switch(color){
|
||||||
@@ -123,7 +93,7 @@ private Spatial createColor(Color color) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
private BitmapText createName(String name, boolean first, boolean own){
|
private Spatial createName(String name, boolean first, boolean own){
|
||||||
BitmapText hudText = new BitmapText(playerFont);
|
BitmapText hudText = new BitmapText(playerFont);
|
||||||
//renderedSize = 45
|
//renderedSize = 45
|
||||||
hudText.setSize(TEXT_SIZE);
|
hudText.setSize(TEXT_SIZE);
|
||||||
@@ -154,18 +124,5 @@ public String getName(Color color){
|
|||||||
return colorNameMap.get(color);
|
return colorNameMap.get(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addCard(Color color){
|
|
||||||
colorCardMap.put(color, colorCardMap.getOrDefault(color, 0) + 1);
|
|
||||||
drawPlayers();
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
drawPlayers();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,7 @@
|
|||||||
import com.jme3.network.*;
|
import com.jme3.network.*;
|
||||||
import com.jme3.network.serializing.Serializer;
|
import com.jme3.network.serializing.Serializer;
|
||||||
import com.jme3.network.serializing.serializers.EnumSerializer;
|
import com.jme3.network.serializing.serializers.EnumSerializer;
|
||||||
import pp.mdga.Resources;
|
|
||||||
import pp.mdga.game.*;
|
import pp.mdga.game.*;
|
||||||
import pp.mdga.game.card.*;
|
|
||||||
import pp.mdga.message.client.*;
|
import pp.mdga.message.client.*;
|
||||||
import pp.mdga.message.server.*;
|
import pp.mdga.message.server.*;
|
||||||
import pp.mdga.server.ServerGameLogic;
|
import pp.mdga.server.ServerGameLogic;
|
||||||
@@ -125,7 +123,7 @@ private void initializeSerializables() {
|
|||||||
Serializer.registerClass(NoTurnMessage.class);
|
Serializer.registerClass(NoTurnMessage.class);
|
||||||
Serializer.registerClass(PauseGameMessage.class);
|
Serializer.registerClass(PauseGameMessage.class);
|
||||||
Serializer.registerClass(PlayCardMessage.class);
|
Serializer.registerClass(PlayCardMessage.class);
|
||||||
Serializer.registerClass(PossibleCardsMessage.class);
|
Serializer.registerClass(PossibleCardMessage.class);
|
||||||
Serializer.registerClass(PossiblePieceMessage.class);
|
Serializer.registerClass(PossiblePieceMessage.class);
|
||||||
Serializer.registerClass(RankingResponseMessage.class);
|
Serializer.registerClass(RankingResponseMessage.class);
|
||||||
Serializer.registerClass(RankingRollAgainMessage.class);
|
Serializer.registerClass(RankingRollAgainMessage.class);
|
||||||
@@ -137,7 +135,6 @@ private void initializeSerializables() {
|
|||||||
Serializer.registerClass(UpdateReadyMessage.class);
|
Serializer.registerClass(UpdateReadyMessage.class);
|
||||||
Serializer.registerClass(UpdateTSKMessage.class);
|
Serializer.registerClass(UpdateTSKMessage.class);
|
||||||
Serializer.registerClass(WaitPieceMessage.class);
|
Serializer.registerClass(WaitPieceMessage.class);
|
||||||
Serializer.registerClass(IncorrectRequestMessage.class);
|
|
||||||
Serializer.registerClass(Player.class);
|
Serializer.registerClass(Player.class);
|
||||||
Serializer.registerClass(Statistic.class);
|
Serializer.registerClass(Statistic.class);
|
||||||
Serializer.registerClass(Board.class);
|
Serializer.registerClass(Board.class);
|
||||||
@@ -145,17 +142,10 @@ private void initializeSerializables() {
|
|||||||
Serializer.registerClass(Piece.class);
|
Serializer.registerClass(Piece.class);
|
||||||
Serializer.registerClass(BonusNode.class);
|
Serializer.registerClass(BonusNode.class);
|
||||||
Serializer.registerClass(StartNode.class);
|
Serializer.registerClass(StartNode.class);
|
||||||
|
Serializer.registerClass(PlayerData.class);
|
||||||
Serializer.registerClass(HomeNode.class);
|
Serializer.registerClass(HomeNode.class);
|
||||||
Serializer.registerClass(PowerCard.class);
|
Serializer.registerClass(PlayerDataMessage.class);
|
||||||
Serializer.registerClass(TurboCard.class);
|
Serializer.registerClass(StartBriefingMessage.class);
|
||||||
Serializer.registerClass(SwapCard.class);
|
|
||||||
Serializer.registerClass(ShieldCard.class);
|
|
||||||
Serializer.registerClass(HiddenCard.class);
|
|
||||||
|
|
||||||
Serializer.registerClass(Color.class, new EnumSerializer());
|
|
||||||
Serializer.registerClass(PieceState.class, new EnumSerializer());
|
|
||||||
Serializer.registerClass(ShieldState.class, new EnumSerializer());
|
|
||||||
Serializer.registerClass(BonusCard.class, new EnumSerializer());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerListeners() {
|
private void registerListeners() {
|
||||||
@@ -208,31 +198,12 @@ private void messageReceived(HostedConnection source, ClientMessage message) {
|
|||||||
pendingMessages.add(new ReceivedMessage(message, source.getId()));
|
pendingMessages.add(new ReceivedMessage(message, source.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method will be used to handle all connections which are connected to the server.
|
|
||||||
* It will check if the maximum number of connected clients are already reached. If yes it will send a
|
|
||||||
* LobbyDenyMessage to the given hostedConnection parameter and close it, otherwise it will send a
|
|
||||||
* LobbyAcceptMessage to the given hostedConnection parameter. In Addition, if the number of connected clients is
|
|
||||||
* equal to 1 it will set the host of the game to the id of the given hostedConnection parameter.
|
|
||||||
*
|
|
||||||
* @param server as the server which is contains all connections as a Server object.
|
|
||||||
* @param hostedConnection as the connection which is added to the server as a HostedConnection object.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void connectionAdded(Server server, HostedConnection hostedConnection) {
|
public void connectionAdded(Server server, HostedConnection hostedConnection) {
|
||||||
System.out.println("new connection " + hostedConnection); //NON-NLS
|
System.out.println("new connection " + hostedConnection); //NON-NLS
|
||||||
LOGGER.log(Level.DEBUG, "new connection {0}", hostedConnection); //NON-NLS
|
LOGGER.log(Level.DEBUG, "new connection {0}", hostedConnection); //NON-NLS
|
||||||
|
if (this.myServer.getConnections().size() == 1) {
|
||||||
if (this.myServer.getConnections().size() > Resources.MAX_PLAYERS) {
|
this.logic.getGame().setHost(hostedConnection.getId());
|
||||||
this.logic.getServerSender().send(hostedConnection.getId(), new LobbyDenyMessage());
|
|
||||||
hostedConnection.close("");
|
|
||||||
} else {
|
|
||||||
if (hostedConnection.getAddress().contains("127.0.0.1") && this.logic.getGame().getHost() == -1) {
|
|
||||||
this.logic.getGame().setHost(hostedConnection.getId());
|
|
||||||
this.logic.getServerSender().send(hostedConnection.getId(), new LobbyAcceptMessage(hostedConnection.getId()));
|
|
||||||
} else {
|
|
||||||
this.logic.getServerSender().send(hostedConnection.getId(), new LobbyAcceptMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,21 +278,4 @@ public void broadcast(ServerMessage message) {
|
|||||||
public void disconnectClient(int id) {
|
public void disconnectClient(int id) {
|
||||||
this.myServer.getConnection(id).close("");
|
this.myServer.getConnection(id).close("");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method will be used to shut down the server.
|
|
||||||
* It will iterate threw all connections of myServer attribute and check if they are equal to null. If not they will
|
|
||||||
* be closed. After that the myServer attribute will be closed and this program will be exited with the exit code 0.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void shutdown() {
|
|
||||||
for (HostedConnection client : this.myServer.getConnections()) {
|
|
||||||
if (client != null) {
|
|
||||||
client.close("Host closed the server.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.myServer.close();
|
|
||||||
this.exit(0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -206,19 +206,11 @@ public void addCeremonyParticipant(Color color, int pos, String name) {
|
|||||||
ceremonyButtons.add(button);
|
ceremonyButtons.add(button);
|
||||||
|
|
||||||
if(state.equals(SubState.AWARD_CEREMONY)) {
|
if(state.equals(SubState.AWARD_CEREMONY)) {
|
||||||
button.hide();
|
|
||||||
button.show();
|
button.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addStatisticsRow(String name, int v1, int v2, int v3, int v4, int v5, int v6) {
|
public void addStatisticsRow(String name, int v1, int v2, int v3, int v4, int v5, int v6) {
|
||||||
ceremonyDialog.addStatisticsRow(name, v1, v2, v3, v4, v5, v6);
|
ceremonyDialog.addStatisticsRow(name, v1, v2, v3, v4, v5, v6);
|
||||||
|
|
||||||
ceremonyDialog.hide();
|
|
||||||
ceremonyDialog.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void afterGameCleanup() {
|
|
||||||
ceremonyDialog.prepare();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,31 @@
|
|||||||
package pp.mdga.client.view;
|
package pp.mdga.client.view;
|
||||||
|
|
||||||
import com.jme3.post.FilterPostProcessor;
|
import com.jme3.post.FilterPostProcessor;
|
||||||
import com.jme3.scene.Node;
|
import pp.mdga.client.MdgaState;
|
||||||
import pp.mdga.client.acoustic.MdgaSound;
|
import pp.mdga.client.acoustic.MdgaSound;
|
||||||
import pp.mdga.client.board.BoardHandler;
|
import pp.mdga.client.board.BoardHandler;
|
||||||
import pp.mdga.client.board.CameraHandler;
|
import pp.mdga.client.board.CameraHandler;
|
||||||
import pp.mdga.client.MdgaApp;
|
import pp.mdga.client.MdgaApp;
|
||||||
import pp.mdga.client.button.ButtonLeft;
|
import pp.mdga.client.button.ButtonLeft;
|
||||||
import pp.mdga.client.button.ButtonRight;
|
import pp.mdga.client.button.ButtonRight;
|
||||||
import pp.mdga.client.dialog.InterruptDialog;
|
|
||||||
import pp.mdga.client.gui.GuiHandler;
|
import pp.mdga.client.gui.GuiHandler;
|
||||||
|
import pp.mdga.game.BonusCard;
|
||||||
import pp.mdga.game.Color;
|
import pp.mdga.game.Color;
|
||||||
|
import pp.mdga.notification.AcquireCardNotification;
|
||||||
|
import pp.mdga.notification.ActivePlayerNotification;
|
||||||
|
import pp.mdga.notification.DiceNowNotification;
|
||||||
|
import pp.mdga.notification.GameNotification;
|
||||||
|
import pp.mdga.notification.MovePieceNotification;
|
||||||
|
import pp.mdga.notification.PlayerInGameNotification;
|
||||||
|
import pp.mdga.notification.RollDiceNotification;
|
||||||
|
import pp.mdga.notification.SelectableCardsNotification;
|
||||||
|
import pp.mdga.notification.SelectableMoveNotification;
|
||||||
|
import pp.mdga.notification.SelectableSwapNotification;
|
||||||
|
import pp.mdga.notification.ShieldActiveNotification;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class GameView extends MdgaView {
|
public class GameView extends MdgaView {
|
||||||
private BoardHandler boardHandler;
|
private BoardHandler boardHandler;
|
||||||
@@ -20,38 +35,28 @@ public class GameView extends MdgaView {
|
|||||||
private ButtonLeft leaveButton;
|
private ButtonLeft leaveButton;
|
||||||
private ButtonRight confirmButton;
|
private ButtonRight confirmButton;
|
||||||
|
|
||||||
private ButtonRight noPowerButton;
|
|
||||||
|
|
||||||
private Color ownColor = null;
|
private Color ownColor = null;
|
||||||
|
|
||||||
private InterruptDialog interruptDialog;
|
|
||||||
|
|
||||||
private FilterPostProcessor fpp;
|
private FilterPostProcessor fpp;
|
||||||
|
|
||||||
private Node guiHandlerNode = new Node();
|
|
||||||
|
|
||||||
public GameView(MdgaApp app) {
|
public GameView(MdgaApp app) {
|
||||||
super(app);
|
super(app);
|
||||||
|
|
||||||
leaveButton = new ButtonLeft(app, settingsNode, () -> app.getModelSynchronize().leave(), "Spiel verlassen", 1);
|
leaveButton = new ButtonLeft(app, overlayNode, () -> app.getModelSynchronize().leave(), "Spiel verlassen", 1);
|
||||||
|
|
||||||
confirmButton = new ButtonRight(app, guiNode, () -> app.getModelSynchronize().confirm(), "Bestätigen", 1);
|
confirmButton = new ButtonRight(app, guiNode, () -> app.getModelSynchronize().confirm(), "Bestätigen", 1);
|
||||||
|
|
||||||
noPowerButton = new ButtonRight(app, guiNode, () -> app.getModelSynchronize().confirm(), "Verzichten", 1);
|
|
||||||
|
|
||||||
interruptDialog = new InterruptDialog(app, guiNode);
|
|
||||||
|
|
||||||
fpp = new FilterPostProcessor(app.getAssetManager());
|
fpp = new FilterPostProcessor(app.getAssetManager());
|
||||||
this.camera = new CameraHandler(app, fpp);
|
this.camera = new CameraHandler(app, fpp);
|
||||||
this.boardHandler = new BoardHandler(app, rootNode, fpp);
|
this.boardHandler = new BoardHandler(app, rootNode, fpp);
|
||||||
|
|
||||||
guiHandler = new GuiHandler(app, guiHandlerNode);
|
guiHandler = new GuiHandler(app, guiNode);
|
||||||
|
|
||||||
guiNode.attachChild(guiHandlerNode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnter() {
|
public void onEnter() {
|
||||||
|
setOwnColor(Color.AIRFORCE);
|
||||||
camera.init(ownColor);
|
camera.init(ownColor);
|
||||||
boardHandler.init();
|
boardHandler.init();
|
||||||
guiHandler.init(ownColor);
|
guiHandler.init(ownColor);
|
||||||
@@ -59,6 +64,13 @@ public void onEnter() {
|
|||||||
app.getViewPort().addProcessor(fpp);
|
app.getViewPort().addProcessor(fpp);
|
||||||
|
|
||||||
app.getAcousticHandler().playSound(MdgaSound.START);
|
app.getAcousticHandler().playSound(MdgaSound.START);
|
||||||
|
|
||||||
|
// guiHandler.addPlayer(Color.AIRFORCE, "Cedric");
|
||||||
|
// guiHandler.addPlayer(Color.ARMY, "Ben");
|
||||||
|
// guiHandler.addPlayer(Color.CYBER, "Felix");
|
||||||
|
// guiHandler.addPlayer(Color.NAVY, "Daniel");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -69,7 +81,6 @@ public void onLeave() {
|
|||||||
|
|
||||||
|
|
||||||
confirmButton.hide();
|
confirmButton.hide();
|
||||||
noPowerButton.hide();
|
|
||||||
|
|
||||||
app.getViewPort().removeProcessor(fpp);
|
app.getViewPort().removeProcessor(fpp);
|
||||||
}
|
}
|
||||||
@@ -114,45 +125,10 @@ public Color getOwnColor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void needConfirm() {
|
public void needConfirm() {
|
||||||
noPowerButton.hide();
|
|
||||||
confirmButton.show();
|
confirmButton.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void noConfirm() {
|
public void noConfirm() {
|
||||||
confirmButton.hide();
|
confirmButton.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showNoPower() {
|
|
||||||
confirmButton.hide();
|
|
||||||
noPowerButton.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void hideNoPower() {
|
|
||||||
noPowerButton.hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void enterInterrupt(Color color) {
|
|
||||||
enterOverlay(Overlay.INTERRUPT);
|
|
||||||
|
|
||||||
guiNode.detachChild(guiHandlerNode);
|
|
||||||
app.getGuiNode().attachChild(guiNode);
|
|
||||||
|
|
||||||
app.getInputSynchronize().setClickAllowed(false);
|
|
||||||
|
|
||||||
interruptDialog.setColor(color);
|
|
||||||
interruptDialog.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void leaveInterrupt() {
|
|
||||||
leaveOverlay(Overlay.INTERRUPT);
|
|
||||||
|
|
||||||
app.getGuiNode().detachChild(guiNode);
|
|
||||||
guiNode.attachChild(guiHandlerNode);
|
|
||||||
|
|
||||||
app.getInputSynchronize().setClickAllowed(true);
|
|
||||||
|
|
||||||
app.getAcousticHandler().playSound(MdgaSound.START);
|
|
||||||
|
|
||||||
interruptDialog.hide();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
import pp.mdga.client.button.LobbyButton;
|
import pp.mdga.client.button.LobbyButton;
|
||||||
import pp.mdga.client.button.SettingsButton;
|
import pp.mdga.client.button.SettingsButton;
|
||||||
import pp.mdga.game.Color;
|
import pp.mdga.game.Color;
|
||||||
import pp.mdga.message.client.StartGameMessage;
|
|
||||||
import pp.mdga.notification.GameNotification;
|
import pp.mdga.notification.GameNotification;
|
||||||
|
|
||||||
public class LobbyView extends MdgaView {
|
public class LobbyView extends MdgaView {
|
||||||
@@ -26,7 +25,6 @@ public class LobbyView extends MdgaView {
|
|||||||
|
|
||||||
private ButtonLeft leaveButton;
|
private ButtonLeft leaveButton;
|
||||||
private ButtonRight readyButton;
|
private ButtonRight readyButton;
|
||||||
private ButtonRight startButton;
|
|
||||||
|
|
||||||
private LobbyButton cyberButton;
|
private LobbyButton cyberButton;
|
||||||
private LobbyButton airforceButton;
|
private LobbyButton airforceButton;
|
||||||
@@ -44,7 +42,6 @@ public LobbyView(MdgaApp app) {
|
|||||||
|
|
||||||
leaveButton = new ButtonLeft(app, guiNode, this::leaveLobby, "Verlassen", 1);
|
leaveButton = new ButtonLeft(app, guiNode, this::leaveLobby, "Verlassen", 1);
|
||||||
readyButton = new ButtonRight(app, guiNode, this::ready, "Bereit", 1);
|
readyButton = new ButtonRight(app, guiNode, this::ready, "Bereit", 1);
|
||||||
startButton = new ButtonRight(app, guiNode, () -> app.getGameLogic().selectStart(), "Starten", 7);
|
|
||||||
|
|
||||||
cyberButton = new LobbyButton(app, guiNode, rootNode, () -> toggleTsk(Color.CYBER), Color.CYBER);
|
cyberButton = new LobbyButton(app, guiNode, rootNode, () -> toggleTsk(Color.CYBER), Color.CYBER);
|
||||||
airforceButton = new LobbyButton(app, guiNode, rootNode, () -> toggleTsk(Color.AIRFORCE), Color.AIRFORCE);
|
airforceButton = new LobbyButton(app, guiNode, rootNode, () -> toggleTsk(Color.AIRFORCE), Color.AIRFORCE);
|
||||||
@@ -64,10 +61,6 @@ public void onEnter() {
|
|||||||
leaveButton.show();
|
leaveButton.show();
|
||||||
readyButton.show();
|
readyButton.show();
|
||||||
|
|
||||||
if(app.getGameLogic().isHost()) {
|
|
||||||
startButton.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
cyberButton.show();
|
cyberButton.show();
|
||||||
airforceButton.show();
|
airforceButton.show();
|
||||||
armyButton.show();
|
armyButton.show();
|
||||||
@@ -102,7 +95,6 @@ public void onEnter() {
|
|||||||
public void onLeave() {
|
public void onLeave() {
|
||||||
leaveButton.hide();
|
leaveButton.hide();
|
||||||
readyButton.hide();
|
readyButton.hide();
|
||||||
startButton.hide();
|
|
||||||
|
|
||||||
airforceButton.hide();
|
airforceButton.hide();
|
||||||
armyButton.hide();
|
armyButton.hide();
|
||||||
@@ -231,10 +223,6 @@ private void toggleTsk(Color color) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isReady) {
|
|
||||||
setReady(own, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (taken) {
|
switch (taken) {
|
||||||
case NOT:
|
case NOT:
|
||||||
app.getModelSynchronize().selectTsk(color);
|
app.getModelSynchronize().selectTsk(color);
|
||||||
|
|||||||
@@ -7,6 +7,9 @@
|
|||||||
import pp.mdga.client.dialog.JoinDialog;
|
import pp.mdga.client.dialog.JoinDialog;
|
||||||
import pp.mdga.client.dialog.StartDialog;
|
import pp.mdga.client.dialog.StartDialog;
|
||||||
|
|
||||||
|
import java.net.Inet4Address;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
public class MainView extends MdgaView {
|
public class MainView extends MdgaView {
|
||||||
private enum SubState {
|
private enum SubState {
|
||||||
HOST,
|
HOST,
|
||||||
@@ -60,12 +63,12 @@ public void onUpdate(float tpf) {
|
|||||||
@Override
|
@Override
|
||||||
protected void onEnterOverlay(Overlay overlay) {
|
protected void onEnterOverlay(Overlay overlay) {
|
||||||
guiNode.detachChild(background);
|
guiNode.detachChild(background);
|
||||||
settingsNode.attachChild(background);
|
overlayNode.attachChild(background);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onLeaveOverlay(Overlay overlay) {
|
protected void onLeaveOverlay(Overlay overlay) {
|
||||||
settingsNode.detachChild(background);
|
overlayNode.detachChild(background);
|
||||||
guiNode.attachChild(background);
|
guiNode.attachChild(background);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +96,6 @@ private void mainMenu() {
|
|||||||
private void tryHost() {
|
private void tryHost() {
|
||||||
int port = 0;
|
int port = 0;
|
||||||
String text = hostDialog.getPort();
|
String text = hostDialog.getPort();
|
||||||
app.getGameLogic().selectHost("");
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
port = Integer.parseInt(text);
|
port = Integer.parseInt(text);
|
||||||
@@ -106,6 +108,10 @@ private void tryHost() {
|
|||||||
} catch (InterruptedException ignored) {
|
} catch (InterruptedException ignored) {
|
||||||
}
|
}
|
||||||
hostDialog.connectServerAsClient();
|
hostDialog.connectServerAsClient();
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (InterruptedException ignored) {
|
||||||
|
}
|
||||||
app.getModelSynchronize().setHost(port);
|
app.getModelSynchronize().setHost(port);
|
||||||
//app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT);
|
//app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT);
|
||||||
return;
|
return;
|
||||||
@@ -121,7 +127,6 @@ private void tryJoin() {
|
|||||||
int port = 0;
|
int port = 0;
|
||||||
String ip = joinDialog.getIpt();
|
String ip = joinDialog.getIpt();
|
||||||
String portText = joinDialog.getPort();
|
String portText = joinDialog.getPort();
|
||||||
app.getGameLogic().selectJoin("");
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Validate the port
|
// Validate the port
|
||||||
@@ -135,6 +140,11 @@ private void tryJoin() {
|
|||||||
app.getModelSynchronize().setName(startDialog.getName());
|
app.getModelSynchronize().setName(startDialog.getName());
|
||||||
joinDialog.setHostname(ip);
|
joinDialog.setHostname(ip);
|
||||||
joinDialog.connectToServer();
|
joinDialog.connectToServer();
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (InterruptedException ignored) {
|
||||||
|
}
|
||||||
|
app.getModelSynchronize().setJoin(ip, port);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
@@ -224,13 +234,5 @@ public void back() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public JoinDialog getJoinDialog() {
|
|
||||||
return joinDialog;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HostDialog getHostDialog() {
|
|
||||||
return hostDialog;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,9 @@
|
|||||||
|
|
||||||
import com.jme3.asset.TextureKey;
|
import com.jme3.asset.TextureKey;
|
||||||
import com.jme3.material.Material;
|
import com.jme3.material.Material;
|
||||||
import com.jme3.math.ColorRGBA;
|
|
||||||
import com.jme3.math.Vector2f;
|
|
||||||
import com.jme3.scene.Geometry;
|
import com.jme3.scene.Geometry;
|
||||||
import com.jme3.scene.Node;
|
import com.jme3.scene.Node;
|
||||||
import com.jme3.scene.shape.Quad;
|
import com.jme3.scene.shape.Quad;
|
||||||
import com.jme3.system.NanoTimer;
|
|
||||||
import com.jme3.texture.Texture;
|
import com.jme3.texture.Texture;
|
||||||
import pp.mdga.client.MdgaApp;
|
import pp.mdga.client.MdgaApp;
|
||||||
import pp.mdga.client.acoustic.MdgaSound;
|
import pp.mdga.client.acoustic.MdgaSound;
|
||||||
@@ -25,7 +22,7 @@ public enum Overlay {
|
|||||||
protected MdgaApp app;
|
protected MdgaApp app;
|
||||||
protected Node rootNode = new Node("View Root");
|
protected Node rootNode = new Node("View Root");
|
||||||
protected Node guiNode = new Node("View Root GUI");
|
protected Node guiNode = new Node("View Root GUI");
|
||||||
protected Node settingsNode = new Node("View Root Overlay");
|
protected Node overlayNode = new Node("View Root Overlay");
|
||||||
|
|
||||||
private SettingsButton settingsButton;
|
private SettingsButton settingsButton;
|
||||||
|
|
||||||
@@ -33,18 +30,15 @@ public enum Overlay {
|
|||||||
private VideoSettingsDialog videoSettingsDialog;
|
private VideoSettingsDialog videoSettingsDialog;
|
||||||
private AudioSettingsDialog audioSettingsDialog;
|
private AudioSettingsDialog audioSettingsDialog;
|
||||||
|
|
||||||
protected LabelButton infoLabel = null;
|
|
||||||
protected NanoTimer infoTimer = new NanoTimer();
|
|
||||||
|
|
||||||
private int settingsDepth = 0;
|
private int settingsDepth = 0;
|
||||||
|
|
||||||
public MdgaView(MdgaApp app) {
|
public MdgaView(MdgaApp app) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
settingsButton = new SettingsButton(app, guiNode, this::enterSettings);
|
settingsButton = new SettingsButton(app, guiNode, this::enterSettings);
|
||||||
|
|
||||||
settingsDialog = new SettingsDialog(app, settingsNode, this);
|
settingsDialog = new SettingsDialog(app, overlayNode, this);
|
||||||
videoSettingsDialog = new VideoSettingsDialog(app, settingsNode, this);
|
videoSettingsDialog = new VideoSettingsDialog(app, overlayNode, this);
|
||||||
audioSettingsDialog = new AudioSettingsDialog(app, settingsNode, this);
|
audioSettingsDialog = new AudioSettingsDialog(app, overlayNode, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enter() {
|
public void enter() {
|
||||||
@@ -86,11 +80,6 @@ public void update(float tpf) {
|
|||||||
videoSettingsDialog.update();
|
videoSettingsDialog.update();
|
||||||
audioSettingsDialog.update();
|
audioSettingsDialog.update();
|
||||||
|
|
||||||
if (null != infoLabel && infoTimer.getTimeInSeconds() > 5) {
|
|
||||||
infoLabel.hide();
|
|
||||||
infoLabel = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
onUpdate(tpf);
|
onUpdate(tpf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,7 +113,7 @@ protected Geometry createBackground(String texturePath) {
|
|||||||
public void enterSettings() {
|
public void enterSettings() {
|
||||||
enterOverlay(Overlay.SETTINGS);
|
enterOverlay(Overlay.SETTINGS);
|
||||||
|
|
||||||
app.getGuiNode().attachChild(settingsNode);
|
app.getGuiNode().attachChild(overlayNode);
|
||||||
|
|
||||||
settingsDialog.show();
|
settingsDialog.show();
|
||||||
|
|
||||||
@@ -134,7 +123,7 @@ public void enterSettings() {
|
|||||||
public void leaveSettings() {
|
public void leaveSettings() {
|
||||||
leaveOverlay(Overlay.SETTINGS);
|
leaveOverlay(Overlay.SETTINGS);
|
||||||
|
|
||||||
app.getGuiNode().detachChild(settingsNode);
|
app.getGuiNode().detachChild(overlayNode);
|
||||||
|
|
||||||
settingsDialog.hide();
|
settingsDialog.hide();
|
||||||
|
|
||||||
@@ -204,24 +193,4 @@ public void pressForward() {
|
|||||||
ceremonyView.forward();
|
ceremonyView.forward();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showInfo(String error, boolean isError) {
|
|
||||||
infoTimer.reset();
|
|
||||||
|
|
||||||
if(null != infoLabel) {
|
|
||||||
infoLabel.hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
infoLabel = new LabelButton(app, guiNode, error, new Vector2f(5.5f, 2), new Vector2f(0.5f, AbstractButton.VERTICAL - 0.5f), false);
|
|
||||||
|
|
||||||
ColorRGBA color;
|
|
||||||
|
|
||||||
if(isError) {
|
|
||||||
color = ColorRGBA.Red.clone();
|
|
||||||
} else {
|
|
||||||
color = ColorRGBA.Green.clone();
|
|
||||||
}
|
|
||||||
|
|
||||||
infoLabel.setColor(ColorRGBA.Black, color);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
Projekte/mdga/client/src/main/resources/Images/b1.png
Normal file
|
After Width: | Height: | Size: 216 KiB |
BIN
Projekte/mdga/client/src/main/resources/Images/b2.png
Normal file
|
After Width: | Height: | Size: 274 KiB |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 46 KiB |
|
Before Width: | Height: | Size: 140 B |
|
Before Width: | Height: | Size: 6.2 KiB |
|
Before Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 18 KiB |
@@ -1,7 +1,7 @@
|
|||||||
world 0,0 90
|
world 0,0 90
|
||||||
treesBigBackground 0,0 90
|
|
||||||
treesSmallBackground 0,0 90
|
|
||||||
|
|
||||||
|
#tree_small 1,1 0
|
||||||
|
#tree_big 0,0 0
|
||||||
|
|
||||||
#Marine Pos
|
#Marine Pos
|
||||||
marine 4,-5 270
|
marine 4,-5 270
|
||||||
@@ -58,8 +58,7 @@ big_tent -10,-9 130
|
|||||||
big_tent 9,-10 225
|
big_tent 9,-10 225
|
||||||
radar 0,10 -20
|
radar 0,10 -20
|
||||||
tank -1,-10 135
|
tank -1,-10 135
|
||||||
#tank 0,-18 180
|
tank 0,-18 180
|
||||||
tank_shoot 0,-18 180
|
|
||||||
tank 3,-18 180
|
tank 3,-18 180
|
||||||
tank -3,-18 180
|
tank -3,-18 180
|
||||||
|
|
||||||
@@ -132,145 +131,3 @@ node_home_blue 4,0 0
|
|||||||
node_home_blue 3,0 0
|
node_home_blue 3,0 0
|
||||||
node_home_blue 2,0 0
|
node_home_blue 2,0 0
|
||||||
node_home_blue 1,0 0
|
node_home_blue 1,0 0
|
||||||
|
|
||||||
# Randomly Distributed Trees within Radius 12 to 40
|
|
||||||
|
|
||||||
treeSmall 10,15 180
|
|
||||||
treeBig -15,12 45
|
|
||||||
treeSmall -8,-22 270
|
|
||||||
treeBig 22,8 90
|
|
||||||
treeSmall -18,-10 135
|
|
||||||
treeBig 9,24 300
|
|
||||||
treeSmall 17,-9 60
|
|
||||||
treeBig -20,5 330
|
|
||||||
treeSmall -14,18 200
|
|
||||||
treeBig 25,-7 120
|
|
||||||
treeBig -12,-18 150
|
|
||||||
treeSmall 19,-16 45
|
|
||||||
treeBig 7,10 90
|
|
||||||
treeBig -19,-9 270
|
|
||||||
treeSmall 21,4 110
|
|
||||||
treeBig -11,17 300
|
|
||||||
treeSmall 3,-21 360
|
|
||||||
treeSmall -23,14 100
|
|
||||||
treeBig 4,26 330
|
|
||||||
treeSmall 12,13 270
|
|
||||||
treeBig -18,8 45
|
|
||||||
treeBig 11,-10 135
|
|
||||||
treeSmall 16,5 180
|
|
||||||
treeBig -13,-17 330
|
|
||||||
treeSmall -2,14 270
|
|
||||||
#treeBig 7,9 300
|
|
||||||
treeSmall 23,-10 240
|
|
||||||
treeBig -6,18 180
|
|
||||||
treeSmall 5,27 270
|
|
||||||
treeBig 14,-11 60
|
|
||||||
treeSmall 9,-16 180
|
|
||||||
treeBig -12,22 240
|
|
||||||
treeBig 18,7 360
|
|
||||||
treeSmall -24,-4 200
|
|
||||||
treeBig -8,21 300
|
|
||||||
treeSmall 12,-19 120
|
|
||||||
treeBig 6,-12 180
|
|
||||||
treeSmall -11,10 75
|
|
||||||
treeBig 9,6 270
|
|
||||||
treeSmall 8,-14 150
|
|
||||||
treeBig 3,18 30
|
|
||||||
treeSmall 17,13 100
|
|
||||||
treeBig -9,20 90
|
|
||||||
treeBig 6,-22 330
|
|
||||||
treeSmall -20,7 45
|
|
||||||
treeBig 21,11 150
|
|
||||||
treeSmall 15,-18 270
|
|
||||||
treeBig -3,-12 200
|
|
||||||
treeBig 12,-28 330
|
|
||||||
treeSmall -17,-7 120
|
|
||||||
treeBig -10,9 300
|
|
||||||
treeSmall 2,-14 240
|
|
||||||
treeBig 24,2 360
|
|
||||||
treeSmall 4,-13 300
|
|
||||||
treeBig -19,20 90
|
|
||||||
#treeSmall -11,5 45
|
|
||||||
treeBig 15,9 180
|
|
||||||
treeSmall -6,10 240
|
|
||||||
treeBig 3,15 30
|
|
||||||
treeSmall 9,-19 150
|
|
||||||
treeBig -21,-4 330
|
|
||||||
treeSmall 19,11 270
|
|
||||||
treeSmall 12,24 110
|
|
||||||
treeBig -13,15 45
|
|
||||||
treeSmall 7,-15 240
|
|
||||||
treeBig 26,-8 300
|
|
||||||
treeSmall -16,14 120
|
|
||||||
treeBig 14,18 360
|
|
||||||
treeSmall 8,21 100
|
|
||||||
treeBig -8,-18 240
|
|
||||||
treeSmall 9,15 180
|
|
||||||
treeBig 10,-20 270
|
|
||||||
treeSmall 2,27 90
|
|
||||||
treeBig 18,12 300
|
|
||||||
treeSmall -10,-14 150
|
|
||||||
treeBig -15,16 330
|
|
||||||
treeSmall -9,19 45
|
|
||||||
treeBig 17,-14 120
|
|
||||||
treeSmall 5,-25 180
|
|
||||||
treeBig 7,23 30
|
|
||||||
treeSmall -14,-12 200
|
|
||||||
treeBig 6,-16 300
|
|
||||||
treeSmall -20,-8 100
|
|
||||||
treeBig 4,11 240
|
|
||||||
treeSmall 24,-15 90
|
|
||||||
treeSmall -19,-19 360
|
|
||||||
treeBig 20,8 45
|
|
||||||
treeSmall 3,22 270
|
|
||||||
treeBig 13,-9 180
|
|
||||||
treeSmall -11,18 150
|
|
||||||
treeBig -17,-4 300
|
|
||||||
treeSmall 5,-14 240
|
|
||||||
treeBig 9,17 330
|
|
||||||
treeSmall 15,13 90
|
|
||||||
treeBig -21,18 30
|
|
||||||
treeSmall 6,20 100
|
|
||||||
treeBig -16,22 180
|
|
||||||
treeSmall -5,18 360
|
|
||||||
treeBig 22,11 45
|
|
||||||
treeSmall 10,-23 240
|
|
||||||
treeBig -10,-16 300
|
|
||||||
treeSmall -17,14 120
|
|
||||||
treeBig 20,4 150
|
|
||||||
treeSmall 11,-22 180
|
|
||||||
treeBig -24,-11 200
|
|
||||||
treeSmall 14,17 150
|
|
||||||
treeBig -8,-12 300
|
|
||||||
treeSmall 7,-18 100
|
|
||||||
treeBig -5,16 330
|
|
||||||
treeSmall 16,-14 200
|
|
||||||
treeBig 18,-8 90
|
|
||||||
treeSmall -23,-9 45
|
|
||||||
treeBig 24,10 300
|
|
||||||
treeSmall -4,19 180
|
|
||||||
treeBig 12,-5 330
|
|
||||||
treeSmall -19,16 100
|
|
||||||
treeBig 14,20 150
|
|
||||||
treeSmall 9,12 180
|
|
||||||
treeBig -22,8 60
|
|
||||||
treeSmall 6,18 360
|
|
||||||
treeBig 25,-9 45
|
|
||||||
treeBig -10,12 240
|
|
||||||
treeSmall 19,-17 100
|
|
||||||
treeSmall -13,19 90
|
|
||||||
treeSmall 16,-12 120
|
|
||||||
treeBig 22,-6 45
|
|
||||||
treeSmall -18,15 200
|
|
||||||
treeBig 14,-10 300
|
|
||||||
treeBig 6,10 330
|
|
||||||
treeSmall 17,18 90
|
|
||||||
treeBig -20,4 180
|
|
||||||
treeBig 19,-16 300
|
|
||||||
treeSmall -15,9 270
|
|
||||||
treeBig 12,22 360
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
// Samplers for textures
|
// Samplers for textures
|
||||||
uniform sampler2D m_Texture;
|
uniform sampler2D m_Texture;
|
||||||
uniform sampler2D m_OutlineDepthTexture;
|
uniform sampler2D m_OutlineDepthTexture;
|
||||||
|
uniform sampler2D m_DepthTexture;
|
||||||
|
|
||||||
// Input texture coordinates from the vertex shader
|
// Input texture coordinates from the vertex shader
|
||||||
in vec2 texCoord;
|
in vec2 texCoord;
|
||||||
@@ -14,25 +15,26 @@ uniform float m_OutlineWidth;
|
|||||||
out vec4 fragColor;
|
out vec4 fragColor;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
// Sample depth textures at various offsets
|
// Sample depth textures
|
||||||
vec4 depth = texture(m_OutlineDepthTexture, texCoord);
|
vec4 depth = texture(m_OutlineDepthTexture, texCoord);
|
||||||
vec4 depth1 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(m_OutlineWidth, m_OutlineWidth)) / m_Resolution);
|
vec4 depth1 = texture(m_OutlineDepthTexture, ((texCoord * m_Resolution) + vec2(m_OutlineWidth, m_OutlineWidth)) / m_Resolution);
|
||||||
vec4 depth2 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(m_OutlineWidth, -m_OutlineWidth)) / m_Resolution);
|
vec4 depth2 = texture(m_OutlineDepthTexture, ((texCoord * m_Resolution) + vec2(m_OutlineWidth, -m_OutlineWidth)) / m_Resolution);
|
||||||
vec4 depth3 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(-m_OutlineWidth, m_OutlineWidth)) / m_Resolution);
|
vec4 depth3 = texture(m_OutlineDepthTexture, ((texCoord * m_Resolution) + vec2(-m_OutlineWidth, m_OutlineWidth)) / m_Resolution);
|
||||||
vec4 depth4 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(-m_OutlineWidth, -m_OutlineWidth)) / m_Resolution);
|
vec4 depth4 = texture(m_OutlineDepthTexture, ((texCoord * m_Resolution) + vec2(-m_OutlineWidth, -m_OutlineWidth)) / m_Resolution);
|
||||||
vec4 depth5 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(0.0, m_OutlineWidth)) / m_Resolution);
|
vec4 depth5 = texture(m_OutlineDepthTexture, ((texCoord * m_Resolution) + vec2(0.0, m_OutlineWidth)) / m_Resolution);
|
||||||
vec4 depth6 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(0.0, -m_OutlineWidth)) / m_Resolution);
|
vec4 depth6 = texture(m_OutlineDepthTexture, ((texCoord * m_Resolution) + vec2(0.0, -m_OutlineWidth)) / m_Resolution);
|
||||||
vec4 depth7 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(m_OutlineWidth, 0.0)) / m_Resolution);
|
vec4 depth7 = texture(m_OutlineDepthTexture, ((texCoord * m_Resolution) + vec2(m_OutlineWidth, 0.0)) / m_Resolution);
|
||||||
vec4 depth8 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(-m_OutlineWidth, 0.0)) / m_Resolution);
|
vec4 depth8 = texture(m_OutlineDepthTexture, ((texCoord * m_Resolution) + vec2(-m_OutlineWidth, 0.0)) / m_Resolution);
|
||||||
|
|
||||||
// Sample the main texture
|
// Sample the main texture
|
||||||
vec4 color = texture(m_Texture, texCoord);
|
vec4 color = texture(m_Texture, texCoord);
|
||||||
|
|
||||||
// Check if an outline should be applied
|
// Determine whether to apply the outline color
|
||||||
bool isEdge = (depth == vec4(0.0)) &&
|
if (depth == vec4(0.0) &&
|
||||||
(depth1 != depth || depth2 != depth || depth3 != depth || depth4 != depth ||
|
(depth1 != depth || depth2 != depth || depth3 != depth || depth4 != depth ||
|
||||||
depth5 != depth || depth6 != depth || depth7 != depth || depth8 != depth);
|
depth5 != depth || depth6 != depth || depth7 != depth || depth8 != depth)) {
|
||||||
|
fragColor = m_OutlineColor; // Apply outline color
|
||||||
// Output the final color
|
} else {
|
||||||
fragColor = isEdge ? m_OutlineColor : color;
|
fragColor = color; // Use the original texture color
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
// Input texture coordinates from the vertex shader
|
|
||||||
|
// Use 'in' instead of 'varying' for inputs from the vertex shader
|
||||||
in vec2 texCoord;
|
in vec2 texCoord;
|
||||||
|
|
||||||
// Output variable for the fragment color
|
// Declare a custom output variable for the fragment color
|
||||||
out vec4 fragColor;
|
out vec4 fragColor;
|
||||||
|
|
||||||
// Uniform samplers for textures
|
// Uniform samplers
|
||||||
uniform sampler2D m_Texture;
|
uniform sampler2D m_Texture;
|
||||||
uniform sampler2D m_NormalsTexture;
|
uniform sampler2D m_NormalsTexture;
|
||||||
uniform sampler2D m_DepthTexture;
|
uniform sampler2D m_DepthTexture;
|
||||||
@@ -12,7 +13,6 @@ uniform sampler2D m_DepthTexture;
|
|||||||
void main() {
|
void main() {
|
||||||
// Sample the texture at the given texture coordinates
|
// Sample the texture at the given texture coordinates
|
||||||
vec4 color = texture(m_Texture, texCoord);
|
vec4 color = texture(m_Texture, texCoord);
|
||||||
|
|
||||||
// Assign the color to the output variable
|
// Assign the color to the output variable
|
||||||
fragColor = color;
|
fragColor = color;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,78 +1,109 @@
|
|||||||
// Uniform samplers
|
|
||||||
uniform sampler2D m_Texture;
|
uniform sampler2D m_Texture;
|
||||||
uniform sampler2D m_OutlineDepthTexture;
|
uniform sampler2D m_OutlineDepthTexture;
|
||||||
uniform sampler2D m_DepthTexture;
|
uniform sampler2D m_DepthTexture;
|
||||||
|
varying vec2 texCoord;
|
||||||
|
|
||||||
// Input texture coordinates from the vertex shader
|
|
||||||
in vec2 texCoord;
|
|
||||||
|
|
||||||
// Uniforms for resolution, outline color, and width
|
|
||||||
uniform vec2 m_Resolution;
|
uniform vec2 m_Resolution;
|
||||||
uniform vec4 m_OutlineColor;
|
uniform vec4 m_OutlineColor;
|
||||||
uniform float m_OutlineWidth;
|
uniform float m_OutlineWidth;
|
||||||
|
|
||||||
// Output variable for fragment color
|
|
||||||
out vec4 fragColor;
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
vec4 depth = texture(m_OutlineDepthTexture, texCoord);
|
vec4 depth = texture2D(m_OutlineDepthTexture, texCoord);
|
||||||
vec4 depth1 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(m_OutlineWidth, m_OutlineWidth)) / m_Resolution);
|
vec4 depth1 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(m_OutlineWidth,m_OutlineWidth))/m_Resolution);
|
||||||
vec4 depth2 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(m_OutlineWidth, -m_OutlineWidth)) / m_Resolution);
|
vec4 depth2 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(m_OutlineWidth,-m_OutlineWidth))/m_Resolution);
|
||||||
vec4 depth3 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(-m_OutlineWidth, m_OutlineWidth)) / m_Resolution);
|
vec4 depth3 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(-m_OutlineWidth,m_OutlineWidth))/m_Resolution);
|
||||||
vec4 depth4 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(-m_OutlineWidth, -m_OutlineWidth)) / m_Resolution);
|
vec4 depth4 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(-m_OutlineWidth,-m_OutlineWidth))/m_Resolution);
|
||||||
vec4 depth5 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(0.0, m_OutlineWidth)) / m_Resolution);
|
vec4 depth5 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(0.,m_OutlineWidth))/m_Resolution);
|
||||||
vec4 depth6 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(0.0, -m_OutlineWidth)) / m_Resolution);
|
vec4 depth6 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(0.,-m_OutlineWidth))/m_Resolution);
|
||||||
vec4 depth7 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(m_OutlineWidth, 0.0)) / m_Resolution);
|
vec4 depth7 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(m_OutlineWidth,0.))/m_Resolution);
|
||||||
vec4 depth8 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(-m_OutlineWidth, 0.0)) / m_Resolution);
|
vec4 depth8 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(-m_OutlineWidth,0.))/m_Resolution);
|
||||||
|
vec4 color = texture2D(m_Texture, texCoord);
|
||||||
vec4 color = texture(m_Texture, texCoord);
|
//如果是背景
|
||||||
|
float ratio=0.;
|
||||||
float ratio = 0.0;
|
if(depth==vec4(0.) && (depth1 != depth || depth2 != depth || depth3 != depth || depth4 != depth||depth5 != depth || depth6 != depth || depth7 != depth || depth8 != depth)){
|
||||||
if (depth == vec4(0.0) &&
|
float dist=m_OutlineWidth;
|
||||||
(depth1 != depth || depth2 != depth || depth3 != depth || depth4 != depth ||
|
//距离边的像素
|
||||||
depth5 != depth || depth6 != depth || depth7 != depth || depth8 != depth)) {
|
vec4 nearDepth;
|
||||||
float dist = m_OutlineWidth;
|
if(depth1 != depth){
|
||||||
vec4 nearDepth;
|
for(float i=0.;i<m_OutlineWidth;i++){
|
||||||
|
nearDepth = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(i,i))/m_Resolution);
|
||||||
// Iterate to find the distance to the nearest edge
|
if(nearDepth != depth){
|
||||||
for (float i = 0.0; i < m_OutlineWidth; i++) {
|
dist = i;
|
||||||
if (depth1 != depth) {
|
break;
|
||||||
nearDepth = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(i, i)) / m_Resolution);
|
}
|
||||||
if (nearDepth != depth) { dist = i; break; }
|
}
|
||||||
} else if (depth2 != depth) {
|
}else
|
||||||
nearDepth = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(i, -i)) / m_Resolution);
|
if(depth2 != depth){
|
||||||
if (nearDepth != depth) { dist = i; break; }
|
for(float i=0.;i<m_OutlineWidth;i++){
|
||||||
} else if (depth3 != depth) {
|
nearDepth = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(i,-i))/m_Resolution);
|
||||||
nearDepth = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(-i, i)) / m_Resolution);
|
if(nearDepth != depth){
|
||||||
if (nearDepth != depth) { dist = i; break; }
|
dist = i;
|
||||||
} else if (depth4 != depth) {
|
break;
|
||||||
nearDepth = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(-i, -i)) / m_Resolution);
|
}
|
||||||
if (nearDepth != depth) { dist = i; break; }
|
}
|
||||||
} else if (depth5 != depth) {
|
}else
|
||||||
nearDepth = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(0.0, i)) / m_Resolution);
|
if(depth3 != depth){
|
||||||
if (nearDepth != depth) { dist = i; break; }
|
for(float i=0.;i<m_OutlineWidth;i++){
|
||||||
} else if (depth6 != depth) {
|
nearDepth = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(-i,i))/m_Resolution);
|
||||||
nearDepth = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(0.0, -i)) / m_Resolution);
|
if(nearDepth != depth){
|
||||||
if (nearDepth != depth) { dist = i; break; }
|
dist = i;
|
||||||
} else if (depth7 != depth) {
|
break;
|
||||||
nearDepth = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(i, 0.0)) / m_Resolution);
|
}
|
||||||
if (nearDepth != depth) { dist = i; break; }
|
}
|
||||||
} else if (depth8 != depth) {
|
}else
|
||||||
nearDepth = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(-i, 0.0)) / m_Resolution);
|
if(depth4 != depth){
|
||||||
if (nearDepth != depth) { dist = i; break; }
|
for(float i=0.;i<m_OutlineWidth;i++){
|
||||||
}
|
nearDepth = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(-i,-i))/m_Resolution);
|
||||||
}
|
if(nearDepth != depth){
|
||||||
|
dist = i;
|
||||||
// Calculate ratio for outline blending
|
break;
|
||||||
ratio = clamp(1.0 - dist / m_OutlineWidth, 0.0, 1.0);
|
}
|
||||||
|
}
|
||||||
// Blend the outline color with the base color
|
}else
|
||||||
fragColor = color * (1.0 - ratio) + m_OutlineColor * ratio;
|
if(depth5 != depth){
|
||||||
} else {
|
for(float i=0.;i<m_OutlineWidth;i++){
|
||||||
// No outline, use the base texture color
|
nearDepth = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(0.,i))/m_Resolution);
|
||||||
fragColor = color;
|
if(nearDepth != depth){
|
||||||
}
|
dist = i;
|
||||||
|
break;
|
||||||
// Optional: Debugging outline visualization
|
}
|
||||||
// fragColor = vec4(0.0, 1.0 - ratio, 0.0, 1.0);
|
}
|
||||||
|
}else
|
||||||
|
if(depth6 != depth){
|
||||||
|
for(float i=0.;i<m_OutlineWidth;i++){
|
||||||
|
nearDepth = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(0.,-i))/m_Resolution);
|
||||||
|
if(nearDepth != depth){
|
||||||
|
dist = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else
|
||||||
|
if(depth7 != depth){
|
||||||
|
for(float i=0.;i<m_OutlineWidth;i++){
|
||||||
|
nearDepth = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(i,0.))/m_Resolution);
|
||||||
|
if(nearDepth != depth){
|
||||||
|
dist = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else
|
||||||
|
if(depth8 != depth){
|
||||||
|
for(float i=0.;i<m_OutlineWidth;i++){
|
||||||
|
nearDepth = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(-i,0.))/m_Resolution);
|
||||||
|
if(nearDepth != depth){
|
||||||
|
dist = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//0:场景颜色 1:outline颜色
|
||||||
|
ratio = clamp(1.- dist/m_OutlineWidth,0.,1.);
|
||||||
|
//float off = (1.-ratio*ratio)*(1.-ratio*ratio);
|
||||||
|
gl_FragColor = color*(1.-ratio) +m_OutlineColor*ratio;
|
||||||
|
//gl_FragColor = m_OutlineColor;
|
||||||
|
}else{
|
||||||
|
gl_FragColor = color;
|
||||||
|
}
|
||||||
|
//debug
|
||||||
|
//gl_FragColor = vec4(0.,(1.-ratio),0.,1.);
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
// Vertex attributes
|
// Use 'in' for vertex attributes
|
||||||
in vec4 inPosition;
|
in vec4 inPosition;
|
||||||
in vec2 inTexCoord;
|
in vec2 inTexCoord;
|
||||||
|
|
||||||
// Output to fragment shader
|
// Use 'out' for passing data to the fragment shader
|
||||||
out vec2 texCoord;
|
out vec2 texCoord;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
# Blender MTL File: 'untitled.blend'
|
|
||||||
# Material Count: 3
|
|
||||||
|
|
||||||
newmtl Material.001
|
|
||||||
Ns 96.078431
|
|
||||||
Ka 0.000000 0.000000 0.000000
|
|
||||||
Kd 0.640000 0.640000 0.640000
|
|
||||||
Ks 0.500000 0.500000 0.500000
|
|
||||||
Ni 1.000000
|
|
||||||
d 1.000000
|
|
||||||
illum 2
|
|
||||||
map_Kd untiffftled.jpg
|
|
||||||
|
|
||||||
newmtl Material.002
|
|
||||||
Ns 96.078431
|
|
||||||
Ka 0.000000 0.000000 0.000000
|
|
||||||
Kd 0.640000 0.640000 0.640000
|
|
||||||
Ks 0.500000 0.500000 0.500000
|
|
||||||
Ni 1.000000
|
|
||||||
d 1.000000
|
|
||||||
illum 2
|
|
||||||
map_Kd untiffftled.jpg
|
|
||||||
|
|
||||||
newmtl Material.004
|
|
||||||
Ns 96.078431
|
|
||||||
Ka 0.000000 0.000000 0.000000
|
|
||||||
Kd 0.640000 0.640000 0.640000
|
|
||||||
Ks 0.500000 0.500000 0.500000
|
|
||||||
Ni 1.000000
|
|
||||||
d 1.000000
|
|
||||||
illum 2
|
|
||||||
map_Kd untiffftled.jpg
|
|
||||||
|
Before Width: | Height: | Size: 42 KiB |
@@ -1,554 +0,0 @@
|
|||||||
# Blender 3.6.5
|
|
||||||
# www.blender.org
|
|
||||||
o tank_top
|
|
||||||
v 0.136104 -4.382030 2.447842
|
|
||||||
v 0.136104 -4.313100 2.681757
|
|
||||||
v -0.107755 -4.382030 2.447842
|
|
||||||
v -0.107755 -4.313100 2.681757
|
|
||||||
v 0.136104 -5.171963 2.680617
|
|
||||||
v 0.136104 -5.103033 2.914532
|
|
||||||
v -0.107755 -5.171963 2.680617
|
|
||||||
v -0.107755 -5.103033 2.914532
|
|
||||||
v 0.104217 -1.266581 1.563035
|
|
||||||
v 0.104217 -1.215678 1.735777
|
|
||||||
v -0.075869 -1.266581 1.563035
|
|
||||||
v -0.075869 -1.215678 1.735777
|
|
||||||
v 0.104218 -5.321341 2.757877
|
|
||||||
v 0.104218 -5.270438 2.930620
|
|
||||||
v -0.075868 -5.321341 2.757877
|
|
||||||
v -0.075868 -5.270438 2.930620
|
|
||||||
v 0.170290 -1.697908 1.621255
|
|
||||||
v 0.170290 -1.609653 1.920754
|
|
||||||
v -0.141942 -1.697908 1.621255
|
|
||||||
v -0.141942 -1.609653 1.920754
|
|
||||||
v 0.229706 -1.077489 1.376490
|
|
||||||
v 0.229706 -0.955645 1.789975
|
|
||||||
v -0.201358 -1.077489 1.376490
|
|
||||||
v -0.201358 -0.955645 1.789975
|
|
||||||
v 0.514900 0.276165 1.806222
|
|
||||||
v 0.514900 0.588869 2.433130
|
|
||||||
v -0.442998 0.276164 1.806222
|
|
||||||
v -0.442998 0.588869 2.433130
|
|
||||||
v 0.514900 0.342851 1.772958
|
|
||||||
v 0.514900 0.655556 2.399867
|
|
||||||
v -0.442998 0.342851 1.772958
|
|
||||||
v -0.442998 0.655556 2.399867
|
|
||||||
v -0.571633 -0.809063 1.704162
|
|
||||||
v -0.571633 -0.809063 2.393599
|
|
||||||
v -0.723737 -0.809063 1.704162
|
|
||||||
v -0.723737 -0.809063 2.393599
|
|
||||||
v -0.571633 -0.656959 1.704161
|
|
||||||
v -0.571633 -0.656959 2.393600
|
|
||||||
v -0.723737 -0.656959 1.704161
|
|
||||||
v -0.723737 -0.656959 2.393600
|
|
||||||
v -0.950927 -0.897974 2.389141
|
|
||||||
v -0.950927 -0.803313 2.389141
|
|
||||||
v -0.861627 -0.897974 2.604730
|
|
||||||
v -0.861627 -0.803313 2.604730
|
|
||||||
v -0.646038 -0.897974 2.694029
|
|
||||||
v -0.646038 -0.803313 2.694029
|
|
||||||
v -0.430449 -0.897974 2.604729
|
|
||||||
v -0.430449 -0.803313 2.604730
|
|
||||||
v -0.341149 -0.897974 2.389141
|
|
||||||
v -0.341149 -0.803313 2.389141
|
|
||||||
v -0.430449 -0.897974 2.173552
|
|
||||||
v -0.430449 -0.803313 2.173552
|
|
||||||
v -0.646038 -0.897974 2.084251
|
|
||||||
v -0.646038 -0.803313 2.084251
|
|
||||||
v -0.861627 -0.897974 2.173552
|
|
||||||
v -0.861627 -0.803313 2.173552
|
|
||||||
v -0.799948 -0.357073 2.051851
|
|
||||||
v -0.784767 0.368207 2.051851
|
|
||||||
v -0.423762 0.888095 2.051851
|
|
||||||
v 0.525389 0.907164 2.051851
|
|
||||||
v 0.864924 0.401350 2.051851
|
|
||||||
v 0.849742 -0.323930 2.051851
|
|
||||||
v 0.387428 -1.063397 2.051851
|
|
||||||
v -0.368214 -1.078578 2.051851
|
|
||||||
v -1.026731 -0.445682 1.384443
|
|
||||||
v -1.007409 0.477460 1.384443
|
|
||||||
v -0.547920 1.139177 1.384443
|
|
||||||
v 0.660166 1.163448 1.384443
|
|
||||||
v 1.092329 0.519645 1.384443
|
|
||||||
v 1.073006 -0.403497 1.384443
|
|
||||||
v 0.484569 -1.344695 1.384443
|
|
||||||
v -0.477218 -1.364018 1.384443
|
|
||||||
v -1.077985 -0.465708 1.887314
|
|
||||||
v -1.057726 0.502151 1.887314
|
|
||||||
v -0.575980 1.195922 1.887314
|
|
||||||
v 0.690626 1.221368 1.887314
|
|
||||||
v 1.143722 0.546380 1.887314
|
|
||||||
v 1.123464 -0.421479 1.887314
|
|
||||||
v 0.506523 -1.408269 1.887314
|
|
||||||
v -0.501853 -1.428528 1.887314
|
|
||||||
v -1.085964 0.516008 1.535923
|
|
||||||
v -0.591726 1.227766 1.535923
|
|
||||||
v 0.707720 1.253873 1.535923
|
|
||||||
v 1.172564 0.561383 1.535923
|
|
||||||
v 1.151780 -0.431571 1.535923
|
|
||||||
v 0.518844 -1.443946 1.535923
|
|
||||||
v -0.515678 -1.464730 1.535923
|
|
||||||
v -1.106748 -0.476946 1.535923
|
|
||||||
v 0.612842 -0.142856 2.090828
|
|
||||||
v 0.612842 0.599197 2.091472
|
|
||||||
v -0.540940 -0.142856 2.090828
|
|
||||||
v -0.540940 0.599197 2.091472
|
|
||||||
v 0.612842 -0.142788 2.011893
|
|
||||||
v 0.612842 0.599266 2.012537
|
|
||||||
v -0.540940 -0.142788 2.011893
|
|
||||||
v -0.540940 0.599265 2.012537
|
|
||||||
v 0.445467 -0.035209 2.095495
|
|
||||||
v 0.445467 0.491550 2.095952
|
|
||||||
v -0.373565 -0.035210 2.095495
|
|
||||||
v -0.373565 0.491550 2.095952
|
|
||||||
vn -0.0000 0.9592 -0.2827
|
|
||||||
vn -1.0000 -0.0000 -0.0000
|
|
||||||
vn -0.0000 -0.9592 0.2827
|
|
||||||
vn 1.0000 -0.0000 -0.0000
|
|
||||||
vn -0.0000 -0.2827 -0.9592
|
|
||||||
vn -0.0000 0.2827 0.9592
|
|
||||||
vn -0.9960 -0.0855 0.0252
|
|
||||||
vn 0.9960 -0.0855 0.0252
|
|
||||||
vn -0.0000 -0.3670 -0.9302
|
|
||||||
vn -0.0000 0.1961 0.9806
|
|
||||||
vn -0.0000 -0.8949 0.4464
|
|
||||||
vn -0.0000 0.8949 -0.4464
|
|
||||||
vn -0.0000 -0.4464 -0.8949
|
|
||||||
vn -0.0000 0.4464 0.8949
|
|
||||||
vn -0.0000 -1.0000 -0.0000
|
|
||||||
vn -0.0000 1.0000 -0.0000
|
|
||||||
vn -0.0000 -0.0000 -1.0000
|
|
||||||
vn -0.0000 -0.0000 1.0000
|
|
||||||
vn -0.9239 -0.0000 0.3827
|
|
||||||
vn -0.3827 -0.0000 0.9239
|
|
||||||
vn 0.3827 -0.0000 0.9239
|
|
||||||
vn 0.9239 -0.0000 0.3827
|
|
||||||
vn 0.9239 -0.0000 -0.3827
|
|
||||||
vn 0.3827 -0.0000 -0.9239
|
|
||||||
vn -0.3827 -0.0000 -0.9239
|
|
||||||
vn -0.9239 -0.0000 -0.3827
|
|
||||||
vn -0.5124 0.0107 0.8587
|
|
||||||
vn -0.3944 0.2739 0.8772
|
|
||||||
vn -0.0094 0.4678 0.8838
|
|
||||||
vn 0.3870 0.2598 0.8847
|
|
||||||
vn 0.5124 -0.0107 0.8587
|
|
||||||
vn 0.4253 -0.2659 0.8651
|
|
||||||
vn 0.0086 -0.4282 0.9037
|
|
||||||
vn -0.4187 -0.2505 0.8729
|
|
||||||
vn -0.8549 -0.5116 0.0863
|
|
||||||
vn 0.0200 -0.9946 0.1017
|
|
||||||
vn 0.8450 -0.5283 0.0833
|
|
||||||
vn 0.9965 -0.0209 0.0809
|
|
||||||
vn 0.8268 0.5550 0.0916
|
|
||||||
vn -0.0200 0.9956 0.0911
|
|
||||||
vn -0.8182 0.5681 0.0882
|
|
||||||
vn -0.9965 0.0209 0.0809
|
|
||||||
vn -0.8856 0.0185 -0.4640
|
|
||||||
vn -0.7133 0.4953 -0.4959
|
|
||||||
vn -0.0173 0.8609 -0.5085
|
|
||||||
vn 0.7140 0.4793 -0.5103
|
|
||||||
vn 0.8856 -0.0185 -0.4640
|
|
||||||
vn 0.7463 -0.4666 -0.4746
|
|
||||||
vn 0.0168 -0.8346 -0.5506
|
|
||||||
vn -0.7489 -0.4482 -0.4881
|
|
||||||
vn -0.0000 -0.0009 1.0000
|
|
||||||
vn -0.0000 0.0009 -1.0000
|
|
||||||
vn -0.0000 -1.0000 -0.0009
|
|
||||||
vn -0.0000 1.0000 0.0009
|
|
||||||
vt 0.302708 0.924112
|
|
||||||
vt 0.288040 0.909443
|
|
||||||
vt 0.302708 0.909443
|
|
||||||
vt 0.693823 0.755933
|
|
||||||
vt 0.708491 0.805468
|
|
||||||
vt 0.693821 0.805468
|
|
||||||
vt 0.933974 0.202686
|
|
||||||
vt 0.919330 0.188017
|
|
||||||
vt 0.933973 0.188017
|
|
||||||
vt 0.651344 0.857452
|
|
||||||
vt 0.636674 0.807918
|
|
||||||
vt 0.651343 0.807918
|
|
||||||
vt 0.134278 0.805715
|
|
||||||
vt 0.119609 0.855249
|
|
||||||
vt 0.119609 0.805715
|
|
||||||
vt 0.708491 0.751615
|
|
||||||
vt 0.693871 0.702081
|
|
||||||
vt 0.708540 0.702096
|
|
||||||
vt 0.766441 0.570082
|
|
||||||
vt 0.755608 0.559249
|
|
||||||
vt 0.766441 0.559249
|
|
||||||
vt 0.537931 0.359392
|
|
||||||
vt 0.548757 0.613657
|
|
||||||
vt 0.537924 0.613657
|
|
||||||
vt 0.781573 0.570082
|
|
||||||
vt 0.770759 0.559250
|
|
||||||
vt 0.781572 0.559250
|
|
||||||
vt 0.579073 0.613652
|
|
||||||
vt 0.568233 0.359392
|
|
||||||
vt 0.579066 0.359392
|
|
||||||
vt 0.563915 0.359392
|
|
||||||
vt 0.553082 0.613655
|
|
||||||
vt 0.553082 0.359392
|
|
||||||
vt 0.437696 0.622253
|
|
||||||
vt 0.448781 0.368077
|
|
||||||
vt 0.448529 0.622264
|
|
||||||
vt 0.615148 0.975854
|
|
||||||
vt 0.633896 0.957072
|
|
||||||
vt 0.633897 0.975854
|
|
||||||
vt 0.948652 0.917591
|
|
||||||
vt 0.926304 0.957587
|
|
||||||
vt 0.929870 0.917591
|
|
||||||
vt 0.106854 0.798464
|
|
||||||
vt 0.132782 0.772534
|
|
||||||
vt 0.132782 0.798464
|
|
||||||
vt 0.952676 0.496495
|
|
||||||
vt 0.930312 0.536496
|
|
||||||
vt 0.926746 0.496495
|
|
||||||
vt 0.938021 0.614748
|
|
||||||
vt 0.960377 0.574830
|
|
||||||
vt 0.956803 0.614748
|
|
||||||
vt 0.948620 0.913273
|
|
||||||
vt 0.926304 0.873209
|
|
||||||
vt 0.952234 0.873235
|
|
||||||
vt 0.288040 0.924112
|
|
||||||
vt 0.708492 0.755933
|
|
||||||
vt 0.919331 0.202686
|
|
||||||
vt 0.636675 0.857452
|
|
||||||
vt 0.134278 0.855249
|
|
||||||
vt 0.693822 0.751601
|
|
||||||
vt 0.755609 0.570082
|
|
||||||
vt 0.548764 0.359392
|
|
||||||
vt 0.770759 0.570082
|
|
||||||
vt 0.568241 0.613652
|
|
||||||
vt 0.563915 0.613655
|
|
||||||
vt 0.437949 0.368066
|
|
||||||
vt 0.615148 0.957072
|
|
||||||
vt 0.952234 0.957587
|
|
||||||
vt 0.106853 0.772534
|
|
||||||
vt 0.949094 0.536496
|
|
||||||
vt 0.934447 0.574830
|
|
||||||
vt 0.929838 0.913255
|
|
||||||
vt 0.040925 0.927951
|
|
||||||
vt 0.002159 0.870340
|
|
||||||
vt 0.040923 0.870330
|
|
||||||
vt 0.834247 0.352865
|
|
||||||
vt 0.838729 0.310724
|
|
||||||
vt 0.838729 0.352865
|
|
||||||
vt 0.508750 0.936735
|
|
||||||
vt 0.546231 0.879133
|
|
||||||
vt 0.546232 0.936754
|
|
||||||
vt 0.843047 0.310724
|
|
||||||
vt 0.847530 0.352865
|
|
||||||
vt 0.843047 0.352865
|
|
||||||
vt 0.697810 0.640142
|
|
||||||
vt 0.693822 0.697763
|
|
||||||
vt 0.693822 0.640142
|
|
||||||
vt 0.323097 0.582179
|
|
||||||
vt 0.319198 0.524554
|
|
||||||
vt 0.323154 0.524558
|
|
||||||
vt 0.768084 0.828693
|
|
||||||
vt 0.777234 0.870091
|
|
||||||
vt 0.768084 0.870092
|
|
||||||
vt 0.499788 0.814544
|
|
||||||
vt 0.508937 0.856016
|
|
||||||
vt 0.499788 0.856016
|
|
||||||
vt 0.218712 0.819723
|
|
||||||
vt 0.227862 0.861192
|
|
||||||
vt 0.218712 0.861192
|
|
||||||
vt 0.420031 0.812900
|
|
||||||
vt 0.429180 0.854372
|
|
||||||
vt 0.420031 0.854372
|
|
||||||
vt 0.785891 0.559250
|
|
||||||
vt 0.795040 0.568399
|
|
||||||
vt 0.785891 0.568399
|
|
||||||
vt 0.537924 0.700847
|
|
||||||
vt 0.547080 0.691706
|
|
||||||
vt 0.547071 0.700856
|
|
||||||
vt 0.966064 0.285237
|
|
||||||
vt 0.971814 0.298192
|
|
||||||
vt 0.966120 0.298192
|
|
||||||
vt 0.453257 0.607137
|
|
||||||
vt 0.458792 0.620111
|
|
||||||
vt 0.453099 0.620105
|
|
||||||
vt 0.453125 0.594168
|
|
||||||
vt 0.458949 0.607142
|
|
||||||
vt 0.961680 0.298192
|
|
||||||
vt 0.956052 0.285237
|
|
||||||
vt 0.961746 0.285237
|
|
||||||
vt 0.961746 0.311174
|
|
||||||
vt 0.955987 0.298192
|
|
||||||
vt 0.578003 0.963076
|
|
||||||
vt 0.583636 0.950107
|
|
||||||
vt 0.583697 0.963076
|
|
||||||
vt 0.713986 0.956996
|
|
||||||
vt 0.737947 0.947070
|
|
||||||
vt 0.747872 0.971032
|
|
||||||
vt 0.578003 0.937139
|
|
||||||
vt 0.577943 0.950107
|
|
||||||
vt 0.971758 0.311174
|
|
||||||
vt 0.966064 0.311174
|
|
||||||
vt 0.307851 0.954728
|
|
||||||
vt 0.317762 0.944793
|
|
||||||
vt 0.331777 0.978655
|
|
||||||
vt 0.921986 0.878344
|
|
||||||
vt 0.905406 0.827575
|
|
||||||
vt 0.921986 0.820132
|
|
||||||
vt 0.884350 0.795866
|
|
||||||
vt 0.893886 0.777817
|
|
||||||
vt 0.827291 0.793524
|
|
||||||
vt 0.817744 0.774692
|
|
||||||
vt 0.789645 0.814701
|
|
||||||
vt 0.806235 0.823505
|
|
||||||
vt 0.789645 0.872913
|
|
||||||
vt 0.833108 0.912166
|
|
||||||
vt 0.825506 0.933015
|
|
||||||
vt 0.878533 0.914030
|
|
||||||
vt 0.886125 0.935503
|
|
||||||
vt 0.036904 0.863435
|
|
||||||
vt 0.057955 0.805815
|
|
||||||
vt 0.058039 0.865604
|
|
||||||
vt 0.893784 0.134399
|
|
||||||
vt 0.914942 0.195798
|
|
||||||
vt 0.893712 0.196631
|
|
||||||
vt 0.011369 0.804651
|
|
||||||
vt 0.032412 0.863875
|
|
||||||
vt 0.011276 0.866012
|
|
||||||
vt 0.032503 0.745834
|
|
||||||
vt 0.011370 0.744910
|
|
||||||
vt 0.032435 0.705568
|
|
||||||
vt 0.011300 0.703600
|
|
||||||
vt 0.297104 0.788044
|
|
||||||
vt 0.318245 0.865182
|
|
||||||
vt 0.297086 0.866212
|
|
||||||
vt 0.057959 0.746102
|
|
||||||
vt 0.036897 0.705526
|
|
||||||
vt 0.058032 0.703600
|
|
||||||
vt 0.036826 0.746953
|
|
||||||
vt 0.067083 0.748470
|
|
||||||
vt 0.067078 0.803985
|
|
||||||
vt 0.067151 0.708957
|
|
||||||
vt 0.288040 0.863346
|
|
||||||
vt 0.288056 0.790674
|
|
||||||
vt 0.002181 0.709075
|
|
||||||
vt 0.002246 0.747480
|
|
||||||
vt 0.002245 0.803021
|
|
||||||
vt 0.002159 0.860067
|
|
||||||
vt 0.884977 0.194314
|
|
||||||
vt 0.885044 0.136458
|
|
||||||
vt 0.067157 0.859570
|
|
||||||
vt 0.709979 0.282916
|
|
||||||
vt 0.754532 0.352364
|
|
||||||
vt 0.709910 0.352320
|
|
||||||
vt 0.702128 0.640146
|
|
||||||
vt 0.706914 0.684776
|
|
||||||
vt 0.702166 0.684781
|
|
||||||
vt 0.415360 0.813107
|
|
||||||
vt 0.370725 0.882511
|
|
||||||
vt 0.370725 0.813107
|
|
||||||
vt 0.427272 0.808484
|
|
||||||
vt 0.432057 0.763854
|
|
||||||
vt 0.432020 0.808488
|
|
||||||
vt 0.542664 0.617975
|
|
||||||
vt 0.537927 0.687379
|
|
||||||
vt 0.537924 0.617975
|
|
||||||
vt 0.457848 0.589850
|
|
||||||
vt 0.453099 0.520446
|
|
||||||
vt 0.457847 0.520446
|
|
||||||
vt 0.919379 0.134399
|
|
||||||
vt 0.951006 0.183699
|
|
||||||
vt 0.919330 0.183667
|
|
||||||
vt 0.002161 0.927961
|
|
||||||
vt 0.834247 0.310724
|
|
||||||
vt 0.508749 0.879113
|
|
||||||
vt 0.847530 0.310724
|
|
||||||
vt 0.697810 0.697763
|
|
||||||
vt 0.319140 0.582175
|
|
||||||
vt 0.777234 0.828693
|
|
||||||
vt 0.508937 0.814544
|
|
||||||
vt 0.227862 0.819722
|
|
||||||
vt 0.429180 0.812900
|
|
||||||
vt 0.795040 0.559250
|
|
||||||
vt 0.537933 0.691697
|
|
||||||
vt 0.971758 0.285237
|
|
||||||
vt 0.458817 0.594174
|
|
||||||
vt 0.956052 0.311174
|
|
||||||
vt 0.723911 0.980958
|
|
||||||
vt 0.713986 0.971033
|
|
||||||
vt 0.723911 0.947070
|
|
||||||
vt 0.747872 0.956995
|
|
||||||
vt 0.737947 0.980958
|
|
||||||
vt 0.583697 0.937139
|
|
||||||
vt 0.331777 0.944776
|
|
||||||
vt 0.341688 0.954686
|
|
||||||
vt 0.341688 0.968720
|
|
||||||
vt 0.317762 0.978673
|
|
||||||
vt 0.307851 0.968762
|
|
||||||
vt 0.905406 0.871198
|
|
||||||
vt 0.806235 0.867128
|
|
||||||
vt 0.036821 0.805157
|
|
||||||
vt 0.915012 0.135139
|
|
||||||
vt 0.032502 0.804065
|
|
||||||
vt 0.318263 0.788989
|
|
||||||
vt 0.754601 0.282960
|
|
||||||
vt 0.706876 0.640142
|
|
||||||
vt 0.415360 0.882511
|
|
||||||
vt 0.427309 0.763850
|
|
||||||
vt 0.542666 0.687379
|
|
||||||
vt 0.453100 0.589850
|
|
||||||
vt 0.951055 0.134431
|
|
||||||
s 1
|
|
||||||
f 3/1/1 2/2/1 1/3/1
|
|
||||||
f 7/4/2 4/5/2 3/6/2
|
|
||||||
f 5/7/3 8/8/3 7/9/3
|
|
||||||
f 1/10/4 6/11/4 5/12/4
|
|
||||||
f 1/13/5 7/14/5 3/15/5
|
|
||||||
f 8/16/6 2/17/6 4/18/6
|
|
||||||
f 11/19/1 10/20/1 9/21/1
|
|
||||||
f 15/22/2 12/23/2 11/24/2
|
|
||||||
f 13/25/3 16/26/3 15/27/3
|
|
||||||
f 9/28/4 14/29/4 13/30/4
|
|
||||||
f 9/31/5 15/32/5 11/33/5
|
|
||||||
f 14/34/6 12/35/6 16/36/6
|
|
||||||
f 18/37/3 19/38/3 17/39/3
|
|
||||||
f 20/40/7 23/41/7 19/42/7
|
|
||||||
f 24/43/1 21/44/1 23/45/1
|
|
||||||
f 22/46/8 17/47/8 21/48/8
|
|
||||||
f 19/49/9 21/50/9 17/51/9
|
|
||||||
f 20/52/10 22/53/10 24/54/10
|
|
||||||
f 3/1/1 4/55/1 2/2/1
|
|
||||||
f 7/4/2 8/56/2 4/5/2
|
|
||||||
f 5/7/3 6/57/3 8/8/3
|
|
||||||
f 1/10/4 2/58/4 6/11/4
|
|
||||||
f 1/13/5 5/59/5 7/14/5
|
|
||||||
f 8/16/6 6/60/6 2/17/6
|
|
||||||
f 11/19/1 12/61/1 10/20/1
|
|
||||||
f 15/22/2 16/62/2 12/23/2
|
|
||||||
f 13/25/3 14/63/3 16/26/3
|
|
||||||
f 9/28/4 10/64/4 14/29/4
|
|
||||||
f 9/31/5 13/65/5 15/32/5
|
|
||||||
f 14/34/6 10/66/6 12/35/6
|
|
||||||
f 18/37/3 20/67/3 19/38/3
|
|
||||||
f 20/40/7 24/68/7 23/41/7
|
|
||||||
f 24/43/1 22/69/1 21/44/1
|
|
||||||
f 22/46/8 18/70/8 17/47/8
|
|
||||||
f 19/49/9 23/71/9 21/50/9
|
|
||||||
f 20/52/10 18/72/10 22/53/10
|
|
||||||
f 25/73/11 28/74/11 27/75/11
|
|
||||||
f 27/76/2 32/77/2 31/78/2
|
|
||||||
f 32/79/12 29/80/12 31/81/12
|
|
||||||
f 30/82/4 25/83/4 29/84/4
|
|
||||||
f 31/85/13 25/86/13 27/87/13
|
|
||||||
f 32/88/14 26/89/14 30/90/14
|
|
||||||
f 34/91/15 35/92/15 33/93/15
|
|
||||||
f 36/94/2 39/95/2 35/96/2
|
|
||||||
f 40/97/16 37/98/16 39/99/16
|
|
||||||
f 38/100/4 33/101/4 37/102/4
|
|
||||||
f 35/103/17 37/104/17 33/105/17
|
|
||||||
f 36/106/18 38/107/18 40/108/18
|
|
||||||
f 43/109/19 42/110/19 41/111/19
|
|
||||||
f 45/112/20 44/113/20 43/114/20
|
|
||||||
f 47/115/21 46/116/21 45/112/21
|
|
||||||
f 49/117/22 48/118/22 47/119/22
|
|
||||||
f 51/120/23 50/121/23 49/117/23
|
|
||||||
f 51/122/24 54/123/24 52/124/24
|
|
||||||
f 46/125/16 50/126/16 54/127/16
|
|
||||||
f 55/128/25 54/123/25 53/129/25
|
|
||||||
f 41/111/26 56/130/26 55/131/26
|
|
||||||
f 45/132/15 43/133/15 51/134/15
|
|
||||||
f 73/135/27 58/136/27 74/137/27
|
|
||||||
f 74/137/28 59/138/28 75/139/28
|
|
||||||
f 75/139/29 60/140/29 76/141/29
|
|
||||||
f 60/140/30 77/142/30 76/141/30
|
|
||||||
f 61/143/31 78/144/31 77/142/31
|
|
||||||
f 78/144/32 63/145/32 79/146/32
|
|
||||||
f 61/143/18 60/140/18 59/138/18
|
|
||||||
f 79/146/33 64/147/33 80/148/33
|
|
||||||
f 64/147/34 73/135/34 80/148/34
|
|
||||||
f 80/149/35 88/150/35 87/151/35
|
|
||||||
f 86/152/36 80/153/36 87/154/36
|
|
||||||
f 85/155/37 79/156/37 86/157/37
|
|
||||||
f 77/158/38 85/155/38 84/159/38
|
|
||||||
f 76/160/39 84/159/39 83/161/39
|
|
||||||
f 82/162/40 76/163/40 83/164/40
|
|
||||||
f 81/165/41 75/166/41 82/167/41
|
|
||||||
f 88/150/42 74/168/42 81/165/42
|
|
||||||
f 88/150/43 66/169/43 65/170/43
|
|
||||||
f 81/165/44 67/171/44 66/169/44
|
|
||||||
f 82/162/45 68/172/45 67/173/45
|
|
||||||
f 68/174/46 84/159/46 69/175/46
|
|
||||||
f 69/175/47 85/155/47 70/176/47
|
|
||||||
f 85/155/48 71/177/48 70/176/48
|
|
||||||
f 86/152/49 72/178/49 71/179/49
|
|
||||||
f 72/180/50 88/150/50 65/170/50
|
|
||||||
f 89/181/51 92/182/51 91/183/51
|
|
||||||
f 92/184/2 95/185/2 91/186/2
|
|
||||||
f 96/187/52 93/188/52 95/189/52
|
|
||||||
f 93/190/4 90/191/4 89/192/4
|
|
||||||
f 95/193/53 89/194/53 91/195/53
|
|
||||||
f 96/196/54 90/197/54 94/198/54
|
|
||||||
f 97/199/51 100/200/51 99/201/51
|
|
||||||
f 25/73/11 26/202/11 28/74/11
|
|
||||||
f 27/76/2 28/203/2 32/77/2
|
|
||||||
f 32/79/12 30/204/12 29/80/12
|
|
||||||
f 30/82/4 26/205/4 25/83/4
|
|
||||||
f 31/85/13 29/206/13 25/86/13
|
|
||||||
f 32/88/14 28/207/14 26/89/14
|
|
||||||
f 34/91/15 36/208/15 35/92/15
|
|
||||||
f 36/94/2 40/209/2 39/95/2
|
|
||||||
f 40/97/16 38/210/16 37/98/16
|
|
||||||
f 38/100/4 34/211/4 33/101/4
|
|
||||||
f 35/103/17 39/212/17 37/104/17
|
|
||||||
f 36/106/18 34/213/18 38/107/18
|
|
||||||
f 43/109/19 44/214/19 42/110/19
|
|
||||||
f 45/112/20 46/116/20 44/113/20
|
|
||||||
f 47/115/21 48/215/21 46/116/21
|
|
||||||
f 49/117/22 50/121/22 48/118/22
|
|
||||||
f 51/120/23 52/216/23 50/121/23
|
|
||||||
f 51/122/24 53/129/24 54/123/24
|
|
||||||
f 42/217/16 44/218/16 46/125/16
|
|
||||||
f 46/125/16 48/219/16 50/126/16
|
|
||||||
f 50/126/16 52/220/16 54/127/16
|
|
||||||
f 54/127/16 56/221/16 42/217/16
|
|
||||||
f 42/217/16 46/125/16 54/127/16
|
|
||||||
f 55/128/25 56/222/25 54/123/25
|
|
||||||
f 41/111/26 42/110/26 56/130/26
|
|
||||||
f 43/133/15 41/223/15 51/134/15
|
|
||||||
f 41/223/15 55/224/15 51/134/15
|
|
||||||
f 55/224/15 53/225/15 51/134/15
|
|
||||||
f 51/134/15 49/226/15 47/227/15
|
|
||||||
f 47/227/15 45/132/15 51/134/15
|
|
||||||
f 73/135/27 57/228/27 58/136/27
|
|
||||||
f 74/137/28 58/136/28 59/138/28
|
|
||||||
f 75/139/29 59/138/29 60/140/29
|
|
||||||
f 60/140/30 61/143/30 77/142/30
|
|
||||||
f 61/143/31 62/229/31 78/144/31
|
|
||||||
f 78/144/32 62/229/32 63/145/32
|
|
||||||
f 59/138/18 58/136/18 61/143/18
|
|
||||||
f 58/136/18 57/228/18 62/229/18
|
|
||||||
f 61/143/18 58/136/18 62/229/18
|
|
||||||
f 57/228/18 64/147/18 63/145/18
|
|
||||||
f 63/145/18 62/229/18 57/228/18
|
|
||||||
f 79/146/33 63/145/33 64/147/33
|
|
||||||
f 64/147/34 57/228/34 73/135/34
|
|
||||||
f 80/149/35 73/230/35 88/150/35
|
|
||||||
f 86/152/36 79/231/36 80/153/36
|
|
||||||
f 85/155/37 78/232/37 79/156/37
|
|
||||||
f 77/158/38 78/232/38 85/155/38
|
|
||||||
f 76/160/39 77/158/39 84/159/39
|
|
||||||
f 82/162/40 75/233/40 76/163/40
|
|
||||||
f 81/165/41 74/168/41 75/166/41
|
|
||||||
f 88/150/42 73/230/42 74/168/42
|
|
||||||
f 88/150/43 81/165/43 66/169/43
|
|
||||||
f 81/165/44 82/167/44 67/171/44
|
|
||||||
f 82/162/45 83/164/45 68/172/45
|
|
||||||
f 68/174/46 83/161/46 84/159/46
|
|
||||||
f 69/175/47 84/159/47 85/155/47
|
|
||||||
f 85/155/48 86/157/48 71/177/48
|
|
||||||
f 86/152/49 87/154/49 72/178/49
|
|
||||||
f 72/180/50 87/151/50 88/150/50
|
|
||||||
f 89/181/51 90/234/51 92/182/51
|
|
||||||
f 92/184/2 96/235/2 95/185/2
|
|
||||||
f 96/187/52 94/236/52 93/188/52
|
|
||||||
f 93/190/4 94/237/4 90/191/4
|
|
||||||
f 95/193/53 93/238/53 89/194/53
|
|
||||||
f 96/196/54 92/239/54 90/197/54
|
|
||||||
f 97/199/51 98/240/51 100/200/51
|
|
||||||
|
Before Width: | Height: | Size: 93 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 13 MiB After Width: | Height: | Size: 10 MiB |
|
Before Width: | Height: | Size: 10 MiB |
@@ -0,0 +1,4 @@
|
|||||||
|
package pp.mdga.client.settings;
|
||||||
|
|
||||||
|
public class AudioSettings {
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package pp.mdga.client.settings;
|
||||||
|
|
||||||
|
public class VideoSettings {
|
||||||
|
}
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
package pp.mdga;
|
|
||||||
|
|
||||||
import java.util.ResourceBundle;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Provides access to the resource bundle of the game.
|
|
||||||
*
|
|
||||||
* @see #BUNDLE
|
|
||||||
*/
|
|
||||||
public class Resources {
|
|
||||||
/**
|
|
||||||
* Create Resources constants.
|
|
||||||
*/
|
|
||||||
public static final int MAX_PLAYERS = 4;
|
|
||||||
public static final int MAX_PIECES = 4;
|
|
||||||
public static final int MAX_EYES = 6;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The resource bundle for the MDGA game.
|
|
||||||
*/
|
|
||||||
public static final ResourceBundle BUNDLE = ResourceBundle.getBundle("mdga"); //NON-NLS
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a string for the given key from the resource bundle in {@linkplain #BUNDLE}.
|
|
||||||
*
|
|
||||||
* @param key the key for the desired string
|
|
||||||
* @return the string for the given key
|
|
||||||
* @throws NullPointerException if {@code key} is {@code null}
|
|
||||||
* @throws java.util.MissingResourceException if no object for the given key can be found
|
|
||||||
* @throws ClassCastException if the object found for the given key is not a string
|
|
||||||
*/
|
|
||||||
public static String stringLookup(String key) {
|
|
||||||
return BUNDLE.getString(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a int for the given key from the resource bundle in {@linkplain #BUNDLE}.
|
|
||||||
*
|
|
||||||
* @param key the key for the desired string
|
|
||||||
* @return the string for the given key
|
|
||||||
* @throws NullPointerException if {@code key} is {@code null}
|
|
||||||
* @throws java.util.MissingResourceException if no object for the given key can be found
|
|
||||||
* @throws ClassCastException if the object found for the given key is not a string
|
|
||||||
*/
|
|
||||||
public static int intLookup(String key) {
|
|
||||||
return Integer.parseInt(BUNDLE.getString(key));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a boolean for the given key from the resource bundle in {@linkplain #BUNDLE}.
|
|
||||||
*
|
|
||||||
* @param key the key for the desired string
|
|
||||||
* @return the string for the given key
|
|
||||||
* @throws NullPointerException if {@code key} is {@code null}
|
|
||||||
* @throws java.util.MissingResourceException if no object for the given key can be found
|
|
||||||
* @throws ClassCastException if the object found for the given key is not a string
|
|
||||||
*/
|
|
||||||
public static boolean boolLookup(String key) {
|
|
||||||
return Boolean.parseBoolean(BUNDLE.getString(key));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a double for the given key from the resource bundle in {@linkplain #BUNDLE}.
|
|
||||||
*
|
|
||||||
* @param key the key for the desired string
|
|
||||||
* @return the string for the given key
|
|
||||||
* @throws NullPointerException if {@code key} is {@code null}
|
|
||||||
* @throws java.util.MissingResourceException if no object for the given key can be found
|
|
||||||
* @throws ClassCastException if the object found for the given key is not a string
|
|
||||||
*/
|
|
||||||
public static double doubleLookup(String key) {
|
|
||||||
return Double.parseDouble(BUNDLE.getString(key));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Private constructor to prevent instantiation.
|
|
||||||
*/
|
|
||||||
private Resources() { /* do not instantiate */ }
|
|
||||||
}
|
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
package pp.mdga.client;
|
package pp.mdga.client;
|
||||||
|
|
||||||
import pp.mdga.client.ceremonystate.CeremonyStates;
|
import pp.mdga.client.ceremonyState.CeremonyStates;
|
||||||
import pp.mdga.client.ceremonystate.PodiumState;
|
import pp.mdga.client.ceremonyState.PodiumState;
|
||||||
import pp.mdga.client.ceremonystate.StatisticsState;
|
import pp.mdga.client.ceremonyState.StatisticsState;
|
||||||
|
import pp.mdga.notification.CeremonyNotification;
|
||||||
|
|
||||||
public class CeremonyState extends ClientState {
|
public class CeremonyState extends ClientState {
|
||||||
|
|
||||||
@@ -11,38 +12,21 @@ public class CeremonyState extends ClientState {
|
|||||||
private final PodiumState podiumState = new PodiumState(this, logic);
|
private final PodiumState podiumState = new PodiumState(this, logic);
|
||||||
private final StatisticsState statisticsState = new StatisticsState(this, logic);
|
private final StatisticsState statisticsState = new StatisticsState(this, logic);
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new CeremonyState
|
|
||||||
*
|
|
||||||
* @param parent the parent state
|
|
||||||
* @param logic the game logic
|
|
||||||
*/
|
|
||||||
public CeremonyState(ClientState parent, ClientGameLogic logic) {
|
public CeremonyState(ClientState parent, ClientGameLogic logic) {
|
||||||
super(parent, logic);
|
super(parent, logic);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Enters the new state machine
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void enter() {
|
public void enter() {
|
||||||
setState(podiumState);
|
setState(podiumState);
|
||||||
logic.addNotification(createCeremonyNotification());
|
logic.addNotification(createCeremonyNotification());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* exits this state
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void exit() {
|
public void exit() {
|
||||||
currentState.exit();
|
currentState.exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is used to set a new SubState
|
|
||||||
*
|
|
||||||
* @param state the state to be set
|
|
||||||
*/
|
|
||||||
public void setState(CeremonyStates state){
|
public void setState(CeremonyStates state){
|
||||||
if(this.currentState != null){
|
if(this.currentState != null){
|
||||||
this.currentState.exit();
|
this.currentState.exit();
|
||||||
@@ -51,29 +35,14 @@ public void setState(CeremonyStates state){
|
|||||||
currentState = state;
|
currentState = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method get the PodiumState
|
|
||||||
*
|
|
||||||
* @return the PodiumState
|
|
||||||
*/
|
|
||||||
public PodiumState getPodiumState(){
|
public PodiumState getPodiumState(){
|
||||||
return podiumState;
|
return podiumState;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method get the StatisticsState
|
|
||||||
*
|
|
||||||
* @return the StatisticsState
|
|
||||||
*/
|
|
||||||
public StatisticsState getStatisticsState(){
|
public StatisticsState getStatisticsState(){
|
||||||
return statisticsState;
|
return statisticsState;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is used to get the current State
|
|
||||||
*
|
|
||||||
* @return the current State
|
|
||||||
*/
|
|
||||||
public CeremonyStates getState(){
|
public CeremonyStates getState(){
|
||||||
return currentState;
|
return currentState;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +1,18 @@
|
|||||||
package pp.mdga.client;
|
package pp.mdga.client;
|
||||||
|
|
||||||
import pp.mdga.Resources;
|
|
||||||
import pp.mdga.game.BonusCard;
|
import pp.mdga.game.BonusCard;
|
||||||
import pp.mdga.game.Color;
|
import pp.mdga.game.Color;
|
||||||
import pp.mdga.game.Game;
|
import pp.mdga.game.Game;
|
||||||
import pp.mdga.game.Piece;
|
import pp.mdga.game.Piece;
|
||||||
|
import pp.mdga.game.PlayerData;
|
||||||
import pp.mdga.message.client.ClientMessage;
|
import pp.mdga.message.client.ClientMessage;
|
||||||
import pp.mdga.message.server.*;
|
import pp.mdga.message.server.*;
|
||||||
import pp.mdga.notification.InfoNotification;
|
import pp.mdga.notification.*;
|
||||||
import pp.mdga.notification.Notification;
|
|
||||||
import pp.mdga.notification.StartDialogNotification;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
|
||||||
* The ClientGameLogic class is the main class for the client side of the game.
|
|
||||||
* It is responsible for handling the game logic on the client side.
|
|
||||||
*/
|
|
||||||
public class ClientGameLogic implements ServerInterpreter {
|
public class ClientGameLogic implements ServerInterpreter {
|
||||||
static final System.Logger LOGGER = System.getLogger(ClientGameLogic.class.getName());
|
static final System.Logger LOGGER = System.getLogger(ClientGameLogic.class.getName());
|
||||||
|
|
||||||
@@ -26,8 +21,6 @@ public class ClientGameLogic implements ServerInterpreter {
|
|||||||
private ClientState state;
|
private ClientState state;
|
||||||
private final ArrayList<Notification> notifications = new ArrayList<>();
|
private final ArrayList<Notification> notifications = new ArrayList<>();
|
||||||
private boolean isHost;
|
private boolean isHost;
|
||||||
private int ownPlayerID;
|
|
||||||
private String ownPlayerName;
|
|
||||||
|
|
||||||
private final DialogsState dialogsState = new DialogsState(null, this);
|
private final DialogsState dialogsState = new DialogsState(null, this);
|
||||||
private final GameState gameState = new GameState(null, this);
|
private final GameState gameState = new GameState(null, this);
|
||||||
@@ -35,11 +28,6 @@ public class ClientGameLogic implements ServerInterpreter {
|
|||||||
private final InterruptState interruptState = new InterruptState(null, this);
|
private final InterruptState interruptState = new InterruptState(null, this);
|
||||||
private final SettingsState settingsState = new SettingsState(null, this);
|
private final SettingsState settingsState = new SettingsState(null, this);
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new ClientGameLogic
|
|
||||||
*
|
|
||||||
* @param clientSender the client sender
|
|
||||||
*/
|
|
||||||
public ClientGameLogic(ClientSender clientSender) {
|
public ClientGameLogic(ClientSender clientSender) {
|
||||||
this.game = new Game();
|
this.game = new Game();
|
||||||
this.clientSender = clientSender;
|
this.clientSender = clientSender;
|
||||||
@@ -47,26 +35,15 @@ public ClientGameLogic(ClientSender clientSender) {
|
|||||||
state = dialogsState;
|
state = dialogsState;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void send(ClientMessage msg){
|
||||||
* This method is used to send a message to the server
|
|
||||||
*
|
|
||||||
* @param msg the message to be sent
|
|
||||||
*/
|
|
||||||
public void send(ClientMessage msg) {
|
|
||||||
LOGGER.log(System.Logger.Level.INFO, "send {0}", msg);
|
LOGGER.log(System.Logger.Level.INFO, "send {0}", msg);
|
||||||
clientSender.send(msg);
|
clientSender.send(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private Piece getPiece(UUID pieceId){
|
||||||
* This method is used to get a piece by its id
|
for(Map.Entry<Color, PlayerData> entry : game.getBoard().getPlayerData().entrySet()){
|
||||||
*
|
for(Piece piece : entry.getValue().getPieces()){
|
||||||
* @param pieceId the UUID of the piece
|
if(piece.getUuid().equals(pieceId)){
|
||||||
* @return the piece
|
|
||||||
*/
|
|
||||||
private Piece getPiece(UUID pieceId) {
|
|
||||||
for (var player : this.game.getPlayers().values()) {
|
|
||||||
for (Piece piece : player.getPieces()) {
|
|
||||||
if (piece.getUuid().equals(pieceId)) {
|
|
||||||
return piece;
|
return piece;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -74,610 +51,289 @@ private Piece getPiece(UUID pieceId) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public ClientSender getClientSender(){
|
||||||
* This method returns the clientSender
|
|
||||||
*
|
|
||||||
* @return the clientSender
|
|
||||||
*/
|
|
||||||
public ClientSender getClientSender() {
|
|
||||||
return clientSender;
|
return clientSender;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public Game getGame(){
|
||||||
* This method is used to get the ownPlayerId
|
|
||||||
*
|
|
||||||
* @return the ownPlayerId
|
|
||||||
*/
|
|
||||||
public int getOwnPlayerId() {
|
|
||||||
return ownPlayerID;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is used to get the ownPlayerName
|
|
||||||
*
|
|
||||||
* @return the ownPlayerName
|
|
||||||
*/
|
|
||||||
public String getOwnPlayerName() {
|
|
||||||
return ownPlayerName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is used to set the ownPlayerName
|
|
||||||
*
|
|
||||||
* @param ownPlayerName the ownPlayerName to be set
|
|
||||||
*/
|
|
||||||
public void setOwnPlayerName(String ownPlayerName) {
|
|
||||||
this.ownPlayerName = ownPlayerName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is used to set the ownPlayerId
|
|
||||||
*
|
|
||||||
* @param ownPlayerId the ownPlayerId to be set
|
|
||||||
*/
|
|
||||||
public void setOwnPlayerId(int ownPlayerId) {
|
|
||||||
this.ownPlayerID = ownPlayerId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method returns the game
|
|
||||||
*
|
|
||||||
* @return the game
|
|
||||||
*/
|
|
||||||
public Game getGame() {
|
|
||||||
return game;
|
return game;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public ClientState getState(){
|
||||||
* This method returns the current State
|
|
||||||
*
|
|
||||||
* @return the current State
|
|
||||||
*/
|
|
||||||
public ClientState getState() {
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public boolean isHost(){
|
||||||
* This method returns if the client is a host
|
|
||||||
*
|
|
||||||
* @return if the client is a host
|
|
||||||
*/
|
|
||||||
public boolean isHost() {
|
|
||||||
return isHost;
|
return isHost;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public int getCalculatedMoves(){
|
||||||
* This method returns the steps you can calculate steps
|
return game.getDiceEyes() * game.getDiceModifier();
|
||||||
*
|
|
||||||
* @return the calculated moves as int
|
|
||||||
*/
|
|
||||||
public int getCalculatedMoves() {
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void setHost(boolean isHost){
|
||||||
* This method sets if the player is a host
|
|
||||||
*
|
|
||||||
* @param isHost the boolean value
|
|
||||||
*/
|
|
||||||
public void setHost(boolean isHost) {
|
|
||||||
this.isHost = isHost;
|
this.isHost = isHost;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method calls the method received of the state
|
|
||||||
*
|
|
||||||
* @param msg the ActivePlayer message received
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void received(ActivePlayerMessage msg) {
|
public void received(ActivePlayerMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method calls the method received of the state
|
|
||||||
*
|
|
||||||
* @param msg the AnyPiece message received
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void received(AnyPieceMessage msg) {
|
public void received(AnyPieceMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method calls the method received of the state
|
|
||||||
*
|
|
||||||
* @param msg the Briefing message received
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void received(BriefingMessage msg) {
|
public void received(BriefingMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method calls the method received of the state
|
|
||||||
*
|
|
||||||
* @param msg the Ceremony message received
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void received(CeremonyMessage msg) {
|
public void received(CeremonyMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method calls the method received of the state
|
|
||||||
*
|
|
||||||
* @param msg the Dice message received
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void received(DieMessage msg) {
|
public void received(DieMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method calls the method received of the state
|
|
||||||
*
|
|
||||||
* @param msg the DiceAgain message received
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void received(DiceAgainMessage msg) {
|
public void received(DiceAgainMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method calls the method received of the state
|
|
||||||
*
|
|
||||||
* @param msg the DiceNow message received
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void received(DiceNowMessage msg) {
|
public void received(DiceNowMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method calls the method received of the state
|
|
||||||
*
|
|
||||||
* @param msg the EndOfGame message received
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void received(EndOfTurnMessage msg) {
|
public void received(EndOfTurnMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method calls the method received of the state
|
|
||||||
*
|
|
||||||
* @param msg the GameOver message received
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void received(LobbyAcceptMessage msg) {
|
public void received(LobbyAcceptMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method calls the method received of the state
|
|
||||||
*
|
|
||||||
* @param msg the LobbyDeny message received
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void received(LobbyDenyMessage msg) {
|
public void received(LobbyDenyMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method calls the method received of the state
|
|
||||||
*
|
|
||||||
* @param msg the LobbyPlayerJoin message received
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void received(LobbyPlayerJoinedMessage msg) {
|
public void received(LobbyPlayerJoinedMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method calls the method received of the state
|
|
||||||
*
|
|
||||||
* @param msg the LobbyPlayerLeave message received
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void received(LobbyPlayerLeaveMessage msg) {
|
public void received(LobbyPlayerLeaveMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method calls the method received of the state
|
|
||||||
*
|
|
||||||
* @param msg the MoveMessage message received
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void received(MoveMessage msg) {
|
public void received(MoveMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method calls the method received of the state
|
|
||||||
*
|
|
||||||
* @param msg the NoTurn message received
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void received(NoTurnMessage msg) {
|
public void received(NoTurnMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method calls the method received of the state
|
|
||||||
*
|
|
||||||
* @param msg the PauseGame message received
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void received(PauseGameMessage msg) {
|
public void received(PauseGameMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method calls the method received of the state
|
|
||||||
*
|
|
||||||
* @param msg the PlayCard message received
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void received(PlayCardMessage msg) {
|
public void received(PlayCardMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method calls the method received of the state
|
|
||||||
*
|
|
||||||
* @param msg the PossibleCard message received
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void received(PossibleCardsMessage msg) {
|
public void received(PossibleCardMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method calls the method received of the state
|
|
||||||
*
|
|
||||||
* @param msg the PossiblePiece message received
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void received(PossiblePieceMessage msg) {
|
public void received(PossiblePieceMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method calls the method received of the state
|
|
||||||
*
|
|
||||||
* @param msg the RankingResponse message received
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void received(RankingResponseMessage msg) {
|
public void received(RankingResponseMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method calls the method received of the state
|
|
||||||
*
|
|
||||||
* @param msg the RankingRollAgain message received
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void received(RankingRollAgainMessage msg) {
|
public void received(RankingRollAgainMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method calls the method received of the state
|
|
||||||
*
|
|
||||||
* @param msg the ReconnectBriefing message received
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void received(ReconnectBriefingMessage msg) {
|
public void received(ReconnectBriefingMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method calls the method received of the state
|
|
||||||
*
|
|
||||||
* @param msg the ResumeGame message received
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void received(ResumeGameMessage msg) {
|
public void received(ResumeGameMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method calls the method received of the state
|
|
||||||
*
|
|
||||||
* @param msg the ServerStartGame message received
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void received(ServerStartGameMessage msg) {
|
public void received(ServerStartGameMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method calls the method received of the state
|
|
||||||
*
|
|
||||||
* @param msg the SelectTSK message received.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void received(ShutdownMessage msg) {
|
public void received(ShutdownMessage msg) {state.received(msg);}
|
||||||
addNotification(new InfoNotification(Resources.stringLookup("server.shutdown")));
|
|
||||||
addNotification(new StartDialogNotification());
|
@Override
|
||||||
setState(dialogsState);
|
public void received(StartBriefingMessage msg) {
|
||||||
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles a IncorrectRequest message received from the server.
|
|
||||||
*
|
|
||||||
* @param msg the IncorrectRequest message received.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void received(IncorrectRequestMessage msg) {
|
public void received(PlayerDataMessage msg) {
|
||||||
addNotification(new InfoNotification(Resources.stringLookup("incorrect.request." + msg.getId())));
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method calls the method received of the state
|
|
||||||
*
|
|
||||||
* @param msg the StartPiece message received
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void received(StartPieceMessage msg) {
|
public void received(StartPieceMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method calls the method received of the state
|
|
||||||
*
|
|
||||||
* @param msg the UpdateReady message received
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void received(UpdateReadyMessage msg) {
|
public void received(UpdateReadyMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method calls the method received of the state
|
|
||||||
*
|
|
||||||
* @param msg the UpdateTSK message received
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void received(UpdateTSKMessage msg) {
|
public void received(UpdateTSKMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method calls the method received of the state
|
|
||||||
*
|
|
||||||
* @param msg the WaitPiece message received
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void received(WaitPieceMessage msg) {
|
public void received(WaitPieceMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method calls the method received of the state
|
|
||||||
*
|
|
||||||
* @param msg the Spectator message received.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void received(SpectatorMessage msg) {
|
public void received(SpectatorMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method calls the method received of the state
|
|
||||||
*
|
|
||||||
* @param msg the SelectPiece message received.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void received(SelectPieceMessage msg) {
|
public void received(SelectPieceMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void selectPiece(UUID pieceId){
|
||||||
* This method calls the method selectPiece
|
|
||||||
*
|
|
||||||
* @param pieceId the pieceID
|
|
||||||
*/
|
|
||||||
public void selectPiece(UUID pieceId) {
|
|
||||||
state.selectPiece(getPiece(pieceId));
|
state.selectPiece(getPiece(pieceId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void selectNext(){
|
||||||
* This method call the method selectNExt of the state
|
|
||||||
*/
|
|
||||||
public void selectNext() {
|
|
||||||
state.selectNext();
|
state.selectNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void selectCard(BonusCard card){
|
||||||
* This method calls the method selectCard of the state
|
|
||||||
*
|
|
||||||
* @param card the BonusCard to selected
|
|
||||||
*/
|
|
||||||
public void selectCard(BonusCard card) {
|
|
||||||
state.selectCard(card);
|
state.selectCard(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void selectTsk(Color color){
|
||||||
* This method call the method selectTsk of the state
|
|
||||||
*
|
|
||||||
* @param color the Color to be selected
|
|
||||||
*/
|
|
||||||
public void selectTsk(Color color) {
|
|
||||||
state.selectTSK(color);
|
state.selectTSK(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void deselectTSK(Color color){
|
||||||
* The method calls the method deselectTsk of the state
|
|
||||||
*
|
|
||||||
* @param color the color to be deselcted
|
|
||||||
*/
|
|
||||||
public void deselectTSK(Color color) {
|
|
||||||
state.deselectTSK(color);
|
state.deselectTSK(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void selectDice(){
|
||||||
* This method calls the selectDice method of the state
|
|
||||||
*/
|
|
||||||
public void selectDice() {
|
|
||||||
state.selectDice();
|
state.selectDice();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void selectName(String name){
|
||||||
* This method calls the selectName method of the state
|
|
||||||
*
|
|
||||||
* @param name the name to be set
|
|
||||||
*/
|
|
||||||
public void selectName(String name) {
|
|
||||||
state.setName(name);
|
state.setName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void selectReady(boolean ready){
|
||||||
* This method calls a method of the state base on the parameter value
|
if(ready){
|
||||||
*
|
|
||||||
* @param ready the value if this method should ready or unready
|
|
||||||
*/
|
|
||||||
public void selectReady(boolean ready) {
|
|
||||||
if (ready) {
|
|
||||||
state.selectReady();
|
state.selectReady();
|
||||||
} else {
|
} else {
|
||||||
state.selectUnready();
|
state.selectUnready();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void selectHost(String name){
|
||||||
* This method calls the selectHost method of the state
|
|
||||||
*
|
|
||||||
* @param name the name of the player hosting
|
|
||||||
*/
|
|
||||||
public void selectHost(String name) {
|
|
||||||
state.selectHost(name);
|
state.selectHost(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void selectLeave(){
|
||||||
* This method calls the selectLeave method of the state
|
|
||||||
*/
|
|
||||||
public void selectLeave() {
|
|
||||||
state.selectLeave();
|
state.selectLeave();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void selectJoin(String ip){
|
||||||
* This method calls the selectJoin method of the state
|
|
||||||
*
|
|
||||||
* @param ip the ip to cennect to
|
|
||||||
*/
|
|
||||||
public void selectJoin(String ip) {
|
|
||||||
state.selectJoin(ip);
|
state.selectJoin(ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void selectAnimationEnd(){
|
||||||
* This method calls the selectAnimationEnd method of the state
|
|
||||||
*/
|
|
||||||
public void selectAnimationEnd() {
|
|
||||||
state.selectAnimationEnd();
|
state.selectAnimationEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void selectStart(){
|
||||||
* This method calls the selectStart method of the state
|
|
||||||
*/
|
|
||||||
public void selectStart() {
|
|
||||||
state.selectStart();
|
state.selectStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void selectResume(){
|
||||||
* This method calls the selectResume method of the state
|
|
||||||
*/
|
|
||||||
public void selectResume() {
|
|
||||||
state.selectResume();
|
state.selectResume();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void setState(ClientState state){
|
||||||
* This method is used to transition between states
|
|
||||||
*
|
|
||||||
* @param state the new state
|
|
||||||
*/
|
|
||||||
public void setState(ClientState state) {
|
|
||||||
this.state.exit();
|
this.state.exit();
|
||||||
state.enter();
|
state.enter();
|
||||||
this.state = state;
|
this.state = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void enterInterrupt(){
|
||||||
* This method is used to enter the interrupt state and save the previous state
|
|
||||||
*/
|
|
||||||
public void enterInterrupt() {
|
|
||||||
interruptState.enter();
|
interruptState.enter();
|
||||||
interruptState.setPreviousState(state);
|
interruptState.setPreviousState(state);
|
||||||
this.state = interruptState;
|
this.state = interruptState;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public GameState getGameState(){
|
||||||
* This method is used to get the GameState
|
|
||||||
*
|
|
||||||
* @return the GameState
|
|
||||||
*/
|
|
||||||
public GameState getGameState() {
|
|
||||||
return gameState;
|
return gameState;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public CeremonyState getCeremony(){
|
||||||
* This method is used to get the CeremonyState
|
|
||||||
*
|
|
||||||
* @return the CeremonyState
|
|
||||||
*/
|
|
||||||
public CeremonyState getCeremony() {
|
|
||||||
return ceremonyState;
|
return ceremonyState;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public InterruptState getInterrupt(){
|
||||||
* This method is used to get the InterruptState
|
|
||||||
*
|
|
||||||
* @return the InterruptState
|
|
||||||
*/
|
|
||||||
public InterruptState getInterrupt() {
|
|
||||||
return interruptState;
|
return interruptState;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public DialogsState getDialogs(){
|
||||||
* This method is used to get the DialogsState
|
|
||||||
*
|
|
||||||
* @return the DialogsState
|
|
||||||
*/
|
|
||||||
public DialogsState getDialogs() {
|
|
||||||
return dialogsState;
|
return dialogsState;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public SettingsState getSettings(){
|
||||||
* This method is used to get the SettingsState
|
|
||||||
*
|
|
||||||
* @return the SettingsState
|
|
||||||
*/
|
|
||||||
public SettingsState getSettings() {
|
|
||||||
return settingsState;
|
return settingsState;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public Notification getNotification(){
|
||||||
* This method is used to get the next notification
|
if(!notifications.isEmpty()){
|
||||||
*
|
|
||||||
* @return the next notification
|
|
||||||
*/
|
|
||||||
public Notification getNotification() {
|
|
||||||
if (!notifications.isEmpty()) {
|
|
||||||
return notifications.remove(0);
|
return notifications.remove(0);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void addNotification(Notification notification){
|
||||||
* This method is used to add a notification
|
|
||||||
*
|
|
||||||
* @param notification the notification to be added
|
|
||||||
*/
|
|
||||||
public void addNotification(Notification notification) {
|
|
||||||
notifications.add(notification);
|
notifications.add(notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,155 +37,159 @@ public String toString(){
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(ActivePlayerMessage msg) {
|
public void received(ActivePlayerMessage msg) {
|
||||||
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
|
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(AnyPieceMessage msg) {
|
public void received(AnyPieceMessage msg) {
|
||||||
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
|
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(BriefingMessage msg) {
|
public void received(BriefingMessage msg) {
|
||||||
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
|
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(CeremonyMessage msg) {
|
public void received(CeremonyMessage msg) {
|
||||||
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
|
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(DieMessage msg) {
|
public void received(DieMessage msg) {
|
||||||
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
|
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(DiceAgainMessage msg) {
|
public void received(DiceAgainMessage msg) {
|
||||||
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
|
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(DiceNowMessage msg) {
|
public void received(DiceNowMessage msg) {
|
||||||
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
|
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(EndOfTurnMessage msg) {
|
public void received(EndOfTurnMessage msg) {
|
||||||
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
|
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(LobbyAcceptMessage msg) {
|
public void received(LobbyAcceptMessage msg) {
|
||||||
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
|
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(LobbyDenyMessage msg) {
|
public void received(LobbyDenyMessage msg) {
|
||||||
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
|
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(LobbyPlayerJoinedMessage msg) {
|
public void received(LobbyPlayerJoinedMessage msg) {
|
||||||
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
|
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(LobbyPlayerLeaveMessage msg) {
|
public void received(LobbyPlayerLeaveMessage msg) {
|
||||||
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
|
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(MoveMessage msg) {
|
public void received(MoveMessage msg) {
|
||||||
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
|
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(NoTurnMessage msg) {
|
public void received(NoTurnMessage msg) {
|
||||||
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
|
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(PauseGameMessage msg) {
|
public void received(PauseGameMessage msg) {
|
||||||
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
|
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(PlayCardMessage msg) {
|
public void received(PlayCardMessage msg) {
|
||||||
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
|
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(PossibleCardsMessage msg) {
|
public void received(PossibleCardMessage msg) {
|
||||||
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
|
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(PossiblePieceMessage msg) {
|
public void received(PossiblePieceMessage msg) {
|
||||||
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
|
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(RankingResponseMessage msg) {
|
public void received(RankingResponseMessage msg) {
|
||||||
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
|
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(RankingRollAgainMessage msg) {
|
public void received(RankingRollAgainMessage msg) {
|
||||||
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
|
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(ReconnectBriefingMessage msg) {
|
public void received(ReconnectBriefingMessage msg) {
|
||||||
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
|
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(ResumeGameMessage msg) {
|
public void received(ResumeGameMessage msg) {
|
||||||
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
|
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(ServerStartGameMessage msg) {
|
public void received(ServerStartGameMessage msg) {
|
||||||
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
|
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(ShutdownMessage msg) {LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());}
|
public void received(ShutdownMessage msg) {LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(StartPieceMessage msg) {
|
public void received(StartPieceMessage msg) {
|
||||||
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
|
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(UpdateReadyMessage msg) {
|
public void received(UpdateReadyMessage msg) {
|
||||||
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
|
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(UpdateTSKMessage msg) {
|
public void received(UpdateTSKMessage msg) {
|
||||||
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
|
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(SpectatorMessage msg) {
|
public void received(SpectatorMessage msg) {
|
||||||
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
|
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(SelectPieceMessage msg) {
|
public void received(SelectPieceMessage msg) {
|
||||||
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
|
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(WaitPieceMessage msg) {
|
public void received(WaitPieceMessage msg) {
|
||||||
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
|
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(IncorrectRequestMessage msg) {
|
public void received(StartBriefingMessage msg) {
|
||||||
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
|
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void received(PlayerDataMessage msg) {
|
||||||
|
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectPiece(Piece piece) {
|
public void selectPiece(Piece piece) {
|
||||||
@@ -248,11 +252,6 @@ public void selectResume(){
|
|||||||
LOGGER.log(Level.DEBUG, "Resume not allowed");
|
LOGGER.log(Level.DEBUG, "Resume not allowed");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is used to create a CeremonyNotification
|
|
||||||
*
|
|
||||||
* @return the created CeremonyNotification
|
|
||||||
*/
|
|
||||||
protected CeremonyNotification createCeremonyNotification(){
|
protected CeremonyNotification createCeremonyNotification(){
|
||||||
CeremonyNotification notification = new CeremonyNotification();
|
CeremonyNotification notification = new CeremonyNotification();
|
||||||
for (var player : logic.getGame().getPlayers().entrySet()){
|
for (var player : logic.getGame().getPlayers().entrySet()){
|
||||||
|
|||||||