diff --git a/core/assets/characters.png b/core/assets/characters.png new file mode 100644 index 0000000..8db79d0 Binary files /dev/null and b/core/assets/characters.png differ diff --git a/core/src/netwerkprog/game/client/MainGame.java b/core/src/netwerkprog/game/client/MainGame.java index 8f2e484..6ff783d 100644 --- a/core/src/netwerkprog/game/client/MainGame.java +++ b/core/src/netwerkprog/game/client/MainGame.java @@ -6,11 +6,21 @@ import com.badlogic.gdx.Gdx; import com.badlogic.gdx.audio.Music; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.OrthographicCamera; +import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.SpriteBatch; + +import com.badlogic.gdx.graphics.g2d.TextureRegion; +import netwerkprog.game.client.game.characters.Agent; +import netwerkprog.game.client.game.characters.Hacker; +import netwerkprog.game.client.game.characters.abilities.BodySwap; +import netwerkprog.game.client.game.characters.abilities.Implant; +import netwerkprog.game.client.game.characters.abilities.Scrambler; import netwerkprog.game.client.game.map.Map; import netwerkprog.game.client.game.map.MapRenderer; import netwerkprog.game.client.game.map.GameInputProcessor; +import netwerkprog.game.util.game.Character; import netwerkprog.game.util.graphics.FrameRate; +import netwerkprog.game.util.tree.BST; public class MainGame extends ApplicationAdapter{ SpriteBatch batch; @@ -24,6 +34,9 @@ public class MainGame extends ApplicationAdapter{ private Map map; public MapRenderer mapRenderer; + private BST tree; + public Character testCharacter; + @Override @@ -58,6 +71,9 @@ public class MainGame extends ApplicationAdapter{ camera.viewportWidth = screenWidth / 2; camera.viewportHeight = screenHeight / 2; camera.update(); + this.tree = new BST<>(); + initCharaters(); +// this.tree.insert(new Hacker(,new BodySwap())); // playSong(); @@ -66,6 +82,14 @@ public class MainGame extends ApplicationAdapter{ // connectToServer(); } + private void initCharaters() { + Texture texture = new Texture(Gdx.files.internal("core/assets/characters.png")); + TextureRegion[][] characters = TextureRegion.split(texture,32,32); + this.testCharacter = new Hacker(characters[1][0],new BodySwap("test")); + this.tree.insert(testCharacter); + this.tree.insert(new Agent(characters[2][0],new Implant("test"))); + } + private void playSong() { // play music @@ -144,5 +168,8 @@ public class MainGame extends ApplicationAdapter{ return map.getWidth(); } + public BST getTree() { + return tree; + } } diff --git a/core/src/netwerkprog/game/client/game/characters/Agent.java b/core/src/netwerkprog/game/client/game/characters/Agent.java new file mode 100644 index 0000000..26a32e3 --- /dev/null +++ b/core/src/netwerkprog/game/client/game/characters/Agent.java @@ -0,0 +1,12 @@ +package netwerkprog.game.client.game.characters; + +import com.badlogic.gdx.graphics.g2d.TextureRegion; +import netwerkprog.game.util.game.Ability; +import netwerkprog.game.util.game.Character; +import netwerkprog.game.util.game.Faction; + +public class Agent extends Character { + public Agent(TextureRegion textureRegion, Ability... abilities) { + super("Agent", Faction.MEGACORPORATION, textureRegion, abilities); + } +} diff --git a/core/src/netwerkprog/game/client/game/characters/Hacker.java b/core/src/netwerkprog/game/client/game/characters/Hacker.java new file mode 100644 index 0000000..66adbad --- /dev/null +++ b/core/src/netwerkprog/game/client/game/characters/Hacker.java @@ -0,0 +1,12 @@ +package netwerkprog.game.client.game.characters; + +import com.badlogic.gdx.graphics.g2d.TextureRegion; +import netwerkprog.game.util.game.Ability; +import netwerkprog.game.util.game.Character; +import netwerkprog.game.util.game.Faction; + +public class Hacker extends Character { + public Hacker(TextureRegion textureRegion, Ability... abilities) { + super("Hacker", Faction.HACKER, textureRegion, abilities); + } +} diff --git a/core/src/netwerkprog/game/client/game/characters/abilities/BodySwap.java b/core/src/netwerkprog/game/client/game/characters/abilities/BodySwap.java index 97514b0..7244e8a 100644 --- a/core/src/netwerkprog/game/client/game/characters/abilities/BodySwap.java +++ b/core/src/netwerkprog/game/client/game/characters/abilities/BodySwap.java @@ -1,4 +1,14 @@ package netwerkprog.game.client.game.characters.abilities; -public class BodySwap { +import netwerkprog.game.util.game.Ability; + +public class BodySwap extends Ability { + public BodySwap(String name) { + super(name); + } + + @Override + public String getCommand() { + return null; + } } diff --git a/core/src/netwerkprog/game/client/game/characters/abilities/Implant.java b/core/src/netwerkprog/game/client/game/characters/abilities/Implant.java index 1f86e28..f6d3b39 100644 --- a/core/src/netwerkprog/game/client/game/characters/abilities/Implant.java +++ b/core/src/netwerkprog/game/client/game/characters/abilities/Implant.java @@ -1,4 +1,14 @@ package netwerkprog.game.client.game.characters.abilities; -public class Implant { +import netwerkprog.game.util.game.Ability; + +public class Implant extends Ability { + public Implant(String name) { + super(name); + } + + @Override + public String getCommand() { + return null; + } } diff --git a/core/src/netwerkprog/game/client/game/map/GameInputProcessor.java b/core/src/netwerkprog/game/client/game/map/GameInputProcessor.java index 061d867..de38be2 100644 --- a/core/src/netwerkprog/game/client/game/map/GameInputProcessor.java +++ b/core/src/netwerkprog/game/client/game/map/GameInputProcessor.java @@ -128,6 +128,7 @@ public class GameInputProcessor implements InputProcessor { GameTile gameTile = game.mapRenderer.getGameTiles()[row][col]; if (gameTile.contains(touchPoint.x, touchPoint.y)) { System.out.println(gameTile + " row: " + row + ", col: " + col); + gameTile.setCharacter(this.game.testCharacter); //TODO make stuff happen with the tile return true; } diff --git a/core/src/netwerkprog/game/client/game/map/GameTile.java b/core/src/netwerkprog/game/client/game/map/GameTile.java index 4797b2a..1c85c0e 100644 --- a/core/src/netwerkprog/game/client/game/map/GameTile.java +++ b/core/src/netwerkprog/game/client/game/map/GameTile.java @@ -25,7 +25,7 @@ public class GameTile extends Rectangle { } public boolean containsCharacter() { - return character == null; + return character != null; } /** diff --git a/core/src/netwerkprog/game/client/game/map/MapRenderer.java b/core/src/netwerkprog/game/client/game/map/MapRenderer.java index 30b6a30..d98c07b 100644 --- a/core/src/netwerkprog/game/client/game/map/MapRenderer.java +++ b/core/src/netwerkprog/game/client/game/map/MapRenderer.java @@ -97,7 +97,7 @@ public class MapRenderer implements Renderable { GameTile cur = gameTileRow[col]; batch.draw(cur.getTextureRegion(), cur.x, cur.y); if (cur.containsCharacter()) { - batch.draw(cur.getCharacter().getTextureRegion(), x, y); + batch.draw(cur.getCharacter().getTextureRegion(), cur.x, cur.y); } } } diff --git a/core/src/netwerkprog/game/util/game/Character.java b/core/src/netwerkprog/game/util/game/Character.java index 807e748..43654d9 100644 --- a/core/src/netwerkprog/game/util/game/Character.java +++ b/core/src/netwerkprog/game/util/game/Character.java @@ -6,7 +6,7 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion; import java.util.Arrays; import java.util.HashSet; -public abstract class Character { +public abstract class Character implements Comparable { protected String name; protected Faction faction; protected HashSet abilities; @@ -39,9 +39,18 @@ public abstract class Character { return textureRegion; } + public void setTextureRegion(TextureRegion textureRegion) { + this.textureRegion = textureRegion; + } + public void render(float x, float y) { batch.begin(); batch.draw(this.textureRegion, x, y); batch.end(); } + + @Override + public int compareTo(Character o) { + return this.name.compareTo(o.name); + } } diff --git a/core/src/netwerkprog/game/util/game/Faction.java b/core/src/netwerkprog/game/util/game/Faction.java index dd347f5..970be94 100644 --- a/core/src/netwerkprog/game/util/game/Faction.java +++ b/core/src/netwerkprog/game/util/game/Faction.java @@ -1,4 +1,6 @@ package netwerkprog.game.util.game; public enum Faction { + HACKER, + MEGACORPORATION }