From 92a60f998d2355e64fed13268987bdb0810355f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 6 Oct 2014 11:11:55 +0200 Subject: Map: add a reference to GameCtrl instance --- core/src/ch/asynk/tankontank/game/GameCtrl.java | 2 +- core/src/ch/asynk/tankontank/game/GameFactory.java | 6 +++--- core/src/ch/asynk/tankontank/game/Map.java | 7 +++++-- core/src/ch/asynk/tankontank/game/MapA.java | 4 ++-- core/src/ch/asynk/tankontank/game/MapB.java | 4 ++-- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/core/src/ch/asynk/tankontank/game/GameCtrl.java b/core/src/ch/asynk/tankontank/game/GameCtrl.java index 3b60f05..fc4df91 100644 --- a/core/src/ch/asynk/tankontank/game/GameCtrl.java +++ b/core/src/ch/asynk/tankontank/game/GameCtrl.java @@ -27,7 +27,7 @@ public class GameCtrl implements Disposable this.game = game; this.factory = new GameFactory(game.manager); - this.map = factory.getMap(game.manager, GameFactory.MapType.MAP_A); + this.map = factory.getMap(this, game.manager, GameFactory.MapType.MAP_A); this.hud = new Hud(game); diff --git a/core/src/ch/asynk/tankontank/game/GameFactory.java b/core/src/ch/asynk/tankontank/game/GameFactory.java index 110cbda..bd4294a 100644 --- a/core/src/ch/asynk/tankontank/game/GameFactory.java +++ b/core/src/ch/asynk/tankontank/game/GameFactory.java @@ -123,17 +123,17 @@ public class GameFactory implements Board.TileBuilder, Disposable return cfg; } - public Map getMap(AssetManager manager, MapType t) + public Map getMap(GameCtrl ctrl, AssetManager manager, MapType t) { Board.Config cfg = config(); Map m = null; switch(t) { case MAP_A: - m = new MapA(this, config(), manager.get("data/map_a.png", Texture.class)); + m = new MapA(ctrl, this, config(), manager.get("data/map_a.png", Texture.class)); break; case MAP_B: - m = new MapB(this, config(), manager.get("data/map_b.png", Texture.class)); + m = new MapB(ctrl, this, config(), manager.get("data/map_b.png", Texture.class)); break; } diff --git a/core/src/ch/asynk/tankontank/game/Map.java b/core/src/ch/asynk/tankontank/game/Map.java index bef7422..cd715fb 100644 --- a/core/src/ch/asynk/tankontank/game/Map.java +++ b/core/src/ch/asynk/tankontank/game/Map.java @@ -16,6 +16,8 @@ import ch.asynk.tankontank.engine.Orientation; public abstract class Map extends Board { + private final GameCtrl ctrl; + private final ArrayList finalPath = new ArrayList(10); private final ArrayList possibleMoves = new ArrayList(40); private final ArrayList possibleTargets = new ArrayList(10); @@ -23,9 +25,10 @@ public abstract class Map extends Board protected abstract void setup(); - public Map(GameFactory gameFactory, Board.Config cfg, Texture texture) + public Map(GameCtrl ctrl, GameFactory factory, Board.Config cfg, Texture texture) { - super(gameFactory, cfg, texture); + super(factory, cfg, texture); + this.ctrl = ctrl; setup(); } diff --git a/core/src/ch/asynk/tankontank/game/MapA.java b/core/src/ch/asynk/tankontank/game/MapA.java index 686efed..edf4dee 100644 --- a/core/src/ch/asynk/tankontank/game/MapA.java +++ b/core/src/ch/asynk/tankontank/game/MapA.java @@ -8,9 +8,9 @@ import ch.asynk.tankontank.engine.Orientation; public class MapA extends Map { - public MapA(GameFactory gameFactory, Board.Config cfg, Texture texture) + public MapA(GameCtrl ctrl, GameFactory factory, Board.Config cfg, Texture texture) { - super(gameFactory, cfg, texture); + super(ctrl, factory, cfg, texture); } @Override diff --git a/core/src/ch/asynk/tankontank/game/MapB.java b/core/src/ch/asynk/tankontank/game/MapB.java index 35416a9..9682482 100644 --- a/core/src/ch/asynk/tankontank/game/MapB.java +++ b/core/src/ch/asynk/tankontank/game/MapB.java @@ -8,9 +8,9 @@ import ch.asynk.tankontank.engine.Orientation; public class MapB extends Map { - public MapB(GameFactory gameFactory, Board.Config cfg, Texture texture) + public MapB(GameCtrl ctrl, GameFactory factory, Board.Config cfg, Texture texture) { - super(gameFactory, cfg, texture); + super(ctrl, factory, cfg, texture); } @Override -- cgit v1.1-2-g2b99