merge dev into test #30
@@ -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.*;
|
||||||
import com.jme3.network.serializing.Serializer;
|
import com.jme3.network.serializing.Serializer;
|
||||||
import pp.mdga.game.Game;
|
import pp.mdga.game.*;
|
||||||
import pp.mdga.game.Player;
|
|
||||||
import pp.mdga.game.Statistic;
|
|
||||||
import pp.mdga.message.client.*;
|
import pp.mdga.message.client.*;
|
||||||
import pp.mdga.message.server.*;
|
import pp.mdga.message.server.*;
|
||||||
import pp.mdga.server.ServerGameLogic;
|
import pp.mdga.server.ServerGameLogic;
|
||||||
@@ -138,6 +136,13 @@ private void initializeSerializables() {
|
|||||||
Serializer.registerClass(WaitPieceMessage.class);
|
Serializer.registerClass(WaitPieceMessage.class);
|
||||||
Serializer.registerClass(Player.class);
|
Serializer.registerClass(Player.class);
|
||||||
Serializer.registerClass(Statistic.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() {
|
private void registerListeners() {
|
||||||
|
|||||||
@@ -106,13 +106,10 @@ private void tryHost() {
|
|||||||
try {
|
try {
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
} catch (InterruptedException ignored) {
|
} catch (InterruptedException ignored) {
|
||||||
// todo: implement
|
|
||||||
}
|
}
|
||||||
hostDialog.connectServerAsClient();
|
hostDialog.connectServerAsClient();
|
||||||
try {
|
while (hostDialog.getNetwork().isConnected()){
|
||||||
Thread.sleep(1000);
|
int i = 2;
|
||||||
} catch (InterruptedException ignored) {
|
|
||||||
// todo: implement
|
|
||||||
}
|
}
|
||||||
app.getModelSynchronize().setHost(port);
|
app.getModelSynchronize().setHost(port);
|
||||||
//app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT);
|
//app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT);
|
||||||
@@ -142,9 +139,8 @@ private void tryJoin() {
|
|||||||
app.getModelSynchronize().setName(startDialog.getName());
|
app.getModelSynchronize().setName(startDialog.getName());
|
||||||
joinDialog.setHostname(ip);
|
joinDialog.setHostname(ip);
|
||||||
joinDialog.connectToServer();
|
joinDialog.connectToServer();
|
||||||
try {
|
while (!joinDialog.getNetwork().isConnected()){
|
||||||
Thread.sleep(1000);
|
int i = 2;
|
||||||
} catch (InterruptedException ignored) {
|
|
||||||
}
|
}
|
||||||
app.getModelSynchronize().setJoin(ip, port);
|
app.getModelSynchronize().setJoin(ip, port);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -8,6 +8,9 @@
|
|||||||
|
|
||||||
public class GameState extends ClientState {
|
public class GameState extends ClientState {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the current substate
|
||||||
|
*/
|
||||||
private GameStates state;
|
private GameStates state;
|
||||||
|
|
||||||
private final AnimationState animationState = new AnimationState(this, logic);
|
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 TurnState turnState = new TurnState(this, logic);
|
||||||
private final WaitingState waitingState = new WaitingState(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) {
|
public GameState(ClientState parent, ClientGameLogic logic) {
|
||||||
super(parent, logic);
|
super(parent, logic);
|
||||||
state = determineStartPlayerState;
|
state = determineStartPlayerState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The method to enter the state
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void enter() {
|
public void enter() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the method to exit this state
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void exit() {
|
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){
|
public void setState(GameStates newState){
|
||||||
state.exit();
|
state.exit();
|
||||||
state.enter();
|
state.enter();
|
||||||
|
|||||||
@@ -26,19 +26,35 @@ public void enter() {
|
|||||||
previousState = null;
|
previousState = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* exits this state
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void exit() {
|
public void exit() {
|
||||||
previousState = null;
|
previousState = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method sets the stores the gamestate as previous state
|
||||||
|
*
|
||||||
|
* @param previousState
|
||||||
|
*/
|
||||||
public void setPreviousState(ClientState previousState) {
|
public void setPreviousState(ClientState previousState) {
|
||||||
this.previousState = previousState;
|
this.previousState = previousState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns teh previous gamestate
|
||||||
|
*
|
||||||
|
* @return the previous gamestate
|
||||||
|
*/
|
||||||
public ClientState getPreviousState() {
|
public ClientState getPreviousState() {
|
||||||
return previousState;
|
return previousState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The host resumes the game
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void selectResume(){
|
public void selectResume(){
|
||||||
if(logic.isHost()){
|
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) {
|
public void received(ResumeGameMessage msg) {
|
||||||
//TODO: logic.addNotification(new ResumeNotification());
|
//TODO: logic.addNotification(new ResumeNotification());
|
||||||
logic.setState(previousState);
|
logic.setState(previousState);
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
package pp.mdga.game;
|
package pp.mdga.game;
|
||||||
|
|
||||||
|
import com.jme3.network.serializing.Serializable;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class will be used to hold all Board relevant data.
|
* This class will be used to hold all Board relevant data.
|
||||||
*/
|
*/
|
||||||
|
@Serializable
|
||||||
public class Board {
|
public class Board {
|
||||||
private Map<Color, PlayerData> playerData;
|
private Map<Color, PlayerData> playerData;
|
||||||
private final Node[] infield;
|
private final Node[] infield;
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
package pp.mdga.game;
|
package pp.mdga.game;
|
||||||
|
|
||||||
|
import com.jme3.network.serializing.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents a BonusNode
|
* This class represents a BonusNode
|
||||||
*/
|
*/
|
||||||
|
@Serializable
|
||||||
public class BonusNode extends Node {
|
public class BonusNode extends Node {
|
||||||
|
BonusNode(){
|
||||||
|
super();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
package pp.mdga.game;
|
package pp.mdga.game;
|
||||||
|
|
||||||
|
import com.jme3.network.serializing.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a home node.
|
* Represents a home node.
|
||||||
*/
|
*/
|
||||||
|
@Serializable
|
||||||
public class HomeNode extends Node {
|
public class HomeNode extends Node {
|
||||||
|
public HomeNode() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,18 @@
|
|||||||
package pp.mdga.game;
|
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
|
* This class will be used the represent a Node on which the pieces can travel along
|
||||||
*/
|
*/
|
||||||
|
@Serializable
|
||||||
public class Node {
|
public class Node {
|
||||||
protected Piece occupant;
|
protected Piece occupant;
|
||||||
|
|
||||||
|
public Node(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is used to get an occupant of the Node.
|
* This method is used to get an occupant of the Node.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
package pp.mdga.game;
|
package pp.mdga.game;
|
||||||
|
|
||||||
|
import com.jme3.network.serializing.Serializable;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class will be used to hold all Piece relevant data.
|
* This class will be used to hold all Piece relevant data.
|
||||||
*/
|
*/
|
||||||
|
@Serializable
|
||||||
public class Piece {
|
public class Piece {
|
||||||
/**
|
/**
|
||||||
* The shield state of the piece.
|
* The shield state of the piece.
|
||||||
@@ -38,6 +41,10 @@ public Piece(Color color, PieceState state, int id) {
|
|||||||
shield = ShieldState.NONE;
|
shield = ShieldState.NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Piece() {
|
||||||
|
color = null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is used to get the color of the piece
|
* This method is used to get the color of the piece
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package pp.mdga.game;
|
package pp.mdga.game;
|
||||||
|
|
||||||
|
import com.jme3.network.serializing.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is used to represent PlayerData related to the board
|
* This class is used to represent PlayerData related to the board
|
||||||
*/
|
*/
|
||||||
|
@Serializable
|
||||||
public class PlayerData {
|
public class PlayerData {
|
||||||
/**
|
/**
|
||||||
* An array of HomeNode objects representing the home nodes of the player.
|
* 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
|
* This method returns an Array of HomeNodes
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package pp.mdga.game;
|
package pp.mdga.game;
|
||||||
|
|
||||||
|
import com.jme3.network.serializing.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a start node.
|
* Represents a start node.
|
||||||
*/
|
*/
|
||||||
|
@Serializable
|
||||||
public class StartNode extends Node {
|
public class StartNode extends Node {
|
||||||
/**
|
/**
|
||||||
* The color of the node.
|
* The color of the node.
|
||||||
@@ -18,6 +21,10 @@ public StartNode(Color color) {
|
|||||||
this.color = color;
|
this.color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private StartNode() {
|
||||||
|
color = null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is used to get the color of the node
|
* This method is used to get the color of the node
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user