17 |
Location leftUpper; |
Location leftUpper; |
18 |
|
|
19 |
|
|
20 |
Location blocks[][] = new Location[2][2]; // [width][height] - [0][0] == leftUpper |
Location blocks[][]; // [width][height] - [0][0] == leftUpper |
21 |
|
|
22 |
int material; |
int material; |
23 |
|
|
24 |
int direction; |
int direction; |
25 |
|
|
26 |
int width = 2; |
int width; |
27 |
int height = 2; |
int height; |
28 |
|
|
29 |
|
|
30 |
public Door(Block sign) { |
public Door(Block sign, int width, int height, DoorStorage store) throws ConflictingDoorException{ |
31 |
leftUpper = sign.getLocation().clone(); |
leftUpper = sign.getLocation().clone(); |
32 |
|
|
33 |
|
this.width = width; |
34 |
|
this.height = height; |
35 |
|
|
36 |
|
blocks = new Location[width][height]; |
37 |
|
|
38 |
direction = sign.getData() - 2; |
direction = sign.getData() - 2; |
39 |
|
|
57 |
material = leftUpper.getBlock().getTypeId(); |
material = leftUpper.getBlock().getTypeId(); |
58 |
|
|
59 |
loadBlocks(); |
loadBlocks(); |
60 |
|
|
61 |
|
|
62 |
|
for (int w=0; w<width; w++) { |
63 |
|
for (int h=0; h<height; h++) { |
64 |
|
Door d = store.findDoor( blocks[w][h] ); |
65 |
|
if (d != null) { |
66 |
|
throw new ConflictingDoorException(); |
67 |
|
} |
68 |
|
} |
69 |
|
} |
70 |
|
|
71 |
} |
} |
72 |
|
|
78 |
leftUpper = new Location(w, Integer.parseInt(parts[1]), Integer.parseInt(parts[2]), Integer.parseInt(parts[3]) ); |
leftUpper = new Location(w, Integer.parseInt(parts[1]), Integer.parseInt(parts[2]), Integer.parseInt(parts[3]) ); |
79 |
direction = Integer.parseInt( parts[4] ); |
direction = Integer.parseInt( parts[4] ); |
80 |
material = Integer.parseInt( parts[5] ); |
material = Integer.parseInt( parts[5] ); |
81 |
|
|
82 |
|
width = Integer.parseInt( parts[6] ); |
83 |
|
height = Integer.parseInt( parts[7] ); |
84 |
|
|
85 |
loadBlocks(); |
loadBlocks(); |
86 |
} |
} |
87 |
|
|
129 |
|
|
130 |
sb.append( ":" + direction ); |
sb.append( ":" + direction ); |
131 |
|
|
|
|
|
132 |
sb.append( ":" + material ); |
sb.append( ":" + material ); |
133 |
|
|
134 |
|
sb.append( ":" + width ); |
135 |
|
sb.append( ":" + height ); |
136 |
|
|
137 |
return sb.toString(); |
return sb.toString(); |
138 |
} |
} |