cleaned up formatting:

- removed trailing whitespace
- changed all leading whitespace to tabs
- removed IDE created author comments
This commit is contained in:
Evan Debenham
2015-06-12 16:22:26 -04:00
parent baa83b7e43
commit cebdff0221
335 changed files with 8555 additions and 8714 deletions
@@ -60,92 +60,92 @@ public class SewerBossLevel extends RegularLevel {
initRooms();
int distance;
//if we ever need to try 20 or more times to find a room, better to give up and try again.
//if we ever need to try 20 or more times to find a room, better to give up and try again.
int retry = 0;
//start with finding an entrance room (will also contain exit)
//the room must be at least 4x4 and be nearer the top of the map(so that it is less likely something connects to the top)
do {
if (retry++ > 20) {
return false;
}
roomEntrance = Random.element( rooms );
} while (roomEntrance.width() != 8 || roomEntrance.height() < 5 || roomEntrance.top == 0 || roomEntrance.top >= 8);
//start with finding an entrance room (will also contain exit)
//the room must be at least 4x4 and be nearer the top of the map(so that it is less likely something connects to the top)
do {
if (retry++ > 20) {
return false;
}
roomEntrance = Random.element( rooms );
} while (roomEntrance.width() != 8 || roomEntrance.height() < 5 || roomEntrance.top == 0 || roomEntrance.top >= 8);
roomEntrance.type = Type.ENTRANCE;
roomExit = roomEntrance;
roomEntrance.type = Type.ENTRANCE;
roomExit = roomEntrance;
//now find the rest of the rooms for this boss mini-maze
Room curRoom = null;
Room lastRoom = roomEntrance;
//we make 4 rooms, last iteration is tieing the final room to the start
for(int i = 0; i <= 4; i++){
retry = 0;
//find a suitable room the first four times
//suitable room should be empty, have a distance of 2 from the current room, and not touch the entrance.
if (i < 4) {
do {
if (retry++ > 20) {
return false;
}
curRoom = Random.element(rooms);
Graph.buildDistanceMap(rooms, curRoom);
distance = lastRoom.distance();
} while (curRoom.type != Type.NULL || distance != 3 || curRoom.neigbours.contains(roomEntrance));
//now find the rest of the rooms for this boss mini-maze
Room curRoom = null;
Room lastRoom = roomEntrance;
//we make 4 rooms, last iteration is tieing the final room to the start
for(int i = 0; i <= 4; i++){
retry = 0;
//find a suitable room the first four times
//suitable room should be empty, have a distance of 2 from the current room, and not touch the entrance.
if (i < 4) {
do {
if (retry++ > 20) {
return false;
}
curRoom = Random.element(rooms);
Graph.buildDistanceMap(rooms, curRoom);
distance = lastRoom.distance();
} while (curRoom.type != Type.NULL || distance != 3 || curRoom.neigbours.contains(roomEntrance));
curRoom.type = Type.STANDARD;
curRoom.type = Type.STANDARD;
//otherwise, we're on the last iteration.
} else {
//set the current room to the entrance, so we can build a connection to it.
curRoom = roomEntrance;
}
//otherwise, we're on the last iteration.
} else {
//set the current room to the entrance, so we can build a connection to it.
curRoom = roomEntrance;
}
//now build a connection between the current room and the last one.
Graph.buildDistanceMap( rooms, curRoom );
List<Room> path = Graph.buildPath( rooms, lastRoom, curRoom );
//now build a connection between the current room and the last one.
Graph.buildDistanceMap( rooms, curRoom );
List<Room> path = Graph.buildPath( rooms, lastRoom, curRoom );
Graph.setPrice( path, lastRoom.distance );
Graph.setPrice( path, lastRoom.distance );
path = Graph.buildPath( rooms, lastRoom, curRoom );
path = Graph.buildPath( rooms, lastRoom, curRoom );
Room room = lastRoom;
for (Room next : path) {
room.connect( next );
room = next;
}
Room room = lastRoom;
for (Room next : path) {
room.connect( next );
room = next;
}
if (i == 4) {
if (i == 4) {
//we must find a room for his royal highness!
//look at rooms adjacent to the final found room (likely to be furthest from start)
ArrayList<Room> candidates = new ArrayList<Room>();
for (Room r : lastRoom.neigbours) {
if (r.type == Type.NULL && r.connected.size() == 0 && !r.neigbours.contains(roomEntrance)) {
candidates.add(r);
}
}
//we must find a room for his royal highness!
//look at rooms adjacent to the final found room (likely to be furthest from start)
ArrayList<Room> candidates = new ArrayList<Room>();
for (Room r : lastRoom.neigbours) {
if (r.type == Type.NULL && r.connected.size() == 0 && !r.neigbours.contains(roomEntrance)) {
candidates.add(r);
}
}
//if we have candidates, pick a room and put the king there
if (candidates.size() > 0) {
Room kingsRoom = Random.element(candidates);
kingsRoom.connect(lastRoom);
kingsRoom.type = Room.Type.RAT_KING;
//if we have candidates, pick a room and put the king there
if (candidates.size() > 0) {
Room kingsRoom = Random.element(candidates);
kingsRoom.connect(lastRoom);
kingsRoom.type = Room.Type.RAT_KING;
//unacceptable! make a new level...
} else {
return false;
}
}
lastRoom = curRoom;
}
//unacceptable! make a new level...
} else {
return false;
}
}
lastRoom = curRoom;
}
//the connection structure ensures that (most of the time) there is a nice loop for the player to kite the
//boss around. What's nice is that there is enough chaos such that the loop is rarely straightforward
//and boring.
//the connection structure ensures that (most of the time) there is a nice loop for the player to kite the
//boss around. What's nice is that there is enough chaos such that the loop is rarely straightforward
//and boring.
//fills our connection rooms in with tunnel
//fills our connection rooms in with tunnel
for (Room r : rooms) {
if (r.type == Type.NULL && r.connected.size() > 0) {
r.type = Type.TUNNEL;
@@ -154,9 +154,9 @@ public class SewerBossLevel extends RegularLevel {
paint();
//sticks the exit in the room entrance.
exit = roomEntrance.top * Level.WIDTH + (roomEntrance.left + roomEntrance.right) / 2;
map[exit] = Terrain.LOCKED_EXIT;
//sticks the exit in the room entrance.
exit = roomEntrance.top * Level.WIDTH + (roomEntrance.left + roomEntrance.right) / 2;
map[exit] = Terrain.LOCKED_EXIT;
//make sure the exit is only visible in the entrance room.
int count = 0;
@@ -184,7 +184,7 @@ public class SewerBossLevel extends RegularLevel {
}
@Override
protected void decorate() {
protected void decorate() {
int start = roomExit.top * WIDTH + roomExit.left + 1;
int end = start + roomExit.width() - 1;
for (int i=start; i < end; i++) {
@@ -208,10 +208,10 @@ public class SewerBossLevel extends RegularLevel {
@Override
protected void createMobs() {
Mob mob = Bestiary.mob( Dungeon.depth );
Room room;
do {
room = Random.element(rooms);
} while (room.type != Type.STANDARD);
Room room;
do {
room = Random.element(rooms);
} while (room.type != Type.STANDARD);
mob.pos = room.random();
mobs.add( mob );
}
@@ -255,7 +255,7 @@ public class SewerBossLevel extends RegularLevel {
public void unseal() {
if (stairs != 0) {
super.unseal();
super.unseal();
entrance = stairs;
stairs = 0;