Merge branch 'development' into dev/client_koppe2
This commit is contained in:
@@ -30,14 +30,14 @@ public enum Asset {
|
||||
tank,
|
||||
world(1.2f),
|
||||
shieldRing("Models/shieldRing/shieldRing.j3o", null),
|
||||
treeSmall,
|
||||
treeBig,
|
||||
treeSmall(1.2f),
|
||||
treeBig(1.2f),
|
||||
turboCard,
|
||||
turboSymbol("Models/turboCard/turboSymbol.j3o", "Models/turboCard/turboCard_diff.j3o"),
|
||||
turboSymbol("Models/turboCard/turboSymbol.j3o", "Models/turboCard/turboCard_diff.png"),
|
||||
swapCard,
|
||||
swapSymbol("Models/swapCard/swapSymbol.j3o", "Models/swapCard/swapCard_diff.j3o"),
|
||||
swapSymbol("Models/swapCard/swapSymbol.j3o", "Models/swapCard/swapCard_diff.png"),
|
||||
shieldCard,
|
||||
shieldSymbol("Models/shieldCard/shieldSymbol.j3o", "Models/shieldCard/shieldCard_diff.j3o"),
|
||||
shieldSymbol("Models/shieldCard/shieldSymbol.j3o", "Models/shieldCard/shieldCard_diff.png"),
|
||||
dice
|
||||
;
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
import pp.mdga.client.board.OutlineControl;
|
||||
import pp.mdga.client.board.PieceControl;
|
||||
import pp.mdga.client.gui.CardControl;
|
||||
import pp.mdga.client.gui.DiceControl;
|
||||
import pp.mdga.client.view.GameView;
|
||||
import pp.mdga.game.BonusCard;
|
||||
import pp.mdga.game.Color;
|
||||
@@ -26,6 +27,7 @@
|
||||
import pp.mdga.notification.SelectableCardsNotification;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class InputSynchronizer {
|
||||
|
||||
@@ -93,10 +95,14 @@ public void onAction(String name, boolean isPressed, float tpf) {
|
||||
}
|
||||
if(name.equals("Click") && isPressed) {
|
||||
if (app.getView() instanceof GameView gameView) {
|
||||
DiceControl diceSelect = checkHover(gameView.getGuiHandler().getCardLayerCamera(), gameView.getGuiHandler().getCardLayerRootNode(), DiceControl.class);
|
||||
CardControl cardLayerSelect = checkHover(gameView.getGuiHandler().getCardLayerCamera(), gameView.getGuiHandler().getCardLayerRootNode(), CardControl.class);
|
||||
OutlineControl boardSelect = checkHover(app.getCamera(), app.getRootNode(), OutlineControl.class);
|
||||
|
||||
if(cardLayerSelect != null) {
|
||||
if(diceSelect != null) {
|
||||
app.getModelSynchronize().rolledDice();
|
||||
}
|
||||
else if(cardLayerSelect != null) {
|
||||
//cardSelect
|
||||
if(cardLayerSelect.isSelectable()) gameView.getGuiHandler().selectCard(cardLayerSelect);
|
||||
}
|
||||
@@ -118,8 +124,21 @@ else if(boardSelect != null) {
|
||||
}
|
||||
if(name.equals("Test") &&isPressed){
|
||||
if(app.getView() instanceof GameView gameView){
|
||||
// app.getNotificationSynchronizer().addTestNotification(new FinishNotification(Color.NAVY));
|
||||
// app.getNotificationSynchronizer().addTestNotification(new MovePieceNotification());
|
||||
// gameView.getGuiHandler().rollRankingResult(Color.AIRFORCE, 1);
|
||||
// gameView.getGuiHandler().rollRankingResult(Color.ARMY, 2);
|
||||
// gameView.getGuiHandler().rollRankingResult(Color.NAVY, 3);
|
||||
// gameView.getGuiHandler().rollRankingResult(Color.CYBER, 4);
|
||||
// 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);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,18 @@
|
||||
|
||||
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 pp.mdga.client.dialog.JoinDialog;
|
||||
import pp.mdga.client.view.*;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.prefs.Preferences;
|
||||
@@ -39,7 +45,7 @@ public class MdgaApp extends SimpleApplication {
|
||||
private MdgaState state = null;
|
||||
|
||||
/** Scale for rendering images. */
|
||||
private float imageScale = prefs.getInt("scale", 1);
|
||||
private final float imageScale = prefs.getInt("scale", 1);
|
||||
|
||||
/** The main menu view. */
|
||||
private MdgaView mainView;
|
||||
@@ -60,7 +66,7 @@ public class MdgaApp extends SimpleApplication {
|
||||
|
||||
private ServerConnection networkConnection;
|
||||
|
||||
private MdgaApp() {
|
||||
public MdgaApp() {
|
||||
networkConnection = new NetworkSupport(this);
|
||||
this.clientGameLogic = new ClientGameLogic(networkConnection);
|
||||
}
|
||||
@@ -76,12 +82,15 @@ public static void main(String[] args) {
|
||||
settings.setSamples(128);
|
||||
settings.setWidth(prefs.getInt("width", 1280));
|
||||
settings.setHeight(prefs.getInt("height", 720));
|
||||
settings.setFullscreen(prefs.getBoolean("fullscreen", false));
|
||||
settings.setCenterWindow(true);
|
||||
settings.setVSync(false);
|
||||
|
||||
settings.setTitle("MDGA");
|
||||
MdgaApp app = new MdgaApp();
|
||||
app.setSettings(settings);
|
||||
app.setShowSettings(false);
|
||||
app.setPauseOnLostFocus(false);
|
||||
|
||||
app.start();
|
||||
}
|
||||
|
||||
@@ -106,7 +115,7 @@ public void simpleInitApp() {
|
||||
gameView = new GameView(this);
|
||||
ceremonyView = new CeremonyView(this);
|
||||
|
||||
enter(MdgaState.MAIN);
|
||||
enter(MdgaState.GAME);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -244,30 +253,50 @@ public ServerConnection getNetworkSupport(){
|
||||
return networkConnection;
|
||||
}
|
||||
|
||||
public void updateResolution(int width, int height, float imageFactor) {
|
||||
prefs.putInt("width", width);
|
||||
prefs.putInt("height", height);
|
||||
prefs.putFloat("scale", imageFactor);
|
||||
public void updateResolution(int width, int height, float imageFactor, boolean isFullscreen) {
|
||||
if(isFullscreen) {
|
||||
int baseWidth = 1280;
|
||||
int baseHeight = 720;
|
||||
float baseAspectRatio = (float) baseWidth / baseHeight;
|
||||
float newAspectRatio = (float) width / height;
|
||||
|
||||
try {
|
||||
restartApp();
|
||||
} catch (Exception e) {
|
||||
//nothing
|
||||
float scaleFactor = Math.max((float) width / baseWidth, (float) height / baseHeight);
|
||||
|
||||
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() throws IOException {
|
||||
String javaBin = System.getProperty("java.home") + "/bin/java";
|
||||
String classPath = System.getProperty("java.class.path");
|
||||
String className = System.getProperty("sun.java.command");
|
||||
public static void restartApp() {
|
||||
try {
|
||||
String javaBin = System.getProperty("java.home") + "/bin/java";
|
||||
String classPath = System.getProperty("java.class.path");
|
||||
String className = System.getProperty("sun.java.command");
|
||||
|
||||
ProcessBuilder builder = new ProcessBuilder(
|
||||
javaBin, "-cp", classPath, className
|
||||
);
|
||||
ProcessBuilder builder = new ProcessBuilder(
|
||||
javaBin, "-cp", classPath, className
|
||||
);
|
||||
|
||||
builder.start();
|
||||
builder.start();
|
||||
|
||||
System.exit(0);
|
||||
System.exit(0);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("restart failed");
|
||||
}
|
||||
}
|
||||
|
||||
public void afterGameCleanup() {
|
||||
MainView main = (MainView) mainView;
|
||||
|
||||
main.getJoinDialog().disconnect();
|
||||
main.getHostDialog().shutdownServer();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,32 +26,42 @@ public void addTestNotification(Notification n) {
|
||||
|
||||
public void update() {
|
||||
Notification n = app.getGameLogic().getNotification();
|
||||
|
||||
if(n != null) {
|
||||
switch (app.getState()) {
|
||||
case MAIN:
|
||||
handleMain(n);
|
||||
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.toString());
|
||||
while (n != null) {
|
||||
if(n instanceof InfoNotification infoNotification) {
|
||||
app.getView().showInfo(infoNotification.getMessage(), infoNotification.isError());
|
||||
return;
|
||||
}
|
||||
|
||||
if(n != null) {
|
||||
switch (app.getState()) {
|
||||
case MAIN:
|
||||
handleMain(n);
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
n = app.getGameLogic().getNotification();
|
||||
}
|
||||
}
|
||||
|
||||
private void handleMain(Notification notification) {
|
||||
if (notification instanceof LobbyDialogNotification) {
|
||||
app.enter(MdgaState.LOBBY);
|
||||
} else if (notification instanceof StartDialogNotification) {
|
||||
//nothing
|
||||
} else {
|
||||
throw new RuntimeException("notification not expected: ");
|
||||
throw new RuntimeException("notification not expected in main: "+ notification.getClass().getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,6 +71,7 @@ private void handleLobby(Notification notification) {
|
||||
if (notification instanceof TskSelectNotification n) {
|
||||
lobbyView.setTaken(n.getColor(), true, n.isSelf(), n.getName());
|
||||
} else if (notification instanceof StartDialogNotification) {
|
||||
app.afterGameCleanup();
|
||||
app.enter(MdgaState.MAIN);
|
||||
} else if (notification instanceof TskUnselectNotification n) {
|
||||
lobbyView.setTaken(n.getColor(), false, false, null);
|
||||
@@ -70,7 +81,7 @@ private void handleLobby(Notification notification) {
|
||||
app.enter(MdgaState.GAME);
|
||||
((GameView) app.getView()).setOwnColor(n.getOwnColor());
|
||||
} else {
|
||||
throw new RuntimeException("notification not expected: " + notification.toString());
|
||||
throw new RuntimeException("notification not expected in lobby: " + notification.getClass().getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +92,7 @@ private void handleGame(Notification notification) {
|
||||
ModelSynchronizer modelSynchronizer = app.getModelSynchronize();
|
||||
|
||||
if (notification instanceof AcquireCardNotification n) {
|
||||
guiHandler.addCard(n.getBonusCard());
|
||||
guiHandler.addCardOwn(n.getBonusCard());
|
||||
} else if (notification instanceof ActivePlayerNotification n) {
|
||||
gameView.getGuiHandler().setActivePlayer(n.getColor());
|
||||
boardHandler.showDice(n.getColor());
|
||||
@@ -136,18 +147,15 @@ private void handleGame(Notification notification) {
|
||||
} else if (notification instanceof NoShieldNotification n) {
|
||||
boardHandler.unshieldPiece(n.getPieceId());
|
||||
} else if (notification instanceof PlayCardNotification n) {
|
||||
switch(n.getCard()){
|
||||
case SWAP -> guiHandler.swap();
|
||||
case TURBO -> guiHandler.turbo();
|
||||
case SHIELD -> guiHandler.shield();
|
||||
default -> throw new RuntimeException("invalid card");
|
||||
}
|
||||
if(n.getColor() == gameView.getOwnColor()) guiHandler.playCardOwn(n.getCard());
|
||||
else guiHandler.playCardEnemy(n.getColor(), n.getCard());
|
||||
} else if (notification instanceof PlayerInGameNotification n) {
|
||||
boardHandler.addPlayer(n.getColor(),n.getPiecesList());
|
||||
guiHandler.addPlayer(n.getColor(),n.getName());
|
||||
} else if (notification instanceof ResumeNotification) {
|
||||
//ignore
|
||||
} else if (notification instanceof RollDiceNotification n) {
|
||||
gameView.getGuiHandler().hideText();
|
||||
if(n.getColor() == gameView.getOwnColor()){
|
||||
guiHandler.rollDice(n.getEyes(), n.isTurbo() ? n.getMultiplier() : -1);
|
||||
}
|
||||
@@ -163,6 +171,7 @@ private void handleGame(Notification notification) {
|
||||
} else if (notification instanceof ShieldSuppressedNotification n) {
|
||||
boardHandler.suppressShield(n.getPieceId());
|
||||
} else if (notification instanceof StartDialogNotification) {
|
||||
app.afterGameCleanup();
|
||||
app.enter(MdgaState.MAIN);
|
||||
} else if (notification instanceof SwapPieceNotification n) {
|
||||
// boardHandler.swapPieces(n.getFirstPiece(), n.getSecondPiece());
|
||||
@@ -183,15 +192,16 @@ private void handleGame(Notification notification) {
|
||||
} else if (notification instanceof FinishNotification n){
|
||||
guiHandler.finish(n.getColorFinished());
|
||||
} else {
|
||||
throw new RuntimeException("notification not expected: " + notification.toString());
|
||||
throw new RuntimeException("notification not expected in game: " + notification.getClass().getName());
|
||||
}
|
||||
}
|
||||
|
||||
private void handleCeremony(Notification notification) {
|
||||
if (notification instanceof StartDialogNotification) {
|
||||
app.afterGameCleanup();
|
||||
app.enter(MdgaState.MAIN);
|
||||
} else {
|
||||
throw new RuntimeException("notification not expected: " + notification.toString());
|
||||
throw new RuntimeException("notification not expected in ceremony: " + notification.getClass().getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
import com.jme3.math.Quaternion;
|
||||
import com.jme3.math.Vector3f;
|
||||
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.shadow.DirectionalLightShadowFilter;
|
||||
import com.jme3.shadow.EdgeFilteringMode;
|
||||
@@ -37,6 +39,8 @@ public class CameraHandler {
|
||||
private Color ownColor;
|
||||
private boolean init;
|
||||
private boolean initRot;
|
||||
private SSAOFilter ssaoFilter;
|
||||
private FXAAFilter fxaaFilter;
|
||||
|
||||
/**
|
||||
* Constructor for the CameraHandler. Initializes the camera settings and lighting.
|
||||
@@ -65,6 +69,9 @@ public CameraHandler(MdgaApp app, FilterPostProcessor fpp) {
|
||||
dlsf.setEnabled(true);
|
||||
dlsf.setEdgeFilteringMode(EdgeFilteringMode.PCFPOISSON);
|
||||
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);
|
||||
|
||||
@@ -82,6 +89,8 @@ public void init(Color ownColor) {
|
||||
app.getRootNode().addLight(ambient);
|
||||
app.getRootNode().attachChild(sky);
|
||||
fpp.addFilter(dlsf);
|
||||
fpp.addFilter(ssaoFilter);
|
||||
fpp.addFilter(fxaaFilter);
|
||||
init = true;
|
||||
initRot = true;
|
||||
this.ownColor = ownColor;
|
||||
|
||||
@@ -107,8 +107,8 @@ private static Asset getLoadedAsset(String assetName) {
|
||||
case "radar" -> Asset.radar;
|
||||
case "ship" -> Asset.ship;
|
||||
case "tank" -> Asset.tank;
|
||||
case "tree_small" -> Asset.treeSmall;
|
||||
case "tree_big" -> Asset.treeBig;
|
||||
case "treeSmall" -> Asset.treeSmall;
|
||||
case "treeBig" -> Asset.treeBig;
|
||||
default -> throw new IllegalStateException("Unexpected value: " + assetName);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -92,4 +92,16 @@ public void resetPort() {
|
||||
public void connectToServer() {
|
||||
connectServer();
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
NetworkSupport network = getNetwork();
|
||||
if (network != null) {
|
||||
try {
|
||||
network.disconnect();
|
||||
} catch (Exception e) {
|
||||
System.err.println("Error while disconnecting: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@ public abstract class NetworkDialog extends Dialog {
|
||||
private String hostname;
|
||||
private int portNumber;
|
||||
private Future<Object> connectionFuture;
|
||||
private MdgaServer serverInstance;
|
||||
private Thread serverThread;
|
||||
|
||||
public NetworkDialog(MdgaApp app, Node node, NetworkSupport network) {
|
||||
super(app, node);
|
||||
@@ -28,7 +30,6 @@ public void setPortNumber(int portNumber) {
|
||||
this.portNumber = portNumber;
|
||||
}
|
||||
|
||||
|
||||
protected Object initNetwork() {
|
||||
try {
|
||||
this.network.initNetwork(this.hostname, this.portNumber);
|
||||
@@ -39,25 +40,49 @@ protected Object initNetwork() {
|
||||
}
|
||||
|
||||
protected void connectServer() {
|
||||
|
||||
try {
|
||||
connectionFuture = this.network.getApp().getExecutor().submit(this::initNetwork);
|
||||
} catch (NumberFormatException var2) {
|
||||
throw new NumberFormatException("Port must be a number");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void startServer() {
|
||||
(new Thread(() -> {
|
||||
serverThread = new Thread(() -> {
|
||||
try {
|
||||
MdgaServer mdgaServer = new MdgaServer(portNumber);
|
||||
mdgaServer.run();
|
||||
serverInstance = new MdgaServer(portNumber);
|
||||
serverInstance.run();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
|
||||
})).start();
|
||||
serverThread.start();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
public void update(float delta) {
|
||||
@@ -65,14 +90,14 @@ public void update(float delta) {
|
||||
try {
|
||||
this.connectionFuture.get();
|
||||
} catch (ExecutionException ignored) {
|
||||
// todo: implement
|
||||
// TODO: implement
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public NetworkSupport getNetwork(){
|
||||
public NetworkSupport getNetwork() {
|
||||
return network;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,6 +177,109 @@ public String getName() {
|
||||
"CarryPro",
|
||||
"ProBaiter",
|
||||
"GameWarden",
|
||||
"KartoffelKönig",
|
||||
"SaufenderWolf",
|
||||
"WurstGriller",
|
||||
"Flitzekacke",
|
||||
"BratwurstBub",
|
||||
"Hoppeldoppels",
|
||||
"BananenMensch",
|
||||
"KlopapierGuru",
|
||||
"SchnitzelKing",
|
||||
"NerdNomade",
|
||||
"Dönertänzer",
|
||||
"GlitzerGurke",
|
||||
"SchinkenShrek",
|
||||
"KäseKalle",
|
||||
"SchokoSchnecke",
|
||||
"KeksKämpfer",
|
||||
"QuarkPiraten",
|
||||
"Müslimonster",
|
||||
"KnuddelNase",
|
||||
"FantaFighter",
|
||||
"SchnapsSaurier",
|
||||
"Wackelpudding",
|
||||
"ZitronenZock",
|
||||
"FettWurst",
|
||||
"PlüschPanda",
|
||||
"Zuckerschnur",
|
||||
"FluffiKopf",
|
||||
"DonutDöner",
|
||||
"VollpfostenX",
|
||||
"Schraubenschlüssel",
|
||||
"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",
|
||||
"KampfKohlenhydrate",
|
||||
"SockenZirkus",
|
||||
"SchwimmBärchen",
|
||||
"TanzenderDachgepäckträger",
|
||||
"PizzamarktMensch",
|
||||
"ZahnarztZocker",
|
||||
"RollerCoasterTester",
|
||||
"WaschmaschinenPilot",
|
||||
"WitzigeZwiebel",
|
||||
"Pillenschlucker",
|
||||
"ZwiebelReiter",
|
||||
"HüpfenderKaktus",
|
||||
"KochenderAsteroid",
|
||||
"ChaosKarotte",
|
||||
"WolkenFurz",
|
||||
"SchnitzelPartikel",
|
||||
"WackelBiene",
|
||||
};
|
||||
|
||||
Random random = new Random();
|
||||
|
||||
@@ -3,13 +3,20 @@
|
||||
import com.jme3.math.Vector2f;
|
||||
import com.jme3.scene.Node;
|
||||
import pp.mdga.client.MdgaApp;
|
||||
import pp.mdga.client.button.AbstractButton;
|
||||
import pp.mdga.client.button.ButtonLeft;
|
||||
import pp.mdga.client.button.ButtonRight;
|
||||
import pp.mdga.client.button.MenuButton;
|
||||
import pp.mdga.client.view.MdgaView;
|
||||
|
||||
import java.util.prefs.Preferences;
|
||||
|
||||
public class VideoSettingsDialog extends Dialog {
|
||||
private static Preferences prefs = Preferences.userNodeForPackage(JoinDialog.class);
|
||||
|
||||
private ButtonRight fullscreenButton;
|
||||
private MenuButton backButton;
|
||||
private ButtonRight restartButton;
|
||||
|
||||
private ButtonLeft hdButton9;
|
||||
private ButtonLeft fullHdButton9;
|
||||
@@ -29,20 +36,24 @@ public VideoSettingsDialog(MdgaApp app, Node node, MdgaView view) {
|
||||
|
||||
backButton = new MenuButton(app, node, view::leaveVideoSettings, "Zurück");
|
||||
|
||||
// MenuButton für verschiedene Auflösungen erstellen
|
||||
hdButton9 = new ButtonLeft(app, node, () -> app.updateResolution(1280, 720, 1.0f), "hd 16:9", 10);
|
||||
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);
|
||||
restartButton = new ButtonRight(app, node, MdgaApp::restartApp, "Neustart", 1);
|
||||
|
||||
fullscreenButton = new ButtonRight(app, node, () -> updateResolution(0, 0, 0, true), "Vollbild", 1);
|
||||
|
||||
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, () -> app.updateResolution(1280, 800, 1.0f), "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, () -> app.updateResolution(2560, 1600, 4.0f), "wqhd 16:10", 10);
|
||||
hdButton10 = new ButtonRight(app, node, () -> updateResolution(1280, 800, 1.0f, false), "hd 16:10", 10);
|
||||
fullHdButton10 = new ButtonRight(app, node, () -> updateResolution(1920, 1200, 2.25f, false), "full hd 16:10", 10);
|
||||
wqhdButton10 = new ButtonRight(app, node, () -> updateResolution(2560, 1600, 4.0f, false), "wqhd 16:10", 10);
|
||||
|
||||
float offset = 2.8f;
|
||||
|
||||
hdButton9.setPos(new Vector2f(hdButton9.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;
|
||||
|
||||
fullHdButton9.setPos(new Vector2f(fullHdButton9.getPos().x, MenuButton.VERTICAL - offset));
|
||||
@@ -68,6 +79,7 @@ protected void onShow() {
|
||||
fullHdButton10.show();
|
||||
wqhdButton10.show();
|
||||
|
||||
fullscreenButton.show();
|
||||
backButton.show();
|
||||
}
|
||||
|
||||
@@ -83,7 +95,9 @@ protected void onHide() {
|
||||
fullHdButton10.hide();
|
||||
wqhdButton10.hide();
|
||||
|
||||
fullscreenButton.hide();
|
||||
backButton.hide();
|
||||
restartButton.hide();
|
||||
}
|
||||
|
||||
public void update() {
|
||||
@@ -91,4 +105,12 @@ public void update() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
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,19 +10,20 @@
|
||||
import pp.mdga.client.animation.ZoomControl;
|
||||
import pp.mdga.game.Color;
|
||||
|
||||
public class ActionTextHandler {
|
||||
class ActionTextHandler {
|
||||
private Node root;
|
||||
private BitmapFont font;
|
||||
private AppSettings appSettings;
|
||||
private int ranking;
|
||||
|
||||
public ActionTextHandler(Node guiNode, AssetManager assetManager, AppSettings appSettings){
|
||||
ActionTextHandler(Node guiNode, AssetManager assetManager, AppSettings appSettings){
|
||||
root = new Node("actionTextRoot");
|
||||
guiNode.attachChild(root);
|
||||
|
||||
root.setLocalTranslation(center(appSettings.getWidth(), appSettings.getHeight(), Vector3f.ZERO));
|
||||
font = assetManager.loadFont("Fonts/Gunplay.fnt");
|
||||
this.appSettings = appSettings;
|
||||
|
||||
ranking = 0;
|
||||
}
|
||||
|
||||
private Node createTextWithSpacing(String[] textArr, float spacing, float size, ColorRGBA[] colorArr) {
|
||||
@@ -74,48 +75,48 @@ private Vector3f centerText(float width, float height, Vector3f pos){
|
||||
return center(-width, height, pos);
|
||||
}
|
||||
|
||||
public 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());
|
||||
}
|
||||
|
||||
public 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());
|
||||
}
|
||||
|
||||
public 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(String.valueOf(diceNum), 10, 100, ColorRGBA.White, 100);
|
||||
|
||||
}
|
||||
|
||||
public 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[]{String.valueOf(diceNum), " x" + mult + " = " + (diceNum*mult)}, 20, 100, new ColorRGBA[]{ColorRGBA.White,ColorRGBA.Red}, 100);
|
||||
}
|
||||
|
||||
public void ownDice(int diceNum){
|
||||
void ownDice(int diceNum){
|
||||
createTopText(String.valueOf(diceNum), 10, 100, ColorRGBA.White, 0);
|
||||
}
|
||||
|
||||
public 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);
|
||||
}
|
||||
|
||||
public 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());
|
||||
}
|
||||
|
||||
public 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());
|
||||
}
|
||||
|
||||
public 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());
|
||||
}
|
||||
|
||||
public 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());
|
||||
}
|
||||
|
||||
@@ -131,9 +132,25 @@ private ColorRGBA playerColorToColorRGBA(Color color){
|
||||
};
|
||||
}
|
||||
|
||||
public void hide(){
|
||||
root.detachAllChildren();
|
||||
void hide(){
|
||||
ranking = 0;
|
||||
root.detachAllChildren();
|
||||
}
|
||||
|
||||
float paddingRanked = 100;
|
||||
|
||||
void rollRankingResult(String name, Color color, int eye){
|
||||
createTopText(new String[]{name,": "+eye}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, paddingRanked*ranking);
|
||||
ranking++;
|
||||
}
|
||||
|
||||
void rollRankingResultOwn(Color color, int eye){
|
||||
createTopText(new String[]{"Du",": "+eye}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, paddingRanked*ranking);
|
||||
ranking++;
|
||||
}
|
||||
|
||||
void diceNow(){
|
||||
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");
|
||||
mat.setColor("Color", ColorRGBA.Black);
|
||||
circle.setMaterial(mat);
|
||||
root.attachChild(circle);
|
||||
// root.attachChild(circle);
|
||||
BitmapFont guiFont = getApp().getAssetManager().loadFont("Fonts/Gunplay.fnt");
|
||||
num = new BitmapText(guiFont);
|
||||
num.setSize(0.3f);
|
||||
|
||||
@@ -86,7 +86,7 @@ public void render(RenderManager rm) {
|
||||
public void update(float tpf) {
|
||||
if (init && !cardBuffer.isEmpty()) {
|
||||
for (Spatial spatial : cardBuffer) {
|
||||
root.attachChild(spatial);
|
||||
// root.attachChild(spatial);
|
||||
}
|
||||
cardBuffer.clear();
|
||||
}
|
||||
@@ -94,7 +94,9 @@ public void update(float tpf) {
|
||||
}
|
||||
|
||||
public void addSpatial(Spatial card) {
|
||||
cardBuffer.add(card);
|
||||
// cardBuffer.add(card);
|
||||
root.attachChild(card);
|
||||
root = root;
|
||||
}
|
||||
|
||||
public void deleteSpatial(Spatial spatial) {
|
||||
|
||||
@@ -85,6 +85,19 @@ public void addCard(BonusCard card) {
|
||||
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() {
|
||||
for (CardControl control : selectableCards) {
|
||||
control.setSelectable(false);
|
||||
|
||||
@@ -67,14 +67,38 @@ public void showRolledDice(int rollNum, Color color) {
|
||||
|
||||
public void showDice() {
|
||||
cardLayerHandler.showDice();
|
||||
actionTextHandler.diceNow();
|
||||
}
|
||||
|
||||
public void hideDice() {
|
||||
cardLayerHandler.hideDice();
|
||||
}
|
||||
|
||||
public void addCard(BonusCard card) {
|
||||
//add own handCard
|
||||
public void addCardOwn(BonusCard 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() {
|
||||
@@ -124,9 +148,11 @@ public void hideText(){
|
||||
actionTextHandler.hide();
|
||||
}
|
||||
|
||||
//addCard Enemy (DrawCardNotification)
|
||||
public void drawCard(Color color) {
|
||||
if (ownColor == color) actionTextHandler.drawCardOwn(color);
|
||||
else actionTextHandler.drawCard(playerNameHandler.getName(color), color);
|
||||
//Color != ownColor
|
||||
actionTextHandler.drawCard(playerNameHandler.getName(color), color);
|
||||
playerNameHandler.addCard(color);
|
||||
}
|
||||
|
||||
public void finish(Color color){
|
||||
@@ -134,5 +160,12 @@ public void finish(Color color){
|
||||
else actionTextHandler.finishText(playerNameHandler.getName(color), color);
|
||||
}
|
||||
|
||||
public void rollRankingResult(Color color, int eye){
|
||||
if(ownColor == color) actionTextHandler.rollRankingResultOwn(color, eye);
|
||||
else actionTextHandler.rollRankingResult(playerNameHandler.getName(color), color, eye);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -4,23 +4,27 @@
|
||||
import com.jme3.font.BitmapFont;
|
||||
import com.jme3.font.BitmapText;
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.scene.Node;
|
||||
import com.jme3.scene.Spatial;
|
||||
import com.jme3.system.AppSettings;
|
||||
import com.jme3.ui.Picture;
|
||||
import pp.mdga.game.BonusCard;
|
||||
import pp.mdga.game.Color;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
public class PlayerNameHandler {
|
||||
private final BitmapFont playerFont;
|
||||
private final Node playerNameNode;
|
||||
private final List<Color> playerOrder;
|
||||
private final Map<Color, String> colorNameMap;
|
||||
private final Map<Color, Integer> colorCardMap;
|
||||
|
||||
private final AppSettings appSettings;
|
||||
private final AssetManager assetManager;
|
||||
private Color ownColor;
|
||||
@@ -43,6 +47,7 @@ public PlayerNameHandler(Node guiNode, AssetManager assetManager, AppSettings ap
|
||||
playerNameNode = new Node("player name node");
|
||||
playerOrder = new ArrayList<>();
|
||||
colorNameMap = new HashMap<>();
|
||||
colorCardMap = new HashMap<>();
|
||||
this.appSettings = appSettings;
|
||||
this.assetManager = assetManager;
|
||||
}
|
||||
@@ -64,13 +69,38 @@ private void drawPlayers(){
|
||||
if(!colorNameMap.containsKey(color)) throw new RuntimeException(color + " isn't mapped to a name");
|
||||
|
||||
Node nameParent = new Node("nameParent");
|
||||
nameParent.attachChild(createName(colorNameMap.get(color), i == 0, color == ownColor));
|
||||
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);
|
||||
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){
|
||||
String root = "./Images/name_pictures/";
|
||||
return switch(color){
|
||||
@@ -93,7 +123,7 @@ private Spatial createColor(Color color) {
|
||||
|
||||
|
||||
|
||||
private Spatial createName(String name, boolean first, boolean own){
|
||||
private BitmapText createName(String name, boolean first, boolean own){
|
||||
BitmapText hudText = new BitmapText(playerFont);
|
||||
//renderedSize = 45
|
||||
hudText.setSize(TEXT_SIZE);
|
||||
@@ -120,8 +150,22 @@ public void setActivePlayer(Color color) {
|
||||
}
|
||||
|
||||
public String getName(Color color){
|
||||
if(!colorNameMap.containsKey(color)) throw new RuntimeException("color is not in colorNameMap");
|
||||
return colorNameMap.get(color);
|
||||
}
|
||||
|
||||
public void addCard(Color color){
|
||||
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,6 +3,7 @@
|
||||
import com.jme3.network.*;
|
||||
import com.jme3.network.serializing.Serializer;
|
||||
import com.jme3.network.serializing.serializers.EnumSerializer;
|
||||
import pp.mdga.Resources;
|
||||
import pp.mdga.game.*;
|
||||
import pp.mdga.message.client.*;
|
||||
import pp.mdga.message.server.*;
|
||||
@@ -135,6 +136,7 @@ private void initializeSerializables() {
|
||||
Serializer.registerClass(UpdateReadyMessage.class);
|
||||
Serializer.registerClass(UpdateTSKMessage.class);
|
||||
Serializer.registerClass(WaitPieceMessage.class);
|
||||
Serializer.registerClass(IncorrectRequestMessage.class);
|
||||
Serializer.registerClass(Player.class);
|
||||
Serializer.registerClass(Statistic.class);
|
||||
Serializer.registerClass(Board.class);
|
||||
@@ -144,8 +146,10 @@ private void initializeSerializables() {
|
||||
Serializer.registerClass(StartNode.class);
|
||||
Serializer.registerClass(PlayerData.class);
|
||||
Serializer.registerClass(HomeNode.class);
|
||||
Serializer.registerClass(PlayerDataMessage.class);
|
||||
Serializer.registerClass(StartBriefingMessage.class);
|
||||
|
||||
Serializer.registerClass(Color.class, new EnumSerializer());
|
||||
Serializer.registerClass(PieceState.class, new EnumSerializer());
|
||||
Serializer.registerClass(ShieldState.class, new EnumSerializer());
|
||||
}
|
||||
|
||||
private void registerListeners() {
|
||||
@@ -198,12 +202,31 @@ private void messageReceived(HostedConnection source, ClientMessage message) {
|
||||
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
|
||||
public void connectionAdded(Server server, HostedConnection hostedConnection) {
|
||||
System.out.println("new connection " + hostedConnection); //NON-NLS
|
||||
LOGGER.log(Level.DEBUG, "new connection {0}", hostedConnection); //NON-NLS
|
||||
if (this.myServer.getConnections().size() == 1) {
|
||||
this.logic.getGame().setHost(hostedConnection.getId());
|
||||
|
||||
if (this.myServer.getConnections().size() > Resources.MAX_PLAYERS) {
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,4 +301,21 @@ public void broadcast(ServerMessage message) {
|
||||
public void disconnectClient(int id) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +65,13 @@ public void onEnter() {
|
||||
|
||||
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
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
import pp.mdga.client.button.LobbyButton;
|
||||
import pp.mdga.client.button.SettingsButton;
|
||||
import pp.mdga.game.Color;
|
||||
import pp.mdga.message.client.StartGameMessage;
|
||||
import pp.mdga.notification.GameNotification;
|
||||
|
||||
public class LobbyView extends MdgaView {
|
||||
@@ -25,6 +26,7 @@ public class LobbyView extends MdgaView {
|
||||
|
||||
private ButtonLeft leaveButton;
|
||||
private ButtonRight readyButton;
|
||||
private ButtonRight startButton;
|
||||
|
||||
private LobbyButton cyberButton;
|
||||
private LobbyButton airforceButton;
|
||||
@@ -42,6 +44,7 @@ public LobbyView(MdgaApp app) {
|
||||
|
||||
leaveButton = new ButtonLeft(app, guiNode, this::leaveLobby, "Verlassen", 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);
|
||||
airforceButton = new LobbyButton(app, guiNode, rootNode, () -> toggleTsk(Color.AIRFORCE), Color.AIRFORCE);
|
||||
@@ -61,6 +64,10 @@ public void onEnter() {
|
||||
leaveButton.show();
|
||||
readyButton.show();
|
||||
|
||||
if(app.getGameLogic().isHost()) {
|
||||
startButton.show();
|
||||
}
|
||||
|
||||
cyberButton.show();
|
||||
airforceButton.show();
|
||||
armyButton.show();
|
||||
@@ -95,6 +102,7 @@ public void onEnter() {
|
||||
public void onLeave() {
|
||||
leaveButton.hide();
|
||||
readyButton.hide();
|
||||
startButton.hide();
|
||||
|
||||
airforceButton.hide();
|
||||
armyButton.hide();
|
||||
@@ -223,6 +231,10 @@ private void toggleTsk(Color color) {
|
||||
break;
|
||||
}
|
||||
|
||||
if(isReady) {
|
||||
setReady(own, false);
|
||||
}
|
||||
|
||||
switch (taken) {
|
||||
case NOT:
|
||||
app.getModelSynchronize().selectTsk(color);
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
package pp.mdga.client.view;
|
||||
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Vector2f;
|
||||
import com.jme3.scene.Geometry;
|
||||
import pp.mdga.client.MdgaApp;
|
||||
import pp.mdga.client.acoustic.MdgaSound;
|
||||
import pp.mdga.client.button.AbstractButton;
|
||||
import pp.mdga.client.button.LabelButton;
|
||||
import pp.mdga.client.dialog.HostDialog;
|
||||
import pp.mdga.client.dialog.JoinDialog;
|
||||
import pp.mdga.client.dialog.StartDialog;
|
||||
@@ -96,6 +100,7 @@ private void mainMenu() {
|
||||
private void tryHost() {
|
||||
int port = 0;
|
||||
String text = hostDialog.getPort();
|
||||
app.getGameLogic().selectHost("");
|
||||
|
||||
try {
|
||||
port = Integer.parseInt(text);
|
||||
@@ -108,10 +113,6 @@ private void tryHost() {
|
||||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
hostDialog.connectServerAsClient();
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
app.getModelSynchronize().setHost(port);
|
||||
//app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT);
|
||||
return;
|
||||
@@ -127,6 +128,7 @@ private void tryJoin() {
|
||||
int port = 0;
|
||||
String ip = joinDialog.getIpt();
|
||||
String portText = joinDialog.getPort();
|
||||
app.getGameLogic().selectJoin("");
|
||||
|
||||
try {
|
||||
// Validate the port
|
||||
@@ -140,11 +142,6 @@ private void tryJoin() {
|
||||
app.getModelSynchronize().setName(startDialog.getName());
|
||||
joinDialog.setHostname(ip);
|
||||
joinDialog.connectToServer();
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
app.getModelSynchronize().setJoin(ip, port);
|
||||
return;
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
@@ -234,5 +231,13 @@ public void back() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public JoinDialog getJoinDialog() {
|
||||
return joinDialog;
|
||||
}
|
||||
|
||||
public HostDialog getHostDialog() {
|
||||
return hostDialog;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,12 @@
|
||||
|
||||
import com.jme3.asset.TextureKey;
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Vector2f;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.Node;
|
||||
import com.jme3.scene.shape.Quad;
|
||||
import com.jme3.system.NanoTimer;
|
||||
import com.jme3.texture.Texture;
|
||||
import pp.mdga.client.MdgaApp;
|
||||
import pp.mdga.client.acoustic.MdgaSound;
|
||||
@@ -30,6 +33,9 @@ public enum Overlay {
|
||||
private VideoSettingsDialog videoSettingsDialog;
|
||||
private AudioSettingsDialog audioSettingsDialog;
|
||||
|
||||
protected LabelButton infoLabel = null;
|
||||
protected NanoTimer infoTimer = new NanoTimer();
|
||||
|
||||
private int settingsDepth = 0;
|
||||
|
||||
public MdgaView(MdgaApp app) {
|
||||
@@ -80,6 +86,11 @@ public void update(float tpf) {
|
||||
videoSettingsDialog.update();
|
||||
audioSettingsDialog.update();
|
||||
|
||||
if (null != infoLabel && infoTimer.getTimeInSeconds() > 5) {
|
||||
infoLabel.hide();
|
||||
infoLabel = null;
|
||||
}
|
||||
|
||||
onUpdate(tpf);
|
||||
}
|
||||
|
||||
@@ -193,4 +204,24 @@ public void pressForward() {
|
||||
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/handcard.png
Normal file
BIN
Projekte/mdga/client/src/main/resources/Images/handcard.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
@@ -1,7 +1,5 @@
|
||||
world 0,0 90
|
||||
|
||||
#tree_small 1,1 0
|
||||
#tree_big 0,0 0
|
||||
|
||||
#Marine Pos
|
||||
marine 4,-5 270
|
||||
@@ -131,3 +129,144 @@ node_home_blue 4,0 0
|
||||
node_home_blue 3,0 0
|
||||
node_home_blue 2,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
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 0 B After Width: | Height: | Size: 93 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 0 B After Width: | Height: | Size: 59 KiB |
Reference in New Issue
Block a user