diff options
-rw-r--r-- | src/com/fourisland/frigidearth/Item.java | 32 | ||||
-rw-r--r-- | src/com/fourisland/frigidearth/MapViewGameState.java | 71 | ||||
-rw-r--r-- | src/com/fourisland/frigidearth/mobs/Spider.java | 2 |
3 files changed, 64 insertions, 41 deletions
diff --git a/src/com/fourisland/frigidearth/Item.java b/src/com/fourisland/frigidearth/Item.java index 689d991..717d09c 100644 --- a/src/com/fourisland/frigidearth/Item.java +++ b/src/com/fourisland/frigidearth/Item.java | |||
@@ -38,7 +38,7 @@ public enum Item | |||
38 | return ItemType.Scroll; | 38 | return ItemType.Scroll; |
39 | } | 39 | } |
40 | 40 | ||
41 | public void useItem() | 41 | public boolean useItem() |
42 | { | 42 | { |
43 | Main.currentGame.health += 20; | 43 | Main.currentGame.health += 20; |
44 | 44 | ||
@@ -46,6 +46,34 @@ public enum Item | |||
46 | { | 46 | { |
47 | Main.currentGame.health = Main.currentGame.maxHealth; | 47 | Main.currentGame.health = Main.currentGame.maxHealth; |
48 | } | 48 | } |
49 | |||
50 | return true; | ||
51 | } | ||
52 | }, | ||
53 | Key { | ||
54 | public String getItemName() | ||
55 | { | ||
56 | return "Key"; | ||
57 | } | ||
58 | |||
59 | public char getDisplayCharacter() | ||
60 | { | ||
61 | return 'k'; | ||
62 | } | ||
63 | |||
64 | public Color getDisplayColor() | ||
65 | { | ||
66 | return Color.YELLOW; | ||
67 | } | ||
68 | |||
69 | public ItemType getItemType() | ||
70 | { | ||
71 | return ItemType.Special; | ||
72 | } | ||
73 | |||
74 | public boolean useItem() | ||
75 | { | ||
76 | return false; | ||
49 | } | 77 | } |
50 | }; | 78 | }; |
51 | 79 | ||
@@ -53,7 +81,7 @@ public enum Item | |||
53 | public abstract char getDisplayCharacter(); | 81 | public abstract char getDisplayCharacter(); |
54 | public abstract Color getDisplayColor(); | 82 | public abstract Color getDisplayColor(); |
55 | public abstract ItemType getItemType(); | 83 | public abstract ItemType getItemType(); |
56 | public abstract void useItem(); | 84 | public abstract boolean useItem(); |
57 | 85 | ||
58 | public static Item getWeightedRandomItem() | 86 | public static Item getWeightedRandomItem() |
59 | { | 87 | { |
diff --git a/src/com/fourisland/frigidearth/MapViewGameState.java b/src/com/fourisland/frigidearth/MapViewGameState.java index cfb7690..793fae9 100644 --- a/src/com/fourisland/frigidearth/MapViewGameState.java +++ b/src/com/fourisland/frigidearth/MapViewGameState.java | |||
@@ -46,9 +46,6 @@ public class MapViewGameState implements GameState | |||
46 | private int playery = 4; | 46 | private int playery = 4; |
47 | private int viewportx = 0; | 47 | private int viewportx = 0; |
48 | private int viewporty = 0; | 48 | private int viewporty = 0; |
49 | private int keyx; | ||
50 | private int keyy; | ||
51 | private boolean haveKey = false; | ||
52 | private boolean snowGrow = false; | 49 | private boolean snowGrow = false; |
53 | private int heartbeat = 0; | 50 | private int heartbeat = 0; |
54 | private int floor; | 51 | private int floor; |
@@ -317,37 +314,41 @@ public class MapViewGameState implements GameState | |||
317 | } | 314 | } |
318 | } | 315 | } |
319 | 316 | ||
317 | ItemInstance key = new ItemInstance(); | ||
318 | key.item = Item.Key; | ||
319 | |||
320 | switch (keyRoomDirection) | 320 | switch (keyRoomDirection) |
321 | { | 321 | { |
322 | case North: | 322 | case North: |
323 | grid[room.getX()+room.getWidth()/2][room.getY()+room.getHeight()] = Tile.Door; | 323 | grid[room.getX()+room.getWidth()/2][room.getY()+room.getHeight()] = Tile.Door; |
324 | grid[room.getX()+room.getWidth()/2][room.getY()+room.getHeight()-1] = Tile.DirtFloor; | 324 | grid[room.getX()+room.getWidth()/2][room.getY()+room.getHeight()-1] = Tile.DirtFloor; |
325 | keyx = room.getX()+3; | 325 | key.x = room.getX()+3; |
326 | keyy = room.getY()+3; | 326 | key.y = room.getY()+3; |
327 | break; | 327 | break; |
328 | 328 | ||
329 | case East: | 329 | case East: |
330 | grid[room.getX()-1][room.getY()+room.getHeight()/2] = Tile.Door; | 330 | grid[room.getX()-1][room.getY()+room.getHeight()/2] = Tile.Door; |
331 | grid[room.getX()][room.getY()+room.getHeight()/2] = Tile.DirtFloor; | 331 | grid[room.getX()][room.getY()+room.getHeight()/2] = Tile.DirtFloor; |
332 | keyx = room.getX()+10; | 332 | key.x = room.getX()+10; |
333 | keyy = room.getY()+3; | 333 | key.y = room.getY()+3; |
334 | break; | 334 | break; |
335 | 335 | ||
336 | case South: | 336 | case South: |
337 | grid[room.getX()+room.getWidth()/2][room.getY()-1] = Tile.Door; | 337 | grid[room.getX()+room.getWidth()/2][room.getY()-1] = Tile.Door; |
338 | grid[room.getX()+room.getWidth()/2][room.getY()] = Tile.DirtFloor; | 338 | grid[room.getX()+room.getWidth()/2][room.getY()] = Tile.DirtFloor; |
339 | keyx = room.getX()+3; | 339 | key.x = room.getX()+3; |
340 | keyy = room.getY()+10; | 340 | key.y = room.getY()+10; |
341 | break; | 341 | break; |
342 | 342 | ||
343 | case West: | 343 | case West: |
344 | grid[room.getX()+room.getWidth()][room.getY()+room.getHeight()/2] = Tile.Door; | 344 | grid[room.getX()+room.getWidth()][room.getY()+room.getHeight()/2] = Tile.Door; |
345 | grid[room.getX()+room.getWidth()-1][room.getY()+room.getHeight()/2] = Tile.DirtFloor; | 345 | grid[room.getX()+room.getWidth()-1][room.getY()+room.getHeight()/2] = Tile.DirtFloor; |
346 | keyx = room.getX()+3; | 346 | key.x = room.getX()+3; |
347 | keyy = room.getY()+3; | 347 | key.y = room.getY()+3; |
348 | break; | 348 | break; |
349 | } | 349 | } |
350 | 350 | ||
351 | items.add(key); | ||
351 | rooms.add(room); | 352 | rooms.add(room); |
352 | 353 | ||
353 | adjustViewport(); | 354 | adjustViewport(); |
@@ -710,12 +711,6 @@ public class MapViewGameState implements GameState | |||
710 | } | 711 | } |
711 | } | 712 | } |
712 | 713 | ||
713 | // Render key | ||
714 | if ((!haveKey) && (gridLighting[keyx][keyy])) | ||
715 | { | ||
716 | g.drawImage(SystemFont.getCharacter('k', Color.YELLOW), (keyx-viewportx)*TILE_WIDTH, (keyy-viewporty)*TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT, null); | ||
717 | } | ||
718 | |||
719 | // Render items | 714 | // Render items |
720 | for (ItemInstance ii : items) | 715 | for (ItemInstance ii : items) |
721 | { | 716 | { |
@@ -853,32 +848,31 @@ public class MapViewGameState implements GameState | |||
853 | break; | 848 | break; |
854 | 849 | ||
855 | case KeyEvent.VK_G: | 850 | case KeyEvent.VK_G: |
856 | if ((playerx == keyx) && (playery == keyy) && (!haveKey)) | 851 | for (ItemInstance ii : items) |
857 | { | 852 | { |
858 | haveKey = true; | 853 | if ((ii.x == playerx) && (ii.y == playery)) |
859 | printMessage("You get the key"); | ||
860 | printMessage("All the windows in the room shatter!"); | ||
861 | |||
862 | for (int x=0; x<mapWidth; x++) | ||
863 | { | 854 | { |
864 | for (int y=0; y<mapHeight; y++) | 855 | printMessage("You get a " + ii.item.getItemName().toLowerCase()); |
856 | Main.currentGame.inventory.add(ii.item); | ||
857 | items.remove(ii); | ||
858 | |||
859 | if (ii.item == Item.Key) | ||
865 | { | 860 | { |
866 | if (grid[x][y] == Tile.Window) | 861 | printMessage("All the windows in the room shatter!"); |
862 | |||
863 | for (int x=0; x<mapWidth; x++) | ||
867 | { | 864 | { |
868 | grid[x][y] = Tile.ShatteredWindow; | 865 | for (int y=0; y<mapHeight; y++) |
866 | { | ||
867 | if (grid[x][y] == Tile.Window) | ||
868 | { | ||
869 | grid[x][y] = Tile.ShatteredWindow; | ||
870 | } | ||
871 | } | ||
869 | } | 872 | } |
870 | } | 873 | } |
871 | } | 874 | |
872 | } else { | 875 | break; |
873 | for (ItemInstance ii : items) | ||
874 | { | ||
875 | if ((ii.x == playerx) && (ii.y == playery)) | ||
876 | { | ||
877 | printMessage("You get a " + ii.item.getItemName().toLowerCase()); | ||
878 | Main.currentGame.inventory.add(ii.item); | ||
879 | items.remove(ii); | ||
880 | break; | ||
881 | } | ||
882 | } | 876 | } |
883 | } | 877 | } |
884 | 878 | ||
@@ -893,8 +887,9 @@ public class MapViewGameState implements GameState | |||
893 | { | 887 | { |
894 | if (grid[playerx][playery] == Tile.UpStairs) | 888 | if (grid[playerx][playery] == Tile.UpStairs) |
895 | { | 889 | { |
896 | if (haveKey) | 890 | if (Main.currentGame.inventory.contains(Item.Key)) |
897 | { | 891 | { |
892 | Main.currentGame.inventory.remove(Item.Key); | ||
898 | Main.setGameState(new MapViewGameState(floor+1)); | 893 | Main.setGameState(new MapViewGameState(floor+1)); |
899 | } else { | 894 | } else { |
900 | printMessage("The stairs are locked! You need a key."); | 895 | printMessage("The stairs are locked! You need a key."); |
diff --git a/src/com/fourisland/frigidearth/mobs/Spider.java b/src/com/fourisland/frigidearth/mobs/Spider.java index 7d3330e..ac3eb9d 100644 --- a/src/com/fourisland/frigidearth/mobs/Spider.java +++ b/src/com/fourisland/frigidearth/mobs/Spider.java | |||
@@ -49,6 +49,6 @@ public class Spider extends Mob | |||
49 | 49 | ||
50 | public int getBaseExperience() | 50 | public int getBaseExperience() |
51 | { | 51 | { |
52 | return 200; | 52 | return 150; |
53 | } | 53 | } |
54 | } | 54 | } |