-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChangeableData.java
266 lines (258 loc) · 7.99 KB
/
ChangeableData.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.ArrayList;
/**
* This is my database class for data that can be changed.
* This class keeps track of locations of items that can be picked up.
* It also locates characters that can move.
* The player's "bag" is also modified in this class.
*
* @author Isabel Rosa
*/
public class ChangeableData extends Actor{
protected ArrayList<BagThings> bag = new ArrayList<>();
private int[] keysXY;
private boolean[] keysBoolean;
private int[] artXY;
private boolean[] artBoolean;
private int[] magnifierXY;
private boolean[] magnifierBoolean;
private int[] realArtXY;
private boolean[] realArtBoolean;
private int[] flashlightXY;
private boolean[] flashlightBoolean;
private boolean[][] doorsLocked;
private int[][] sRoom;
private int[][] aRoom;
private int[][] hRoom;
private int[][] cRoom;
/**
* Constructor for ChangeableData class.
* Initializes all the variables above (except bag, which is added to during the game).
* These are the starting positions of everything.
*
* I use a lot of different styles of keeping tracks of things here.
* It may seem haphazard, but I wanted to be flexible and creative.
*/
protected ChangeableData(){
keysXY = new int[] {
100, 100,
-1, -1,
-1, -1,
-1, -1,
-1, -1,
-1, -1,
-1, -1};
keysBoolean = new boolean[] {
true,
false,
false,
false,
false,
false,
false};
artXY = new int[] {
400, 300,
-1, -1,
400, 100,
-1, -1,
-1, -1,
-1, -1,
-1, -1};
artBoolean = new boolean[] {
true,
false,
true,
false,
false,
false,
false};
magnifierXY = new int[] {
-1, -1,
-1, -1,
300, 100,
-1, -1,
-1, -1,
-1, -1,
-1, -1};
magnifierBoolean = new boolean[] {
false,
false,
true,
false,
false,
false,
false};
realArtXY = new int[] {
-1 ,-1,
-1, -1,
-1, -1,
-1, -1,
350, 20,
-1, -1,
-1, -1};
realArtBoolean = new boolean[] {
false,
false,
false,
false,
true,
false,
false};
flashlightXY = new int[] {
400, 75,
-1, -1,
-1, -1,
-1, -1,
-1, -1,
-1, -1,
-1, -1};
flashlightBoolean = new boolean[]{
true,
false,
false,
false,
false,
false,
false};
doorsLocked = new boolean[][] {
new boolean[] {false, false, false, true},
new boolean[] {false, false, false, false},
new boolean[] {false, false, false, false},
new boolean[] {false, false, true, false},
new boolean[] {false, true, true, false},
new boolean[] {true, false, false, false},
new boolean[] {true, false, false, false}};
sRoom = new int[][] {
new int[] {1, 50, 100},
new int[] {0, 200, 100},
new int[] {0, 200, 250},
new int[] {0, 300, 100},
new int[] {0, 100, 200},
new int[] {0, 300, 50},
new int[] {0, 30, 100}};
aRoom = new int[][] {
new int[] {0, 200, 100},
new int[] {0, 50, 50},
new int[] {0, 350, 350},
new int[] {0, 150, 250},
new int[] {1, 250, 200},
new int[] {0, 200, 100},
new int[] {0, 350, 350}};
hRoom = new int[][] {
new int[] {0, 60, 140},
new int[] {0, 100, 200},
new int[] {0, 350, 200},
new int[] {0, 100, 300},
new int[] {0, 20, 50},
new int[] {1, 250, 200},
new int[] {0, 200, 100}};
cRoom = new int[][] {
new int[] {0, 50, 50},
new int[] {1, 50, 50},
new int[] {0, 100, 300},
new int[] {0, 400, 200},
new int[] {0, 300, 300},
new int[] {0, 275, 200},
new int[] {0, 100, 100}
};
}
/**
* This returns a coordinate of an object, specified by the parameters.
*/
protected int getSpecificCoordinate(int ind, String str){
if(str.equals("art"))
return artXY[ind];
else if(str.equals("key"))
return keysXY[ind];
else if(str.equals("magnifier"))
return magnifierXY[ind];
else if(str.equals("real art"))
return realArtXY[ind];
else if(str.equals("flashlight"))
return flashlightXY[ind];
else if(str.equals("S"))
return sRoom[ind/3][ind%3];
else if(str.equals("A"))
return aRoom[ind/3][ind%3];
else if(str.equals("H"))
return hRoom[ind/3][ind%3];
else if(str.equals("C"))
return cRoom[ind/3][ind%3];
return -1;
}
/**
* This modifies a spot in the coordinate array of a specific object/person.
* The spot and the object/person and the value it's being set to are all parameters.
*/
protected void changeCoordinateArray(int ind, int val, String str){
if(str.equals("art"))
artXY[ind]=val;
else if(str.equals("key"))
keysXY[ind]=val;
else if(str.equals("magnifier"))
magnifierXY[ind]=val;
else if(str.equals("real art"))
realArtXY[ind]=val;
else if(str.equals("flashlight"))
flashlightXY[ind]=val;
else if(str.equals("S"))
sRoom[ind/3][ind%3]=val;
else if(str.equals("A"))
aRoom[ind/3][ind%3]=val;
else if(str.equals("H"))
hRoom[ind/3][ind%3]=val;
else if(str.equals("C"))
cRoom[ind/3][ind%3]=val;
}
/**
* This changes the value in a boolean array, specified by parameters.
*/
protected void changeBooleanArray(int ind, boolean val, String str){
if(str.equals("art"))
artBoolean[ind]=val;
else if(str.equals("key"))
keysBoolean[ind]=val;
else if(str.equals("magnifier"))
magnifierBoolean[ind]=val;
else if(str.equals("real art"))
realArtBoolean[ind]=val;
else if(str.equals("flashlight"))
flashlightBoolean[ind]=val;
}
/**
* This returns true if an object/person is in a room, false if it is not.
*/
protected boolean getSpecificBoolean(int ind, String str){
if(str.equals("art"))
return artBoolean[ind];
else if(str.equals("key"))
return keysBoolean[ind];
else if(str.equals("magnifier"))
return magnifierBoolean[ind];
else if(str.equals("real art"))
return realArtBoolean[ind];
else if(str.equals("flashlight"))
return flashlightBoolean[ind];
else if(str.equals("S"))
return sRoom[ind][0]==1;
else if(str.equals("A"))
return aRoom[ind][0]==1;
else if(str.equals("H"))
return hRoom[ind][0]==1;
else if(str.equals("C"))
return cRoom[ind][0]==1;
return false;
}
/**
* This returns true if the door in question is locked.
*/
protected boolean getDoorLocked(int room, int door){
return doorsLocked[room][door];
}
/**
* This sets a specific door to be either locked or unlocked.
*/
protected void setDoorLocked(int room, int door, boolean val){
doorsLocked[room][door]=val;
}
}