diff options
Diffstat (limited to 'src/com/fourisland')
-rw-r--r-- | src/com/fourisland/frigidearth/GridSpace.java | 26 | ||||
-rw-r--r-- | src/com/fourisland/frigidearth/Item.java | 315 | ||||
-rw-r--r-- | src/com/fourisland/frigidearth/MapViewGameState.java | 253 |
3 files changed, 180 insertions, 414 deletions
diff --git a/src/com/fourisland/frigidearth/GridSpace.java b/src/com/fourisland/frigidearth/GridSpace.java new file mode 100644 index 0000000..16dac4c --- /dev/null +++ b/src/com/fourisland/frigidearth/GridSpace.java | |||
@@ -0,0 +1,26 @@ | |||
1 | /* | ||
2 | * To change this template, choose Tools | Templates | ||
3 | * and open the template in the editor. | ||
4 | */ | ||
5 | package com.fourisland.frigidearth; | ||
6 | |||
7 | import java.util.ArrayList; | ||
8 | import java.util.List; | ||
9 | |||
10 | /** | ||
11 | * | ||
12 | * @author hatkirby | ||
13 | */ | ||
14 | public class GridSpace | ||
15 | { | ||
16 | public Tile tile; | ||
17 | public boolean lit; | ||
18 | public List<Item> items; | ||
19 | |||
20 | public GridSpace() | ||
21 | { | ||
22 | tile = Tile.Unused; | ||
23 | lit = false; | ||
24 | items = new ArrayList<Item>(); | ||
25 | } | ||
26 | } | ||
diff --git a/src/com/fourisland/frigidearth/Item.java b/src/com/fourisland/frigidearth/Item.java index d58f3c3..604432e 100644 --- a/src/com/fourisland/frigidearth/Item.java +++ b/src/com/fourisland/frigidearth/Item.java | |||
@@ -17,27 +17,7 @@ import java.util.Random; | |||
17 | */ | 17 | */ |
18 | public enum Item | 18 | public enum Item |
19 | { | 19 | { |
20 | ScrollOfHealing { | 20 | ScrollOfHealing("Scroll of Healing", '~', Color.YELLOW, ItemType.Scroll) { |
21 | public String getItemName() | ||
22 | { | ||
23 | return "Scroll of Healing"; | ||
24 | } | ||
25 | |||
26 | public char getDisplayCharacter() | ||
27 | { | ||
28 | return '~'; | ||
29 | } | ||
30 | |||
31 | public Color getDisplayColor() | ||
32 | { | ||
33 | return Color.YELLOW; | ||
34 | } | ||
35 | |||
36 | public ItemType getItemType() | ||
37 | { | ||
38 | return ItemType.Scroll; | ||
39 | } | ||
40 | |||
41 | public boolean useItem() | 21 | public boolean useItem() |
42 | { | 22 | { |
43 | Main.currentGame.health += 20; | 23 | Main.currentGame.health += 20; |
@@ -50,267 +30,32 @@ public enum Item | |||
50 | return true; | 30 | return true; |
51 | } | 31 | } |
52 | }, | 32 | }, |
53 | WoodenHelmet { | 33 | WoodenHelmet("Wooden Helmet", '^', new Color(128, 42, 42), ItemType.Helmet) { |
54 | public String getItemName() | ||
55 | { | ||
56 | return "Wooden Helmet"; | ||
57 | } | ||
58 | |||
59 | public char getDisplayCharacter() | ||
60 | { | ||
61 | return '^'; | ||
62 | } | ||
63 | |||
64 | public Color getDisplayColor() | ||
65 | { | ||
66 | return new Color(128, 42, 42); | ||
67 | } | ||
68 | |||
69 | public ItemType getItemType() | ||
70 | { | ||
71 | return ItemType.Helmet; | ||
72 | } | ||
73 | |||
74 | public int getDefense() | 34 | public int getDefense() |
75 | { | 35 | { |
76 | return 1; | 36 | return 1; |
77 | } | 37 | } |
78 | }, | 38 | }, |
79 | WoodenSword { | 39 | WoodenSword("Wooden Sword", '/', new Color(128, 42, 42), ItemType.Sword) { |
80 | public String getItemName() | ||
81 | { | ||
82 | return "Wooden Sword"; | ||
83 | } | ||
84 | |||
85 | public char getDisplayCharacter() | ||
86 | { | ||
87 | return '/'; | ||
88 | } | ||
89 | |||
90 | public Color getDisplayColor() | ||
91 | { | ||
92 | return new Color(128, 42, 42); | ||
93 | } | ||
94 | |||
95 | public ItemType getItemType() | ||
96 | { | ||
97 | return ItemType.Sword; | ||
98 | } | ||
99 | |||
100 | public int getAttackPower() | 40 | public int getAttackPower() |
101 | { | 41 | { |
102 | return 1; | 42 | return 1; |
103 | } | 43 | } |
104 | }, | 44 | }, |
105 | WoodenShield { | 45 | WoodenShield("Wooden Shield", 'O', new Color(128, 42, 42), ItemType.Shield) { |
106 | public String getItemName() | ||
107 | { | ||
108 | return "Wooden Shield"; | ||
109 | } | ||
110 | |||
111 | public char getDisplayCharacter() | ||
112 | { | ||
113 | return 'O'; | ||
114 | } | ||
115 | |||
116 | public Color getDisplayColor() | ||
117 | { | ||
118 | return new Color(128, 42, 42); | ||
119 | } | ||
120 | |||
121 | public ItemType getItemType() | ||
122 | { | ||
123 | return ItemType.Shield; | ||
124 | } | ||
125 | |||
126 | public int getDefense() | 46 | public int getDefense() |
127 | { | 47 | { |
128 | return 1; | 48 | return 1; |
129 | } | 49 | } |
130 | }, | 50 | }, |
131 | RingOfRegeneration { | 51 | RingOfRegeneration("Ring of Regeneration", 'o', Color.YELLOW, ItemType.Ring) {}, |
132 | public String getItemName() | 52 | Crocs("Crocs", 'd', new Color(128, 42, 42), ItemType.Shoes), |
133 | { | 53 | GlassHelmet("Glass Helmet", '^', Color.CYAN, ItemType.Helmet), |
134 | return "Ring of Regeneration"; | 54 | GlassSword("Glass Sword", '/', Color.CYAN, ItemType.Sword), |
135 | } | 55 | GlassShield("Glass Shield", 'O', Color.CYAN, ItemType.Shield), |
136 | 56 | WeddingRing("Wedding Ring", 'o', Color.YELLOW, ItemType.Ring), | |
137 | public char getDisplayCharacter() | 57 | GlassSlippers("Glass Slippers", 'd', Color.CYAN, ItemType.Shoes), |
138 | { | 58 | Key("Key", 'k', Color.YELLOW, ItemType.Special) { |
139 | return 'o'; | ||
140 | } | ||
141 | |||
142 | public Color getDisplayColor() | ||
143 | { | ||
144 | return Color.YELLOW; | ||
145 | } | ||
146 | |||
147 | public ItemType getItemType() | ||
148 | { | ||
149 | return ItemType.Ring; | ||
150 | } | ||
151 | }, | ||
152 | Crocs { | ||
153 | public String getItemName() | ||
154 | { | ||
155 | return "Crocs"; | ||
156 | } | ||
157 | |||
158 | public char getDisplayCharacter() | ||
159 | { | ||
160 | return 'd'; | ||
161 | } | ||
162 | |||
163 | public Color getDisplayColor() | ||
164 | { | ||
165 | return new Color(128, 42, 42); | ||
166 | } | ||
167 | |||
168 | public ItemType getItemType() | ||
169 | { | ||
170 | return ItemType.Shoes; | ||
171 | } | ||
172 | }, | ||
173 | GlassHelmet { | ||
174 | public String getItemName() | ||
175 | { | ||
176 | return "Glass Helmet"; | ||
177 | } | ||
178 | |||
179 | public char getDisplayCharacter() | ||
180 | { | ||
181 | return '^'; | ||
182 | } | ||
183 | |||
184 | public Color getDisplayColor() | ||
185 | { | ||
186 | return Color.CYAN; | ||
187 | } | ||
188 | |||
189 | public ItemType getItemType() | ||
190 | { | ||
191 | return ItemType.Helmet; | ||
192 | } | ||
193 | |||
194 | public int getDefense() | ||
195 | { | ||
196 | return 0; | ||
197 | } | ||
198 | }, | ||
199 | GlassSword { | ||
200 | public String getItemName() | ||
201 | { | ||
202 | return "Glass Sword"; | ||
203 | } | ||
204 | |||
205 | public char getDisplayCharacter() | ||
206 | { | ||
207 | return '/'; | ||
208 | } | ||
209 | |||
210 | public Color getDisplayColor() | ||
211 | { | ||
212 | return Color.CYAN; | ||
213 | } | ||
214 | |||
215 | public ItemType getItemType() | ||
216 | { | ||
217 | return ItemType.Sword; | ||
218 | } | ||
219 | |||
220 | public int getAttackPower() | ||
221 | { | ||
222 | return 0; | ||
223 | } | ||
224 | }, | ||
225 | GlassShield { | ||
226 | public String getItemName() | ||
227 | { | ||
228 | return "Glass Shield"; | ||
229 | } | ||
230 | |||
231 | public char getDisplayCharacter() | ||
232 | { | ||
233 | return 'O'; | ||
234 | } | ||
235 | |||
236 | public Color getDisplayColor() | ||
237 | { | ||
238 | return Color.CYAN; | ||
239 | } | ||
240 | |||
241 | public ItemType getItemType() | ||
242 | { | ||
243 | return ItemType.Shield; | ||
244 | } | ||
245 | |||
246 | public int getDefense() | ||
247 | { | ||
248 | return 0; | ||
249 | } | ||
250 | }, | ||
251 | WeddingRing { | ||
252 | public String getItemName() | ||
253 | { | ||
254 | return "Wedding Ring"; | ||
255 | } | ||
256 | |||
257 | public char getDisplayCharacter() | ||
258 | { | ||
259 | return 'o'; | ||
260 | } | ||
261 | |||
262 | public Color getDisplayColor() | ||
263 | { | ||
264 | return Color.YELLOW; | ||
265 | } | ||
266 | |||
267 | public ItemType getItemType() | ||
268 | { | ||
269 | return ItemType.Ring; | ||
270 | } | ||
271 | }, | ||
272 | GlassSlippers { | ||
273 | public String getItemName() | ||
274 | { | ||
275 | return "Glass Slippers"; | ||
276 | } | ||
277 | |||
278 | public char getDisplayCharacter() | ||
279 | { | ||
280 | return 'd'; | ||
281 | } | ||
282 | |||
283 | public Color getDisplayColor() | ||
284 | { | ||
285 | return Color.CYAN; | ||
286 | } | ||
287 | |||
288 | public ItemType getItemType() | ||
289 | { | ||
290 | return ItemType.Shoes; | ||
291 | } | ||
292 | }, | ||
293 | Key { | ||
294 | public String getItemName() | ||
295 | { | ||
296 | return "Key"; | ||
297 | } | ||
298 | |||
299 | public char getDisplayCharacter() | ||
300 | { | ||
301 | return 'k'; | ||
302 | } | ||
303 | |||
304 | public Color getDisplayColor() | ||
305 | { | ||
306 | return Color.YELLOW; | ||
307 | } | ||
308 | |||
309 | public ItemType getItemType() | ||
310 | { | ||
311 | return ItemType.Special; | ||
312 | } | ||
313 | |||
314 | public boolean useItem() | 59 | public boolean useItem() |
315 | { | 60 | { |
316 | ((MapViewGameState) Main.getGameState()).printMessage("There's nothing to use the key on!"); | 61 | ((MapViewGameState) Main.getGameState()).printMessage("There's nothing to use the key on!"); |
@@ -319,10 +64,38 @@ public enum Item | |||
319 | } | 64 | } |
320 | }; | 65 | }; |
321 | 66 | ||
322 | public abstract String getItemName(); | 67 | private String itemName; |
323 | public abstract char getDisplayCharacter(); | 68 | private char displayChar; |
324 | public abstract Color getDisplayColor(); | 69 | private Color displayColor; |
325 | public abstract ItemType getItemType(); | 70 | private ItemType itemType; |
71 | |||
72 | Item(String m_itemName, char m_displayChar, Color m_displayColor, ItemType m_itemType) | ||
73 | { | ||
74 | itemName = m_itemName; | ||
75 | displayChar = m_displayChar; | ||
76 | displayColor = m_displayColor; | ||
77 | itemType = m_itemType; | ||
78 | } | ||
79 | |||
80 | public String getItemName() | ||
81 | { | ||
82 | return itemName; | ||
83 | } | ||
84 | |||
85 | public char getDisplayCharacter() | ||
86 | { | ||
87 | return displayChar; | ||
88 | } | ||
89 | |||
90 | public Color getDisplayColor() | ||
91 | { | ||
92 | return displayColor; | ||
93 | } | ||
94 | |||
95 | public ItemType getItemType() | ||
96 | { | ||
97 | return itemType; | ||
98 | } | ||
326 | 99 | ||
327 | public boolean useItem() | 100 | public boolean useItem() |
328 | { | 101 | { |
diff --git a/src/com/fourisland/frigidearth/MapViewGameState.java b/src/com/fourisland/frigidearth/MapViewGameState.java index 0e136d5..67c7b19 100644 --- a/src/com/fourisland/frigidearth/MapViewGameState.java +++ b/src/com/fourisland/frigidearth/MapViewGameState.java | |||
@@ -38,12 +38,10 @@ public class MapViewGameState implements GameState | |||
38 | private final int[][] OCTET_MULTIPLIERS = new int[][] {new int[] {1,0,0,-1,-1,0,0,1}, new int[] {0,1,-1,0,0,-1,1,0}, new int[] {0,1,1,0,0,-1,-1,0}, new int[] {1,0,0,1,-1,0,0,-1}}; | 38 | private final int[][] OCTET_MULTIPLIERS = new int[][] {new int[] {1,0,0,-1,-1,0,0,1}, new int[] {0,1,-1,0,0,-1,1,0}, new int[] {0,1,1,0,0,-1,-1,0}, new int[] {1,0,0,1,-1,0,0,-1}}; |
39 | private int mapWidth = 60; | 39 | private int mapWidth = 60; |
40 | private int mapHeight = 60; | 40 | private int mapHeight = 60; |
41 | private Tile[][] grid; | 41 | private GridSpace[][] grid; |
42 | private boolean[][] gridLighting; | ||
43 | private String[] messages = new String[MESSAGE_HEIGHT]; | 42 | private String[] messages = new String[MESSAGE_HEIGHT]; |
44 | private List<Room> rooms = new ArrayList<Room>(); | 43 | private List<Room> rooms = new ArrayList<Room>(); |
45 | private List<Mob> mobs = new ArrayList<Mob>(); | 44 | private List<Mob> mobs = new ArrayList<Mob>(); |
46 | private List<ItemInstance> items = new ArrayList<ItemInstance>(); | ||
47 | private int playerx = 4; | 45 | private int playerx = 4; |
48 | private int playery = 4; | 46 | private int playery = 4; |
49 | private int viewportx = 0; | 47 | private int viewportx = 0; |
@@ -62,18 +60,17 @@ public class MapViewGameState implements GameState | |||
62 | mapWidth += (50 * (floor-1)); | 60 | mapWidth += (50 * (floor-1)); |
63 | mapHeight += (50 * (floor-1)); | 61 | mapHeight += (50 * (floor-1)); |
64 | 62 | ||
65 | grid = new Tile[mapWidth][mapHeight]; | 63 | grid = new GridSpace[mapWidth][mapHeight]; |
66 | gridLighting = new boolean[mapWidth][mapHeight]; | ||
67 | 64 | ||
68 | for (int x=0; x<mapWidth; x++) | 65 | for (int x=0; x<mapWidth; x++) |
69 | { | 66 | { |
70 | for (int y=0; y<mapHeight; y++) | 67 | for (int y=0; y<mapHeight; y++) |
71 | { | 68 | { |
69 | grid[x][y] = new GridSpace(); | ||
70 | |||
72 | if ((x == 0) || (x == mapWidth-1) || (y == 0) || (y == mapHeight-1)) | 71 | if ((x == 0) || (x == mapWidth-1) || (y == 0) || (y == mapHeight-1)) |
73 | { | 72 | { |
74 | grid[x][y] = Tile.StoneWall; | 73 | grid[x][y].tile = Tile.StoneWall; |
75 | } else { | ||
76 | grid[x][y] = Tile.Unused; | ||
77 | } | 74 | } |
78 | } | 75 | } |
79 | } | 76 | } |
@@ -122,24 +119,24 @@ public class MapViewGameState implements GameState | |||
122 | newy = Functions.random(1, mapHeight-1); | 119 | newy = Functions.random(1, mapHeight-1); |
123 | validTile = null; | 120 | validTile = null; |
124 | 121 | ||
125 | if ((grid[newx][newy] == Tile.DirtWall) || (grid[newx][newy] == Tile.Corridor)) | 122 | if ((grid[newx][newy].tile == Tile.DirtWall) || (grid[newx][newy].tile == Tile.Corridor)) |
126 | { | 123 | { |
127 | if ((grid[newx][newy+1] == Tile.DirtFloor) || (grid[newx][newy+1] == Tile.Corridor)) | 124 | if ((grid[newx][newy+1].tile == Tile.DirtFloor) || (grid[newx][newy+1].tile == Tile.Corridor)) |
128 | { | 125 | { |
129 | validTile = Direction.North; | 126 | validTile = Direction.North; |
130 | xmod = 0; | 127 | xmod = 0; |
131 | ymod = -1; | 128 | ymod = -1; |
132 | } else if ((grid[newx-1][newy] == Tile.DirtFloor) || (grid[newx-1][newy] == Tile.Corridor)) | 129 | } else if ((grid[newx-1][newy].tile == Tile.DirtFloor) || (grid[newx-1][newy].tile == Tile.Corridor)) |
133 | { | 130 | { |
134 | validTile = Direction.East; | 131 | validTile = Direction.East; |
135 | xmod = 1; | 132 | xmod = 1; |
136 | ymod = 0; | 133 | ymod = 0; |
137 | } else if ((grid[newx][newy-1] == Tile.DirtFloor) || (grid[newx][newy-1] == Tile.Corridor)) | 134 | } else if ((grid[newx][newy-1].tile == Tile.DirtFloor) || (grid[newx][newy-1].tile == Tile.Corridor)) |
138 | { | 135 | { |
139 | validTile = Direction.South; | 136 | validTile = Direction.South; |
140 | xmod = 0; | 137 | xmod = 0; |
141 | ymod = 1; | 138 | ymod = 1; |
142 | } else if ((grid[newx+1][newy] == Tile.DirtFloor) || (grid[newx+1][newy] == Tile.Corridor)) | 139 | } else if ((grid[newx+1][newy].tile == Tile.DirtFloor) || (grid[newx+1][newy].tile == Tile.Corridor)) |
143 | { | 140 | { |
144 | validTile = Direction.West; | 141 | validTile = Direction.West; |
145 | xmod = -1; | 142 | xmod = -1; |
@@ -148,16 +145,16 @@ public class MapViewGameState implements GameState | |||
148 | 145 | ||
149 | if (validTile != null) | 146 | if (validTile != null) |
150 | { | 147 | { |
151 | if ((grid[newx][newy+1] == Tile.ClosedDoor) || (grid[newx][newy+1] == Tile.OpenDoor)) | 148 | if ((grid[newx][newy+1].tile == Tile.ClosedDoor) || (grid[newx][newy+1].tile == Tile.OpenDoor)) |
152 | { | 149 | { |
153 | validTile = null; | 150 | validTile = null; |
154 | } else if ((grid[newx-1][newy] == Tile.ClosedDoor) || (grid[newx-1][newy] == Tile.OpenDoor)) | 151 | } else if ((grid[newx-1][newy].tile == Tile.ClosedDoor) || (grid[newx-1][newy].tile == Tile.OpenDoor)) |
155 | { | 152 | { |
156 | validTile = null; | 153 | validTile = null; |
157 | } else if ((grid[newx][newy-1] == Tile.ClosedDoor) || (grid[newx][newy-1] == Tile.OpenDoor)) | 154 | } else if ((grid[newx][newy-1].tile == Tile.ClosedDoor) || (grid[newx][newy-1].tile == Tile.OpenDoor)) |
158 | { | 155 | { |
159 | validTile = null; | 156 | validTile = null; |
160 | } else if ((grid[newx+1][newy] == Tile.ClosedDoor) || (grid[newx+1][newy] == Tile.OpenDoor)) | 157 | } else if ((grid[newx+1][newy].tile == Tile.ClosedDoor) || (grid[newx+1][newy].tile == Tile.OpenDoor)) |
161 | { | 158 | { |
162 | validTile = null; | 159 | validTile = null; |
163 | } | 160 | } |
@@ -177,14 +174,14 @@ public class MapViewGameState implements GameState | |||
177 | if (makeRoom(newx+xmod, newy+ymod, validTile, legalBounds)) | 174 | if (makeRoom(newx+xmod, newy+ymod, validTile, legalBounds)) |
178 | { | 175 | { |
179 | currentFeatures++; | 176 | currentFeatures++; |
180 | grid[newx][newy] = Tile.ClosedDoor; | 177 | grid[newx][newy].tile = Tile.ClosedDoor; |
181 | grid[newx+xmod][newy+ymod] = Tile.DirtFloor; | 178 | grid[newx+xmod][newy+ymod].tile = Tile.DirtFloor; |
182 | } | 179 | } |
183 | } else { | 180 | } else { |
184 | if (makeCorridor(newx+xmod, newy+ymod, validTile)) | 181 | if (makeCorridor(newx+xmod, newy+ymod, validTile)) |
185 | { | 182 | { |
186 | currentFeatures++; | 183 | currentFeatures++; |
187 | grid[newx][newy] = Tile.ClosedDoor; | 184 | grid[newx][newy].tile = Tile.ClosedDoor; |
188 | } | 185 | } |
189 | } | 186 | } |
190 | } | 187 | } |
@@ -206,7 +203,7 @@ public class MapViewGameState implements GameState | |||
206 | { | 203 | { |
207 | Point to = dir.to(new Point(newx, newy)); | 204 | Point to = dir.to(new Point(newx, newy)); |
208 | 205 | ||
209 | if ((isValidPosition(to.x, to.y)) && (grid[to.x][to.y] == Tile.DirtFloor) || (grid[to.x][to.y] == Tile.Corridor)) | 206 | if ((isValidPosition(to.x, to.y)) && (grid[to.x][to.y].tile == Tile.DirtFloor) || (grid[to.x][to.y].tile == Tile.Corridor)) |
210 | { | 207 | { |
211 | ways--; | 208 | ways--; |
212 | } | 209 | } |
@@ -216,7 +213,7 @@ public class MapViewGameState implements GameState | |||
216 | { | 213 | { |
217 | if (ways == 0) | 214 | if (ways == 0) |
218 | { | 215 | { |
219 | grid[newx][newy] = Tile.UpStairs; | 216 | grid[newx][newy].tile = Tile.UpStairs; |
220 | state = 1; | 217 | state = 1; |
221 | break; | 218 | break; |
222 | } | 219 | } |
@@ -224,7 +221,7 @@ public class MapViewGameState implements GameState | |||
224 | { | 221 | { |
225 | if (ways == 0) | 222 | if (ways == 0) |
226 | { | 223 | { |
227 | grid[newx][newy] = Tile.DownStairs; | 224 | grid[newx][newy].tile = Tile.DownStairs; |
228 | playerx=newx; | 225 | playerx=newx; |
229 | playery=newy; | 226 | playery=newy; |
230 | state = 10; | 227 | state = 10; |
@@ -284,75 +281,67 @@ public class MapViewGameState implements GameState | |||
284 | { | 281 | { |
285 | if (((keyRoomDirection == Direction.North) || (keyRoomDirection == Direction.South)) && (ytemp % 2 == 0) && (ytemp != room.getY())) | 282 | if (((keyRoomDirection == Direction.North) || (keyRoomDirection == Direction.South)) && (ytemp % 2 == 0) && (ytemp != room.getY())) |
286 | { | 283 | { |
287 | grid[xtemp][ytemp] = Tile.Window; | 284 | grid[xtemp][ytemp].tile = Tile.Window; |
288 | } else { | 285 | } else { |
289 | grid[xtemp][ytemp] = Tile.DirtWall; | 286 | grid[xtemp][ytemp].tile = Tile.DirtWall; |
290 | } | 287 | } |
291 | } else if (xtemp == room.getX()+room.getWidth()-1) | 288 | } else if (xtemp == room.getX()+room.getWidth()-1) |
292 | { | 289 | { |
293 | if (((keyRoomDirection == Direction.North) || (keyRoomDirection == Direction.South)) && (ytemp % 2 == 0) && (ytemp != (room.getY()+room.getHeight()))) | 290 | if (((keyRoomDirection == Direction.North) || (keyRoomDirection == Direction.South)) && (ytemp % 2 == 0) && (ytemp != (room.getY()+room.getHeight()))) |
294 | { | 291 | { |
295 | grid[xtemp][ytemp] = Tile.Window; | 292 | grid[xtemp][ytemp].tile = Tile.Window; |
296 | } else { | 293 | } else { |
297 | grid[xtemp][ytemp] = Tile.DirtWall; | 294 | grid[xtemp][ytemp].tile = Tile.DirtWall; |
298 | } | 295 | } |
299 | } else if (ytemp == room.getY()) | 296 | } else if (ytemp == room.getY()) |
300 | { | 297 | { |
301 | if (((keyRoomDirection == Direction.West) || (keyRoomDirection == Direction.East)) && (xtemp % 2 == 0) && (xtemp != room.getX())) | 298 | if (((keyRoomDirection == Direction.West) || (keyRoomDirection == Direction.East)) && (xtemp % 2 == 0) && (xtemp != room.getX())) |
302 | { | 299 | { |
303 | grid[xtemp][ytemp] = Tile.Window; | 300 | grid[xtemp][ytemp].tile = Tile.Window; |
304 | } else { | 301 | } else { |
305 | grid[xtemp][ytemp] = Tile.DirtWall; | 302 | grid[xtemp][ytemp].tile = Tile.DirtWall; |
306 | } | 303 | } |
307 | } else if (ytemp == room.getY()+room.getHeight()-1) | 304 | } else if (ytemp == room.getY()+room.getHeight()-1) |
308 | { | 305 | { |
309 | if (((keyRoomDirection == Direction.West) || (keyRoomDirection == Direction.East)) && (xtemp % 2 == 0) && (xtemp != (room.getX()+room.getWidth()))) | 306 | if (((keyRoomDirection == Direction.West) || (keyRoomDirection == Direction.East)) && (xtemp % 2 == 0) && (xtemp != (room.getX()+room.getWidth()))) |
310 | { | 307 | { |
311 | grid[xtemp][ytemp] = Tile.Window; | 308 | grid[xtemp][ytemp].tile = Tile.Window; |
312 | } else { | 309 | } else { |
313 | grid[xtemp][ytemp] = Tile.DirtWall; | 310 | grid[xtemp][ytemp].tile = Tile.DirtWall; |
314 | } | 311 | } |
315 | } else { | 312 | } else { |
316 | grid[xtemp][ytemp] = Tile.DirtFloor; | 313 | grid[xtemp][ytemp].tile = Tile.DirtFloor; |
317 | } | 314 | } |
318 | } | 315 | } |
319 | } | 316 | } |
320 | 317 | ||
321 | ItemInstance key = new ItemInstance(); | ||
322 | key.item = Item.Key; | ||
323 | |||
324 | switch (keyRoomDirection) | 318 | switch (keyRoomDirection) |
325 | { | 319 | { |
326 | case North: | 320 | case North: |
327 | grid[room.getX()+room.getWidth()/2][room.getY()+room.getHeight()] = Tile.ClosedDoor; | 321 | grid[room.getX()+room.getWidth()/2][room.getY()+room.getHeight()].tile = Tile.ClosedDoor; |
328 | grid[room.getX()+room.getWidth()/2][room.getY()+room.getHeight()-1] = Tile.DirtFloor; | 322 | grid[room.getX()+room.getWidth()/2][room.getY()+room.getHeight()-1].tile = Tile.DirtFloor; |
329 | key.x = room.getX()+3; | 323 | grid[room.getX()+3][room.getY()+3].items.add(Item.Key); |
330 | key.y = room.getY()+3; | ||
331 | break; | 324 | break; |
332 | 325 | ||
333 | case East: | 326 | case East: |
334 | grid[room.getX()-1][room.getY()+room.getHeight()/2] = Tile.ClosedDoor; | 327 | grid[room.getX()-1][room.getY()+room.getHeight()/2].tile = Tile.ClosedDoor; |
335 | grid[room.getX()][room.getY()+room.getHeight()/2] = Tile.DirtFloor; | 328 | grid[room.getX()][room.getY()+room.getHeight()/2].tile = Tile.DirtFloor; |
336 | key.x = room.getX()+10; | 329 | grid[room.getX()+10][room.getY()+3].items.add(Item.Key); |
337 | key.y = room.getY()+3; | ||
338 | break; | 330 | break; |
339 | 331 | ||
340 | case South: | 332 | case South: |
341 | grid[room.getX()+room.getWidth()/2][room.getY()-1] = Tile.ClosedDoor; | 333 | grid[room.getX()+room.getWidth()/2][room.getY()-1].tile = Tile.ClosedDoor; |
342 | grid[room.getX()+room.getWidth()/2][room.getY()] = Tile.DirtFloor; | 334 | grid[room.getX()+room.getWidth()/2][room.getY()].tile = Tile.DirtFloor; |
343 | key.x = room.getX()+3; | 335 | grid[room.getX()+3][room.getY()+10].items.add(Item.Key); |
344 | key.y = room.getY()+10; | ||
345 | break; | 336 | break; |
346 | 337 | ||
347 | case West: | 338 | case West: |
348 | grid[room.getX()+room.getWidth()][room.getY()+room.getHeight()/2] = Tile.ClosedDoor; | 339 | grid[room.getX()+room.getWidth()][room.getY()+room.getHeight()/2].tile = Tile.ClosedDoor; |
349 | grid[room.getX()+room.getWidth()-1][room.getY()+room.getHeight()/2] = Tile.DirtFloor; | 340 | grid[room.getX()+room.getWidth()-1][room.getY()+room.getHeight()/2].tile = Tile.DirtFloor; |
350 | key.x = room.getX()+3; | 341 | grid[room.getX()+3][room.getY()+3].items.add(Item.Key); |
351 | key.y = room.getY()+3; | ||
352 | break; | 342 | break; |
353 | } | 343 | } |
354 | 344 | ||
355 | items.add(key); | ||
356 | rooms.add(room); | 345 | rooms.add(room); |
357 | 346 | ||
358 | adjustViewport(); | 347 | adjustViewport(); |
@@ -410,7 +399,7 @@ public class MapViewGameState implements GameState | |||
410 | return false; | 399 | return false; |
411 | } | 400 | } |
412 | 401 | ||
413 | if (grid[xtemp][ytemp] != Tile.Unused) | 402 | if (grid[xtemp][ytemp].tile != Tile.Unused) |
414 | { | 403 | { |
415 | return false; | 404 | return false; |
416 | } | 405 | } |
@@ -423,18 +412,18 @@ public class MapViewGameState implements GameState | |||
423 | { | 412 | { |
424 | if (xtemp == room.getX()) | 413 | if (xtemp == room.getX()) |
425 | { | 414 | { |
426 | grid[xtemp][ytemp] = Tile.DirtWall; | 415 | grid[xtemp][ytemp].tile = Tile.DirtWall; |
427 | } else if (xtemp == room.getX()+room.getWidth()-1) | 416 | } else if (xtemp == room.getX()+room.getWidth()-1) |
428 | { | 417 | { |
429 | grid[xtemp][ytemp] = Tile.DirtWall; | 418 | grid[xtemp][ytemp].tile = Tile.DirtWall; |
430 | } else if (ytemp == room.getY()) | 419 | } else if (ytemp == room.getY()) |
431 | { | 420 | { |
432 | grid[xtemp][ytemp] = Tile.DirtWall; | 421 | grid[xtemp][ytemp].tile = Tile.DirtWall; |
433 | } else if (ytemp == room.getY()+room.getHeight()-1) | 422 | } else if (ytemp == room.getY()+room.getHeight()-1) |
434 | { | 423 | { |
435 | grid[xtemp][ytemp] = Tile.DirtWall; | 424 | grid[xtemp][ytemp].tile = Tile.DirtWall; |
436 | } else { | 425 | } else { |
437 | grid[xtemp][ytemp] = Tile.DirtFloor; | 426 | grid[xtemp][ytemp].tile = Tile.DirtFloor; |
438 | } | 427 | } |
439 | } | 428 | } |
440 | } | 429 | } |
@@ -462,11 +451,7 @@ public class MapViewGameState implements GameState | |||
462 | { | 451 | { |
463 | perf /= 2; | 452 | perf /= 2; |
464 | 453 | ||
465 | ItemInstance ii = new ItemInstance(); | 454 | grid[Functions.random(room.getX()+1, room.getX()+room.getWidth()-2)][Functions.random(room.getY()+1, room.getY()+room.getHeight()-2)].items.add(Item.getWeightedRandomItem()); |
466 | ii.item = Item.getWeightedRandomItem(); | ||
467 | ii.x = Functions.random(room.getX()+1, room.getX()+room.getWidth()-2); | ||
468 | ii.y = Functions.random(room.getY()+1, room.getY()+room.getHeight()-2); | ||
469 | items.add(ii); | ||
470 | } else { | 455 | } else { |
471 | break; | 456 | break; |
472 | } | 457 | } |
@@ -499,7 +484,7 @@ public class MapViewGameState implements GameState | |||
499 | return false; | 484 | return false; |
500 | } | 485 | } |
501 | 486 | ||
502 | if (grid[xtemp][ytemp] != Tile.Unused) | 487 | if (grid[xtemp][ytemp].tile != Tile.Unused) |
503 | { | 488 | { |
504 | return false; | 489 | return false; |
505 | } | 490 | } |
@@ -507,7 +492,7 @@ public class MapViewGameState implements GameState | |||
507 | 492 | ||
508 | for (ytemp = y; ytemp > (y-length); ytemp--) | 493 | for (ytemp = y; ytemp > (y-length); ytemp--) |
509 | { | 494 | { |
510 | grid[xtemp][ytemp] = Tile.Corridor; | 495 | grid[xtemp][ytemp].tile = Tile.Corridor; |
511 | } | 496 | } |
512 | 497 | ||
513 | break; | 498 | break; |
@@ -527,7 +512,7 @@ public class MapViewGameState implements GameState | |||
527 | return false; | 512 | return false; |
528 | } | 513 | } |
529 | 514 | ||
530 | if (grid[xtemp][ytemp] != Tile.Unused) | 515 | if (grid[xtemp][ytemp].tile != Tile.Unused) |
531 | { | 516 | { |
532 | return false; | 517 | return false; |
533 | } | 518 | } |
@@ -535,7 +520,7 @@ public class MapViewGameState implements GameState | |||
535 | 520 | ||
536 | for (xtemp = x; xtemp < (x+length); xtemp++) | 521 | for (xtemp = x; xtemp < (x+length); xtemp++) |
537 | { | 522 | { |
538 | grid[xtemp][ytemp] = Tile.Corridor; | 523 | grid[xtemp][ytemp].tile = Tile.Corridor; |
539 | } | 524 | } |
540 | 525 | ||
541 | break; | 526 | break; |
@@ -555,7 +540,7 @@ public class MapViewGameState implements GameState | |||
555 | return false; | 540 | return false; |
556 | } | 541 | } |
557 | 542 | ||
558 | if (grid[xtemp][ytemp] != Tile.Unused) | 543 | if (grid[xtemp][ytemp].tile != Tile.Unused) |
559 | { | 544 | { |
560 | return false; | 545 | return false; |
561 | } | 546 | } |
@@ -563,7 +548,7 @@ public class MapViewGameState implements GameState | |||
563 | 548 | ||
564 | for (ytemp = y; ytemp < (y+length); ytemp++) | 549 | for (ytemp = y; ytemp < (y+length); ytemp++) |
565 | { | 550 | { |
566 | grid[xtemp][ytemp] = Tile.Corridor; | 551 | grid[xtemp][ytemp].tile = Tile.Corridor; |
567 | } | 552 | } |
568 | 553 | ||
569 | break; | 554 | break; |
@@ -583,7 +568,7 @@ public class MapViewGameState implements GameState | |||
583 | return false; | 568 | return false; |
584 | } | 569 | } |
585 | 570 | ||
586 | if (grid[xtemp][ytemp] != Tile.Unused) | 571 | if (grid[xtemp][ytemp].tile != Tile.Unused) |
587 | { | 572 | { |
588 | return false; | 573 | return false; |
589 | } | 574 | } |
@@ -591,7 +576,7 @@ public class MapViewGameState implements GameState | |||
591 | 576 | ||
592 | for (xtemp = x; xtemp > (x-length); xtemp--) | 577 | for (xtemp = x; xtemp > (x-length); xtemp--) |
593 | { | 578 | { |
594 | grid[xtemp][ytemp] = Tile.Corridor; | 579 | grid[xtemp][ytemp].tile = Tile.Corridor; |
595 | } | 580 | } |
596 | 581 | ||
597 | break; | 582 | break; |
@@ -606,7 +591,7 @@ public class MapViewGameState implements GameState | |||
606 | { | 591 | { |
607 | for (int y=0; y<mapHeight; y++) | 592 | for (int y=0; y<mapHeight; y++) |
608 | { | 593 | { |
609 | gridLighting[x][y] = false; | 594 | grid[x][y].lit = false; |
610 | } | 595 | } |
611 | } | 596 | } |
612 | 597 | ||
@@ -649,12 +634,12 @@ public class MapViewGameState implements GameState | |||
649 | } else { | 634 | } else { |
650 | if ((dx*dx + dy*dy) < r2) | 635 | if ((dx*dx + dy*dy) < r2) |
651 | { | 636 | { |
652 | gridLighting[x][y] = true; | 637 | grid[x][y].lit = true; |
653 | } | 638 | } |
654 | 639 | ||
655 | if (blocked) | 640 | if (blocked) |
656 | { | 641 | { |
657 | if (grid[x][y].isBlocked()) | 642 | if (grid[x][y].tile.isBlocked()) |
658 | { | 643 | { |
659 | newStart = r_slope; | 644 | newStart = r_slope; |
660 | continue; | 645 | continue; |
@@ -663,7 +648,7 @@ public class MapViewGameState implements GameState | |||
663 | start = newStart; | 648 | start = newStart; |
664 | } | 649 | } |
665 | } else { | 650 | } else { |
666 | if ((grid[x][y].isBlocked()) && (j < radius)) | 651 | if ((grid[x][y].tile.isBlocked()) && (j < radius)) |
667 | { | 652 | { |
668 | blocked = true; | 653 | blocked = true; |
669 | castLight(cx, cy, j+1, start, l_slope, radius, xx, xy, yx, yy, id+1); | 654 | castLight(cx, cy, j+1, start, l_slope, radius, xx, xy, yx, yy, id+1); |
@@ -687,10 +672,10 @@ public class MapViewGameState implements GameState | |||
687 | { | 672 | { |
688 | for (int y=viewporty; y<viewporty+VIEWPORT_HEIGHT; y++) | 673 | for (int y=viewporty; y<viewporty+VIEWPORT_HEIGHT; y++) |
689 | { | 674 | { |
690 | if (gridLighting[x][y]) | 675 | if (grid[x][y].lit) |
691 | { | 676 | { |
692 | char displayChar = grid[x][y].getDisplayCharacter(); | 677 | char displayChar = grid[x][y].tile.getDisplayCharacter(); |
693 | Color displayColor = grid[x][y].getBackgroundColor(); | 678 | Color displayColor = grid[x][y].tile.getBackgroundColor(); |
694 | 679 | ||
695 | if (!displayColor.equals(Color.BLACK)) | 680 | if (!displayColor.equals(Color.BLACK)) |
696 | { | 681 | { |
@@ -700,7 +685,12 @@ public class MapViewGameState implements GameState | |||
700 | 685 | ||
701 | if (displayChar != ' ') | 686 | if (displayChar != ' ') |
702 | { | 687 | { |
703 | g.drawImage(SystemFont.getCharacter(grid[x][y].getDisplayCharacter(), Color.WHITE), (x-viewportx)*TILE_WIDTH, (y-viewporty)*TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT, null); | 688 | g.drawImage(SystemFont.getCharacter(grid[x][y].tile.getDisplayCharacter(), Color.WHITE), (x-viewportx)*TILE_WIDTH, (y-viewporty)*TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT, null); |
689 | } | ||
690 | |||
691 | for (Item item : grid[x][y].items) | ||
692 | { | ||
693 | g.drawImage(SystemFont.getCharacter(item.getDisplayCharacter(), item.getDisplayColor()), (x-viewportx)*TILE_WIDTH, (y-viewporty)*TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT, null); | ||
704 | } | 694 | } |
705 | } | 695 | } |
706 | } | 696 | } |
@@ -709,21 +699,12 @@ public class MapViewGameState implements GameState | |||
709 | // Render mobs | 699 | // Render mobs |
710 | for (Mob mob : mobs) | 700 | for (Mob mob : mobs) |
711 | { | 701 | { |
712 | if ((gridLighting[mob.x][mob.y]) && (isInViewport(mob.x, mob.y))) | 702 | if ((grid[mob.x][mob.y].lit) && (isInViewport(mob.x, mob.y))) |
713 | { | 703 | { |
714 | g.drawImage(SystemFont.getCharacter(mob.getDisplayCharacter(), mob.getDisplayColor()), (mob.x-viewportx)*TILE_WIDTH, (mob.y-viewporty)*TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT, null); | 704 | g.drawImage(SystemFont.getCharacter(mob.getDisplayCharacter(), mob.getDisplayColor()), (mob.x-viewportx)*TILE_WIDTH, (mob.y-viewporty)*TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT, null); |
715 | } | 705 | } |
716 | } | 706 | } |
717 | 707 | ||
718 | // Render items | ||
719 | for (ItemInstance ii : items) | ||
720 | { | ||
721 | if (gridLighting[ii.x][ii.y]) | ||
722 | { | ||
723 | g.drawImage(SystemFont.getCharacter(ii.item.getDisplayCharacter(), ii.item.getDisplayColor()), (ii.x-viewportx)*TILE_WIDTH, (ii.y-viewporty)*TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT, null); | ||
724 | } | ||
725 | } | ||
726 | |||
727 | // Render player | 708 | // Render player |
728 | g.drawImage(SystemFont.getCharacter('@', Color.WHITE), (playerx-viewportx)*TILE_WIDTH, (playery-viewporty)*TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT, null); | 709 | g.drawImage(SystemFont.getCharacter('@', Color.WHITE), (playerx-viewportx)*TILE_WIDTH, (playery-viewporty)*TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT, null); |
729 | 710 | ||
@@ -812,9 +793,9 @@ public class MapViewGameState implements GameState | |||
812 | Direction dir = Direction.fromKeyEvent(e); | 793 | Direction dir = Direction.fromKeyEvent(e); |
813 | Point to = dir.to(new Point(playerx, playery)); | 794 | Point to = dir.to(new Point(playerx, playery)); |
814 | 795 | ||
815 | if ((isValidPosition(to.x,to.y)) && (grid[to.x][to.y] == Tile.OpenDoor)) | 796 | if ((isValidPosition(to.x,to.y)) && (grid[to.x][to.y].tile == Tile.OpenDoor)) |
816 | { | 797 | { |
817 | grid[to.x][to.y] = Tile.ClosedDoor; | 798 | grid[to.x][to.y].tile = Tile.ClosedDoor; |
818 | } else { | 799 | } else { |
819 | printMessage("There is no closed door in that direction"); | 800 | printMessage("There is no closed door in that direction"); |
820 | } | 801 | } |
@@ -839,7 +820,7 @@ public class MapViewGameState implements GameState | |||
839 | Direction dir = Direction.fromKeyEvent(e); | 820 | Direction dir = Direction.fromKeyEvent(e); |
840 | Point to = dir.to(new Point(playerx, playery)); | 821 | Point to = dir.to(new Point(playerx, playery)); |
841 | 822 | ||
842 | if ((isValidPosition(to.x,to.y)) && (!grid[to.x][to.y].isBlocked())) | 823 | if ((isValidPosition(to.x,to.y)) && (!grid[to.x][to.y].tile.isBlocked())) |
843 | { | 824 | { |
844 | // Check for mobs | 825 | // Check for mobs |
845 | boolean foundMob = false; | 826 | boolean foundMob = false; |
@@ -870,12 +851,7 @@ public class MapViewGameState implements GameState | |||
870 | 851 | ||
871 | if (Functions.random(0, 1000) < (mob.getBaseExperience() / (floor*floor))) | 852 | if (Functions.random(0, 1000) < (mob.getBaseExperience() / (floor*floor))) |
872 | { | 853 | { |
873 | ItemInstance ii = new ItemInstance(); | 854 | grid[mob.x][mob.y].items.add(Item.getWeightedRandomItem()); |
874 | ii.item = Item.getWeightedRandomItem(); | ||
875 | ii.x = mob.x; | ||
876 | ii.y = mob.y; | ||
877 | |||
878 | items.add(ii); | ||
879 | } | 855 | } |
880 | } | 856 | } |
881 | 857 | ||
@@ -889,11 +865,11 @@ public class MapViewGameState implements GameState | |||
889 | playerx = to.x; | 865 | playerx = to.x; |
890 | playery = to.y; | 866 | playery = to.y; |
891 | } | 867 | } |
892 | } else if (grid[to.x][to.y] == Tile.ClosedDoor) | 868 | } else if (grid[to.x][to.y].tile == Tile.ClosedDoor) |
893 | { | 869 | { |
894 | if (Functions.random(0, 99) < 50) | 870 | if (Functions.random(0, 99) < 50) |
895 | { | 871 | { |
896 | grid[to.x][to.y] = Tile.OpenDoor; | 872 | grid[to.x][to.y].tile = Tile.OpenDoor; |
897 | } else { | 873 | } else { |
898 | printMessage("You cannot quite get the door to open"); | 874 | printMessage("You cannot quite get the door to open"); |
899 | } | 875 | } |
@@ -906,34 +882,30 @@ public class MapViewGameState implements GameState | |||
906 | break; | 882 | break; |
907 | 883 | ||
908 | case KeyEvent.VK_G: | 884 | case KeyEvent.VK_G: |
909 | for (ItemInstance ii : items) | 885 | if (grid[playerx][playery].items.size() > 0) |
910 | { | 886 | { |
911 | if ((ii.x == playerx) && (ii.y == playery)) | 887 | Item item = grid[playerx][playery].items.get(0); |
888 | printMessage("You get a " + item.getItemName().toLowerCase()); | ||
889 | Main.currentGame.inventory.add(item); | ||
890 | grid[playerx][playery].items.remove(0); | ||
891 | |||
892 | if (item == Item.Key) | ||
912 | { | 893 | { |
913 | printMessage("You get a " + ii.item.getItemName().toLowerCase()); | 894 | printMessage("All the windows in the room shatter!"); |
914 | Main.currentGame.inventory.add(ii.item); | ||
915 | items.remove(ii); | ||
916 | 895 | ||
917 | if (ii.item == Item.Key) | 896 | for (int x=0; x<mapWidth; x++) |
918 | { | 897 | { |
919 | printMessage("All the windows in the room shatter!"); | 898 | for (int y=0; y<mapHeight; y++) |
920 | |||
921 | for (int x=0; x<mapWidth; x++) | ||
922 | { | 899 | { |
923 | for (int y=0; y<mapHeight; y++) | 900 | if (grid[x][y].tile == Tile.Window) |
924 | { | 901 | { |
925 | if (grid[x][y] == Tile.Window) | 902 | grid[x][y].tile = Tile.ShatteredWindow; |
926 | { | 903 | } else if ((grid[x][y].tile == Tile.OpenDoor) || (grid[x][y].tile == Tile.ClosedDoor)) |
927 | grid[x][y] = Tile.ShatteredWindow; | 904 | { |
928 | } else if ((grid[x][y] == Tile.OpenDoor) || (grid[x][y] == Tile.ClosedDoor)) | 905 | grid[x][y].tile = Tile.DirtFloor; |
929 | { | ||
930 | grid[x][y] = Tile.DirtFloor; | ||
931 | } | ||
932 | } | 906 | } |
933 | } | 907 | } |
934 | } | 908 | } |
935 | |||
936 | break; | ||
937 | } | 909 | } |
938 | } | 910 | } |
939 | 911 | ||
@@ -946,7 +918,7 @@ public class MapViewGameState implements GameState | |||
946 | case KeyEvent.VK_PERIOD: | 918 | case KeyEvent.VK_PERIOD: |
947 | if (e.isShiftDown()) | 919 | if (e.isShiftDown()) |
948 | { | 920 | { |
949 | if (grid[playerx][playery] == Tile.UpStairs) | 921 | if (grid[playerx][playery].tile == Tile.UpStairs) |
950 | { | 922 | { |
951 | if (Main.currentGame.inventory.contains(Item.Key)) | 923 | if (Main.currentGame.inventory.contains(Item.Key)) |
952 | { | 924 | { |
@@ -1033,7 +1005,7 @@ public class MapViewGameState implements GameState | |||
1033 | { | 1005 | { |
1034 | toDir = Direction.getRandomDirection(); | 1006 | toDir = Direction.getRandomDirection(); |
1035 | Point to = toDir.to(mob.getPosition()); | 1007 | Point to = toDir.to(mob.getPosition()); |
1036 | if ((isValidPosition(to.x,to.y)) && (!grid[to.x][to.y].isBlocked()) && (!to.equals(new Point(playerx, playery)))) | 1008 | if ((isValidPosition(to.x,to.y)) && (!grid[to.x][to.y].tile.isBlocked()) && (!to.equals(new Point(playerx, playery)))) |
1037 | { | 1009 | { |
1038 | boolean found = false; | 1010 | boolean found = false; |
1039 | for (Mob m : mobs) | 1011 | for (Mob m : mobs) |
@@ -1055,7 +1027,7 @@ public class MapViewGameState implements GameState | |||
1055 | } | 1027 | } |
1056 | 1028 | ||
1057 | // Snow weakens (but doesn't kill) mobs too! | 1029 | // Snow weakens (but doesn't kill) mobs too! |
1058 | if ((grid[mob.x][mob.y] == Tile.Snow) && (heartbeat % 2 == 0)) | 1030 | if ((grid[mob.x][mob.y].tile == Tile.Snow) && (heartbeat % 2 == 0)) |
1059 | { | 1031 | { |
1060 | mob.health--; | 1032 | mob.health--; |
1061 | } | 1033 | } |
@@ -1068,14 +1040,14 @@ public class MapViewGameState implements GameState | |||
1068 | { | 1040 | { |
1069 | for (int y=0; y<mapHeight; y++) | 1041 | for (int y=0; y<mapHeight; y++) |
1070 | { | 1042 | { |
1071 | if (grid[x][y] == Tile.Snow) | 1043 | if (grid[x][y].tile == Tile.Snow) |
1072 | { | 1044 | { |
1073 | for (Direction d : Direction.values()) | 1045 | for (Direction d : Direction.values()) |
1074 | { | 1046 | { |
1075 | Point to = d.to(new Point(x, y)); | 1047 | Point to = d.to(new Point(x, y)); |
1076 | if ((!grid[to.x][to.y].isBlocked()) && (grid[to.x][to.y] != Tile.Snow) && (grid[to.x][to.y] != Tile.UpStairs)) | 1048 | if ((!grid[to.x][to.y].tile.isBlocked()) && (grid[to.x][to.y].tile != Tile.Snow) && (grid[to.x][to.y].tile != Tile.UpStairs)) |
1077 | { | 1049 | { |
1078 | grid[to.x][to.y] = Tile.SnowTemp; | 1050 | grid[to.x][to.y].tile = Tile.SnowTemp; |
1079 | } | 1051 | } |
1080 | } | 1052 | } |
1081 | } | 1053 | } |
@@ -1086,19 +1058,19 @@ public class MapViewGameState implements GameState | |||
1086 | { | 1058 | { |
1087 | for (int y=0; y<mapHeight; y++) | 1059 | for (int y=0; y<mapHeight; y++) |
1088 | { | 1060 | { |
1089 | if (grid[x][y] == Tile.ShatteredWindow) | 1061 | if (grid[x][y].tile == Tile.ShatteredWindow) |
1090 | { | 1062 | { |
1091 | for (Direction d : Direction.values()) | 1063 | for (Direction d : Direction.values()) |
1092 | { | 1064 | { |
1093 | Point to = d.to(new Point(x, y)); | 1065 | Point to = d.to(new Point(x, y)); |
1094 | if ((!grid[to.x][to.y].isBlocked()) && (grid[to.x][to.y] != Tile.Snow)) | 1066 | if ((!grid[to.x][to.y].tile.isBlocked()) && (grid[to.x][to.y].tile != Tile.Snow)) |
1095 | { | 1067 | { |
1096 | grid[to.x][to.y] = Tile.Snow; | 1068 | grid[to.x][to.y].tile = Tile.Snow; |
1097 | } | 1069 | } |
1098 | } | 1070 | } |
1099 | } else if (grid[x][y] == Tile.SnowTemp) | 1071 | } else if (grid[x][y].tile == Tile.SnowTemp) |
1100 | { | 1072 | { |
1101 | grid[x][y] = Tile.Snow; | 1073 | grid[x][y].tile = Tile.Snow; |
1102 | } | 1074 | } |
1103 | } | 1075 | } |
1104 | } | 1076 | } |
@@ -1109,13 +1081,13 @@ public class MapViewGameState implements GameState | |||
1109 | // Heartbeat | 1081 | // Heartbeat |
1110 | if (heartbeat % 2 == 0) | 1082 | if (heartbeat % 2 == 0) |
1111 | { | 1083 | { |
1112 | if (grid[playerx][playery] == Tile.Snow) | 1084 | if (grid[playerx][playery].tile == Tile.Snow) |
1113 | { | 1085 | { |
1114 | Main.currentGame.health--; | 1086 | Main.currentGame.health--; |
1115 | } | 1087 | } |
1116 | } | 1088 | } |
1117 | 1089 | ||
1118 | if ((grid[playerx][playery] != Tile.Snow) && ((heartbeat == Functions.random(0, 7)) || (heartbeat == 8) || (Main.currentGame.ring == Item.RingOfRegeneration))) | 1090 | if ((grid[playerx][playery].tile != Tile.Snow) && ((heartbeat == Functions.random(0, 7)) || (heartbeat == 8) || (Main.currentGame.ring == Item.RingOfRegeneration))) |
1119 | { | 1091 | { |
1120 | if (Main.currentGame.health < Main.currentGame.maxHealth) | 1092 | if (Main.currentGame.health < Main.currentGame.maxHealth) |
1121 | { | 1093 | { |
@@ -1137,7 +1109,7 @@ public class MapViewGameState implements GameState | |||
1137 | if (r.canGenerateMonsters()) | 1109 | if (r.canGenerateMonsters()) |
1138 | { | 1110 | { |
1139 | Mob m = createInDepthMonster(r); | 1111 | Mob m = createInDepthMonster(r); |
1140 | if (!gridLighting[m.x][m.y]) | 1112 | if (!grid[m.x][m.y].lit) |
1141 | { | 1113 | { |
1142 | mobs.add(m); | 1114 | mobs.add(m); |
1143 | } | 1115 | } |
@@ -1278,7 +1250,7 @@ public class MapViewGameState implements GameState | |||
1278 | { | 1250 | { |
1279 | return true; | 1251 | return true; |
1280 | } | 1252 | } |
1281 | } while (!grid[x][y].isBlocked()); | 1253 | } while (!grid[x][y].tile.isBlocked()); |
1282 | 1254 | ||
1283 | return false; | 1255 | return false; |
1284 | } else { | 1256 | } else { |
@@ -1299,7 +1271,7 @@ public class MapViewGameState implements GameState | |||
1299 | { | 1271 | { |
1300 | return true; | 1272 | return true; |
1301 | } | 1273 | } |
1302 | } while (!grid[x][y].isBlocked()); | 1274 | } while (!grid[x][y].tile.isBlocked()); |
1303 | 1275 | ||
1304 | return false; | 1276 | return false; |
1305 | } | 1277 | } |
@@ -1354,7 +1326,7 @@ public class MapViewGameState implements GameState | |||
1354 | for (Direction d : Direction.values()) | 1326 | for (Direction d : Direction.values()) |
1355 | { | 1327 | { |
1356 | Point loc = d.to(from); | 1328 | Point loc = d.to(from); |
1357 | if ((isValidPosition(loc.x, loc.y)) && (!grid[loc.x][loc.y].isBlocked())) | 1329 | if ((isValidPosition(loc.x, loc.y)) && (!grid[loc.x][loc.y].tile.isBlocked())) |
1358 | { | 1330 | { |
1359 | ds.add(d); | 1331 | ds.add(d); |
1360 | } | 1332 | } |
@@ -1424,7 +1396,7 @@ public class MapViewGameState implements GameState | |||
1424 | int y = Functions.random(r.getY()+1, r.getY()+r.getHeight()-2); | 1396 | int y = Functions.random(r.getY()+1, r.getY()+r.getHeight()-2); |
1425 | 1397 | ||
1426 | List<Class> mobTypes = new ArrayList<Class>(); | 1398 | List<Class> mobTypes = new ArrayList<Class>(); |
1427 | switch (floor) | 1399 | switch (Math.max(Main.currentGame.level, floor)) |
1428 | { | 1400 | { |
1429 | case 10: | 1401 | case 10: |
1430 | case 9: | 1402 | case 9: |
@@ -1454,11 +1426,6 @@ public class MapViewGameState implements GameState | |||
1454 | 1426 | ||
1455 | public void dropItemAtPlayer(Item item) | 1427 | public void dropItemAtPlayer(Item item) |
1456 | { | 1428 | { |
1457 | ItemInstance ii = new ItemInstance(); | 1429 | grid[playerx][playery].items.add(item); |
1458 | ii.item = item; | ||
1459 | ii.x = playerx; | ||
1460 | ii.y = playery; | ||
1461 | |||
1462 | items.add(ii); | ||
1463 | } | 1430 | } |
1464 | } | 1431 | } |