Merge branch 'master' of https://github.com/SemvdH/netwerk-programming-eindopdracht
# Conflicts: # core/src/netwerkprog/game/server/SessionController.java
This commit is contained in:
@@ -26,6 +26,8 @@ import netwerkprog.game.client.game.map.MapRenderer;
|
||||
import netwerkprog.game.util.data.Data;
|
||||
import netwerkprog.game.util.data.DataCallback;
|
||||
import netwerkprog.game.util.data.DataSource;
|
||||
import netwerkprog.game.util.data.NameData;
|
||||
import netwerkprog.game.util.data.TeamData;
|
||||
import netwerkprog.game.util.game.Faction;
|
||||
import netwerkprog.game.util.game.GameCharacter;
|
||||
import netwerkprog.game.util.graphics.FrameRate;
|
||||
@@ -53,6 +55,7 @@ public class MainGame extends Game implements DataCallback {
|
||||
private boolean gameOver = false;
|
||||
private int turn = 0;
|
||||
private boolean playersTurn = true;
|
||||
private String username;
|
||||
|
||||
private Map map;
|
||||
public MapRenderer mapRenderer;
|
||||
@@ -353,6 +356,22 @@ public class MainGame extends Game implements DataCallback {
|
||||
@Override
|
||||
public void onDataReceived(Data data, DataSource source) {
|
||||
System.out.println("[MAINGAME CALLBACK] Got data: " + data.toString());
|
||||
if (data instanceof NameData) {
|
||||
System.out.println("[MAINGAME CALLBACK] got name data: " + data);
|
||||
this.username = ((NameData) data).getName();
|
||||
System.out.println("[MAINGAME CALLBACK] username is: " + username);
|
||||
} else if (data instanceof TeamData) {
|
||||
if (this.chosenFaction != null) {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.badlogic.gdx.utils.TimeUtils;
|
||||
import netwerkprog.game.client.MainGame;
|
||||
import netwerkprog.game.client.game.GAMESTATE;
|
||||
import netwerkprog.game.util.data.Data;
|
||||
import netwerkprog.game.util.data.TeamData;
|
||||
import netwerkprog.game.util.game.Faction;
|
||||
import netwerkprog.game.util.game.GameCharacter;
|
||||
|
||||
@@ -119,15 +120,17 @@ public class GameInputProcessor implements InputProcessor {
|
||||
if (keycode == Input.Keys.NUM_1) {
|
||||
System.out.println("MEGA CORP");
|
||||
mainGame.setChosenFaction(Faction.MEGACORPORATION);
|
||||
mainGame.initCharacters();
|
||||
mainGame.setGamestate(GAMESTATE.PLAYING);
|
||||
mainGame.send(new TeamData(Faction.MEGACORPORATION, mainGame.getUsername()));
|
||||
// mainGame.initCharacters();
|
||||
// mainGame.setGamestate(GAMESTATE.PLAYING);
|
||||
}
|
||||
if (keycode == Input.Keys.NUM_2) {
|
||||
System.out.println("HACKER");
|
||||
mainGame.setChosenFaction(Faction.HACKER);
|
||||
mainGame.initCharacters();
|
||||
camera.translate(-400, 0);
|
||||
mainGame.setGamestate(GAMESTATE.PLAYING);
|
||||
mainGame.send(new TeamData(Faction.MEGACORPORATION, mainGame.getUsername()));
|
||||
// mainGame.initCharacters();
|
||||
// camera.translate(-400, 0);
|
||||
// mainGame.setGamestate(GAMESTATE.PLAYING);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
15
core/src/netwerkprog/game/util/data/NameData.java
Normal file
15
core/src/netwerkprog/game/util/data/NameData.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package netwerkprog.game.util.data;
|
||||
|
||||
public class NameData extends Data {
|
||||
private String name;
|
||||
public NameData(String name) {
|
||||
super("name");
|
||||
super.setPayload(this);
|
||||
this.name = name;
|
||||
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -4,14 +4,20 @@ import netwerkprog.game.util.game.Faction;
|
||||
|
||||
public class TeamData extends Data {
|
||||
private final Faction faction;
|
||||
private final String username;
|
||||
|
||||
public TeamData(Faction faction) {
|
||||
public TeamData(Faction faction, String username) {
|
||||
super("Team");
|
||||
super.setPayload(this);
|
||||
this.faction = faction;
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public Faction getFaction() {
|
||||
return faction;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user