mhframework
Interface MHInteractive


public interface MHInteractive

This interface is implemented by all objects in the game universe that must interact with each other. It defines a standard set of methods indicating the different ways that one object can act upon another.


Method Summary
 void activate(MHActor actor)
          To be called when an "activate" command is issued to an object.
 java.lang.String examine()
          Returns a description of a game object.
 java.lang.String getName()
          Returns the name of a game object.
 int hitByWeapon(MHWeapon weapon)
          To be called when an object implementing this interface is hit by a weapon.
 boolean isTraversable()
          Returns true if the actor implementing this interface can be "walked" over.
 void movingTo(MHActor actor)
          To be triggered when an actor begins moving toward an object implementing this interface.
 void pickUp(MHActor actor)
          To be called when a character picks up an item.
 void steppedOff(MHActor actor)
          To be triggered when an actor steps off of an object implementing this interface.
 void steppedOn(MHActor actor)
          To be triggered when an actor steps on an object implementing this interface.
 

Method Detail

movingTo

void movingTo(MHActor actor)
To be triggered when an actor begins moving toward an object implementing this interface. Possible uses of this action might include opening a door before the player gets to it, causing an NPC to run away, and checking for collisions.

Parameters:
actor - The actor who is moving toward this object.

steppedOn

void steppedOn(MHActor actor)
To be triggered when an actor steps on an object implementing this interface. Possible uses of this action might include causing damage when a player steps on a hazard, triggering a mechanism when a player steps on a switch, activating automatic devices such as elevators, activating dormant non-player characters when a player enters a certain area, etc.

Parameters:
actor - The actor who stepped on this object.

steppedOff

void steppedOff(MHActor actor)
To be triggered when an actor steps off of an object implementing this interface. Possible uses of this action might include deactivating a mechanism when a player steps off of a switch, etc.

Parameters:
actor - The actor who stepped off of this object.

hitByWeapon

int hitByWeapon(MHWeapon weapon)
To be called when an object implementing this interface is hit by a weapon. For example, this method might be called by a map object when a projectile travels into an occupied map cell, or when a player with a melee weapon issues an "attack" command when adjacent to an occupied map cell. It might also be used to tell an actor that it has been hit so it can update its health data accordingly.

If the object that was "hit" is not an obstacle and therefore should not stop a projectile from travelling on, the method should return -1 to indicate this.

If the object that was hit is an obstacle but is not destructible, the method should return 0.

Parameters:
weapon - The weapon that hit this object.
Returns:
The amount of damage done to this object, or -1 if the weapon is ignored..

activate

void activate(MHActor actor)
To be called when an "activate" command is issued to an object.

Parameters:
actor - The actor that originated the "activate" command.

examine

java.lang.String examine()
Returns a description of a game object. Useful in games where the player needs the ability to look closely at things to get clues, hints, instructions, etc.

Returns:
A string containing a description of an object.

getName

java.lang.String getName()
Returns the name of a game object.

Returns:
A string containing the name of an object.

pickUp

void pickUp(MHActor actor)
To be called when a character picks up an item. May be called in response to a "pick up item" command, or automatically when a player steps on an item (possibly from the steppedOn() method declared in this interface).

Parameters:
actor - The character who is picking up the item.

isTraversable

boolean isTraversable()
Returns true if the actor implementing this interface can be "walked" over.