Development #37
@@ -1,5 +1,6 @@
|
|||||||
package pp.mdga.client;
|
package pp.mdga.client;
|
||||||
|
|
||||||
|
import com.jme3.system.NanoTimer;
|
||||||
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.gui.GuiHandler;
|
import pp.mdga.client.gui.GuiHandler;
|
||||||
@@ -16,13 +17,26 @@ 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 update() {
|
public void update() {
|
||||||
|
while (timer.getTimeInSeconds() >= delay) {
|
||||||
Notification n = app.getGameLogic().getNotification();
|
Notification n = app.getGameLogic().getNotification();
|
||||||
while (n != null) {
|
|
||||||
|
if(n == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
timer.reset();
|
||||||
|
delay = 0;
|
||||||
|
|
||||||
if(n instanceof InfoNotification infoNotification) {
|
if(n instanceof InfoNotification infoNotification) {
|
||||||
app.getView().showInfo(infoNotification.getMessage(), infoNotification.isError());
|
app.getView().showInfo(infoNotification.getMessage(), infoNotification.isError());
|
||||||
return;
|
return;
|
||||||
@@ -46,8 +60,6 @@ public void update() {
|
|||||||
throw new RuntimeException("no notification expected: " + n.getClass().getName());
|
throw new RuntimeException("no notification expected: " + n.getClass().getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
n = app.getGameLogic().getNotification();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,10 +102,12 @@ private void handleGame(Notification notification) {
|
|||||||
if (notification instanceof AcquireCardNotification n) {
|
if (notification instanceof AcquireCardNotification n) {
|
||||||
guiHandler.addCardOwn(n.getBonusCard());
|
guiHandler.addCardOwn(n.getBonusCard());
|
||||||
app.getAcousticHandler().playSound(MdgaSound.BONUS);
|
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);
|
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();
|
||||||
@@ -162,6 +176,7 @@ 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();
|
gameView.showNoPower();
|
||||||
|
|||||||
Reference in New Issue
Block a user