This commit is contained in:
muskenum 2016-04-24 23:31:22 +02:00
commit d731db022f
19 changed files with 400 additions and 371 deletions

View File

@ -1,7 +1,6 @@
package cicaprojekt;
public class Box implements Pickable, Destroyable
{
public class Box implements Pickable, Destroyable {
private int weight = 5;

View File

@ -1,9 +1,35 @@
package cicaprojekt;
import java.io.*;
import java.util.HashMap;
import java.util.Map;
public class Dungeon {
cicaprojekt.Tile buildDungeon(File input) throws IOException
/* NOTE: this function assumes that the parameter input is a well-formatted dungeon file.
* Such file looks like as follows:
*
* <map width>x<map height>
* <empty line>
* <map matrix line 1>
* ...
* ...
* <map matrix line <map height>>
* <empty line>
* <scale y>-<scale x>-<gate y>-<gate x>-<scale trigger weight>
* ...
* ...
* <scale y>-<scale x>-<gate y>-<gate x>-<scale trigger weight>
*
* where the map matrix is a matrix of the following chars:
* W: Wall
* F: Field
* Z: Field with a ZMP
* B: Field with a Box
* O: Field with ONeill
* J: Field with Jaffa
* G: Gate
* S: Scale */
Map<String, Tile> buildDungeon(File input) throws IOException
{
Tile oneilllocation = null;
Tile jaffalocation = null;
@ -17,8 +43,9 @@ public class Dungeon {
Tile[][] dungeon = new Tile[width][height];
String line = null;
Gate gate = new Gate();
Gate lastgate = gate;
Gate tempgate = new Gate();
Scale tempscale = new Scale(tempgate, Integer.MAX_VALUE);
int scalecount = 0;
for (int y = 0; y < height; ++y)
{
line = reader.readLine().replaceAll("\\s",""); // read line and remove whitespaces
@ -59,19 +86,27 @@ public class Dungeon {
break;
case 'G':
dungeon[y][x] = gate;
lastgate = gate;
gate = new Gate();
dungeon[y][x] = tempgate;
break;
case 'S':
dungeon[y][x] = new Scale(lastgate, 5);
dungeon[y][x] = tempscale;
scalecount++;
break;
}
}
}
// NOTE: code seems to be correct till this point based on a debugger run-through
reader.readLine(); // throw empty line away
for (int i = 0; i < scalecount; ++i) // set up scale-gate connections
{
String[] scaledata = reader.readLine().split("-");
dungeon[Integer.parseInt(scaledata[0])][Integer.parseInt(scaledata[1])] =
new Scale((Gate)dungeon[Integer.parseInt(scaledata[2])][Integer.parseInt(scaledata[3])],
Integer.parseInt(scaledata[4]));
}
/* setting up Tile cross references */
for (int y = 0; y < height; ++y)
@ -100,6 +135,11 @@ public class Dungeon {
}
}
}
return oneilllocation;
Map<String, Tile> playermap = new HashMap<>();
playermap.put("oneill", oneilllocation);
playermap.put("jaffa", jaffalocation);
return playermap;
}
}

View File

@ -3,8 +3,7 @@ package cicaprojekt;
import java.util.HashMap;
import java.util.Map;
public class Field extends cicaprojekt.Tile
{
public class Field extends cicaprojekt.Tile {
private static int recursionLimit = 0;

View File

@ -8,7 +8,6 @@ public class FlowOfTime extends Timer{
private long gametime;
public void start()
{
public void start() {
}
}

View File

@ -2,9 +2,12 @@ package cicaprojekt;
public class Game {
private Player oneill;
private Dungeon dungeon;
private FlowOfTime flowoftime;
public static void main(String[] args) {
}
public void allZPMsCollected() {
this.stopGame();
@ -15,6 +18,4 @@ public class Game {
public void stopGame() {
}
public static void main(String[] args) {}
}

View File

@ -1,7 +1,6 @@
package cicaprojekt;
public class Gap extends cicaprojekt.Tile
{
public class Gap extends cicaprojekt.Tile {
public Gap() {
super();
}

View File

@ -1,7 +1,6 @@
package cicaprojekt;
public class Gate extends Tile
{
public class Gate extends Tile {
private boolean open = false;
public Gate() {
@ -15,8 +14,7 @@ public class Gate extends Tile
public void onEntry(PlayerBase playerBase) {
if (open) {
playerBase.setCurrentTile(this);
}
else
} else
return;
}

View File

@ -7,13 +7,11 @@ public class Menu {
public static String tabulator = "\t";
public static void addTab()
{
public static void addTab() {
tabulator += '\t';
}
public static void removeTab()
{
public static void removeTab() {
tabulator = tabulator.substring(0, tabulator.length() - 1);
}

View File

@ -24,8 +24,7 @@ public class Player extends PlayerBase{
}
@Override
public void pickZPM(Tile tile)
{
public void pickZPM(Tile tile) {
zpmContainer.add(tile.getZPMFromTile());
}

View File

@ -6,7 +6,8 @@ public class PlayerBase implements Destroyable{
protected Direction facingDirection;
public void destroy() {}
public void destroy() {
}
public Tile getCurrentTile() {
return currentTile;

View File

@ -1,14 +1,12 @@
package cicaprojekt;
public class Stargate {
private boolean isSpawned;
public static final Stargate yellowStargate = new Stargate();
public static final Stargate blueStargate = new Stargate();
public static final Stargate redStargate = new Stargate();
public static final Stargate greenStargate = new Stargate();
public /*final*/ Stargate other; //TODO find better ways to do this
private boolean isSpawned;
private Wall currentWall;

View File

@ -21,8 +21,7 @@ public class Wall extends Tile {
public void onEntry(PlayerBase playerBase) {
if (sg == null) {
return;
}
else {
} else {
sg.teleport(playerBase.facingDirection);
}
}

View File

@ -1,7 +1,6 @@
package cicaprojekt;
public class ZPM implements Pickable
{
public class ZPM implements Pickable {
public void pick() {
}