-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRoom.java
103 lines (91 loc) · 2.33 KB
/
Room.java
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package TRAFFICSIM;
class Room {
private String roomName;
private int mapX, mapY, trueX, trueY;
private double radius;
/**
* DOWNSTAIRS ROOM
* @param roomName
* @param mapX
* @param mapY
* @param radius
*/
public Room(String roomName, int mapX, int mapY, double radius) {
this.roomName = roomName;
this.mapX = mapX;
this.mapY = mapY;
this.trueX = mapX;
this.trueY = mapY;
this.radius = radius;
}
/**
* DOWNSTAIRS CLASSROOM
* @param roomName
* @param mapX
* @param mapY
*/
public Room(String roomName, int mapX, int mapY) {
this.roomName = roomName;
this.mapX = mapX;
this.mapY = mapY;
this.trueX = mapX;
this.trueY = mapY;
this.radius = Data.classRadius;
}
/**
* UPSTAIRS CLASSROOM
* @param roomName
* @param mapX
* @param mapY
* @param trueX
* @param trueY
*/
public Room(String roomName, int mapX, int mapY, int trueX, int trueY) {
this.roomName = roomName;
this.mapX = mapX;
this.mapY = mapY;
this.trueX = trueX;
this.trueY = trueY;
this.radius = Data.classRadius;
}
public static int[] randSpotInside(int x, int y, double rad) {
int angle = (int)(Math.random() * 360);
double radius = Math.random() * rad;
return new int[] {
x+(int)(radius*Math.cos(angle)),
y+(int)(radius*Math.sin(angle))
};
}
public String getRoomName() {
return roomName;
}
public int getMapX() {
return mapX;
}
public int getMapY() {
return mapY;
}
public int getTrueX() {
return trueX;
}
public int getTrueY() {
return trueY;
}
boolean isClass() {
return roomName.matches("[A-Z]\\d{2,3}");
}
public boolean isUpstairs() {
return mapX != trueX;
}
public String getBuilding() {
return isClass() ? "" + roomName.charAt(0) : "";
}
public int[] randSpotInside() {
int angle = (int)(Math.random() * 360);
double radius = Math.random() * this.radius;
return new int[] {
mapX+(int)(radius*Math.cos(angle)),
mapY+(int)(radius*Math.sin(angle))
};
}
}