made getter for username
This commit is contained in:
@@ -25,6 +25,7 @@ import netwerkprog.game.client.game.map.Map;
|
|||||||
import netwerkprog.game.client.game.map.MapRenderer;
|
import netwerkprog.game.client.game.map.MapRenderer;
|
||||||
import netwerkprog.game.util.data.Data;
|
import netwerkprog.game.util.data.Data;
|
||||||
import netwerkprog.game.util.data.connection.NameData;
|
import netwerkprog.game.util.data.connection.NameData;
|
||||||
|
import netwerkprog.game.util.data.connection.ReadyData;
|
||||||
import netwerkprog.game.util.data.connection.TeamData;
|
import netwerkprog.game.util.data.connection.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;
|
||||||
@@ -387,13 +388,31 @@ public class MainGame extends Game implements ClientCallback {
|
|||||||
|
|
||||||
} else if (data instanceof ReadyData) {
|
} else if (data instanceof ReadyData) {
|
||||||
ReadyData readyData = (ReadyData) data;
|
ReadyData readyData = (ReadyData) data;
|
||||||
if (readyData.getUsername().equals(this.username)) {
|
if (!readyData.getUsername().equals(this.username)) {
|
||||||
|
this.enemyReady = true;
|
||||||
|
System.out.println("enemy is ready");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void chooseHacker() {
|
||||||
|
System.out.println("chose HACKER");
|
||||||
|
setChosenFaction(Faction.HACKER);
|
||||||
|
send(new TeamData(Faction.MEGACORPORATION, getUsername()));
|
||||||
|
// mainGame.initCharacters();
|
||||||
|
// camera.translate(-400, 0);
|
||||||
|
// mainGame.setGamestate(GAMESTATE.PLAYING);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void chooseMegaCorp() {
|
||||||
|
System.out.println("chose MEGA CORP");
|
||||||
|
setChosenFaction(Faction.MEGACORPORATION);
|
||||||
|
send(new TeamData(Faction.MEGACORPORATION, getUsername()));
|
||||||
|
// mainGame.initCharacters();
|
||||||
|
// mainGame.setGamestate(GAMESTATE.PLAYING);
|
||||||
|
}
|
||||||
|
|
||||||
public String getUsername() {
|
public String getUsername() {
|
||||||
return username;
|
return username;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,15 @@ public class Team {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GameCharacter get(String username) {
|
||||||
|
for (GameCharacter cur : this.members) {
|
||||||
|
if (cur.getName().equals(username)) {
|
||||||
|
return cur;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public GameCharacter get(int position) {
|
public GameCharacter get(int position) {
|
||||||
if (position >= this.members.getSize()) {
|
if (position >= this.members.getSize()) {
|
||||||
throw new IndexOutOfBoundsException("position out of range");
|
throw new IndexOutOfBoundsException("position out of range");
|
||||||
|
|||||||
@@ -119,19 +119,10 @@ public class GameInputProcessor implements InputProcessor {
|
|||||||
}
|
}
|
||||||
} else if (mainGame.getGamestate() == GAMESTATE.SELECTING_FACTION) {
|
} else if (mainGame.getGamestate() == GAMESTATE.SELECTING_FACTION) {
|
||||||
if (keycode == Input.Keys.NUM_1) {
|
if (keycode == Input.Keys.NUM_1) {
|
||||||
System.out.println("chose MEGA CORP");
|
mainGame.chooseMegaCorp();
|
||||||
mainGame.setChosenFaction(Faction.MEGACORPORATION);
|
|
||||||
mainGame.send(new TeamData(Faction.MEGACORPORATION, mainGame.getUsername()));
|
|
||||||
// mainGame.initCharacters();
|
|
||||||
// mainGame.setGamestate(GAMESTATE.PLAYING);
|
|
||||||
}
|
}
|
||||||
if (keycode == Input.Keys.NUM_2) {
|
if (keycode == Input.Keys.NUM_2) {
|
||||||
System.out.println("chose HACKER");
|
mainGame.chooseHacker();
|
||||||
mainGame.setChosenFaction(Faction.HACKER);
|
|
||||||
mainGame.send(new TeamData(Faction.MEGACORPORATION, mainGame.getUsername()));
|
|
||||||
// mainGame.initCharacters();
|
|
||||||
// camera.translate(-400, 0);
|
|
||||||
// mainGame.setGamestate(GAMESTATE.PLAYING);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user