diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2015-11-20 15:31:22 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2015-11-20 15:31:22 +0100 |
commit | c2e4fec0d0f32f5abbd609e5778fc1710732400f (patch) | |
tree | 047363b843e7954fbe99fc294600714e16f45286 | |
parent | d50992afc8ffaa06c024267ebc0958dc2083e33a (diff) | |
download | RustAndDust-c2e4fec0d0f32f5abbd609e5778fc1710732400f.zip RustAndDust-c2e4fec0d0f32f5abbd609e5778fc1710732400f.tar.gz |
Board,Map: each Map impelementation owns it's own Config
5 files changed, 48 insertions, 29 deletions
diff --git a/core/src/ch/asynk/rustanddust/engine/Board.java b/core/src/ch/asynk/rustanddust/engine/Board.java index e4aba6d..fb77dd8 100644 --- a/core/src/ch/asynk/rustanddust/engine/Board.java +++ b/core/src/ch/asynk/rustanddust/engine/Board.java @@ -65,6 +65,8 @@ public abstract class Board implements Disposable, Animation protected SelectedTile selectedTile; + abstract protected Config getConfig(); + protected Board(int cols, int rows) { // add a frame of OFFMAP Tiles @@ -74,10 +76,10 @@ public abstract class Board implements Disposable, Animation initSides(); } - public Board(TileBuilder tileBuilder, Config cfg, Texture boardTexture, SelectedTile selectedTile) + public Board(TileBuilder tileBuilder, Texture boardTexture, SelectedTile selectedTile) { board = new Sprite(boardTexture); - this.cfg = cfg; + this.cfg = getConfig(); // add a frame of OFFMAP Tiles this.cols = (cfg.cols + 2); this.rows = (cfg.rows + 2); diff --git a/core/src/ch/asynk/rustanddust/game/Map.java b/core/src/ch/asynk/rustanddust/game/Map.java index dedbf23..e0134cb 100644 --- a/core/src/ch/asynk/rustanddust/game/Map.java +++ b/core/src/ch/asynk/rustanddust/game/Map.java @@ -59,9 +59,9 @@ public abstract class Map extends Board implements MoveToAnimationCb, ObjectiveS protected abstract void setup(); - public Map(final RustAndDust game, Board.Config cfg, String textureName) + public Map(final RustAndDust game, String textureName) { - super(game.factory, cfg, game.manager.get(textureName, Texture.class), + super(game.factory, game.manager.get(textureName, Texture.class), new SelectedTile(game.manager.get("data/hex.png", Texture.class), new float[] {.2f, .1f, .1f, .1f, .2f, .1f} )); this.ctrl = game.ctrl; this.destroy = new DestroyAnimation(); diff --git a/core/src/ch/asynk/rustanddust/game/battles/Factory.java b/core/src/ch/asynk/rustanddust/game/battles/Factory.java index 4390663..2e128d3 100644 --- a/core/src/ch/asynk/rustanddust/game/battles/Factory.java +++ b/core/src/ch/asynk/rustanddust/game/battles/Factory.java @@ -79,34 +79,15 @@ public class Factory implements Board.TileBuilder, Disposable this.assetsLoaded = false; } - private Board.Config config() - { - Board.Config cfg = new Board.Config(); - cfg.cols = 10; - cfg.rows = 9; - cfg.x0 = 86; - cfg.y0 = 182; - cfg.w = 189; - cfg.dw = 94; - cfg.s = 110; - cfg.dh = 53.6f; - cfg.h = cfg.s + cfg.dh; - cfg.slope = (cfg.dh / (float) cfg.dw); - - return cfg; - } - public Map getMap(MapType t) { - Board.Config cfg = config(); - Map m = null; switch(t) { case MAP_A: - m = new MapA(game, config(), "data/map_a.png"); + m = new MapA(game, "data/map_a.png"); break; case MAP_B: - m = new MapB(game, config(), "data/map_b.png"); + m = new MapB(game, "data/map_b.png"); break; } diff --git a/core/src/ch/asynk/rustanddust/game/battles/MapA.java b/core/src/ch/asynk/rustanddust/game/battles/MapA.java index 491b370..f7d33c4 100644 --- a/core/src/ch/asynk/rustanddust/game/battles/MapA.java +++ b/core/src/ch/asynk/rustanddust/game/battles/MapA.java @@ -8,9 +8,27 @@ import ch.asynk.rustanddust.game.Hex; public class MapA extends Map { - public MapA(final RustAndDust game, Board.Config cfg, String textureName) + public MapA(final RustAndDust game, String textureName) { - super(game, cfg, textureName); + super(game, textureName); + } + + @Override + protected Board.Config getConfig() + { + Board.Config cfg = new Board.Config(); + cfg.cols = 10; + cfg.rows = 9; + cfg.x0 = 86; + cfg.y0 = 182; + cfg.w = 189; + cfg.dw = 94; + cfg.s = 110; + cfg.dh = 53.6f; + cfg.h = cfg.s + cfg.dh; + cfg.slope = (cfg.dh / (float) cfg.dw); + + return cfg; } @Override diff --git a/core/src/ch/asynk/rustanddust/game/battles/MapB.java b/core/src/ch/asynk/rustanddust/game/battles/MapB.java index 8636481..2b8838c 100644 --- a/core/src/ch/asynk/rustanddust/game/battles/MapB.java +++ b/core/src/ch/asynk/rustanddust/game/battles/MapB.java @@ -8,9 +8,27 @@ import ch.asynk.rustanddust.game.Hex; public class MapB extends Map { - public MapB(final RustAndDust game, Board.Config cfg, String textureName) + public MapB(final RustAndDust game, String textureName) { - super(game, cfg, textureName); + super(game, textureName); + } + + @Override + protected Board.Config getConfig() + { + Board.Config cfg = new Board.Config(); + cfg.cols = 10; + cfg.rows = 9; + cfg.x0 = 86; + cfg.y0 = 182; + cfg.w = 189; + cfg.dw = 94; + cfg.s = 110; + cfg.dh = 53.6f; + cfg.h = cfg.s + cfg.dh; + cfg.slope = (cfg.dh / (float) cfg.dw); + + return cfg; } @Override |