org.globalse.arena.sword.engine
Class Item

java.lang.Object
  |
  +--org.globalse.arena.frag.objects.FRAGObject
        |
        +--org.globalse.arena.sword.engine.Item
Direct Known Subclasses:
ConsumableItem, Spell, Weapon

public class Item
extends FRAGObject

Item is any object in the game that an adventurer can pick up. The information about the item is stored in its properties. All the items relevant to the choosen mission are placed in the game world by the Sword class once a new game is started or a running one is joined.

See Also:
FRAGObject, Sword, Serialized Form

Field Summary
 double weight
           
 
Fields inherited from class org.globalse.arena.frag.objects.FRAGObject
controller, gameName, influenceRange, objectName, owner, position, visibilityRange
 
Constructor Summary
Item()
           
 
Method Summary
 void actionEvent(ObjectActionEvent event)
          Processes the ObjectActionEvents that the ObjectManager receives for this object.
 MathVector checkCollision(java.lang.String other, MathVector oldPos, MathVector delta)
          Checks possible collisions of this item with other objects.
 void draw(DrawManager drawManager)
          Draws the Item on the screen, according to his current coordinates and visibility
 double getCollisionSphere()
          Returns the collisonSphere property of this item
 java.lang.String getDescription()
          Returns a string that can be displayed on the UI and contains all relevant information about the Item.
 MathVector getDimensions()
          Returns the dimensions of the item.
 java.awt.Image getImage()
          Returns an image that represents the item.
 java.lang.String getObjectName()
          Returns the unique object name of the Item.
 java.lang.String getType()
          Returns the type of this item (sword, apple, ring, ...)
 boolean getVisible()
          Returns whether the item is currently visible on the map or not
 void init(java.lang.String gameName, java.lang.String objectName, double weight, java.lang.String type)
          The constructor creates a new Item object, depending on the following parameters:
 boolean isItemUsableBy(java.lang.String owner)
          Checks if this item is currently used by someone
 void setVisible(boolean visible)
          Sets the visibilty attribute of the item
 boolean useWith(java.lang.String target)
          Doesn't do anything, since all objects, instances of the Item class are by definition useless.
 
Methods inherited from class org.globalse.arena.frag.objects.FRAGObject
checkAndResetMark, checkMark, clone, controlAcquired, controlLost, getGameManager, getInfluenceRange, getObjectManager, getPosition, killed, mark, newerVersion, setInfluenceRange, setPosition
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

weight

public double weight
Constructor Detail

Item

public Item()
Method Detail

init

public void init(java.lang.String gameName,
                 java.lang.String objectName,
                 double weight,
                 java.lang.String type)
The constructor creates a new Item object, depending on the following parameters:
Parameters:
weight - the weight (in kg) of the item
type - a String that denotes the kind of item (sword, apple, ring, ...)

getObjectName

public java.lang.String getObjectName()
Returns the unique object name of the Item.
Returns:
a unique string identifier
Overrides:
getObjectName in class FRAGObject

getDescription

public java.lang.String getDescription()
Returns a string that can be displayed on the UI and contains all relevant information about the Item.
Returns:
a description string

getImage

public java.awt.Image getImage()
Returns an image that represents the item.
Returns:
an image of the item

getDimensions

public MathVector getDimensions()
Returns the dimensions of the item.
Returns:
a MathVector containing the item's dimensions

getVisible

public boolean getVisible()
Returns whether the item is currently visible on the map or not
Returns:
true if the item is currently visible, else false

setVisible

public void setVisible(boolean visible)
Sets the visibilty attribute of the item
Parameters:
visible -  

useWith

public boolean useWith(java.lang.String target)
Doesn't do anything, since all objects, instances of the Item class are by definition useless.
Parameters:
target - the object this Item is to be used with
Returns:
if the Item could be used with this target (always false)

actionEvent

public void actionEvent(ObjectActionEvent event)
Processes the ObjectActionEvents that the ObjectManager receives for this object.
Parameters:
event - the event, that took place
Overrides:
actionEvent in class FRAGObject
See Also:
ObjectActionEvent

draw

public void draw(DrawManager drawManager)
Draws the Item on the screen, according to his current coordinates and visibility
Parameters:
drawManager - an instance of the responisble DrawManager
Overrides:
draw in class FRAGObject
See Also:
DrawManager

isItemUsableBy

public boolean isItemUsableBy(java.lang.String owner)
Checks if this item is currently used by someone
Parameters:
owner - the suspected user of the Item (should always be none)
Returns:
always false

checkCollision

public MathVector checkCollision(java.lang.String other,
                                 MathVector oldPos,
                                 MathVector delta)
Checks possible collisions of this item with other objects.
Parameters:
other - the object, causing a possible collision with this item
Returns:
delta the difference vector between this item and the other object
Overrides:
checkCollision in class FRAGObject
See Also:
FRAGObject.checkCollision(java.lang.String, org.globalse.arena.frag.util.MathVector, org.globalse.arena.frag.util.MathVector)

getCollisionSphere

public double getCollisionSphere()
Returns the collisonSphere property of this item
Returns:
the collisionSphere of this item

getType

public java.lang.String getType()
Returns the type of this item (sword, apple, ring, ...)
Returns:
the type of this item



This page is hosted by the Chair for Applied Software Engineering of the Technische Universität München.
Imprint (Impressum)