fixed bad performancegit status!; edited GameNotification; fixed error because of changed 'Color' enum

This commit is contained in:
Cedric Beck
2024-12-01 17:03:09 +01:00
parent 772c7a51e0
commit eb703cbd2c
12 changed files with 40 additions and 49 deletions

View File

@@ -35,7 +35,7 @@ public class MdgaApp extends SimpleApplication {
private MdgaState state = null;
/** Scale for rendering images. */
private static final float imageScale = 1.5f;
private static final float IMAGE_SCALE = 1.5f;
/** The main menu view. */
private MdgaView mainView;
@@ -59,8 +59,8 @@ public static void main(String[] args) {
AppSettings settings = new AppSettings(true);
settings.setSamples(128);
settings.setCenterWindow(true);
settings.setWidth(1920);
settings.setHeight(1080);
settings.setWidth(1800);
settings.setHeight(900);
settings.setVSync(false);
MdgaApp app = new MdgaApp();
@@ -91,7 +91,7 @@ public void simpleInitApp() {
gameView = new GameView(this);
ceremonyView = new CeremonyView(this);
enter(MdgaState.MAIN);
enter(MdgaState.LOBBY);
}
/**
@@ -174,7 +174,7 @@ public MdgaState getState() {
* @return the image scale as a float
*/
public float getImageScale() {
return imageScale;
return IMAGE_SCALE;
}
/**

View File

@@ -64,8 +64,9 @@ private void handleLobby(Notification notification) {
lobbyView.setTaken(n.getColor(), false, false, null);
//} else if(notification instanceof LobbyReadyNotification lobbyReadyNotification) {
//lobbyView.setReady(lobbyReadyNotification.getColor(), lobbyReadyNotification.isReady()):
} else if (notification instanceof GameNotification) {
} else if (notification instanceof GameNotification n) {
app.enter(MdgaState.GAME);
((GameView) app.getView()).setOwnColor(n.getOwnColor());
} else {
throw new RuntimeException("notification not expected: " + notification.toString());
}

View File

@@ -30,7 +30,7 @@ public class BoardHandler {
private Map<Color, List<PieceControl>> waitingPiecesMap;
private Map<UUID, Color> pieceColor;
private Node node = new Node();
private Node rootNodeBoard;
private final Node rootNode;
private final FilterPostProcessor fpp;
@@ -49,6 +49,7 @@ public BoardHandler(MdgaApp app, Node rootNode, FilterPostProcessor fpp) {
this.app = app;
this.fpp = fpp;
rootNodeBoard = new Node("Board Root Node");
this.rootNode = rootNode;
isInitialised = false;
}
@@ -61,14 +62,14 @@ public void init() {
selectedOwnPiece = null;
selectedEnemyPiece = null;
initMap();
rootNode.attachChild(node);
rootNode.attachChild(rootNodeBoard);
}
public void shutdown(){
clearSelectable();
isInitialised = false;
initMap();
rootNode.detachChild(node);
rootNode.detachChild(rootNodeBoard);
}
private void addFigureToPlayerMap(Color col, AssetOnMap assetOnMap) {
@@ -132,7 +133,7 @@ private Spatial createModel(Asset asset, Vector3f pos, float rot) {
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
mat.setTexture("DiffuseMap", app.getAssetManager().loadTexture(texName));
model.setMaterial(mat);
node.attachChild(model);
rootNodeBoard.attachChild(model);
return model;
}
@@ -468,7 +469,7 @@ public void enableHover(UUID uuid){
}
public void showDice(Color color){
node.attachChild(diceControl.getSpatial());
rootNodeBoard.attachChild(diceControl.getSpatial());
diceControl.setPos(getWaitingPos(color).add(new Vector3f(0,0,4)));
diceControl.spin();
}

View File

@@ -45,12 +45,11 @@ public CameraHandler(MdgaApp app, FilterPostProcessor fpp) {
ambient = new AmbientLight();
ambient.setColor(new ColorRGBA(0.3f, 0.3f, 0.3f, 1));
dlsf = new DirectionalLightShadowFilter(app.getAssetManager(), SHADOWMAP_SIZE, 4);
dlsf = new DirectionalLightShadowFilter(app.getAssetManager(), SHADOWMAP_SIZE, 1);
dlsf.setLight(sun);
dlsf.setEnabled(true);
dlsf.setEdgeFilteringMode(EdgeFilteringMode.PCFPOISSON);
dlsf.setShadowIntensity(0.7f);
fpp.addFilter(dlsf);
sky = SkyFactory.createSky(app.getAssetManager(), "Images/sky/sky.dds", EnvMapType.EquirectMap).rotate(FastMath.HALF_PI*1,0,FastMath.HALF_PI*0.2f);

View File

@@ -110,6 +110,7 @@ public CeremonyButton(MdgaApp app, Node node, Node node3d, Color tsk, Pos pos, S
instance.setText("Marine");
yield Asset.marine;
}
default -> throw new RuntimeException("None is not valid");
};
switch (pos) {

View File

@@ -117,6 +117,7 @@ private ColorRGBA playerColorToColorRGBA(Color color){
case NAVY -> ColorRGBA.Blue;
case CYBER -> ColorRGBA.Orange;
case AIRFORCE -> ColorRGBA.Black;
default -> throw new RuntimeException("None is not valid");
};
}

View File

@@ -78,6 +78,7 @@ private String imagePath(Color color){
case NAVY -> root+"MARINE_IMAGE.png";
case CYBER -> root+"CIR_IMAGE.png";
case AIRFORCE -> root+"LW_IMAGE.png";
default -> throw new RuntimeException("None is not valid");
};
}

View File

@@ -10,6 +10,12 @@
import pp.mdga.client.button.ButtonRight;
import pp.mdga.client.gui.GuiHandler;
import pp.mdga.game.Color;
import pp.mdga.notification.GameNotification;
import pp.mdga.notification.PlayerInGameNotification;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class GameView extends MdgaView {
private BoardHandler boardHandler;
@@ -49,6 +55,7 @@ public void onEnter() {
app.getViewPort().addProcessor(fpp);
app.getAcousticHandler().playSound(MdgaSound.START);
}
@Override

View File

@@ -18,6 +18,7 @@
import pp.mdga.client.button.LobbyButton;
import pp.mdga.client.button.SettingsButton;
import pp.mdga.game.Color;
import pp.mdga.notification.GameNotification;
public class LobbyView extends MdgaView {
private Geometry background;
@@ -186,6 +187,7 @@ public void setReady(Color color, boolean isReady) {
case AIRFORCE -> airforceButton;
case ARMY -> armyButton;
case NAVY -> navyButton;
default -> throw new RuntimeException("None is not valid");
};
button.setReady(isReady);

View File

@@ -20,9 +20,9 @@ public enum Overlay {
}
protected MdgaApp app;
protected Node rootNode = new Node();
protected Node guiNode = new Node();
protected Node overlayNode = new Node();
protected Node rootNode = new Node("View Root");
protected Node guiNode = new Node("View Root GUI");
protected Node overlayNode = new Node("View Root Overlay");
private SettingsButton settingsButton;