finished implementing map parser (Dungeon.buildDungeon())

the parser now sets up references between adjecent Tiles, however a team
consultation is needed regarding the Gates/Scales on the map. note that
the part of the parser that sets the references up is still untested.
This commit is contained in:
Kjistóf 2016-04-23 17:08:32 +02:00
parent e1d24d05dd
commit 7eeeefa3e2

View File

@ -8,6 +8,8 @@ public class Dungeon {
Menu.addTab(); Menu.addTab();
System.out.println(">" + "[" + ":" + this.getClass().getSimpleName() + "]" + Menu.tabulator + "Dungeon.buildDungeon(" + input + ")"); System.out.println(">" + "[" + ":" + this.getClass().getSimpleName() + "]" + Menu.tabulator + "Dungeon.buildDungeon(" + input + ")");
Tile oneilllocation = null;
Tile jaffalocation = null;
try(BufferedReader reader = new BufferedReader(new FileReader(input))) try(BufferedReader reader = new BufferedReader(new FileReader(input)))
{ {
String[] sizedata = reader.readLine().split("x"); // read size data at beginning of file String[] sizedata = reader.readLine().split("x"); // read size data at beginning of file
@ -18,8 +20,6 @@ public class Dungeon {
Tile[][] dungeon = new Tile[width][height]; Tile[][] dungeon = new Tile[width][height];
String line = null; String line = null;
Tile oneilllocation = null;
Tile jaffalocation = null;
Gate gate = new Gate(); Gate gate = new Gate();
Gate lastgate = gate; Gate lastgate = gate;
for (int y = 0; y < height; ++y) for (int y = 0; y < height; ++y)
@ -74,13 +74,38 @@ public class Dungeon {
} }
} }
// TODO: set up cross references in dungeon matrix // NOTE: code seems to be correct till this point based on a debugger run-through
// NOTE: code seems to be correct til this point based on a debugger run-through
/* setting up Tile cross references */
for (int y = 0; y < height; ++y)
{
for (int x = 0; x < width; ++x)
{
if (x-1 >= 0) // leftwards Tile reference
dungeon[y][x].setAdajacentTile(dungeon[y][x-1], Direction.WEST);
else
dungeon[y][x].setAdajacentTile(null, Direction.WEST);
if (x+1 < width) // rightwards Tile reference
dungeon[y][x].setAdajacentTile(dungeon[y][x+1], Direction.EAST);
else
dungeon[y][x].setAdajacentTile(null, Direction.EAST);
if (y+1 < height) // upwards Tile reference
dungeon[y][x].setAdajacentTile(dungeon[y+1][x], Direction.NORTH);
else
dungeon[y][x].setAdajacentTile(null, Direction.NORTH);
if (y-1 >= 0) // downwards Tile reference
dungeon[y][x].setAdajacentTile(dungeon[y-1][x], Direction.SOUTH);
else
dungeon[y][x].setAdajacentTile(null, Direction.SOUTH);
}
}
} }
System.out.println("<" + "[" + ":" + this.getClass().getSimpleName() + "]" + Menu.tabulator + "Dungeon.buildDungeon()"); System.out.println("<" + "[" + ":" + this.getClass().getSimpleName() + "]" + Menu.tabulator + "Dungeon.buildDungeon()");
Menu.removeTab(); Menu.removeTab();
return new cicaprojekt.Field(); /*csak hogy ne sírjon*/ return oneilllocation;
} }
} }