Merge commit
This commit is contained in:
@@ -71,4 +71,8 @@ public void update(float delta) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public NetworkSupport getNetwork(){
|
||||
return network;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
|
||||
import com.jme3.network.*;
|
||||
import com.jme3.network.serializing.Serializer;
|
||||
import pp.mdga.game.Game;
|
||||
import pp.mdga.game.Player;
|
||||
import pp.mdga.game.Statistic;
|
||||
import pp.mdga.game.*;
|
||||
import pp.mdga.message.client.*;
|
||||
import pp.mdga.message.server.*;
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
@@ -138,6 +136,13 @@ private void initializeSerializables() {
|
||||
Serializer.registerClass(WaitPieceMessage.class);
|
||||
Serializer.registerClass(Player.class);
|
||||
Serializer.registerClass(Statistic.class);
|
||||
Serializer.registerClass(Board.class);
|
||||
Serializer.registerClass(Node.class);
|
||||
Serializer.registerClass(Piece.class);
|
||||
Serializer.registerClass(BonusNode.class);
|
||||
Serializer.registerClass(StartNode.class);
|
||||
Serializer.registerClass(PlayerData.class);
|
||||
Serializer.registerClass(HomeNode.class);
|
||||
}
|
||||
|
||||
private void registerListeners() {
|
||||
|
||||
@@ -106,13 +106,10 @@ private void tryHost() {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException ignored) {
|
||||
// todo: implement
|
||||
}
|
||||
hostDialog.connectServerAsClient();
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException ignored) {
|
||||
// todo: implement
|
||||
while (hostDialog.getNetwork().isConnected()){
|
||||
int i = 2;
|
||||
}
|
||||
app.getModelSynchronize().setHost(port);
|
||||
//app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT);
|
||||
@@ -142,9 +139,8 @@ private void tryJoin() {
|
||||
app.getModelSynchronize().setName(startDialog.getName());
|
||||
joinDialog.setHostname(ip);
|
||||
joinDialog.connectToServer();
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException ignored) {
|
||||
while (!joinDialog.getNetwork().isConnected()){
|
||||
int i = 2;
|
||||
}
|
||||
app.getModelSynchronize().setJoin(ip, port);
|
||||
return;
|
||||
|
||||
@@ -53,6 +53,10 @@ public void setOwnPlayerName(String ownPlayerName) {
|
||||
this.ownPlayerName = ownPlayerName;
|
||||
}
|
||||
|
||||
public void setOwnPlayerId(int ownPlayerId) {
|
||||
this.ownPlayerID = ownPlayerId;
|
||||
}
|
||||
|
||||
public LobbyState getLobby() {
|
||||
return lobbyState;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
|
||||
public class GameState extends ClientState {
|
||||
|
||||
/**
|
||||
* the current substate
|
||||
*/
|
||||
private GameStates state;
|
||||
|
||||
private final AnimationState animationState = new AnimationState(this, logic);
|
||||
@@ -16,21 +19,38 @@ public class GameState extends ClientState {
|
||||
private final TurnState turnState = new TurnState(this, logic);
|
||||
private final WaitingState waitingState = new WaitingState(this, logic);
|
||||
|
||||
/**
|
||||
* Constructor for GameState
|
||||
*
|
||||
* @param parent the parent of this state
|
||||
* @param logic the ClientGameLogic
|
||||
*/
|
||||
public GameState(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
state = determineStartPlayerState;
|
||||
}
|
||||
|
||||
/**
|
||||
* The method to enter the state
|
||||
*/
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* the method to exit this state
|
||||
*/
|
||||
@Override
|
||||
public void exit() {
|
||||
|
||||
state.exit();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to set a new SubState
|
||||
*
|
||||
* @param newState the state to be set
|
||||
*/
|
||||
public void setState(GameStates newState){
|
||||
state.exit();
|
||||
state.enter();
|
||||
|
||||
@@ -26,19 +26,35 @@ public void enter() {
|
||||
previousState = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* exits this state
|
||||
*/
|
||||
@Override
|
||||
public void exit() {
|
||||
previousState = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method sets the stores the gamestate as previous state
|
||||
*
|
||||
* @param previousState
|
||||
*/
|
||||
public void setPreviousState(ClientState previousState) {
|
||||
this.previousState = previousState;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns teh previous gamestate
|
||||
*
|
||||
* @return the previous gamestate
|
||||
*/
|
||||
public ClientState getPreviousState() {
|
||||
return previousState;
|
||||
}
|
||||
|
||||
/**
|
||||
* The host resumes the game
|
||||
*/
|
||||
@Override
|
||||
public void selectResume(){
|
||||
if(logic.isHost()){
|
||||
@@ -46,6 +62,11 @@ public void selectResume(){
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The server resumes the game
|
||||
*
|
||||
* @param msg the ResumeGame message received
|
||||
*/
|
||||
public void received(ResumeGameMessage msg) {
|
||||
//TODO: logic.addNotification(new ResumeNotification());
|
||||
logic.setState(previousState);
|
||||
|
||||
@@ -11,10 +11,7 @@
|
||||
import pp.mdga.message.server.ServerStartGameMessage;
|
||||
import pp.mdga.message.server.UpdateReadyMessage;
|
||||
import pp.mdga.message.server.UpdateTSKMessage;
|
||||
import pp.mdga.notification.LobbyReadyNotification;
|
||||
import pp.mdga.notification.StartDialogNotification;
|
||||
import pp.mdga.notification.TskSelectNotification;
|
||||
import pp.mdga.notification.TskUnselectNotification;
|
||||
import pp.mdga.notification.*;
|
||||
|
||||
public class LobbyState extends DialogStates {
|
||||
|
||||
@@ -74,12 +71,16 @@ public void selectStart(){
|
||||
|
||||
@Override
|
||||
public void received(ServerStartGameMessage msg){
|
||||
|
||||
logic.getGame().setBoard(msg.getBoard());
|
||||
logic.addNotification(new GameNotification(logic.getGame().getPlayers().get(parent.getOwnPlayerId()).getColor()));
|
||||
parent.startGame();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(LobbyPlayerJoinedMessage msg){
|
||||
if(msg.getPlayer().getName().equals(parent.getOwnPlayerName())){
|
||||
parent.setOwnPlayerId(msg.getId());
|
||||
}
|
||||
logic.addNotification(new TskSelectNotification(msg.getPlayer().getColor(), msg.getPlayer().getName(), parent.getOwnPlayerId()== msg.getId()));
|
||||
logic.getGame().getPlayers().put(msg.getId(), msg.getPlayer());
|
||||
}
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
package pp.mdga.game;
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* This class will be used to hold all Board relevant data.
|
||||
*/
|
||||
@Serializable
|
||||
public class Board {
|
||||
private Map<Color, PlayerData> playerData;
|
||||
private final Node[] infield;
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
package pp.mdga.game;
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
|
||||
/**
|
||||
* This class represents a BonusNode
|
||||
*/
|
||||
@Serializable
|
||||
public class BonusNode extends Node {
|
||||
BonusNode(){
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
package pp.mdga.game;
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
|
||||
/**
|
||||
* Represents a home node.
|
||||
*/
|
||||
@Serializable
|
||||
public class HomeNode extends Node {
|
||||
public HomeNode() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
package pp.mdga.game;
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
|
||||
/**
|
||||
* This class will be used the represent a Node on which the pieces can travel along
|
||||
*/
|
||||
@Serializable
|
||||
public class Node {
|
||||
protected Piece occupant;
|
||||
|
||||
public Node(){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to get an occupant of the Node.
|
||||
*
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
package pp.mdga.game;
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* This class will be used to hold all Piece relevant data.
|
||||
*/
|
||||
@Serializable
|
||||
public class Piece {
|
||||
/**
|
||||
* The shield state of the piece.
|
||||
@@ -38,6 +41,10 @@ public Piece(Color color, PieceState state, int id) {
|
||||
shield = ShieldState.NONE;
|
||||
}
|
||||
|
||||
private Piece() {
|
||||
color = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to get the color of the piece
|
||||
*
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package pp.mdga.game;
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
|
||||
/**
|
||||
* This class is used to represent PlayerData related to the board
|
||||
*/
|
||||
@Serializable
|
||||
public class PlayerData {
|
||||
/**
|
||||
* An array of HomeNode objects representing the home nodes of the player.
|
||||
@@ -39,6 +42,12 @@ public PlayerData(Color color) {
|
||||
}
|
||||
}
|
||||
|
||||
private PlayerData() {
|
||||
homeNodes = null;
|
||||
waitingArea = null;
|
||||
pieces = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns an Array of HomeNodes
|
||||
*
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package pp.mdga.game;
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
|
||||
/**
|
||||
* Represents a start node.
|
||||
*/
|
||||
@Serializable
|
||||
public class StartNode extends Node {
|
||||
/**
|
||||
* The color of the node.
|
||||
@@ -18,6 +21,10 @@ public StartNode(Color color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
private StartNode() {
|
||||
color = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to get the color of the node
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user