diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-11-13 17:24:21 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-11-13 17:24:21 +0100 |
commit | 52eb838731e3e38a72652d15ebc60e66860cabf0 (patch) | |
tree | c745d14756b1711bb015e0e818d562f00fe036a4 /core/src/ch/asynk | |
parent | f74e9de84574721f7cf0689dc18a05cc50f50ba8 (diff) | |
download | RustAndDust-52eb838731e3e38a72652d15ebc60e66860cabf0.zip RustAndDust-52eb838731e3e38a72652d15ebc60e66860cabf0.tar.gz |
Config: add and use Battle battle
Diffstat (limited to 'core/src/ch/asynk')
4 files changed, 29 insertions, 6 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Config.java b/core/src/ch/asynk/tankontank/game/Config.java index dbbf7bf..c562b50 100644 --- a/core/src/ch/asynk/tankontank/game/Config.java +++ b/core/src/ch/asynk/tankontank/game/Config.java @@ -9,6 +9,7 @@ public class Config public boolean mustValidate; public boolean showEnemyPossibilities; public boolean debug; + public Battle battle; public Config() { @@ -19,5 +20,6 @@ public class Config this.canCancel = true; this.mustValidate = false; this.showEnemyPossibilities = false; + this.battle = null; } } diff --git a/core/src/ch/asynk/tankontank/game/battles/Factory.java b/core/src/ch/asynk/tankontank/game/battles/Factory.java index 8d111d0..09d062d 100644 --- a/core/src/ch/asynk/tankontank/game/battles/Factory.java +++ b/core/src/ch/asynk/tankontank/game/battles/Factory.java @@ -12,6 +12,8 @@ import ch.asynk.tankontank.game.Army; import ch.asynk.tankontank.game.Unit; import ch.asynk.tankontank.game.Unit.UnitId; import ch.asynk.tankontank.game.Unit.UnitType; +import ch.asynk.tankontank.game.Battle; +import ch.asynk.tankontank.game.battles.BattleHeadToHead; public class Factory implements Board.TileBuilder, Disposable { @@ -30,11 +32,15 @@ public class Factory implements Board.TileBuilder, Disposable public TextureAtlas pawnsAtlas; public TextureAtlas pawnOverlaysAtlas; public TextureAtlas tileOverlaysAtlas; + public Battle battles[]; private final TankOnTank game; public Factory(final TankOnTank game) { this.game = game; + battles = new Battle[] { + new BattleHeadToHead(this), + }; } public void assetsLoaded() diff --git a/core/src/ch/asynk/tankontank/screens/GameScreen.java b/core/src/ch/asynk/tankontank/screens/GameScreen.java index 739a3e3..e044262 100644 --- a/core/src/ch/asynk/tankontank/screens/GameScreen.java +++ b/core/src/ch/asynk/tankontank/screens/GameScreen.java @@ -26,7 +26,6 @@ import com.badlogic.gdx.utils.viewport.ScreenViewport; import ch.asynk.tankontank.TankOnTank; import ch.asynk.tankontank.game.Ctrl; -import ch.asynk.tankontank.game.battles.BattleHeadToHead; public class GameScreen implements Screen { @@ -64,7 +63,7 @@ public class GameScreen implements Screen { this.game = game; - this.ctrl = new Ctrl(game, new BattleHeadToHead(game.factory)); + this.ctrl = new Ctrl(game, game.config.battle); DEBUG = game.config.debug; diff --git a/core/src/ch/asynk/tankontank/screens/OptionsScreen.java b/core/src/ch/asynk/tankontank/screens/OptionsScreen.java index f7752ae..44f3264 100644 --- a/core/src/ch/asynk/tankontank/screens/OptionsScreen.java +++ b/core/src/ch/asynk/tankontank/screens/OptionsScreen.java @@ -8,17 +8,19 @@ import com.badlogic.gdx.utils.viewport.FitViewport; import com.badlogic.gdx.scenes.scene2d.ui.Label; import com.badlogic.gdx.scenes.scene2d.ui.CheckBox; import com.badlogic.gdx.scenes.scene2d.ui.TextButton; +import com.badlogic.gdx.scenes.scene2d.ui.List; import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.InputListener; import ch.asynk.tankontank.TankOnTank; +import ch.asynk.tankontank.game.Battle; public class OptionsScreen implements Screen { private final TankOnTank game; private Stage stage; - private Label title; + private Label title1; private TextButton okButton; private CheckBox showMovesCk; private CheckBox showTargetsCk; @@ -27,6 +29,8 @@ public class OptionsScreen implements Screen private CheckBox mustValidateCk; private CheckBox showEnemyPossibilitiesCk; private CheckBox debugCk; + private Label title2; + private List<Battle> scenarios; public OptionsScreen(final TankOnTank game) { @@ -51,6 +55,7 @@ public class OptionsScreen implements Screen game.config.mustValidate = mustValidateCk.isChecked(); game.config.showEnemyPossibilities = showEnemyPossibilitiesCk.isChecked(); game.config.debug = debugCk.isChecked(); + game.config.battle = scenarios.getSelected(); } @Override @@ -61,7 +66,7 @@ public class OptionsScreen implements Screen stage = new Stage(new FitViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight())); Gdx.input.setInputProcessor(stage); - title = new Label("Options", game.skin); + title1 = new Label("Options", game.skin); okButton = new TextButton("OK", game.skin); showMovesCk = new CheckBox("Show Moves", game.skin); showTargetsCk = new CheckBox("Show Targets", game.skin); @@ -70,6 +75,11 @@ public class OptionsScreen implements Screen mustValidateCk = new CheckBox("Must Validate", game.skin); showEnemyPossibilitiesCk = new CheckBox("Show Enemy Possibilities", game.skin); debugCk = new CheckBox("Debug", game.skin); + title2 = new Label("Scenarios", game.skin); + scenarios = new List<Battle>(game.skin); + scenarios.setItems(game.factory.battles); + scenarios.setWidth(170); + scenarios.setSelected(game.factory.battles[0]); showMovesCk.setChecked(game.config.showMoves); showTargetsCk.setChecked(game.config.showTargets); @@ -89,7 +99,7 @@ public class OptionsScreen implements Screen } }); - stage.addActor(title); + stage.addActor(title1); stage.addActor(showMovesCk); stage.addActor(showTargetsCk); stage.addActor(showMoveAssistsCk); @@ -98,6 +108,8 @@ public class OptionsScreen implements Screen stage.addActor(showEnemyPossibilitiesCk); stage.addActor(debugCk); stage.addActor(okButton); + stage.addActor(title2); + stage.addActor(scenarios); } @Override @@ -109,7 +121,7 @@ public class OptionsScreen implements Screen float x = ((width / 2) - 100f); float y = (height - 100f); - title.setPosition(x, y); + title1.setPosition(x, y); y -= 20f; showMovesCk.setPosition(x, y); y -= 20f; @@ -124,6 +136,10 @@ public class OptionsScreen implements Screen showEnemyPossibilitiesCk.setPosition(x, y); y -= 20f; debugCk.setPosition(x, y); + y -= 40f; + title2.setPosition(x, y); + y -= scenarios.getHeight(); + scenarios.setPosition(x, y); x += 200f; y -= 40f; okButton.setPosition(x, y); |