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.Data;
|
||||||
import netwerkprog.game.util.data.DataCallback;
|
import netwerkprog.game.util.data.DataCallback;
|
||||||
import netwerkprog.game.util.data.DataSource;
|
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.Faction;
|
||||||
import netwerkprog.game.util.game.GameCharacter;
|
import netwerkprog.game.util.game.GameCharacter;
|
||||||
import netwerkprog.game.util.graphics.FrameRate;
|
import netwerkprog.game.util.graphics.FrameRate;
|
||||||
@@ -53,6 +55,7 @@ public class MainGame extends Game implements DataCallback {
|
|||||||
private boolean gameOver = false;
|
private boolean gameOver = false;
|
||||||
private int turn = 0;
|
private int turn = 0;
|
||||||
private boolean playersTurn = true;
|
private boolean playersTurn = true;
|
||||||
|
private String username;
|
||||||
|
|
||||||
private Map map;
|
private Map map;
|
||||||
public MapRenderer mapRenderer;
|
public MapRenderer mapRenderer;
|
||||||
@@ -353,6 +356,22 @@ public class MainGame extends Game implements DataCallback {
|
|||||||
@Override
|
@Override
|
||||||
public void onDataReceived(Data data, DataSource source) {
|
public void onDataReceived(Data data, DataSource source) {
|
||||||
System.out.println("[MAINGAME CALLBACK] Got data: " + data.toString());
|
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.MainGame;
|
||||||
import netwerkprog.game.client.game.GAMESTATE;
|
import netwerkprog.game.client.game.GAMESTATE;
|
||||||
import netwerkprog.game.util.data.Data;
|
import netwerkprog.game.util.data.Data;
|
||||||
|
import netwerkprog.game.util.data.TeamData;
|
||||||
import netwerkprog.game.util.game.Faction;
|
import netwerkprog.game.util.game.Faction;
|
||||||
import netwerkprog.game.util.game.GameCharacter;
|
import netwerkprog.game.util.game.GameCharacter;
|
||||||
|
|
||||||
@@ -119,15 +120,17 @@ public class GameInputProcessor implements InputProcessor {
|
|||||||
if (keycode == Input.Keys.NUM_1) {
|
if (keycode == Input.Keys.NUM_1) {
|
||||||
System.out.println("MEGA CORP");
|
System.out.println("MEGA CORP");
|
||||||
mainGame.setChosenFaction(Faction.MEGACORPORATION);
|
mainGame.setChosenFaction(Faction.MEGACORPORATION);
|
||||||
mainGame.initCharacters();
|
mainGame.send(new TeamData(Faction.MEGACORPORATION, mainGame.getUsername()));
|
||||||
mainGame.setGamestate(GAMESTATE.PLAYING);
|
// mainGame.initCharacters();
|
||||||
|
// mainGame.setGamestate(GAMESTATE.PLAYING);
|
||||||
}
|
}
|
||||||
if (keycode == Input.Keys.NUM_2) {
|
if (keycode == Input.Keys.NUM_2) {
|
||||||
System.out.println("HACKER");
|
System.out.println("HACKER");
|
||||||
mainGame.setChosenFaction(Faction.HACKER);
|
mainGame.setChosenFaction(Faction.HACKER);
|
||||||
mainGame.initCharacters();
|
mainGame.send(new TeamData(Faction.MEGACORPORATION, mainGame.getUsername()));
|
||||||
camera.translate(-400, 0);
|
// mainGame.initCharacters();
|
||||||
mainGame.setGamestate(GAMESTATE.PLAYING);
|
// 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 {
|
public class TeamData extends Data {
|
||||||
private final Faction faction;
|
private final Faction faction;
|
||||||
|
private final String username;
|
||||||
|
|
||||||
public TeamData(Faction faction) {
|
public TeamData(Faction faction, String username) {
|
||||||
super("Team");
|
super("Team");
|
||||||
super.setPayload(this);
|
super.setPayload(this);
|
||||||
this.faction = faction;
|
this.faction = faction;
|
||||||
|
this.username = username;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Faction getFaction() {
|
public Faction getFaction() {
|
||||||
return faction;
|
return faction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user