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; package cicaprojekt;
public class Box implements Pickable, Destroyable public class Box implements Pickable, Destroyable {
{
private int weight = 5; private int weight = 5;

View File

@ -1,9 +1,35 @@
package cicaprojekt; package cicaprojekt;
import java.io.*; import java.io.*;
import java.util.HashMap;
import java.util.Map;
public class Dungeon { 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 oneilllocation = null;
Tile jaffalocation = null; Tile jaffalocation = null;
@ -17,8 +43,9 @@ public class Dungeon {
Tile[][] dungeon = new Tile[width][height]; Tile[][] dungeon = new Tile[width][height];
String line = null; String line = null;
Gate gate = new Gate(); Gate tempgate = new Gate();
Gate lastgate = gate; Scale tempscale = new Scale(tempgate, Integer.MAX_VALUE);
int scalecount = 0;
for (int y = 0; y < height; ++y) for (int y = 0; y < height; ++y)
{ {
line = reader.readLine().replaceAll("\\s",""); // read line and remove whitespaces line = reader.readLine().replaceAll("\\s",""); // read line and remove whitespaces
@ -59,19 +86,27 @@ public class Dungeon {
break; break;
case 'G': case 'G':
dungeon[y][x] = gate; dungeon[y][x] = tempgate;
lastgate = gate;
gate = new Gate();
break; break;
case 'S': case 'S':
dungeon[y][x] = new Scale(lastgate, 5); dungeon[y][x] = tempscale;
scalecount++;
break; 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 */ /* setting up Tile cross references */
for (int y = 0; y < height; ++y) 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.HashMap;
import java.util.Map; import java.util.Map;
public class Field extends cicaprojekt.Tile public class Field extends cicaprojekt.Tile {
{
private static int recursionLimit = 0; private static int recursionLimit = 0;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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