Characters moving #9
@@ -9,11 +9,11 @@ import com.badlogic.gdx.graphics.OrthographicCamera;
|
|||||||
import com.badlogic.gdx.graphics.Texture;
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||||
import com.badlogic.gdx.graphics.g2d.GlyphLayout;
|
import com.badlogic.gdx.graphics.g2d.GlyphLayout;
|
||||||
import com.badlogic.gdx.graphics.g2d.Sprite;
|
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
import netwerkprog.game.client.game.GAMESTATE;
|
import netwerkprog.game.client.game.GAMESTATE;
|
||||||
|
import netwerkprog.game.client.game.characters.Agent;
|
||||||
import netwerkprog.game.client.game.characters.Hacker;
|
import netwerkprog.game.client.game.characters.Hacker;
|
||||||
import netwerkprog.game.client.game.characters.Team;
|
import netwerkprog.game.client.game.characters.Team;
|
||||||
import netwerkprog.game.client.game.characters.abilities.BodySwap;
|
import netwerkprog.game.client.game.characters.abilities.BodySwap;
|
||||||
@@ -49,9 +49,6 @@ public class MainGame extends ApplicationAdapter {
|
|||||||
private Map map;
|
private Map map;
|
||||||
public MapRenderer mapRenderer;
|
public MapRenderer mapRenderer;
|
||||||
|
|
||||||
|
|
||||||
public GameCharacter testCharacter;
|
|
||||||
|
|
||||||
private static MainGame INSTANCE;
|
private static MainGame INSTANCE;
|
||||||
|
|
||||||
private MainGame() {
|
private MainGame() {
|
||||||
@@ -100,8 +97,6 @@ public class MainGame extends ApplicationAdapter {
|
|||||||
camera.viewportHeight = screenHeight / 2;
|
camera.viewportHeight = screenHeight / 2;
|
||||||
camera.update();
|
camera.update();
|
||||||
setGamestate(GAMESTATE.SELECTING_FACTION);
|
setGamestate(GAMESTATE.SELECTING_FACTION);
|
||||||
|
|
||||||
initCharacters();
|
|
||||||
// this.tree.insert(new Hacker(,new BodySwap()));
|
// this.tree.insert(new Hacker(,new BodySwap()));
|
||||||
|
|
||||||
|
|
||||||
@@ -111,16 +106,27 @@ public class MainGame extends ApplicationAdapter {
|
|||||||
// connectToServer();
|
// connectToServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initCharacters() {
|
public void initCharacters() {
|
||||||
Texture texture = new Texture(Gdx.files.internal("core/assets/characters.png"));
|
Texture texture = new Texture(Gdx.files.internal("core/assets/characters.png"));
|
||||||
TextureRegion[][] characters = TextureRegion.split(texture, 32, 32);
|
TextureRegion[][] characters = TextureRegion.split(texture, 32, 32);
|
||||||
this.testCharacter = new Hacker("harryyyyyyyyyy", characters[1][0], new BodySwap("test"));
|
|
||||||
GameCharacter character2 = new Hacker("test2", characters[2][0], new BodySwap("test"));
|
|
||||||
mapRenderer.getGameTiles()[1][1].visit(testCharacter);
|
|
||||||
mapRenderer.getGameTiles()[1][2].visit(character2);
|
|
||||||
this.team = new Team();
|
this.team = new Team();
|
||||||
this.team.addMember(this.testCharacter, character2);
|
|
||||||
this.setSelectedCharacter(testCharacter);
|
for (int i = 1; i <= 5; i++) {
|
||||||
|
GameCharacter temp =new Hacker("hacker" + i, characters[5][0], new BodySwap("test"));
|
||||||
|
mapRenderer.getGameTiles()[1][i].visit(temp);
|
||||||
|
if (chosenFaction == Faction.HACKER) {
|
||||||
|
this.team.addMember(temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 1; i <= 5; i++) {
|
||||||
|
GameCharacter temp = new Agent("Agent" + i,characters[11][0],new BodySwap("Test"));
|
||||||
|
mapRenderer.getGameTiles()[3][i].visit(temp);
|
||||||
|
if (chosenFaction == Faction.MEGACORPORATION) {
|
||||||
|
this.team.addMember(temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.setSelectedCharacter(this.team.get(0));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import netwerkprog.game.util.game.Faction;
|
|||||||
import netwerkprog.game.util.game.GameCharacter;
|
import netwerkprog.game.util.game.GameCharacter;
|
||||||
|
|
||||||
public class Agent extends GameCharacter {
|
public class Agent extends GameCharacter {
|
||||||
public Agent(TextureRegion textureRegion, Ability... abilities) {
|
public Agent(String name, TextureRegion textureRegion, Ability... abilities) {
|
||||||
super("Agent", Faction.MEGACORPORATION, textureRegion, abilities);
|
super(name, Faction.MEGACORPORATION, textureRegion, abilities);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,11 +117,13 @@ 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.setGamestate(GAMESTATE.PLAYING);
|
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.setGamestate(GAMESTATE.PLAYING);
|
mainGame.setGamestate(GAMESTATE.PLAYING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -152,16 +154,20 @@ public class GameInputProcessor implements InputProcessor {
|
|||||||
if (gameTile.getSymbol() != '#' && mainGame.mapRenderer.getSurroundedTilesOfCurrentCharacter().contains(gameTile)) {
|
if (gameTile.getSymbol() != '#' && mainGame.mapRenderer.getSurroundedTilesOfCurrentCharacter().contains(gameTile)) {
|
||||||
removeCharacterFromTile(mainGame.getSelectedCharacter());
|
removeCharacterFromTile(mainGame.getSelectedCharacter());
|
||||||
gameTile.visit(mainGame.getSelectedCharacter());
|
gameTile.visit(mainGame.getSelectedCharacter());
|
||||||
mainGame.mapRenderer.setSurroundedTilesOfCurrentCharacter(col,row);
|
mainGame.mapRenderer.setSurroundedTilesOfCurrentCharacter(col, row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!mainGame.hasCharacterSelected() && gameTile.containsCharacter()) {
|
if (!mainGame.hasCharacterSelected() && gameTile.containsCharacter()) {
|
||||||
mainGame.setSelectedCharacter(gameTile.getCharacter());
|
if (gameTile.getCharacter().getFaction() == mainGame.getChosenFaction()) {
|
||||||
mainGame.mapRenderer.setSurroundedTilesOfCurrentCharacter(col,row);
|
mainGame.setSelectedCharacter(gameTile.getCharacter());
|
||||||
|
mainGame.mapRenderer.setSurroundedTilesOfCurrentCharacter(col, row);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (gameTile.containsCharacter() && !mainGame.getSelectedCharacter().equals(gameTile.getCharacter())) {
|
if (gameTile.containsCharacter()
|
||||||
|
&& !mainGame.getSelectedCharacter().equals(gameTile.getCharacter())
|
||||||
|
&& gameTile.getCharacter().getFaction() == mainGame.getChosenFaction()) {
|
||||||
mainGame.setSelectedCharacter(gameTile.getCharacter());
|
mainGame.setSelectedCharacter(gameTile.getCharacter());
|
||||||
mainGame.mapRenderer.setSurroundedTilesOfCurrentCharacter(col,row);
|
mainGame.mapRenderer.setSurroundedTilesOfCurrentCharacter(col, row);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,4 +119,8 @@ public abstract class GameCharacter extends Actor implements Comparable<GameChar
|
|||||||
public void setAllowedToMove(List<GameTile> allowedToMove) {
|
public void setAllowedToMove(List<GameTile> allowedToMove) {
|
||||||
this.allowedToMove = allowedToMove;
|
this.allowedToMove = allowedToMove;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Faction getFaction() {
|
||||||
|
return faction;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user