Characters moving #9
Binary file not shown.
|
Before Width: | Height: | Size: 914 B After Width: | Height: | Size: 907 B |
@@ -157,9 +157,11 @@ public class GameInputProcessor implements InputProcessor {
|
|||||||
}
|
}
|
||||||
if (!mainGame.hasCharacterSelected() && gameTile.containsCharacter()) {
|
if (!mainGame.hasCharacterSelected() && gameTile.containsCharacter()) {
|
||||||
mainGame.setSelectedCharacter(gameTile.getCharacter());
|
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())) {
|
||||||
mainGame.setSelectedCharacter(gameTile.getCharacter());
|
mainGame.setSelectedCharacter(gameTile.getCharacter());
|
||||||
|
mainGame.mapRenderer.setSurroundedTilesOfCurrentCharacter(col,row);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
|||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
||||||
import netwerkprog.game.client.MainGame;
|
import netwerkprog.game.client.MainGame;
|
||||||
|
import netwerkprog.game.util.game.GameCharacter;
|
||||||
import netwerkprog.game.util.graphics.Renderable;
|
import netwerkprog.game.util.graphics.Renderable;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
|
|
||||||
@@ -144,12 +145,14 @@ public class MapRenderer implements Renderable {
|
|||||||
int cy = y + direction[1];
|
int cy = y + direction[1];
|
||||||
if (cy >= 0 && cy < gameTiles.length)
|
if (cy >= 0 && cy < gameTiles.length)
|
||||||
if (cx >= 0 && cx < gameTiles[cy].length)
|
if (cx >= 0 && cx < gameTiles[cy].length)
|
||||||
res.add(gameTiles[cy][cx]);
|
if (gameTiles[cy][cx].getSymbol() != '#')
|
||||||
|
res.add(gameTiles[cy][cx]);
|
||||||
}
|
}
|
||||||
surroundedTilesOfCurrentCharacter = res;
|
surroundedTilesOfCurrentCharacter = res;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getPos(GameTile tile, String choice) {
|
public int getPos(GameTile tile, String choice) {
|
||||||
for (int row = 0; row < this.gameTiles.length; row++) {
|
for (int row = 0; row < this.gameTiles.length; row++) {
|
||||||
for (int col = 0; col < this.gameTiles[0].length; col++) {
|
for (int col = 0; col < this.gameTiles[0].length; col++) {
|
||||||
|
|||||||
@@ -5,10 +5,13 @@ import com.badlogic.gdx.graphics.Texture;
|
|||||||
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 com.badlogic.gdx.scenes.scene2d.Actor;
|
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||||
|
import netwerkprog.game.client.game.map.GameTile;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public abstract class GameCharacter extends Actor implements Comparable<GameCharacter> {
|
public abstract class GameCharacter extends Actor implements Comparable<GameCharacter> {
|
||||||
@@ -18,6 +21,7 @@ public abstract class GameCharacter extends Actor implements Comparable<GameChar
|
|||||||
protected boolean override;
|
protected boolean override;
|
||||||
protected TextureRegion textureRegion;
|
protected TextureRegion textureRegion;
|
||||||
protected int health;
|
protected int health;
|
||||||
|
protected List<GameTile> allowedToMove;
|
||||||
|
|
||||||
public GameCharacter(String name, Faction faction, TextureRegion textureRegion, Ability... abilities) {
|
public GameCharacter(String name, Faction faction, TextureRegion textureRegion, Ability... abilities) {
|
||||||
super();
|
super();
|
||||||
@@ -27,6 +31,7 @@ public abstract class GameCharacter extends Actor implements Comparable<GameChar
|
|||||||
this.override = false;
|
this.override = false;
|
||||||
this.textureRegion = textureRegion;
|
this.textureRegion = textureRegion;
|
||||||
this.health = 100;
|
this.health = 100;
|
||||||
|
this.allowedToMove = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@@ -106,4 +111,12 @@ public abstract class GameCharacter extends Actor implements Comparable<GameChar
|
|||||||
", y=" + super.getY() +
|
", y=" + super.getY() +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<GameTile> getAllowedToMove() {
|
||||||
|
return allowedToMove;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAllowedToMove(List<GameTile> allowedToMove) {
|
||||||
|
this.allowedToMove = allowedToMove;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user