Improve mock
This commit is contained in:
@@ -110,6 +110,8 @@ public void playState(MdgaState state) {
|
|||||||
playGame = false;
|
playGame = false;
|
||||||
asset = MusicAsset.CEREMONY;
|
asset = MusicAsset.CEREMONY;
|
||||||
break;
|
break;
|
||||||
|
case NONE:
|
||||||
|
throw new RuntimeException("no music for state NONE");
|
||||||
}
|
}
|
||||||
|
|
||||||
assert (null != asset) : "music sceduling went wrong";
|
assert (null != asset) : "music sceduling went wrong";
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class BoardView {
|
public class BoardHandler {
|
||||||
private static final float GRID_SIZE = 1.72f;
|
private static final float GRID_SIZE = 1.72f;
|
||||||
private static final float GRID_ELEVATION = 0.0f;
|
private static final float GRID_ELEVATION = 0.0f;
|
||||||
private static final String MAP_NAME = "map.mdga";
|
private static final String MAP_NAME = "map.mdga";
|
||||||
@@ -29,14 +29,16 @@ public class BoardView {
|
|||||||
|
|
||||||
private Map<Color, List<AssetOnMap>> playerMap;
|
private Map<Color, List<AssetOnMap>> playerMap;
|
||||||
|
|
||||||
public BoardView(MdgaApp app) {
|
public BoardHandler(MdgaApp app) {
|
||||||
assert (app != null) : "app is null";
|
assert (app != null) : "app is null";
|
||||||
|
|
||||||
this.app = app;
|
this.app = app;
|
||||||
|
|
||||||
this.pieces = new HashMap<>();
|
this.pieces = new HashMap<>();
|
||||||
this.playerMap = new HashMap<>();
|
this.playerMap = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init() {
|
||||||
initMap();
|
initMap();
|
||||||
initCamera();
|
initCamera();
|
||||||
}
|
}
|
||||||
@@ -87,7 +87,7 @@ private void setupStatistics() {
|
|||||||
container.addChild(new Label("Spieler 3: Punkte 60"));
|
container.addChild(new Label("Spieler 3: Punkte 60"));
|
||||||
|
|
||||||
Button exitButton = container.addChild(new Button("Verlassen"));
|
Button exitButton = container.addChild(new Button("Verlassen"));
|
||||||
exitButton.addClickCommands(source -> app.stop());
|
exitButton.addClickCommands(source -> app.enter(MdgaState.MAIN));
|
||||||
|
|
||||||
statisticsNode.attachChild(container);
|
statisticsNode.attachChild(container);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,27 +8,6 @@
|
|||||||
import pp.dialog.SimpleDialog;
|
import pp.dialog.SimpleDialog;
|
||||||
import pp.mdga.client.MdgaApp;
|
import pp.mdga.client.MdgaApp;
|
||||||
|
|
||||||
public class StartDialog extends SimpleDialog {
|
public class StartDialog {
|
||||||
StartDialog(MdgaApp app) {
|
|
||||||
super(app.getDialogView().getDialogManager());
|
|
||||||
|
|
||||||
Checkbox serverHost = new Checkbox("sdgfsdg");
|
|
||||||
serverHost.setChecked(false);
|
|
||||||
//serverHost.addClickCommands(s -> toggleServerHost());
|
|
||||||
|
|
||||||
final Container input = new Container(new SpringGridLayout());
|
|
||||||
input.addChild(new Label("sdgsgsdg"));
|
|
||||||
//input.addChild(host, 1);
|
|
||||||
input.addChild(new Label("sdfdsgsdgsdg"));
|
|
||||||
//input.addChild(port, 1);
|
|
||||||
input.addChild(serverHost);
|
|
||||||
|
|
||||||
DialogBuilder.simple(app.getDialogView().getDialogManager())
|
|
||||||
.setTitle("server.dialog")
|
|
||||||
.setOkButton("button.connect")
|
|
||||||
.setNoButton("button.cancel")
|
|
||||||
.setOkClose(false)
|
|
||||||
.setNoClose(false)
|
|
||||||
.build(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,31 @@
|
|||||||
package pp.mdga.client;
|
package pp.mdga.client;
|
||||||
|
|
||||||
public class GameView {
|
import com.jme3.material.Material;
|
||||||
|
import com.jme3.scene.Geometry;
|
||||||
|
import com.jme3.scene.Node;
|
||||||
|
import com.jme3.scene.shape.Quad;
|
||||||
|
import com.simsilica.lemur.Button;
|
||||||
|
import com.simsilica.lemur.Container;
|
||||||
|
import com.simsilica.lemur.Label;
|
||||||
|
import pp.mdga.client.Board.BoardHandler;
|
||||||
|
|
||||||
|
public class GameView extends MdgaView {
|
||||||
|
private BoardHandler boardHandler;
|
||||||
|
|
||||||
|
public GameView(MdgaApp app) {
|
||||||
|
super(app);
|
||||||
|
|
||||||
|
boardHandler = new BoardHandler(app);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void enter() {
|
||||||
|
boardHandler.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void leave() {
|
||||||
|
rootNode.detachAllChildren();
|
||||||
|
app.getGuiNode().detachChild(rootNode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public void enter() {
|
|||||||
hostGameButton.addClickCommands(source -> System.out.println("Hosting game..."));
|
hostGameButton.addClickCommands(source -> System.out.println("Hosting game..."));
|
||||||
|
|
||||||
Button joinGameButton = menuContainer.addChild(new Button("Join Game"));
|
Button joinGameButton = menuContainer.addChild(new Button("Join Game"));
|
||||||
joinGameButton.addClickCommands(source -> System.out.println("Joining game..."));
|
joinGameButton.addClickCommands(source -> app.enter(MdgaState.LOBBY));
|
||||||
|
|
||||||
Button exitButton = menuContainer.addChild(new Button("Exit"));
|
Button exitButton = menuContainer.addChild(new Button("Exit"));
|
||||||
exitButton.addClickCommands(source -> app.stop());
|
exitButton.addClickCommands(source -> app.stop());
|
||||||
|
|||||||
@@ -2,24 +2,23 @@
|
|||||||
|
|
||||||
import com.jme3.app.SimpleApplication;
|
import com.jme3.app.SimpleApplication;
|
||||||
import com.jme3.system.NanoTimer;
|
import com.jme3.system.NanoTimer;
|
||||||
import com.simsilica.lemur.Button;
|
|
||||||
import com.simsilica.lemur.GuiGlobals;
|
import com.simsilica.lemur.GuiGlobals;
|
||||||
import pp.mdga.client.Acoustic.AcousticHandler;
|
import pp.mdga.client.Acoustic.AcousticHandler;
|
||||||
import pp.mdga.client.Acoustic.MdgaSound;
|
import pp.mdga.client.Acoustic.MdgaSound;
|
||||||
import pp.mdga.client.Animation.AnimationHandler;
|
import pp.mdga.client.Animation.AnimationHandler;
|
||||||
import com.jme3.system.AppSettings;
|
import com.jme3.system.AppSettings;
|
||||||
import pp.mdga.client.Board.BoardView;
|
import pp.mdga.client.Board.BoardHandler;
|
||||||
import pp.mdga.client.Dialog.DialogView;
|
import pp.mdga.client.Dialog.DialogView;
|
||||||
import pp.mdga.client.Dialog.SoundDialog;
|
|
||||||
|
|
||||||
public class MdgaApp extends SimpleApplication {
|
public class MdgaApp extends SimpleApplication {
|
||||||
private AnimationHandler animationHandler;
|
private AnimationHandler animationHandler;
|
||||||
private AcousticHandler acousticHandler;
|
private AcousticHandler acousticHandler;
|
||||||
private BoardView boardView;
|
|
||||||
private DialogView dialogView;
|
|
||||||
|
|
||||||
NanoTimer test = new NanoTimer();
|
MdgaView view = null;
|
||||||
private MdgaState testState = MdgaState.MAIN;
|
private MdgaState state = MdgaState.MAIN;
|
||||||
|
|
||||||
|
//TODO
|
||||||
|
private NanoTimer test = new NanoTimer();
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
AppSettings settings = new AppSettings(true);
|
AppSettings settings = new AppSettings(true);
|
||||||
@@ -38,53 +37,59 @@ public static void main(String[] args) {
|
|||||||
public void simpleInitApp() {
|
public void simpleInitApp() {
|
||||||
animationHandler = new AnimationHandler(this);
|
animationHandler = new AnimationHandler(this);
|
||||||
acousticHandler = new AcousticHandler(this);
|
acousticHandler = new AcousticHandler(this);
|
||||||
boardView = new BoardView(this);
|
|
||||||
dialogView = new DialogView(this);
|
|
||||||
|
|
||||||
//dialogView.mainMenu();
|
|
||||||
//acousticHandler.playState(MdgaState.GAME);
|
|
||||||
|
|
||||||
acousticHandler.playSound(MdgaSound.LOST);
|
|
||||||
acousticHandler.playSound(MdgaSound.VICTORY);
|
|
||||||
|
|
||||||
//SoundDialog settingsDialog = new SoundDialog(this);
|
|
||||||
//settingsDialog.show();
|
|
||||||
|
|
||||||
// Interact with the dialog
|
|
||||||
//Button closeButton = settingsDialog.getButton("close");
|
|
||||||
//closeButton.addClickCommands(source -> System.out.println("Closing dialog..."));
|
|
||||||
|
|
||||||
GuiGlobals.initialize(this);
|
GuiGlobals.initialize(this);
|
||||||
MainMenuView mainMenuView = new MainMenuView(this);
|
|
||||||
LobbyView lobbyView = new LobbyView(this);
|
|
||||||
//mainMenuView.enter();
|
|
||||||
//lobbyView.enter();
|
|
||||||
|
|
||||||
CeremonyView ceremonyView = new CeremonyView(this);
|
enter(state);
|
||||||
ceremonyView.enter();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void simpleUpdate(float tpf) {
|
public void simpleUpdate(float tpf) {
|
||||||
acousticHandler.update();
|
acousticHandler.update();
|
||||||
|
|
||||||
//test.reset();
|
if(test.getTimeInSeconds() < 10) {
|
||||||
if (test.getTimeInSeconds() > 10) {
|
return;
|
||||||
if (testState == MdgaState.MAIN) {
|
|
||||||
testState = MdgaState.LOBBY;
|
|
||||||
acousticHandler.playState(MdgaState.MAIN);
|
|
||||||
}
|
|
||||||
else if (testState == MdgaState.LOBBY) {
|
|
||||||
testState = MdgaState.CEREMONY;
|
|
||||||
acousticHandler.playState(MdgaState.LOBBY);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
testState = MdgaState.MAIN;
|
|
||||||
acousticHandler.playState(MdgaState.CEREMONY);
|
|
||||||
}
|
|
||||||
|
|
||||||
test.reset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch (state) {
|
||||||
|
case LOBBY:
|
||||||
|
enter(MdgaState.GAME);
|
||||||
|
break;
|
||||||
|
case GAME:
|
||||||
|
enter(MdgaState.CEREMONY);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void enter(MdgaState state) {
|
||||||
|
if(null != view) {
|
||||||
|
view.leave();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.state = state;
|
||||||
|
|
||||||
|
switch (state) {
|
||||||
|
case MAIN:
|
||||||
|
view = new MainMenuView(this);
|
||||||
|
break;
|
||||||
|
case LOBBY:
|
||||||
|
view = new LobbyView(this);
|
||||||
|
test.reset();
|
||||||
|
break;
|
||||||
|
case GAME:
|
||||||
|
view = new GameView(this);
|
||||||
|
test.reset();
|
||||||
|
break;
|
||||||
|
case CEREMONY:
|
||||||
|
view = new CeremonyView(this);
|
||||||
|
break;
|
||||||
|
case NONE:
|
||||||
|
throw new RuntimeException("cant enter state NONE");
|
||||||
|
}
|
||||||
|
|
||||||
|
acousticHandler.playState(state);
|
||||||
|
|
||||||
|
view.enter();
|
||||||
}
|
}
|
||||||
|
|
||||||
public AnimationHandler getAnimationHandler() {
|
public AnimationHandler getAnimationHandler() {
|
||||||
@@ -94,12 +99,4 @@ public AnimationHandler getAnimationHandler() {
|
|||||||
public AcousticHandler getAcousticHandler() {
|
public AcousticHandler getAcousticHandler() {
|
||||||
return acousticHandler;
|
return acousticHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BoardView getBoardView() {
|
|
||||||
return boardView;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DialogView getDialogView() {
|
|
||||||
return dialogView;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user