Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## inventory
Class Inventory

    java.lang.Object
      inventory.Inventory

All Implemented Interfaces:
  java.io.Serializable

    public class Inventory

extends java.lang.Object
implements java.io.Serializable

This class represents the players inventory.

Author:
  Frank Bruns
See Also:
  Serialized Form

Constructor Summary
`Inventory(int width, int height, com.golden.gamedev.engine.BaseInput bsInput)` Creates an inventory area that can store and display items.

Method Summary
`void` | `addItemToInventory(Item item)` Adds an item to the inventory
`java.util.LinkedList<Item>` | `getInventoryItems()` Returns a list with the items in the players inventory
`Item` | `getSelectedInventoryItem()` Returns the currently selected inventory item.
`boolean` | `hasItem(Item item)` Determines whether the inventory contains the specified item
`boolean` | `isLookingAtInventory()` Determines whether the player is currently looking at the inventory.
`void` | `removeItem(Item item)` Removes an item from the inventory.
`void` | `render(java.awt.Graphics2D g)` Draws the inventory area with all its items if the mouse is located within the area's bounds
`void` | `setSelectedInventoryItem(Item inventItem)` Sets the currently selected inventory item to the specified item.
`void` | `update(long elapsedTime)` Updates the inventory items, especially their hotspots in the inventory area

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Inventory

    public Inventory(int width,
                     int height,
                     com.golden.gamedev.engine.BaseInput bsInput)

  Creates an inventory area that can store and display items. The origin of the area will be the upper left corner of the display.

  Parameters:
    `width` - width of the inventory area
    `height` - height of the inventory area
    `bsInput` -

Method Detail

### getInventoryItems

    public java.util.LinkedList<Item> getInventoryItems()

  Returns a list with the items in the players inventory

  Returns:
    list of player inventory items

### addItemToInventory

    public void addItemToInventory(Item item)

  Adds an item to the inventory

  Parameters:
    `item` - Item that shall be added to the inventory

### removeItem

    public void removeItem(Item item)

  Removes an item from the inventory. If there is a concurrent modification exception while calling this method, please consider to add the item to a remove-list and remove the item in the update method instead.

  Parameters:
    `item` - item to remove from the inventory

### isLookingAtInventory

    public boolean isLookingAtInventory()

  Determines whether the player is currently looking at the inventory. For example, this is important for player movement, because the player shall not take a new target location while clicking on an inventory item.

  Returns:
    is player currently looking at inventory? --> true=yes, false=no

### getSelectedInventoryItem

    public Item getSelectedInventoryItem()

  Returns the currently selected inventory item.

  Returns:
    the currently selected inventory item, null if none is selected

### hasItem

    public boolean hasItem(Item item)

  Determines whether the inventory contains the specified item

  Parameters:
    `item` - item to check for existence in the inventory
  Returns:
    inventory contains the item? --> true=yes, false=no

### setSelectedInventoryItem

    public void setSelectedInventoryItem(Item inventItem)

  Sets the currently selected inventory item to the specified item. Set it to null to express that no imventory item is selected

  Parameters:
    `inventItem` - item to set to the seleceted inventory item

### render

    public void render(java.awt.Graphics2D g)

  Draws the inventory area with all its items if the mouse is located within the area's bounds

  Parameters:
    `g` -

### update

    public void update(long elapsedTime)

  Updates the inventory items, especially their hotspots in the inventory area

  Parameters:
    `elapsedTime` - time between two frames

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD