us.asciiroth.client.core
Interface Agent

All Superinterfaces:
Piece
All Known Implementing Classes:
AbstractAgent, AbstractAnimatedAgent, AgentProxy, Alder, Archer, Asciiroth, Boulder, Cactus, Campfire, Cephalid, Commoner, Corvid, Cypress, Elm, Farthapod, Fence, Fir, GreatOldOne, Hemlock, Hooloovoo, ImmobileAgent, KillerBee, LavaWorm, LightningLizard, MallocArcher, MallocCommoner, MallocNoble, MallocRifleman, MallocWizard, Maple, Noble, NPC, Oak, Optilisk, Paralyzed, Pillar, Player, Pusher, Rhindle, Rifleman, RollingBoulder, Sleestak, Slider, Spruce, Statue, Stump, Tetrite, Thermadon, Tree, Triffid, Tumbleweed, Willow, Wizard

public interface Agent
extends Piece

Interface for pieces that exclusively occupy a cell. There can only be one agent in a cell at a time, although not all agents are animate and move around. Things that are usefully placed "on" different kinds of terrain can be modeled as agents.


Method Summary
 boolean canEnter(Direction direction, Cell from, Cell to)
          Can the agent enter this terrain? This method mirrors the same method in Terrain, and both most return true for the agent to be able to move.
 int changeHealth(int value)
          Change health.
 void onDie(Event event, Cell cell)
          Called when the agent dies on a given cell.
 void onHit(Event event, Cell attackerCell, Cell agentLoc, Agent agent)
          Fired when this agent collides with the player, or if this agent is the player, when the player collides with another agent (in other words, this method will not fire if one non-player agent collides with another non-player agent).
 void onHitBy(Event event, Cell agentLoc, Agent agent, Direction dir)
          Called when this agent is hit by another agent (another agent collides with it).
 void onHitBy(Event event, Cell itemLoc, Item item, Direction dir)
          Called when this agent is hit by another item, either by being thrown, or by being wielded by the player.
 
Methods inherited from interface us.asciiroth.client.core.Piece
getColor, getName, getSymbol, is, not
 

Method Detail

canEnter

boolean canEnter(Direction direction,
                 Cell from,
                 Cell to)
Can the agent enter this terrain? This method mirrors the same method in Terrain, and both most return true for the agent to be able to move. You can put the logic for preventing agent movement in either place, depending on where it makes sense in order to centralize it. NOTE: There is currently no canExit method for agents, but it can be added if any piece ever needs it.

Parameters:
direction -
from -
to -
Returns:
true if the agent can enter the terrain moving between the two cells using the indicated direction
See Also:
Terrain.canEnter(Agent, Cell, Direction)

changeHealth

int changeHealth(int value)
Change health. For the player, this method indicates an amount of change to health, and returns the current health of the player after being changed. For other agents, the value an adjustment to the percentage chance that the agent will be hit by an attack.

Parameters:
value - the damage to take or the adjustment to the percentage chance to be hit.
Returns:
returns the current health of the agent, 0 for non-player agents when they have been killed.

onDie

void onDie(Event event,
           Cell cell)
Called when the agent dies on a given cell.

Parameters:
event -
cell -

onHit

void onHit(Event event,
           Cell attackerCell,
           Cell agentLoc,
           Agent agent)
Fired when this agent collides with the player, or if this agent is the player, when the player collides with another agent (in other words, this method will not fire if one non-player agent collides with another non-player agent).

Parameters:
event -
attackerCell -
agentLoc -
agent -

onHitBy

void onHitBy(Event event,
             Cell agentLoc,
             Agent agent,
             Direction dir)
Called when this agent is hit by another agent (another agent collides with it). Typically the move event will be cancelled in this method, unless this agent moves itself out of the way, such as boulders attempt to do.

Parameters:
event -
agentLoc -
agent -
dir -

onHitBy

void onHitBy(Event event,
             Cell itemLoc,
             Item item,
             Direction dir)
Called when this agent is hit by another item, either by being thrown, or by being wielded by the player.

Parameters:
event -
itemLoc -
item -
dir -

0.7

© 2009 Alx Dark