From 6677e63c84447eae786b9b645adb97302206fbde Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Tue, 5 Jun 2012 08:28:20 -0400 Subject: Added item Wooden Helmet (no use yet) and added ability to drop items --- .../fourisland/frigidearth/InventoryOverlay.java | 9 +++++++ src/com/fourisland/frigidearth/Item.java | 28 ++++++++++++++++++++++ src/com/fourisland/frigidearth/ItemType.java | 8 ++++++- .../fourisland/frigidearth/MapViewGameState.java | 16 +++++++++++-- 4 files changed, 58 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/com/fourisland/frigidearth/InventoryOverlay.java b/src/com/fourisland/frigidearth/InventoryOverlay.java index 21f2194..0d7a5ba 100644 --- a/src/com/fourisland/frigidearth/InventoryOverlay.java +++ b/src/com/fourisland/frigidearth/InventoryOverlay.java @@ -111,6 +111,15 @@ public class InventoryOverlay implements Renderable, Inputable return; } + + case KeyEvent.VK_D: + ((MapViewGameState) Main.getGameState()).dropItemAtPlayer(Main.currentGame.inventory.get(id)); + Main.currentGame.inventory.remove(id); + ((MapViewGameState) Main.getGameState()).tick(); + Main.removeRenderable(this); + Main.removeInputable(this); + + return; } } diff --git a/src/com/fourisland/frigidearth/Item.java b/src/com/fourisland/frigidearth/Item.java index 1fe4027..8881b6c 100644 --- a/src/com/fourisland/frigidearth/Item.java +++ b/src/com/fourisland/frigidearth/Item.java @@ -50,6 +50,34 @@ public enum Item return true; } }, + WoodenHelmet { + public String getItemName() + { + return "Wooden Helmet"; + } + + public char getDisplayCharacter() + { + return '^'; + } + + public Color getDisplayColor() + { + return new Color(128, 42, 42); + } + + public ItemType getItemType() + { + return ItemType.Helmet; + } + + public boolean useItem() + { + // Nope not yet + + return true; + } + }, Key { public String getItemName() { diff --git a/src/com/fourisland/frigidearth/ItemType.java b/src/com/fourisland/frigidearth/ItemType.java index d9bf9c5..f870fc6 100644 --- a/src/com/fourisland/frigidearth/ItemType.java +++ b/src/com/fourisland/frigidearth/ItemType.java @@ -10,10 +10,16 @@ package com.fourisland.frigidearth; */ public enum ItemType { + Helmet { + public double getRarity() + { + return 0.75; + } + }, Scroll { public double getRarity() { - return 1; + return 0.25; } }, Special { diff --git a/src/com/fourisland/frigidearth/MapViewGameState.java b/src/com/fourisland/frigidearth/MapViewGameState.java index bbfb9ac..a61d0ee 100644 --- a/src/com/fourisland/frigidearth/MapViewGameState.java +++ b/src/com/fourisland/frigidearth/MapViewGameState.java @@ -55,8 +55,8 @@ public class MapViewGameState implements GameState { this.floor = floor; - mapWidth += (50 * floor); - mapHeight += (50 * floor); + mapWidth += (50 * (floor-1)); + mapHeight += (50 * (floor-1)); grid = new Tile[mapWidth][mapHeight]; gridLighting = new boolean[mapWidth][mapHeight]; @@ -891,6 +891,8 @@ public class MapViewGameState implements GameState { Main.currentGame.inventory.remove(Item.Key); Main.setGameState(new MapViewGameState(floor+1)); + + return; } else { printMessage("The stairs are locked! You need a key."); } @@ -1372,4 +1374,14 @@ public class MapViewGameState implements GameState return null; } } + + public void dropItemAtPlayer(Item item) + { + ItemInstance ii = new ItemInstance(); + ii.item = item; + ii.x = playerx; + ii.y = playery; + + items.add(ii); + } } -- cgit 1.4.1