diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-09-15 23:28:36 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-09-15 23:28:36 +0200 |
commit | 93bfeff7573f12278ed07954f7866d9635e51b1d (patch) | |
tree | 2ed9ed4f0c8d2fb649ed567e54ef8a6d83f72731 /core/src/ch/asynk/tankontank | |
parent | 259b12b915ad366e8faeed0f82b4d3690c31298a (diff) | |
download | RustAndDust-93bfeff7573f12278ed07954f7866d9635e51b1d.zip RustAndDust-93bfeff7573f12278ed07954f7866d9635e51b1d.tar.gz |
add utils/UnitFactory, knows units stats and textures
Diffstat (limited to 'core/src/ch/asynk/tankontank')
-rw-r--r-- | core/src/ch/asynk/tankontank/utils/UnitFactory.java | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/core/src/ch/asynk/tankontank/utils/UnitFactory.java b/core/src/ch/asynk/tankontank/utils/UnitFactory.java new file mode 100644 index 0000000..5157d89 --- /dev/null +++ b/core/src/ch/asynk/tankontank/utils/UnitFactory.java @@ -0,0 +1,102 @@ +package ch.asynk.tankontank.utils; + +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.Unit; +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; + } +} |