com.b3dgs.lionengine.game.hacknslash
Class AbstractItem<TTile extends AbstractPathTile>

java.lang.Object
  extended by com.b3dgs.lionengine.game.hacknslash.AbstractItem<TTile>

public abstract class AbstractItem<TTile extends AbstractPathTile>
extends java.lang.Object

Represents an item which can be hold by a Hero. Items has to be handled by an AbstractItemHandler. They can be placed in a bag, represented by a box. Each item has its own box size, in order to fill the bag.

See Also:
AbstractItemHandler, AbstractHero

Field Summary
protected  int boxSize
           
protected  int heightOnMap
           
protected  int heightOnPanel
           
protected  int widthOnMap
           
protected  int widthOnPanel
           
protected  int x
           
protected  int y
           
 
Constructor Summary
AbstractItem(int boxSize, int widthOnPanel, int heightOnPanel, int widthOnMap, int heightOnMap)
          Create a new abstract item.
 
Method Summary
abstract  boolean canBePicked(Entity owner)
          Check if item can be picked from the map.
 boolean collideOnMap(StrategyCursor cursor)
          Check if cursor hit item on map.
 boolean collideOnPanel(AbstractItem<TTile> item)
          Check if item collide with another item on bag.
 boolean collideOnPanel(StrategyCursor cursor, int offsetX, int offsetY)
          Check if cursor collide current item.
 void drop(TileBasedMap<TTile> map)
          Drop item on map from owner location.
 int getHeightOnMap()
          Get item height (in tile).
 int getHeightOnPanel()
          Get item height (in box).
 int getWidthOnMap()
          Get item width (in tile).
 int getWidthOnPanel()
          Get item width (in box).
 void placeOnMap(int tx, int ty)
          Set item location on map.
 void placeOnPanel(int bx, int by)
          Set item location in bag.
abstract  void render(java.awt.Graphics2D g, int panelX, int panelY)
          Render item on bag.
abstract  void render(java.awt.Graphics2D g, StrategyCamera camera, TileBasedMap<TTile> map)
          Render item on map.
 void setOwner(Entity owner)
          Set item owner reference.
abstract  void update(StrategyCursor cursor)
          Update item on bag.
abstract  void update(StrategyCursor cursor, TileBasedMap<TTile> map)
          Update item on map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

x

protected int x

y

protected int y

widthOnPanel

protected int widthOnPanel

heightOnPanel

protected int heightOnPanel

widthOnMap

protected int widthOnMap

heightOnMap

protected int heightOnMap

boxSize

protected int boxSize
Constructor Detail

AbstractItem

public AbstractItem(int boxSize,
                    int widthOnPanel,
                    int heightOnPanel,
                    int widthOnMap,
                    int heightOnMap)
Create a new abstract item.

Parameters:
boxSize - size of a box from the bag grid (in pixel).
widthOnPanel - item width (in box).
heightOnPanel - item height (in box).
widthOnMap - item width (in tile).
heightOnMap - item height (in tile).
Method Detail

setOwner

public void setOwner(Entity owner)
Set item owner reference.

Parameters:
owner - owner reference.

drop

public void drop(TileBasedMap<TTile> map)
Drop item on map from owner location.

Parameters:
map - map reference.

placeOnPanel

public void placeOnPanel(int bx,
                         int by)
Set item location in bag.

Parameters:
bx - location x (in box).
by - location y (in box).

placeOnMap

public void placeOnMap(int tx,
                       int ty)
Set item location on map.

Parameters:
tx - location x (in tile).
ty - location y (in tile).

collideOnPanel

public boolean collideOnPanel(AbstractItem<TTile> item)
Check if item collide with another item on bag.

Parameters:
item - collide item reference.
Returns:
true if collide (not a free slot).

collideOnPanel

public boolean collideOnPanel(StrategyCursor cursor,
                              int offsetX,
                              int offsetY)
Check if cursor collide current item.

Parameters:
cursor - cursor reference.
offsetX - bag panel location x.
offsetY - bag panel location y.
Returns:
true if collide (cursor hit item).

collideOnMap

public boolean collideOnMap(StrategyCursor cursor)
Check if cursor hit item on map.

Parameters:
cursor - cursor reference.
Returns:
true if collide (cursor hit item on map).

canBePicked

public abstract boolean canBePicked(Entity owner)
Check if item can be picked from the map.

Parameters:
owner - future owner reference.
Returns:
true if can be picked (not too far for example).

update

public abstract void update(StrategyCursor cursor,
                            TileBasedMap<TTile> map)
Update item on map.

Parameters:
cursor - cursor reference.
map - map reference.

update

public abstract void update(StrategyCursor cursor)
Update item on bag.

Parameters:
cursor - cursor reference.

render

public abstract void render(java.awt.Graphics2D g,
                            int panelX,
                            int panelY)
Render item on bag.

Parameters:
g - graphics output.
panelX - bag panel location x.
panelY - bag panel location y.

render

public abstract void render(java.awt.Graphics2D g,
                            StrategyCamera camera,
                            TileBasedMap<TTile> map)
Render item on map.

Parameters:
g - graphics output.
camera - camera reference.
map - map reference.

getWidthOnPanel

public int getWidthOnPanel()
Get item width (in box).

Returns:
item width.

getHeightOnPanel

public int getHeightOnPanel()
Get item height (in box).

Returns:
item height.

getWidthOnMap

public int getWidthOnMap()
Get item width (in tile).

Returns:
item width.

getHeightOnMap

public int getHeightOnMap()
Get item height (in tile).

Returns:
item height.