team picking things

This commit is contained in:
Sem van der Hoeven
2020-06-07 14:42:39 +02:00
parent 0af0ca02b6
commit 79a0348a84

View File

@@ -227,8 +227,8 @@ public class MainGame extends Game implements ClientCallback {
private void renderTurnText() {
String text = playersTurn ? "Your turn, moves left: " + (3 - this.turn) : "Other player's turn";
layout.setText(font,text);
textRenderer.render(text, (Gdx.graphics.getWidth() / 2f) - layout.width / 2f,Gdx.graphics.getHeight() - 3);
layout.setText(font, text);
textRenderer.render(text, (Gdx.graphics.getWidth() / 2f) - layout.width / 2f, Gdx.graphics.getHeight() - 3);
}
/**
@@ -355,18 +355,29 @@ public class MainGame extends Game implements ClientCallback {
public void onDataReceived(Data data) {
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 {
// check if it is not our own message
if (!((TeamData) data).getUsername().equals(this.username)) {
// if we have already chosen a faction, so we were first
if (this.chosenFaction != null) {
TeamData teamData = (TeamData) data;
if (this.chosenFaction != teamData.getFaction()) {
// other player chose other faction
initCharacters();
setGamestate(GAMESTATE.PLAYING);
} else {
// other player chose same faction, send back that that one
// was already taken
}
} else {
}
}
}
}
public String getUsername() {