summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/tankontank
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-10-06 11:11:55 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2014-10-06 11:11:55 +0200
commit92a60f998d2355e64fed13268987bdb0810355f9 (patch)
tree5d04dc066abcad759ea6a31898dc137f892fd3f4 /core/src/ch/asynk/tankontank
parentab3d35d5934f18389da595518ece59a829a756f7 (diff)
downloadRustAndDust-92a60f998d2355e64fed13268987bdb0810355f9.zip
RustAndDust-92a60f998d2355e64fed13268987bdb0810355f9.tar.gz
Map: add a reference to GameCtrl instance
Diffstat (limited to 'core/src/ch/asynk/tankontank')
-rw-r--r--core/src/ch/asynk/tankontank/game/GameCtrl.java2
-rw-r--r--core/src/ch/asynk/tankontank/game/GameFactory.java6
-rw-r--r--core/src/ch/asynk/tankontank/game/Map.java7
-rw-r--r--core/src/ch/asynk/tankontank/game/MapA.java4
-rw-r--r--core/src/ch/asynk/tankontank/game/MapB.java4
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<Vector3> finalPath = new ArrayList<Vector3>(10);
private final ArrayList<GridPoint2> possibleMoves = new ArrayList<GridPoint2>(40);
private final ArrayList<GridPoint2> possibleTargets = new ArrayList<GridPoint2>(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