Characters moving #9

Merged
SemvdH merged 7 commits from characters-moving into master 2020-06-06 14:30:24 +00:00
4 changed files with 36 additions and 20 deletions
Showing only changes of commit ab3d57bc7f - Show all commits

View File

@@ -9,11 +9,11 @@ import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
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.TextureRegion;
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.Team;
import netwerkprog.game.client.game.characters.abilities.BodySwap;
@@ -49,9 +49,6 @@ public class MainGame extends ApplicationAdapter {
private Map map;
public MapRenderer mapRenderer;
public GameCharacter testCharacter;
private static MainGame INSTANCE;
private MainGame() {
@@ -100,8 +97,6 @@ public class MainGame extends ApplicationAdapter {
camera.viewportHeight = screenHeight / 2;
camera.update();
setGamestate(GAMESTATE.SELECTING_FACTION);
initCharacters();
// this.tree.insert(new Hacker(,new BodySwap()));
@@ -111,16 +106,27 @@ public class MainGame extends ApplicationAdapter {
// connectToServer();
}
private void initCharacters() {
public void initCharacters() {
Texture texture = new Texture(Gdx.files.internal("core/assets/characters.png"));
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.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));
}

View File

@@ -6,7 +6,7 @@ import netwerkprog.game.util.game.Faction;
import netwerkprog.game.util.game.GameCharacter;
public class Agent extends GameCharacter {
public Agent(TextureRegion textureRegion, Ability... abilities) {
super("Agent", Faction.MEGACORPORATION, textureRegion, abilities);
public Agent(String name, TextureRegion textureRegion, Ability... abilities) {
super(name, Faction.MEGACORPORATION, textureRegion, abilities);
}
}

View File

@@ -117,11 +117,13 @@ 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);
}
if (keycode == Input.Keys.NUM_2) {
System.out.println("HACKER");
mainGame.setChosenFaction(Faction.HACKER);
mainGame.initCharacters();
mainGame.setGamestate(GAMESTATE.PLAYING);
}
}
@@ -152,16 +154,20 @@ public class GameInputProcessor implements InputProcessor {
if (gameTile.getSymbol() != '#' && mainGame.mapRenderer.getSurroundedTilesOfCurrentCharacter().contains(gameTile)) {
removeCharacterFromTile(mainGame.getSelectedCharacter());
gameTile.visit(mainGame.getSelectedCharacter());
mainGame.mapRenderer.setSurroundedTilesOfCurrentCharacter(col,row);
mainGame.mapRenderer.setSurroundedTilesOfCurrentCharacter(col, row);
}
}
if (!mainGame.hasCharacterSelected() && gameTile.containsCharacter()) {
mainGame.setSelectedCharacter(gameTile.getCharacter());
mainGame.mapRenderer.setSurroundedTilesOfCurrentCharacter(col,row);
if (gameTile.getCharacter().getFaction() == mainGame.getChosenFaction()) {
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.mapRenderer.setSurroundedTilesOfCurrentCharacter(col,row);
mainGame.mapRenderer.setSurroundedTilesOfCurrentCharacter(col, row);
}
return true;
}

View File

@@ -119,4 +119,8 @@ public abstract class GameCharacter extends Actor implements Comparable<GameChar
public void setAllowedToMove(List<GameTile> allowedToMove) {
this.allowedToMove = allowedToMove;
}
public Faction getFaction() {
return faction;
}
}