From 3d81dc6c65f4c8def67675c872a136249755cb02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjist=C3=B3f?= Date: Sat, 7 May 2016 19:15:19 +0200 Subject: [PATCH] Dungeon.buildDungeon() now correctly sets Display up --- cicaprojekt/Dungeon.java | 12 +++++++++++- cicaprojekt/Game.java | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/cicaprojekt/Dungeon.java b/cicaprojekt/Dungeon.java index fe9b061..2aacede 100644 --- a/cicaprojekt/Dungeon.java +++ b/cicaprojekt/Dungeon.java @@ -31,7 +31,7 @@ public class Dungeon { * S: Scale * X: Gap * R: Replicator */ - Map buildDungeon(File input) throws IOException + Map buildDungeon(File input, Display display) throws IOException { Tile defaultTile = new Field(); defaultTile.setX(-666); @@ -63,29 +63,35 @@ public class Dungeon { { case 'W': tile = new Wall(); + display.addVisual(new WallDrawer((Wall) tile)); break; case 'F': tile = new Field(); + display.addVisual(new FieldDrawer((Field) tile)); break; case 'Z': tile = new Field(); + display.addVisual(new FieldDrawer((Field) tile)); tile.setZPMOnTile(new ZPM()); break; case 'B': tile = new Field(); + display.addVisual(new FieldDrawer((Field) tile)); tile.putABox(new Box()); break; case 'O': tile = new Field(); + display.addVisual(new FieldDrawer((Field) tile)); oneilllocation = tile; break; case 'J': tile = new Field(); + display.addVisual(new FieldDrawer((Field) tile)); jaffalocation = tile; break; @@ -100,10 +106,12 @@ public class Dungeon { case 'X': tile = new Gap(); + display.addVisual(new GapDrawer((Gap) tile)); break; case 'R': tile = new Field(); + display.addVisual(new FieldDrawer((Field) tile)); replicatorlocation = tile; break; } @@ -125,10 +133,12 @@ public class Dungeon { int triggerweight = Integer.parseInt(scaledata[4]); Gate gate = new Gate(); + display.addVisual(new GateDrawer(gate)); gate.setY(gy); gate.setX(gx); Scale scale = new Scale(gate, triggerweight); + display.addVisual(new ScaleDrawer(scale)); scale.setY(sy); scale.setX(sx); diff --git a/cicaprojekt/Game.java b/cicaprojekt/Game.java index 566230b..2f82798 100644 --- a/cicaprojekt/Game.java +++ b/cicaprojekt/Game.java @@ -32,7 +32,7 @@ public class Game { public void startGame(File dungeonFile) throws IOException { Stargate.init(); - Map players = dungeon.buildDungeon(dungeonFile); + Map players = dungeon.buildDungeon(dungeonFile, display); oneill = new Player("O'Neill", players.get("oneill"), getRandomDirection()); jaffa = new Player("Jaffa", players.get("jaffa"), getRandomDirection()); replicator = new PlayerBase("Replicator", players.get("replicator"), getRandomDirection());