diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-09-16 10:15:31 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-09-16 10:15:31 +0200 |
commit | 0206a146d6026e9269fbda409e62bab18ae12865 (patch) | |
tree | 0ea300b4efedce6abc40cb9334f6fed17fb3d1f4 /core/src/ch/asynk/tankontank/game | |
parent | ee34fe79fa447e73594e87a13cf35e8b55683c2d (diff) | |
download | RustAndDust-0206a146d6026e9269fbda409e62bab18ae12865.zip RustAndDust-0206a146d6026e9269fbda409e62bab18ae12865.tar.gz |
move Unit and UnitFactory into game/
Diffstat (limited to 'core/src/ch/asynk/tankontank/game')
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Unit.java | 39 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/UnitFactory.java | 101 |
2 files changed, 140 insertions, 0 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Unit.java b/core/src/ch/asynk/tankontank/game/Unit.java new file mode 100644 index 0000000..12681ac --- /dev/null +++ b/core/src/ch/asynk/tankontank/game/Unit.java @@ -0,0 +1,39 @@ +package ch.asynk.tankontank.game; + +import com.badlogic.gdx.graphics.g2d.TextureRegion; + +import ch.asynk.tankontank.actors.Pawn; +import ch.asynk.tankontank.actors.HexMap; + +public class Unit extends Pawn +{ + public int rng; + public int def; + public int cdef; + public int mp; + public boolean hq; + public boolean ht; + + // hard tager + public Unit(boolean hq, int range, int defense, int movementPoints, TextureRegion region, HexMap map) + { + super(region, map); + this.hq = hq; + this.rng = range; + this.def = defense; + this.mp = movementPoints; + this.ht = true; + } + + // soft tager + public Unit(boolean hq, int range, int defense, int concealedDefense, int movementPoints, TextureRegion region, HexMap map) + { + super(region, map); + this.hq = hq; + this.rng = range; + this.def = defense; + this.cdef = concealedDefense; + this.mp = movementPoints; + this.ht = false; + } +} diff --git a/core/src/ch/asynk/tankontank/game/UnitFactory.java b/core/src/ch/asynk/tankontank/game/UnitFactory.java new file mode 100644 index 0000000..513f38f --- /dev/null +++ b/core/src/ch/asynk/tankontank/game/UnitFactory.java @@ -0,0 +1,101 @@ +package ch.asynk.tankontank.game; + +import com.badlogic.gdx.assets.AssetManager; +import com.badlogic.gdx.graphics.g2d.TextureAtlas; +import com.badlogic.gdx.graphics.g2d.TextureRegion; + +import ch.asynk.tankontank.actors.HexMap; + +public class UnitFactory +{ + public enum UnitType + { + GE_AT_GUN, + GE_INFANTRY, + GE_KINGTIGER, + GE_PANZER_IV, + GE_PANZER_IV_HQ, + GE_TIGER, + GE_WESPE, + + US_AT_GUN, + US_INFANTRY, + US_PERSHING, + US_PERSHING_HQ, + US_PRIEST, + US_SHERMAN, + US_SHERMAN_HQ, + US_WOLVERINE + } + + private static HexMap map; + private static TextureAtlas usAtlas; + private static TextureAtlas geAtlas; + + public static void init(AssetManager manager, HexMap m) + { + map = m; + usAtlas = manager.get("images/us.pack", TextureAtlas.class); + geAtlas = manager.get("images/ge.pack", TextureAtlas.class); + } + + public static void dispose() + { + usAtlas.dispose(); + geAtlas.dispose(); + } + + public static Unit getUnit(UnitType t) + { + Unit u = null; + switch(t) { + case GE_AT_GUN: + u = new Unit(false, 3, 8, 9, 1, geAtlas.findRegion("at-gun"), map); + break; + case GE_INFANTRY: + u = new Unit(false, 1, 7, 10, 1, geAtlas.findRegion("infantry"), map); + break; + case GE_KINGTIGER: + u = new Unit(false, 3, 12, 1, geAtlas.findRegion("kingtiger"), map); + break; + case GE_PANZER_IV: + u = new Unit(false, 2, 9, 2, geAtlas.findRegion("panzer-iv"), map); + break; + case GE_PANZER_IV_HQ: + u = new Unit(true, 2, 9, 2, geAtlas.findRegion("panzer-iv-hq"), map); + break; + case GE_TIGER: + u = new Unit(false, 3, 11, 1, geAtlas.findRegion("tiger"), map); + break; + case GE_WESPE: + u = new Unit(false, 5, 8, 1, geAtlas.findRegion("wespe"), map); + break; + case US_AT_GUN: + u = new Unit(false, 1, 7, 10, 1, usAtlas.findRegion("at-gun"), map); + break; + case US_INFANTRY: + u = new Unit(false, 1, 7, 10, 1, usAtlas.findRegion("infantry"), map); + break; + case US_PERSHING: + u = new Unit(false, 3, 10, 2, usAtlas.findRegion("pershing"), map); + break; + case US_PERSHING_HQ: + u = new Unit(true, 3, 10, 2, usAtlas.findRegion("pershing-hq"), map); + break; + case US_PRIEST: + u = new Unit(false, 5, 8, 1, usAtlas.findRegion("priest"), map); + break; + case US_SHERMAN: + u = new Unit(false, 2, 9, 2, usAtlas.findRegion("sherman"), map); + break; + case US_SHERMAN_HQ: + u = new Unit(true, 2, 9, 2, usAtlas.findRegion("sherman-hq"), map); + break; + case US_WOLVERINE: + u = new Unit(false, 3, 8, 3, usAtlas.findRegion("wolverine"), map); + break; + } + + return u; + } +} |