diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-16 15:38:11 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-16 15:38:11 +0200 |
commit | f12da226448e00683286f0a449d4271165377c60 (patch) | |
tree | a296f317660804afc68851e339540c4620313a85 /core/src | |
parent | f986dd3fe0c0cb1e73e47fab2deb5a0929f185a9 (diff) | |
download | RustAndDust-f12da226448e00683286f0a449d4271165377c60.zip RustAndDust-f12da226448e00683286f0a449d4271165377c60.tar.gz |
Factory: big cleanup
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Factory.java | 142 |
1 files changed, 74 insertions, 68 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Factory.java b/core/src/ch/asynk/tankontank/game/Factory.java index 66c19c9..cecfab6 100644 --- a/core/src/ch/asynk/tankontank/game/Factory.java +++ b/core/src/ch/asynk/tankontank/game/Factory.java @@ -8,6 +8,7 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.math.GridPoint2; +import ch.asynk.tankontank.TankOnTank; import ch.asynk.tankontank.engine.Board; import ch.asynk.tankontank.engine.Orientation; import ch.asynk.tankontank.game.Unit.UnitId; @@ -15,17 +16,70 @@ import ch.asynk.tankontank.game.Unit.UnitType; public class Factory implements Board.TileBuilder, Disposable { - private TextureAtlas pawnAtlas; + public enum MapType + { + MAP_A, + MAP_B + } + + public enum Scenarios + { + FAKE + } + + private TextureAtlas atlas; - public Factory(AssetManager manager) + public void setAtlas(TextureAtlas atlas) { - pawnAtlas = manager.get("data/assets.atlas", TextureAtlas.class); + this.atlas = atlas; } @Override public void dispose() { - pawnAtlas.dispose(); + atlas.dispose(); + } + + private Board.Config config() + { + Board.Config cfg = new Board.Config(); + cfg.cols = 10; + cfg.rows = 9; + cfg.x0 = 272; + 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(final TankOnTank game, MapType t) + { + Board.Config cfg = config(); + + Map m = null; + switch(t) { + case MAP_A: + m = new MapA(game, config(), "data/map_a.png"); + break; + case MAP_B: + m = new MapB(game, config(), "data/map_b.png"); + break; + } + + return m; + } + + public Player getPlayer(Army army) + { + if (army == Army.US) + return new Player(Army.US, atlas, "us-flag", 10); + else + return new Player(Army.GE, atlas, "ge-flag", 10); } public Unit getUnit(UnitId id) @@ -36,111 +90,63 @@ public class Factory implements Board.TileBuilder, Disposable switch(id) { case GE_AT_GUN: ut = UnitType.AT_GUN; - u = new Unit(Army.GE, id, ut, 3, 8, 9, 1, pawnAtlas, "ge-at-gun", "head"); + u = new Unit(Army.GE, id, ut, 3, 8, 9, 1, atlas, "ge-at-gun", "head"); break; case GE_INFANTRY: ut = UnitType.INFANTRY; - u = new Unit(Army.GE, id, ut, 1, 7, 10, 1, pawnAtlas, "ge-infantry", "head"); + u = new Unit(Army.GE, id, ut, 1, 7, 10, 1, atlas, "ge-infantry", "head"); break; case GE_KINGTIGER: - u = new Unit(Army.GE, id, ut, 3, 12, 1, pawnAtlas, "ge-kingtiger", "head"); + u = new Unit(Army.GE, id, ut, 3, 12, 1, atlas, "ge-kingtiger", "head"); break; case GE_PANZER_IV: - u = new Unit(Army.GE, id, ut, 2, 9, 2, pawnAtlas, "ge-panzer-iv", "head"); + u = new Unit(Army.GE, id, ut, 2, 9, 2, atlas, "ge-panzer-iv", "head"); break; case GE_PANZER_IV_HQ: - u = new Unit(Army.GE, id, utHq, 2, 9, 2, pawnAtlas, "ge-panzer-iv-hq", "head"); + u = new Unit(Army.GE, id, utHq, 2, 9, 2, atlas, "ge-panzer-iv-hq", "head"); break; case GE_TIGER: - u = new Unit(Army.GE, id, ut, 3, 11, 1, pawnAtlas, "ge-tiger", "head"); + u = new Unit(Army.GE, id, ut, 3, 11, 1, atlas, "ge-tiger", "head"); break; case GE_WESPE: ut = UnitType.ARTILLERY; - u = new Unit(Army.GE, id, ut, 5, 8, 1, pawnAtlas, "ge-wespe", "head"); + u = new Unit(Army.GE, id, ut, 5, 8, 1, atlas, "ge-wespe", "head"); break; case US_AT_GUN: ut = UnitType.AT_GUN; - u = new Unit(Army.US, id, ut, 1, 7, 10, 1, pawnAtlas, "us-at-gun", "head"); + u = new Unit(Army.US, id, ut, 1, 7, 10, 1, atlas, "us-at-gun", "head"); break; case US_INFANTRY: ut = UnitType.INFANTRY; - u = new Unit(Army.US, id, ut, 1, 7, 10, 1, pawnAtlas, "us-infantry", "head"); + u = new Unit(Army.US, id, ut, 1, 7, 10, 1, atlas, "us-infantry", "head"); break; case US_PERSHING: - u = new Unit(Army.US, id, ut, 3, 10, 2, pawnAtlas, "us-pershing", "head"); + u = new Unit(Army.US, id, ut, 3, 10, 2, atlas, "us-pershing", "head"); break; case US_PERSHING_HQ: - u = new Unit(Army.US, id, utHq, 3, 10, 2, pawnAtlas, "us-pershing-hq", "head"); + u = new Unit(Army.US, id, utHq, 3, 10, 2, atlas, "us-pershing-hq", "head"); break; case US_PRIEST: ut = UnitType.ARTILLERY; - u = new Unit(Army.US, id, ut, 5, 8, 1, pawnAtlas, "us-priest", "head"); + u = new Unit(Army.US, id, ut, 5, 8, 1, atlas, "us-priest", "head"); break; case US_SHERMAN: - u = new Unit(Army.US, id, ut, 2, 9, 2, pawnAtlas, "us-sherman", "us-sherman-head"); + u = new Unit(Army.US, id, ut, 2, 9, 2, atlas, "us-sherman", "us-sherman-head"); break; case US_SHERMAN_HQ: - u = new Unit(Army.US, id, utHq, 2, 9, 2, pawnAtlas, "us-sherman-hq", "head"); + u = new Unit(Army.US, id, utHq, 2, 9, 2, atlas, "us-sherman-hq", "head"); break; case US_WOLVERINE: - u = new Unit(Army.US, id, ut, 3, 8, 3, pawnAtlas, "us-wolverine", "head"); + u = new Unit(Army.US, id, ut, 3, 8, 3, atlas, "us-wolverine", "head"); break; } return u; } - public enum MapType - { - MAP_A, - MAP_B - } - - private Board.Config config() - { - Board.Config cfg = new Board.Config(); - cfg.cols = 10; - cfg.rows = 9; - cfg.x0 = 272; - 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(Ctrl ctrl, AssetManager manager, MapType t) - { - Board.Config cfg = config(); - - Map m = null; - switch(t) { - case MAP_A: - m = new MapA(ctrl, this, config(), manager, "data/map_a.png"); - break; - case MAP_B: - m = new MapB(ctrl, this, config(), manager, "data/map_b.png"); - break; - } - - return m; - } - - public Player getPlayer(Army army) - { - if (army == Army.US) - return new Player(Army.US, pawnAtlas, "us-flag", 10); - else - return new Player(Army.GE, pawnAtlas, "ge-flag", 10); - } - public Hex getNewTile(float cx, float cy) { - return new Hex(cx, cy, pawnAtlas); + return new Hex(cx, cy, atlas); } public Player fakeSetup(Map map, Player gePlayer, Player usPlayer) |