Merge commit

This commit is contained in:
Felix Koppe
2024-11-30 10:52:44 +01:00
6 changed files with 126 additions and 41 deletions

View File

@@ -119,4 +119,6 @@ public ModelSyncronizer getModelSyncronizer() {
}
public InputSynchronizer getInputSyncronizer() { return inputSynchronizer; }
public NotificationSynchronizer getNotificationSynchronizer() { return notificationSynchronizer; }
}

View File

@@ -1,76 +1,98 @@
package pp.mdga.client;
import pp.mdga.client.view.CeremonyView;
import pp.mdga.client.view.GameView;
import pp.mdga.client.view.LobbyView;
import pp.mdga.game.BonusCard;
import pp.mdga.game.Color;
import pp.mdga.notification.AcquireCardNotification;
import pp.mdga.notification.DrawCardNotification;
import pp.mdga.notification.TskSelectNotification;
import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
public class ModelSyncronizer {
private static final Logger LOGGER = Logger.getLogger(ModelSyncronizer.class.getName());
private MdgaApp app;
ModelSyncronizer(MdgaApp app) {
this.app = app;
}
public void selectPiece() {
//TODO call from somewhere
System.out.println("selectPiece");
public void animationEnd() {
}
public void selectCard() {
//TODO call from somewhere
System.out.println("selectCard");
public void selectSwap(UUID a, UUID b) {
// TODO call from somewhere
LOGGER.log(Level.INFO, "selectPiece");
}
public void selectPiece(UUID piece) {
// TODO call from somewhere
LOGGER.log(Level.INFO, "selectPiece");
}
public void selectCard(BonusCard card) {
// TODO call from somewhere
LOGGER.log(Level.INFO, "selectCard");
}
public void confirm() {
LOGGER.log(Level.INFO, "confirm");
}
public void selectTsk(Color color) {
//TODO call from somewhere
System.out.println("selectTsk: " + color);
// TODO call from somewhere
LOGGER.log(Level.INFO, "selectTsk: {0}", color);
LobbyView view = (LobbyView) app.getView();
view.setTaken(color, true, true, "OwnPlayerName");
}
public void unselectTsk() {
//TODO call from somewhere
System.out.println("unselectTsk");
// TODO call from somewhere
LOGGER.log(Level.INFO, "unselectTsk");
}
public void rolledDice() {
//TODO call from somewhere
System.out.println("rolledDice");
// TODO call from somewhere
LOGGER.log(Level.INFO, "rolledDice");
}
public void setName(String name) {
//TODO call from somewhere
System.out.println("setName:" + name);
// TODO call from somewhere
LOGGER.log(Level.INFO, "setName: {0}", name);
}
public void setReady() {
//TODO call from somewhere
System.out.println("setReady");
app.enter(MdgaState.GAME);
LOGGER.log(Level.INFO, "setReady");
enter(MdgaState.GAME);
}
public void setHost(int port) {
//TODO call from somewhere
System.out.println("setHost: " + port);
app.enter(MdgaState.LOBBY);
// TODO call from somewhere
LOGGER.log(Level.INFO, "setHost: {0}", port);
enter(MdgaState.LOBBY);
}
public void setJoin(String ip, int port) {
//TODO call from somewhere
System.out.println("setJoin");
app.enter(MdgaState.LOBBY);
// TODO call from somewhere
LOGGER.log(Level.INFO, "setJoin with IP: {0}, Port: {1}", new Object[]{ip, port});
enter(MdgaState.LOBBY);
}
public void leave() {
System.out.println("leave");
app.enter(MdgaState.MAIN);
LOGGER.log(Level.INFO, "leave");
enter(MdgaState.MAIN);
}
public void enter(MdgaState state) {
System.out.println("enter:" + state);
LOGGER.log(Level.INFO, "enter: {0}", state);
app.enter(state);
if(state == MdgaState.CEREMONY) {
if (state == MdgaState.CEREMONY) {
CeremonyView ceremonyView = (CeremonyView) app.getView();
ceremonyView.addCeremonyParticipant(Color.AIRFORCE, 1, "ugidffdg");
ceremonyView.addCeremonyParticipant(Color.ARMY, 2, "ugidffdg");
@@ -83,5 +105,19 @@ public void enter(MdgaState state) {
ceremonyView.addStatisticsRow("player sdgsd", 1, 2, 3, 4, 5, 6);
ceremonyView.addStatisticsRow("Gesamt", 1, 2, 3, 4, 5, 6);
}
if (state == MdgaState.GAME) {
GameView gameView = (GameView) app.getView();
app.getNotificationSynchronizer().addTestNotification(new DrawCardNotification(Color.AIRFORCE, BonusCard.SHIELD));
}
if (state == MdgaState.LOBBY) {
LobbyView lobbyView = (LobbyView) app.getView();
app.getNotificationSynchronizer().addTestNotification(new TskSelectNotification(Color.CYBER, "blablabupp", false));
app.getNotificationSynchronizer().addTestNotification(new TskSelectNotification(Color.ARMY, "Spieler 2", false));
lobbyView.setReady(Color.ARMY, true);
}
}
}

View File

@@ -57,12 +57,12 @@ private void handleMain(Notification notification) {
private void handleLobby(Notification notification) {
LobbyView lobbyView = (LobbyView) app.getView();
if (notification instanceof TskSelectNotification) {
TskSelectNotification n = (TskSelectNotification)notification;
lobbyView.setTaken(n.getColor(), true, n.isSelf(), n.getName());
} else if (notification instanceof TskUnselectNotification) {
TskUnselectNotification n = (TskUnselectNotification)notification;
lobbyView.setTaken(n.getColor(), false, false, null);
if (notification instanceof TskSelectNotification tskSelectNotification) {
lobbyView.setTaken(tskSelectNotification.getColor(), true, tskSelectNotification.isSelf(), tskSelectNotification.getName());
} else if (notification instanceof TskUnselectNotification tskUnselectNotification) {
lobbyView.setTaken(tskUnselectNotification.getColor(), false, false, null);
//} else if(notification instanceof LobbyReadyNotification lobbyReadyNotification) {
// lobbyView.setReady(lobbyReadyNotification.getColor(), lobbyReadyNotification.isReady()):
} else if (notification instanceof GameNotification) {
app.enter(MdgaState.GAME);
} else {

View File

@@ -21,6 +21,12 @@ public enum Taken {
OTHER,
}
static final ColorRGBA LOBBY_TAKEN = ColorRGBA.fromRGBA255(193,58,59, 25);
static final ColorRGBA LOBBY_READY = ColorRGBA.fromRGBA255(55,172,190, 25);
static final ColorRGBA LOBBY_READY_HOVER = ColorRGBA.fromRGBA255(17,211,218, 25);
static final ColorRGBA LOBBY_SELF_NORMAL = ColorRGBA.fromRGBA255(34,103,24, 25);
static final ColorRGBA LOBBY_SELF_HOVER = ColorRGBA.fromRGBA255(42,151,19, 25);
static final float WIDTH = 4.0f;
private final Node node3d;
@@ -33,6 +39,8 @@ public enum Taken {
private LabelButton label;
private boolean isReady = false;
public LobbyButton(MdgaApp app, Node node, Node node3d, Runnable action, Color tsk) {
super(app, node, action, "", new Vector2f(WIDTH, 7), new Vector2f(0, 0));
@@ -89,17 +97,23 @@ public LobbyButton(MdgaApp app, Node node, Node node3d, Runnable action, Color t
@Override
public void onHover() {
/*switch (taken) {
ColorRGBA buttonPressed = BUTTON_PRESSED.clone();
switch (taken) {
case NOT:
buttonPressed.a = 0.3f;
break;
case SELF:
buttonPressed = LOBBY_SELF_HOVER;
break;
case OTHER:
buttonPressed = LOBBY_TAKEN;
break;
}*/
}
ColorRGBA buttonPressed = BUTTON_PRESSED.clone();
buttonPressed.a = 0.3f;
if(isReady) {
buttonPressed = LOBBY_READY_HOVER;
}
QuadBackgroundComponent background = new QuadBackgroundComponent(buttonPressed);
instance.setBackground(background);
@@ -109,17 +123,23 @@ public void onHover() {
@Override
public void onUnHover() {
/*switch (taken) {
ColorRGBA buttonNormal = ColorRGBA.Gray.clone();// BUTTON_NORMAL.clone();
switch (taken) {
case NOT:
buttonNormal.a = 0.1f;
break;
case SELF:
buttonNormal = LOBBY_SELF_NORMAL;
break;
case OTHER:
buttonNormal = LOBBY_TAKEN;
break;
}*/
}
ColorRGBA buttonNormal = ColorRGBA.Gray.clone();// BUTTON_NORMAL.clone();
buttonNormal.a = 0.1f;
if(isReady) {
buttonNormal = LOBBY_READY;
}
QuadBackgroundComponent background = new QuadBackgroundComponent(buttonNormal);
instance.setBackground(background);
@@ -184,8 +204,15 @@ public void setTaken(Taken taken, String name) {
if(taken == Taken.NOT) {
label.setText("- leer -");
isReady = false;
} else {
label.setText(name);
}
onUnHover();
}
public void setReady(boolean isReady) {
this.isReady = isReady;
}
}

View File

@@ -32,6 +32,7 @@ public class GameView extends MdgaView {
private ButtonRight cheatButton; //TODO
private ButtonLeft leaveButton;
private ButtonRight confirmButton;
private Color ownColor = null;
@@ -41,7 +42,9 @@ public GameView(MdgaApp app) {
super(app);
cheatButton = new ButtonRight(app, settingsNode, () -> app.getModelSyncronizer().enter(MdgaState.CEREMONY), "CHEAT", 1);
leaveButton = new ButtonLeft(app, settingsNode, () -> app.getModelSyncronizer().leave(), "Spiel verlassen", 1);
confirmButton = new ButtonRight(app, settingsNode, () -> app.getModelSyncronizer().confirm(), "Bestätigen", 1);
fpp = new FilterPostProcessor(app.getAssetManager());
this.camera = new CameraHandler(app, fpp);

View File

@@ -139,6 +139,23 @@ public void setTaken(Color color, boolean isTaken, boolean isSelf, String name)
}
}
public void setReady(Color color, boolean isReady) {
switch (color) {
case CYBER:
cyberButton.setReady(isReady);
break;
case AIRFORCE:
airforceButton.setReady(isReady);
break;
case ARMY:
armyButton.setReady(isReady);
break;
case NAVY:
navyButton.setReady(isReady);
break;
}
}
private void toggleTsk(Color color) {
LobbyButton.Taken taken = LobbyButton.Taken.NOT;