-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dungeon.pde
67 lines (55 loc) · 1.67 KB
/
Dungeon.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//==============================================
// Class that contain the Dungeon
//
// @author : Tony Chouteau
//
//==============================================
public class Dungeon {
private Floor[] floors;
private int dungeonHeight;
private PVector floorSize;
private PVector roomSize;
private boolean initialized;
Dungeon(int dungeonHeight, PVector floorSize) {
this.floors = new Floor[dungeonHeight];
this.dungeonHeight = dungeonHeight;
this.floorSize = floorSize;
this.roomSize = new PVector(5, 5);
this.initialized = false;
}
public void initialized() {
if (!this.initialized) {
this.initialized = true;
for (int i = 0; i < this.dungeonHeight; i++) {
this.floors[i] = new Floor(this.floorSize, this.roomSize);
}
} else {
println("The Dungeon is already initialized");
}
}
//==============================================
//
//==============================================
public void displayToFrame(int floorNumber) {
this.display(floorNumber, false);
}
public void displayToConsole(int floorNumber) {
this.display(floorNumber, true);
}
private int display(int floorNumber, boolean console) {
if (!this.initialized) {
print("Error : The Dungeon is not initialized yet.");
return 0;
}
if (floorNumber < 0 && floorNumber >= dungeonHeight) {
print("ERROR : Give a valid floorNumber");
return 0;
}
if (console) {
this.floors[floorNumber].displayLineByLine();
} else {
this.floors[floorNumber].display();
}
return 1;
}
}