summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-10-28 15:26:10 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2014-10-28 15:26:10 +0100
commita5e60eb6f1d4335406bb53500e7dd87182d67a1a (patch)
tree86abbb45591e5c6114e3a9cebcf735b0bb2aec8f
parent5bde2499ba50166b55286cfb2481698ff3d2f46c (diff)
downloadRustAndDust-a5e60eb6f1d4335406bb53500e7dd87182d67a1a.zip
RustAndDust-a5e60eb6f1d4335406bb53500e7dd87182d67a1a.tar.gz
use 4 atlases, set Unit overlays
-rw-r--r--core/src/ch/asynk/tankontank/TankOnTank.java10
-rw-r--r--core/src/ch/asynk/tankontank/engine/HeadedPawn.java6
-rw-r--r--core/src/ch/asynk/tankontank/engine/Pawn.java6
-rw-r--r--core/src/ch/asynk/tankontank/game/Hud.java2
-rw-r--r--core/src/ch/asynk/tankontank/game/Unit.java12
-rw-r--r--core/src/ch/asynk/tankontank/game/battles/Factory.java51
6 files changed, 51 insertions, 36 deletions
diff --git a/core/src/ch/asynk/tankontank/TankOnTank.java b/core/src/ch/asynk/tankontank/TankOnTank.java
index 268def1..e9ec02b 100644
--- a/core/src/ch/asynk/tankontank/TankOnTank.java
+++ b/core/src/ch/asynk/tankontank/TankOnTank.java
@@ -39,7 +39,10 @@ public class TankOnTank extends Game
Gdx.app.debug("TankOnTank", " load assets : " + (Gdx.app.getJavaHeap()/1024.0f) + "KB");
manager.load("data/map_a.png", Texture.class);
manager.load("data/map_b.png", Texture.class);
- manager.load("data/assets.atlas", TextureAtlas.class);
+ manager.load("data/hud.atlas", TextureAtlas.class);
+ manager.load("data/pawns.atlas", TextureAtlas.class);
+ manager.load("data/pawn-overlays.atlas", TextureAtlas.class);
+ manager.load("data/tile-overlays.atlas", TextureAtlas.class);
manager.load("data/explosion.png", Texture.class);
manager.load("data/explosions.png", Texture.class);
}
@@ -50,7 +53,10 @@ public class TankOnTank extends Game
Gdx.app.debug("TankOnTank", "diagnostics:\n" + manager.getDiagnostics() );
manager.unload("data/map_a.png");
manager.unload("data/map_b.png");
- manager.unload("data/assets.atlas");
+ manager.unload("data/hud.atlas");
+ manager.unload("data/pawns.atlas");
+ manager.unload("data/pawn-overlays.atlas");
+ manager.unload("data/tile-overlays.atlas");
manager.unload("data/explosion.png");
manager.unload("data/explosions.png");
Gdx.app.debug("TankOnTank", "diagnostics:\n" + manager.getDiagnostics() );
diff --git a/core/src/ch/asynk/tankontank/engine/HeadedPawn.java b/core/src/ch/asynk/tankontank/engine/HeadedPawn.java
index cbe4cd5..fb362bc 100644
--- a/core/src/ch/asynk/tankontank/engine/HeadedPawn.java
+++ b/core/src/ch/asynk/tankontank/engine/HeadedPawn.java
@@ -14,10 +14,10 @@ public abstract class HeadedPawn extends Pawn
private Image head;
protected Orientation orientation;
- public HeadedPawn(Faction faction, TextureAtlas atlas, String pawn, String head)
+ public HeadedPawn(Faction faction, String pawn, String head, TextureAtlas pawns, TextureAtlas overlays)
{
- super(faction, atlas, pawn);
- this.head = new Image(atlas.findRegion(head));
+ super(faction, pawn, pawns, overlays);
+ this.head = new Image(pawns.findRegion(head));
this.orientation = Orientation.KEEP;
this.descr += " " + orientation;
}
diff --git a/core/src/ch/asynk/tankontank/engine/Pawn.java b/core/src/ch/asynk/tankontank/engine/Pawn.java
index a433796..4d6299f 100644
--- a/core/src/ch/asynk/tankontank/engine/Pawn.java
+++ b/core/src/ch/asynk/tankontank/engine/Pawn.java
@@ -79,13 +79,13 @@ public abstract class Pawn implements Moveable, Disposable
this.prevPosition = new Vector3(0f, 0f, 0f);
}
- public Pawn(Faction faction, TextureAtlas atlas, String name)
+ public Pawn(Faction faction, String name, TextureAtlas pawns, TextureAtlas overlays)
{
this();
this.faction = faction;
this.descr = descr;
- this.image = new Image(atlas.findRegion(name));
- this.overlays = new StackedImages(atlas);
+ this.image = new Image(pawns.findRegion(name));
+ this.overlays = new StackedImages(overlays);
}
@Override
diff --git a/core/src/ch/asynk/tankontank/game/Hud.java b/core/src/ch/asynk/tankontank/game/Hud.java
index 4a9e0f9..e4fae79 100644
--- a/core/src/ch/asynk/tankontank/game/Hud.java
+++ b/core/src/ch/asynk/tankontank/game/Hud.java
@@ -43,7 +43,7 @@ public class Hud implements Disposable
this.ctrl = ctrl;
this.corner = new Vector2((Gdx.graphics.getWidth() - OFFSET), OFFSET);
- TextureAtlas atlas = game.manager.get("data/assets.atlas", TextureAtlas.class);
+ TextureAtlas atlas = game.factory.hudAtlas;
moveBtn = new Button(atlas, "btn-move");
rotateBtn = new Button(atlas, "btn-rotate");
diff --git a/core/src/ch/asynk/tankontank/game/Unit.java b/core/src/ch/asynk/tankontank/game/Unit.java
index 56736d2..e22bfc2 100644
--- a/core/src/ch/asynk/tankontank/game/Unit.java
+++ b/core/src/ch/asynk/tankontank/game/Unit.java
@@ -54,15 +54,15 @@ public class Unit extends HeadedPawn
private boolean hasMoved;
private boolean hasFired;
- protected Unit(Army army, TextureAtlas atlas, String pawn, String head)
+ protected Unit(Army army, String pawn, String head, TextureAtlas pawns, TextureAtlas overlays)
{
- super(army, atlas, pawn, head);
+ super(army, pawn, head, pawns, overlays);
}
// hard tager
- public Unit(Army army, UnitId id, UnitType type, int range, int defense, int movementPoints, TextureAtlas atlas, String unit, String head)
+ public Unit(Army army, UnitId id, UnitType type, int range, int defense, int movementPoints, String unit, String head, TextureAtlas pawns, TextureAtlas overlays)
{
- super(army, atlas, unit, head);
+ super(army, unit, head, pawns, overlays);
this.rng = range;
this.def = defense;
this.mp = movementPoints;
@@ -74,9 +74,9 @@ public class Unit extends HeadedPawn
}
// soft tager
- public Unit(Army army, UnitId id, UnitType type, int range, int defense, int concealedDefense, int movementPoints, TextureAtlas atlas, String unit, String head)
+ public Unit(Army army, UnitId id, UnitType type, int range, int defense, int concealedDefense, int movementPoints, String unit, String head, TextureAtlas pawns, TextureAtlas overlays)
{
- super(army, atlas, unit, head);
+ super(army, unit, head, pawns, overlays);
this.rng = range;
this.def = defense;
this.cdef = concealedDefense;
diff --git a/core/src/ch/asynk/tankontank/game/battles/Factory.java b/core/src/ch/asynk/tankontank/game/battles/Factory.java
index 8ab3ba8..332aa27 100644
--- a/core/src/ch/asynk/tankontank/game/battles/Factory.java
+++ b/core/src/ch/asynk/tankontank/game/battles/Factory.java
@@ -26,7 +26,10 @@ public class Factory implements Board.TileBuilder, Disposable
FAKE
}
- private TextureAtlas atlas;
+ public TextureAtlas hudAtlas;
+ public TextureAtlas pawnsAtlas;
+ public TextureAtlas pawnOverlaysAtlas;
+ public TextureAtlas tileOverlaysAtlas;
private final TankOnTank game;
public Factory(final TankOnTank game)
@@ -36,13 +39,19 @@ public class Factory implements Board.TileBuilder, Disposable
public void assetsLoaded()
{
- this.atlas = game.manager.get("data/assets.atlas", TextureAtlas.class);
+ this.hudAtlas = game.manager.get("data/hud.atlas", TextureAtlas.class);
+ this.pawnsAtlas = game.manager.get("data/pawns.atlas", TextureAtlas.class);
+ this.pawnOverlaysAtlas = game.manager.get("data/pawn-overlays.atlas", TextureAtlas.class);
+ this.tileOverlaysAtlas = game.manager.get("data/tile-overlays.atlas", TextureAtlas.class);
}
@Override
public void dispose()
{
- atlas.dispose();
+ hudAtlas.dispose();
+ pawnsAtlas.dispose();
+ pawnOverlaysAtlas.dispose();
+ tileOverlaysAtlas.dispose();
}
private Board.Config config()
@@ -82,9 +91,9 @@ public class Factory implements Board.TileBuilder, Disposable
public Player getPlayer(Army army)
{
if (army == Army.US)
- return new Player(game, Army.US, game.skin.getFont("default-font"), atlas, "us-flag", 10);
+ return new Player(game, Army.US, game.skin.getFont("default-font"), hudAtlas, "us-flag", 10);
else
- return new Player(game, Army.GE, game.skin.getFont("default-font"), atlas, "ge-flag", 10);
+ return new Player(game, Army.GE, game.skin.getFont("default-font"), hudAtlas, "ge-flag", 10);
}
public Unit getUnit(UnitId id)
@@ -95,54 +104,54 @@ 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, atlas, "ge-at-gun", "head");
+ u = new Unit(Army.GE, id, ut, 3, 8, 9, 1, "ge-at-gun", "head", pawnsAtlas, pawnOverlaysAtlas);
break;
case GE_INFANTRY:
ut = UnitType.INFANTRY;
- u = new Unit(Army.GE, id, ut, 1, 7, 10, 1, atlas, "ge-infantry", "head");
+ u = new Unit(Army.GE, id, ut, 1, 7, 10, 1, "ge-infantry", "head", pawnsAtlas, pawnOverlaysAtlas);
break;
case GE_KINGTIGER:
- u = new Unit(Army.GE, id, ut, 3, 12, 1, atlas, "ge-kingtiger", "head");
+ u = new Unit(Army.GE, id, ut, 3, 12, 1, "ge-kingtiger", "head", pawnsAtlas, pawnOverlaysAtlas);
break;
case GE_PANZER_IV:
- u = new Unit(Army.GE, id, ut, 2, 9, 2, atlas, "ge-panzer-iv", "head");
+ u = new Unit(Army.GE, id, ut, 2, 9, 2, "ge-panzer-iv", "head", pawnsAtlas, pawnOverlaysAtlas);
break;
case GE_PANZER_IV_HQ:
- u = new Unit(Army.GE, id, utHq, 2, 9, 2, atlas, "ge-panzer-iv-hq", "head");
+ u = new Unit(Army.GE, id, utHq, 2, 9, 2, "ge-panzer-iv-hq", "head", pawnsAtlas, pawnOverlaysAtlas);
break;
case GE_TIGER:
- u = new Unit(Army.GE, id, ut, 3, 11, 1, atlas, "ge-tiger", "head");
+ u = new Unit(Army.GE, id, ut, 3, 11, 1, "ge-tiger", "head", pawnsAtlas, pawnOverlaysAtlas);
break;
case GE_WESPE:
ut = UnitType.ARTILLERY;
- u = new Unit(Army.GE, id, ut, 5, 8, 1, atlas, "ge-wespe", "head");
+ u = new Unit(Army.GE, id, ut, 5, 8, 1, "ge-wespe", "head", pawnsAtlas, pawnOverlaysAtlas);
break;
case US_AT_GUN:
ut = UnitType.AT_GUN;
- u = new Unit(Army.US, id, ut, 1, 7, 10, 1, atlas, "us-at-gun", "head");
+ u = new Unit(Army.US, id, ut, 1, 7, 10, 1, "us-at-gun", "head", pawnsAtlas, pawnOverlaysAtlas);
break;
case US_INFANTRY:
ut = UnitType.INFANTRY;
- u = new Unit(Army.US, id, ut, 1, 7, 10, 1, atlas, "us-infantry", "head");
+ u = new Unit(Army.US, id, ut, 1, 7, 10, 1, "us-infantry", "head", pawnsAtlas, pawnOverlaysAtlas);
break;
case US_PERSHING:
- u = new Unit(Army.US, id, ut, 3, 10, 2, atlas, "us-pershing", "head");
+ u = new Unit(Army.US, id, ut, 3, 10, 2, "us-pershing", "head", pawnsAtlas, pawnOverlaysAtlas);
break;
case US_PERSHING_HQ:
- u = new Unit(Army.US, id, utHq, 3, 10, 2, atlas, "us-pershing-hq", "head");
+ u = new Unit(Army.US, id, utHq, 3, 10, 2, "us-pershing-hq", "head", pawnsAtlas, pawnOverlaysAtlas);
break;
case US_PRIEST:
ut = UnitType.ARTILLERY;
- u = new Unit(Army.US, id, ut, 5, 8, 1, atlas, "us-priest", "head");
+ u = new Unit(Army.US, id, ut, 5, 8, 1, "us-priest", "head", pawnsAtlas, pawnOverlaysAtlas);
break;
case US_SHERMAN:
- u = new Unit(Army.US, id, ut, 2, 9, 2, atlas, "us-sherman", "us-sherman-head");
+ u = new Unit(Army.US, id, ut, 2, 9, 2, "us-sherman", "us-sherman-head", pawnsAtlas, pawnOverlaysAtlas);
break;
case US_SHERMAN_HQ:
- u = new Unit(Army.US, id, utHq, 2, 9, 2, atlas, "us-sherman-hq", "head");
+ u = new Unit(Army.US, id, utHq, 2, 9, 2, "us-sherman-hq", "head", pawnsAtlas, pawnOverlaysAtlas);
break;
case US_WOLVERINE:
- u = new Unit(Army.US, id, ut, 3, 8, 3, atlas, "us-wolverine", "head");
+ u = new Unit(Army.US, id, ut, 3, 8, 3, "us-wolverine", "head", pawnsAtlas, pawnOverlaysAtlas);
break;
}
@@ -151,6 +160,6 @@ public class Factory implements Board.TileBuilder, Disposable
public Hex getNewTile(float x, float y, int col, int row)
{
- return new Hex(x, y, col, row, atlas);
+ return new Hex(x, y, col, row, tileOverlaysAtlas);
}
}