reformatted code

This commit is contained in:
Bokros Bálint 2016-04-24 23:01:34 +02:00
parent d0d656452c
commit 1ab13398bb
19 changed files with 365 additions and 382 deletions

View File

@ -1,21 +1,20 @@
package cicaprojekt; package cicaprojekt;
public class Box implements Pickable, Destroyable public class Box implements Pickable, Destroyable {
{
private int weight = 5; private int weight = 5;
public Box(){ public Box() {
} }
public void destroy() { public void destroy() {
} }
public void pick() { public void pick() {
} }
@Override @Override
public int weight() { public int weight() {
return this.weight; return this.weight;
} }
} }

View File

@ -1,5 +1,5 @@
package cicaprojekt; package cicaprojekt;
public interface Destroyable { public interface Destroyable {
public void destroy(); public void destroy();
} }

View File

@ -1,5 +1,5 @@
package cicaprojekt; package cicaprojekt;
public enum Direction { public enum Direction {
NORTH, SOUTH, EAST, WEST; NORTH, SOUTH, EAST, WEST;
} }

View File

@ -3,12 +3,10 @@ package cicaprojekt;
import java.io.*; import java.io.*;
public class Dungeon { public class Dungeon {
cicaprojekt.Tile buildDungeon(File input) throws IOException cicaprojekt.Tile buildDungeon(File input) throws IOException {
{
Tile oneilllocation = null; Tile oneilllocation = null;
Tile jaffalocation = 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
reader.readLine(); // throw empty line away reader.readLine(); // throw empty line away
int width = Integer.parseInt(sizedata[0]); int width = Integer.parseInt(sizedata[0]);
@ -19,11 +17,9 @@ public class Dungeon {
String line = null; String line = 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) {
{ line = reader.readLine().replaceAll("\\s", ""); // read line and remove whitespaces
line = reader.readLine().replaceAll("\\s",""); // read line and remove whitespaces for (int x = 0; x < width; ++x) {
for (int x = 0; x < width; ++x)
{
switch (line.charAt(x)) // set the dungeon up switch (line.charAt(x)) // set the dungeon up
{ {
case 'W': case 'W':
@ -74,27 +70,25 @@ public class Dungeon {
// NOTE: code seems to be correct till this point based on a debugger run-through // NOTE: code seems to be correct till this point based on a debugger run-through
/* setting up Tile cross references */ /* setting up Tile cross references */
for (int y = 0; y < height; ++y) for (int y = 0; y < height; ++y) {
{ for (int x = 0; x < width; ++x) {
for (int x = 0; x < width; ++x) if (x - 1 >= 0) // leftwards Tile reference
{ dungeon[y][x].setAdajacentTile(dungeon[y][x - 1], Direction.WEST);
if (x-1 >= 0) // leftwards Tile reference
dungeon[y][x].setAdajacentTile(dungeon[y][x-1], Direction.WEST);
else else
dungeon[y][x].setAdajacentTile(null, Direction.WEST); dungeon[y][x].setAdajacentTile(null, Direction.WEST);
if (x+1 < width) // rightwards Tile reference if (x + 1 < width) // rightwards Tile reference
dungeon[y][x].setAdajacentTile(dungeon[y][x+1], Direction.EAST); dungeon[y][x].setAdajacentTile(dungeon[y][x + 1], Direction.EAST);
else else
dungeon[y][x].setAdajacentTile(null, Direction.EAST); dungeon[y][x].setAdajacentTile(null, Direction.EAST);
if (y+1 < height) // upwards Tile reference if (y + 1 < height) // upwards Tile reference
dungeon[y][x].setAdajacentTile(dungeon[y+1][x], Direction.NORTH); dungeon[y][x].setAdajacentTile(dungeon[y + 1][x], Direction.NORTH);
else else
dungeon[y][x].setAdajacentTile(null, Direction.NORTH); dungeon[y][x].setAdajacentTile(null, Direction.NORTH);
if (y-1 >= 0) // downwards Tile reference if (y - 1 >= 0) // downwards Tile reference
dungeon[y][x].setAdajacentTile(dungeon[y-1][x], Direction.SOUTH); dungeon[y][x].setAdajacentTile(dungeon[y - 1][x], Direction.SOUTH);
else else
dungeon[y][x].setAdajacentTile(null, Direction.SOUTH); dungeon[y][x].setAdajacentTile(null, Direction.SOUTH);
} }

View File

@ -3,32 +3,31 @@ 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;
public Field() { public Field() {
super(); super();
} }
@Override @Override
public void spawnStargate(cicaprojekt.Stargate stargate, Direction direction) { public void spawnStargate(cicaprojekt.Stargate stargate, Direction direction) {
if (recursionLimit++ >= 10) if (recursionLimit++ >= 10)
this.adjacentTile.put(direction, new Wall()); this.adjacentTile.put(direction, new Wall());
adjacentTile.get(direction).spawnStargate(stargate, direction); adjacentTile.get(direction).spawnStargate(stargate, direction);
} }
public void onEntry(PlayerBase playerBase) { public void onEntry(PlayerBase playerBase) {
if(boxStack.size() > 0) if (boxStack.size() > 0)
return; return;
playerBase.setCurrentTile(this); playerBase.setCurrentTile(this);
if(zpmOnTile != null) if (zpmOnTile != null)
playerBase.pickZPM(this); playerBase.pickZPM(this);
} }
public void onExit(PlayerBase playerBase) { public void onExit(PlayerBase playerBase) {
return; return;
} }
} }

View File

@ -3,12 +3,11 @@ package cicaprojekt;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
public class FlowOfTime extends Timer{ public class FlowOfTime extends Timer {
private TimerTask timeup; private TimerTask timeup;
private long gametime; private long gametime;
public void start() public void start() {
{ }
}
} }

View File

@ -1,20 +1,21 @@
package cicaprojekt; package cicaprojekt;
public class Game { public class Game {
private Player oneill; private Player oneill;
private Dungeon dungeon;
private FlowOfTime flowoftime;
private Dungeon dungeon;
private FlowOfTime flowoftime;
public void allZPMsCollected() { public static void main(String[] args) {
this.stopGame(); }
}
public void startGame() { public void allZPMsCollected() {
} this.stopGame();
}
public void stopGame() { public void startGame() {
} }
public static void main(String[] args) {} public void stopGame() {
}
} }

View File

@ -1,26 +1,25 @@
package cicaprojekt; package cicaprojekt;
public class Gap extends cicaprojekt.Tile public class Gap extends cicaprojekt.Tile {
{ public Gap() {
public Gap(){ super();
super(); }
}
@Override @Override
public void spawnStargate(cicaprojekt.Stargate stargate, Direction direction) { public void spawnStargate(cicaprojekt.Stargate stargate, Direction direction) {
adjacentTile.get(direction).spawnStargate(stargate, direction); adjacentTile.get(direction).spawnStargate(stargate, direction);
} }
public void onEntry(PlayerBase playerBase) { public void onEntry(PlayerBase playerBase) {
playerBase.destroy(); playerBase.destroy();
} }
public void onExit(PlayerBase playerBase) throws IllegalStateException { public void onExit(PlayerBase playerBase) throws IllegalStateException {
throw new IllegalStateException("Hiba! A szakadékból nem jut ki semmi!"); throw new IllegalStateException("Hiba! A szakadékból nem jut ki semmi!");
} }
@Override @Override
public void putABox(Box box) { public void putABox(Box box) {
box.destroy(); box.destroy();
} }
} }

View File

@ -1,36 +1,34 @@
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() {
super(); super();
} }
public void spawnStargate(Stargate stargate, Direction direction) { public void spawnStargate(Stargate stargate, Direction direction) {
if(this.open) adjacentTile.get(direction).spawnStargate(stargate, direction); if (this.open) adjacentTile.get(direction).spawnStargate(stargate, direction);
} }
public void onEntry(PlayerBase playerBase) { public void onEntry(PlayerBase playerBase) {
if(open){ if (open) {
playerBase.setCurrentTile(this); playerBase.setCurrentTile(this);
} } else
else return;
return; }
}
public void onExit(PlayerBase playerBase) throws IllegalStateException { public void onExit(PlayerBase playerBase) throws IllegalStateException {
if(!open){ if (!open) {
throw new IllegalStateException("Hiba! Te hogy kerültél a csukott ajtóba?"); throw new IllegalStateException("Hiba! Te hogy kerültél a csukott ajtóba?");
} }
} }
public boolean isOpen() { public boolean isOpen() {
return open; return open;
} }
public void setOpen(boolean gateState) { public void setOpen(boolean gateState) {
this.open = gateState; this.open = gateState;
} }
} }

View File

@ -1,5 +1,5 @@
package cicaprojekt; package cicaprojekt;
public interface Measurable { public interface Measurable {
public int weight(); public int weight();
} }

View File

@ -7,22 +7,20 @@ 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);
} }
public static void main (String[] args) throws IOException{ public static void main(String[] args) throws IOException {
System.out.println("Continuously Integrated Cica Projekt - Skeleton"); System.out.println("Continuously Integrated Cica Projekt - Skeleton");
System.out.println("Üdvözöllek a Babylon Simulator 2000 játékban! Kérlek válassz egy menüpontot!"); System.out.println("Üdvözöllek a Babylon Simulator 2000 játékban! Kérlek válassz egy menüpontot!");
boolean isExiting = false; boolean isExiting = false;
while(!isExiting) { while (!isExiting) {
System.out.println("1. Lépés"); System.out.println("1. Lépés");
System.out.println("2. Doboz felvétele"); System.out.println("2. Doboz felvétele");
System.out.println("3. Doboz lerakása"); System.out.println("3. Doboz lerakása");
@ -36,90 +34,90 @@ public class Menu {
Scanner sc = new Scanner(System.in); Scanner sc = new Scanner(System.in);
switch (sc.nextLine().charAt(0)) { switch (sc.nextLine().charAt(0)) {
case '1' : case '1':
System.out.println("ONeill [északi|nyugati|déli|keleti] irányba lép egyet,"); System.out.println("ONeill [északi|nyugati|déli|keleti] irányba lép egyet,");
System.out.println("Elfogadott bemenet: W, A, S, D"); System.out.println("Elfogadott bemenet: W, A, S, D");
switch (sc.nextLine().charAt(0)) { switch (sc.nextLine().charAt(0)) {
case 'W' : case 'W':
oNeill.move(Direction.NORTH); oNeill.move(Direction.NORTH);
break; break;
case 'A' : case 'A':
oNeill.move(Direction.WEST); oNeill.move(Direction.WEST);
break; break;
case 'S' : case 'S':
oNeill.move(Direction.SOUTH); oNeill.move(Direction.SOUTH);
break; break;
case 'D' : case 'D':
oNeill.move(Direction.EAST); oNeill.move(Direction.EAST);
break; break;
case 'X' : case 'X':
break; break;
} }
break; break;
case '2' : case '2':
System.out.println("Doboz felvétele"); System.out.println("Doboz felvétele");
System.out.println("Elfogadott bemenet: L"); System.out.println("Elfogadott bemenet: L");
switch (sc.nextLine().charAt(0)) { switch (sc.nextLine().charAt(0)) {
case 'L' : case 'L':
oNeill.boxLift(); oNeill.boxLift();
break; break;
case 'X' : case 'X':
break; break;
} }
break; break;
case '3' : case '3':
System.out.println("Doboz lerakása"); System.out.println("Doboz lerakása");
System.out.println("Elfogadott bemenet: D"); System.out.println("Elfogadott bemenet: D");
switch (sc.nextLine().charAt(0)) { switch (sc.nextLine().charAt(0)) {
case 'D': case 'D':
oNeill.boxDrop(); oNeill.boxDrop();
break; break;
case 'X' : case 'X':
break; break;
} }
break; break;
case '4' : case '4':
System.out.println("Elforgás"); System.out.println("Elforgás");
System.out.println("Elfogadott bemenet: L, R"); System.out.println("Elfogadott bemenet: L, R");
switch (sc.nextLine().charAt(0)) { switch (sc.nextLine().charAt(0)) {
case 'L' : case 'L':
oNeill.rotateLeft(); oNeill.rotateLeft();
break; break;
case 'D' : case 'D':
oNeill.rotateRight(); oNeill.rotateRight();
break; break;
case 'X' : case 'X':
break; break;
} }
break; break;
case '5' : case '5':
System.out.println("Nézés"); System.out.println("Nézés");
System.out.println("Elfogadott bemenet: W"); System.out.println("Elfogadott bemenet: W");
switch (sc.nextLine().charAt(0)) { switch (sc.nextLine().charAt(0)) {
case 'W' : case 'W':
Tile t = oNeill.getCurrentTile().getAdjacentTile(oNeill.getFacingDirection()); Tile t = oNeill.getCurrentTile().getAdjacentTile(oNeill.getFacingDirection());
System.out.println("O'Neill előtt egy " + t.toString() + "mező található"); System.out.println("O'Neill előtt egy " + t.toString() + "mező található");
break; break;
case 'X' : case 'X':
break; break;
} }
break; break;
case '6' : case '6':
System.out.println("Csillagkapu lövés"); System.out.println("Csillagkapu lövés");
System.out.println("Elfogadott bemenet: Y, B"); System.out.println("Elfogadott bemenet: Y, B");
Tile t = oNeill.getCurrentTile(); Tile t = oNeill.getCurrentTile();
switch (sc.nextLine().charAt(0)) { switch (sc.nextLine().charAt(0)) {
case 'Y' : case 'Y':
t.spawnStargate(Stargate.yellowStargate, oNeill.getFacingDirection()); t.spawnStargate(Stargate.yellowStargate, oNeill.getFacingDirection());
break; break;
case 'B' : case 'B':
t.spawnStargate(Stargate.blueStargate, oNeill.getFacingDirection()); t.spawnStargate(Stargate.blueStargate, oNeill.getFacingDirection());
break; break;
case 'X' : case 'X':
break; break;
} }
break; break;
case 'X' : case 'X':
System.out.println("Kilépés"); System.out.println("Kilépés");
isExiting = true; isExiting = true;
break; break;

View File

@ -1,5 +1,5 @@
package cicaprojekt; package cicaprojekt;
public interface Pickable extends Destroyable, Measurable { public interface Pickable extends Destroyable, Measurable {
public void pick(); public void pick();
} }

View File

@ -3,33 +3,32 @@ package cicaprojekt;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class Player extends PlayerBase{ public class Player extends PlayerBase {
private List<ZPM> zpmContainer; private List<ZPM> zpmContainer;
private Box boxLifted; private Box boxLifted;
public Player(Tile startTile, Direction startDirection){ public Player(Tile startTile, Direction startDirection) {
zpmContainer = new ArrayList<>(); zpmContainer = new ArrayList<>();
currentTile = startTile; currentTile = startTile;
facingDirection = startDirection; /* Be lehetne állítani egy defaultot is, nem tudom, mennyire kéne */ facingDirection = startDirection; /* Be lehetne állítani egy defaultot is, nem tudom, mennyire kéne */
} }
public void boxLift() { public void boxLift() {
boxLifted = (Box) currentTile.getAdjacentTile(facingDirection).getABox(); boxLifted = (Box) currentTile.getAdjacentTile(facingDirection).getABox();
} }
public void boxDrop() { public void boxDrop() {
currentTile.getAdjacentTile(facingDirection).putABox(boxLifted); currentTile.getAdjacentTile(facingDirection).putABox(boxLifted);
boxLifted = null; boxLifted = null;
} }
@Override @Override
public void pickZPM(Tile tile) public void pickZPM(Tile tile) {
{
zpmContainer.add(tile.getZPMFromTile()); zpmContainer.add(tile.getZPMFromTile());
} }
public void shootStargate(Stargate stargate) { public void shootStargate(Stargate stargate) {
this.currentTile.getAdjacentTile(facingDirection).spawnStargate(stargate, facingDirection); this.currentTile.getAdjacentTile(facingDirection).spawnStargate(stargate, facingDirection);
} }
} }

View File

@ -1,69 +1,70 @@
package cicaprojekt; package cicaprojekt;
public class PlayerBase implements Destroyable{ public class PlayerBase implements Destroyable {
protected Game game; protected Game game;
protected Tile currentTile; protected Tile currentTile;
protected Direction facingDirection; protected Direction facingDirection;
public void destroy() {} public void destroy() {
}
public Tile getCurrentTile() { public Tile getCurrentTile() {
return currentTile; return currentTile;
} }
public void setCurrentTile(Tile newCurrentTile) { public void setCurrentTile(Tile newCurrentTile) {
currentTile = newCurrentTile; currentTile = newCurrentTile;
} }
public void move(Direction direction) { public void move(Direction direction) {
this.setFacingDirection(direction); this.setFacingDirection(direction);
Tile tile = this.getCurrentTile().getAdjacentTile(direction); Tile tile = this.getCurrentTile().getAdjacentTile(direction);
tile.onEntry(this); tile.onEntry(this);
setCurrentTile(tile); setCurrentTile(tile);
} }
public void pickZPM(Tile tile) { /* PlayerBase does not collect ZPM modules */ } public void pickZPM(Tile tile) { /* PlayerBase does not collect ZPM modules */ }
public void rotateLeft() { public void rotateLeft() {
switch (facingDirection) { switch (facingDirection) {
case NORTH: case NORTH:
facingDirection = Direction.WEST; facingDirection = Direction.WEST;
break; break;
case WEST: case WEST:
facingDirection = Direction.SOUTH; facingDirection = Direction.SOUTH;
break; break;
case SOUTH: case SOUTH:
facingDirection = Direction.EAST; facingDirection = Direction.EAST;
break; break;
case EAST: case EAST:
facingDirection = Direction.NORTH; facingDirection = Direction.NORTH;
break; break;
} }
} }
public void rotateRight() { public void rotateRight() {
switch (facingDirection) { switch (facingDirection) {
case NORTH: case NORTH:
facingDirection = Direction.EAST; facingDirection = Direction.EAST;
break; break;
case EAST: case EAST:
facingDirection = Direction.SOUTH; facingDirection = Direction.SOUTH;
break; break;
case SOUTH: case SOUTH:
facingDirection = Direction.WEST; facingDirection = Direction.WEST;
break; break;
case WEST: case WEST:
facingDirection = Direction.NORTH; facingDirection = Direction.NORTH;
break; break;
} }
} }
public Direction getFacingDirection() { public Direction getFacingDirection() {
return facingDirection; return facingDirection;
} }
public void setFacingDirection(Direction direction) { public void setFacingDirection(Direction direction) {
facingDirection = direction; facingDirection = direction;
} }
} }

View File

@ -3,53 +3,53 @@ package cicaprojekt;
import java.util.Stack; import java.util.Stack;
public class Scale extends Field { public class Scale extends Field {
private Gate gateConnected; private Gate gateConnected;
private int threshold; private int threshold;
private int weight; private int weight;
public Scale(Gate gate, int threshold){ public Scale(Gate gate, int threshold) {
gateConnected = gate; gateConnected = gate;
this.threshold = threshold; this.threshold = threshold;
boxStack = new Stack<Box>(); boxStack = new Stack<Box>();
} }
@Override @Override
public void onEntry(PlayerBase playerBase) { public void onEntry(PlayerBase playerBase) {
gateConnected.setOpen(true); gateConnected.setOpen(true);
} }
@Override @Override
public void onExit(PlayerBase playerBase) { public void onExit(PlayerBase playerBase) {
gateConnected.setOpen(false); gateConnected.setOpen(false);
} }
@Override @Override
public Box getABox() { public Box getABox() {
if(boxStack.isEmpty()) if (boxStack.isEmpty())
return null; return null;
weight -= boxStack.peek().weight(); weight -= boxStack.peek().weight();
stackChanged(); stackChanged();
return boxStack.pop(); return boxStack.pop();
} }
@Override @Override
public void putABox(Box box) { public void putABox(Box box) {
if(box == null) if (box == null)
return; return;
boxStack.push(box); boxStack.push(box);
weight += box.weight(); weight += box.weight();
stackChanged(); stackChanged();
} }
public void spawnStargate(Stargate stargate, Direction direction) { public void spawnStargate(Stargate stargate, Direction direction) {
adjacentTile.get(direction).spawnStargate(stargate, direction); adjacentTile.get(direction).spawnStargate(stargate, direction);
} }
private void stackChanged() { private void stackChanged() {
if(weight > threshold) if (weight > threshold)
gateConnected.setOpen(true); gateConnected.setOpen(true);
else else
gateConnected.setOpen(false); gateConnected.setOpen(false);
} }
} }

View File

@ -1,40 +1,38 @@
package cicaprojekt; package cicaprojekt;
public class Stargate { public class Stargate {
private boolean isSpawned; public static final Stargate yellowStargate = new Stargate();
public static final Stargate blueStargate = new Stargate();
public static final Stargate yellowStargate = new Stargate(); public static final Stargate redStargate = new Stargate();
public static final Stargate blueStargate = new Stargate(); public static final Stargate greenStargate = new Stargate();
public static final Stargate redStargate = new Stargate(); public /*final*/ Stargate other; //TODO find better ways to do this
public static final Stargate greenStargate = new Stargate(); private boolean isSpawned;
public /*final*/ Stargate other; //TODO find better ways to do this private Wall currentWall;
private Wall currentWall;
private Stargate() { private Stargate() {
isSpawned = false; isSpawned = false;
} }
public static void init() { public static void init() {
yellowStargate.other = blueStargate; yellowStargate.other = blueStargate;
blueStargate.other = yellowStargate; blueStargate.other = yellowStargate;
redStargate.other = greenStargate; redStargate.other = greenStargate;
greenStargate.other = redStargate; greenStargate.other = redStargate;
} }
public Wall getCurrentWall() { public Wall getCurrentWall() {
return currentWall; return currentWall;
} }
public void setCurrentWall(Wall wall) { public void setCurrentWall(Wall wall) {
currentWall = wall; currentWall = wall;
} }
public boolean isOpen() { public boolean isOpen() {
return isSpawned; return isSpawned;
} }
public void teleport(Direction incomingDirection) { public void teleport(Direction incomingDirection) {
} }
} }

View File

@ -5,48 +5,48 @@ import java.util.Map;
import java.util.Stack; import java.util.Stack;
public abstract class Tile { public abstract class Tile {
protected Map<Direction, Tile> adjacentTile; protected Map<Direction, Tile> adjacentTile;
protected ZPM zpmOnTile; protected ZPM zpmOnTile;
protected Stack<Box> boxStack; protected Stack<Box> boxStack;
public Tile(){ public Tile() {
adjacentTile = new HashMap<Direction, Tile>(); adjacentTile = new HashMap<Direction, Tile>();
} }
public Tile getAdjacentTile(Direction direction) { public Tile getAdjacentTile(Direction direction) {
return adjacentTile.get(direction); return adjacentTile.get(direction);
} }
public void setAdajacentTile(Tile newTile, Direction direction) { public void setAdajacentTile(Tile newTile, Direction direction) {
adjacentTile.put(direction, newTile); adjacentTile.put(direction, newTile);
} }
public abstract void spawnStargate(Stargate stargate, Direction direction); public abstract void spawnStargate(Stargate stargate, Direction direction);
public abstract void onEntry(PlayerBase playerBase); public abstract void onEntry(PlayerBase playerBase);
public abstract void onExit(PlayerBase playerBase); public abstract void onExit(PlayerBase playerBase);
public void setZPMOnTile(ZPM zpm) { public void setZPMOnTile(ZPM zpm) {
zpmOnTile = zpm; zpmOnTile = zpm;
} }
public ZPM getZPMFromTile() { public ZPM getZPMFromTile() {
ZPM zpm = zpmOnTile; ZPM zpm = zpmOnTile;
zpmOnTile = null; zpmOnTile = null;
return zpm; return zpm;
} }
public void putABox(Box box) { public void putABox(Box box) {
if(box == null) if (box == null)
return; return;
boxStack.push(box); boxStack.push(box);
} }
public Box getABox(){ public Box getABox() {
if(boxStack.isEmpty()) if (boxStack.isEmpty())
return null; return null;
return boxStack.pop(); return boxStack.pop();
} }
} }

View File

@ -1,33 +1,32 @@
package cicaprojekt; package cicaprojekt;
public class Wall extends Tile { public class Wall extends Tile {
private Stargate sg; private Stargate sg;
public Wall(){ public Wall() {
super(); super();
} }
public void spawnStargate(Stargate stargate, Direction direction) { public void spawnStargate(Stargate stargate, Direction direction) {
if(sg == null) if (sg == null)
sg = stargate; sg = stargate;
else else
return; return;
} }
public void clearStargate() { public void clearStargate() {
sg = null; sg = null;
} }
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); }
} }
}
public void onExit(PlayerBase playerBase) throws IllegalStateException { public void onExit(PlayerBase playerBase) throws IllegalStateException {
throw new IllegalStateException("Hiba! Te hogy kerültél a falba?"); throw new IllegalStateException("Hiba! Te hogy kerültél a falba?");
} }
} }

View File

@ -1,16 +1,15 @@
package cicaprojekt; package cicaprojekt;
public class ZPM implements Pickable public class ZPM implements Pickable {
{ public void pick() {
public void pick(){ }
}
@Override @Override
public void destroy(){ public void destroy() {
} }
@Override @Override
public int weight() { public int weight() {
return 0; return 0;
} }
} }