diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2015-02-09 14:28:11 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2015-02-09 14:28:11 +0100 |
commit | 17ec9220007929f598b862b3e44eb3128ddf9003 (patch) | |
tree | 15e37eb9583cd723d3046ae8666c4728c997391a /core/src/ch/asynk/tankontank/game | |
parent | 15257cfb2750a439a55e993fd85b2c2ccd5478b8 (diff) | |
download | RustAndDust-17ec9220007929f598b862b3e44eb3128ddf9003.zip RustAndDust-17ec9220007929f598b862b3e44eb3128ddf9003.tar.gz |
Config: add attribute int i to Graphics enum then replace switch code with String.format()
Diffstat (limited to 'core/src/ch/asynk/tankontank/game')
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Config.java | 21 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/battles/Factory.java | 13 |
2 files changed, 11 insertions, 23 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Config.java b/core/src/ch/asynk/tankontank/game/Config.java index c949b54..976f1a6 100644 --- a/core/src/ch/asynk/tankontank/game/Config.java +++ b/core/src/ch/asynk/tankontank/game/Config.java @@ -3,25 +3,20 @@ package ch.asynk.tankontank.game; public class Config { public enum Graphics { - ORIGINAL("original"), - MINE("mine"); + MINE("mine", 0), + ORIGINAL("original", 1); public String s; - Graphics(String s) + public int i; + Graphics(String s, int i) { this.s = s; + this.i = i; } public Graphics next() { - Graphics next = null; - switch(this) { - case ORIGINAL: - next = MINE; - break; - case MINE: - next = ORIGINAL; - break; - } - return next; + if (this == ORIGINAL) + return MINE; + return ORIGINAL; } }; diff --git a/core/src/ch/asynk/tankontank/game/battles/Factory.java b/core/src/ch/asynk/tankontank/game/battles/Factory.java index 57328ad..7002e43 100644 --- a/core/src/ch/asynk/tankontank/game/battles/Factory.java +++ b/core/src/ch/asynk/tankontank/game/battles/Factory.java @@ -60,18 +60,11 @@ public class Factory implements Board.TileBuilder, Disposable public void assetsLoaded() { if (assetsLoaded) return; + int i = game.config.graphics.i; this.hudAtlas = game.manager.get("data/hud.atlas", TextureAtlas.class); this.tileOverlaysAtlas = game.manager.get("data/hex-overlays.atlas", TextureAtlas.class); - switch (game.config.graphics) { - case MINE: - this.pawnsAtlas = game.manager.get("data/units0.atlas", TextureAtlas.class); - this.pawnOverlaysAtlas = game.manager.get("data/unit-overlays0.atlas", TextureAtlas.class); - break; - case ORIGINAL: - this.pawnsAtlas = game.manager.get("data/units1.atlas", TextureAtlas.class); - this.pawnOverlaysAtlas = game.manager.get("data/unit-overlays1.atlas", TextureAtlas.class); - break; - } + this.pawnsAtlas = game.manager.get(String.format("data/units%d.atlas", i), TextureAtlas.class); + this.pawnOverlaysAtlas = game.manager.get(String.format("data/unit-overlays%d.atlas", i), TextureAtlas.class); this.assetsLoaded = true; } |