us.asciiroth.client.agents
Class AgentProxy

java.lang.Object
  extended by us.asciiroth.client.agents.AgentProxy
All Implemented Interfaces:
Agent, Animated, Piece
Direct Known Subclasses:
Paralyzed, Statue

public abstract class AgentProxy
extends java.lang.Object
implements Agent, Animated

An agent decorator that can be subclassed to alter the behavior or appearance of an agent, usually for a period of time (hence the implementation of the Animated interface). Examples include paralysis and being turned to stone (or if you prefer, statues that can come to life).


Constructor Summary
AgentProxy(Agent agent, int flags)
          Constructor.
 
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.
 Agent getAgent()
          Get the agent being proxied.
 Color getColor()
          What is the color of this piece? While many piece types are permanently of color "None", many more can be parameterized with a color in order to tie them together through color-based events.
 java.lang.String getName()
          The visible name of the piece.
 Symbol getSymbol()
          The symbol to display for this piece.
 boolean is(int flag)
          Does this piece have the indicated bit flag?
 boolean not(int flag)
          Does this piece not have the indicated flag?
 void onDie(Event event, Cell agentLoc)
          Called when the agent dies on a given cell.
 void onFrame(Context ctx, Cell cell, int frame)
          Animation callback, executed once each frame for each piece animated on the board.
 void onHit(Event event, Cell attackerLoc, 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 class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface us.asciiroth.client.core.Animated
randomSeed
 

Constructor Detail

AgentProxy

public AgentProxy(Agent agent,
                  int flags)
Constructor.

Parameters:
agent -
flags -
Method Detail

canEnter

public boolean canEnter(Direction direction,
                        Cell from,
                        Cell to)
Description copied from interface: Agent
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.

Specified by:
canEnter in interface Agent
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

public int changeHealth(int value)
Description copied from interface: Agent
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.

Specified by:
changeHealth in interface Agent
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.

getAgent

public Agent getAgent()
Get the agent being proxied.

Returns:
the agent being proxied.

getColor

public Color getColor()
Description copied from interface: Piece
What is the color of this piece? While many piece types are permanently of color "None", many more can be parameterized with a color in order to tie them together through color-based events.

Specified by:
getColor in interface Piece
Returns:
the Color of this piece

getName

public java.lang.String getName()
Description copied from interface: Piece
The visible name of the piece.

Specified by:
getName in interface Piece
Returns:
the name of the piece as displayed to the user.

getSymbol

public Symbol getSymbol()
Description copied from interface: Piece
The symbol to display for this piece.

Specified by:
getSymbol in interface Piece
Returns:
the symbol for this piece

is

public boolean is(int flag)
Description copied from interface: Piece
Does this piece have the indicated bit flag?

Specified by:
is in interface Piece
Returns:
true if piece has the flag
See Also:
Flags

not

public boolean not(int flag)
Description copied from interface: Piece
Does this piece not have the indicated flag?

Specified by:
not in interface Piece
Returns:
true if piece does not have the flag
See Also:
Flags

onDie

public void onDie(Event event,
                  Cell agentLoc)
Description copied from interface: Agent
Called when the agent dies on a given cell.

Specified by:
onDie in interface Agent

onFrame

public void onFrame(Context ctx,
                    Cell cell,
                    int frame)
Description copied from interface: Animated
Animation callback, executed once each frame for each piece animated on the board.

Specified by:
onFrame in interface Animated

onHit

public void onHit(Event event,
                  Cell attackerLoc,
                  Cell agentLoc,
                  Agent agent)
Description copied from interface: 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).

Specified by:
onHit in interface Agent

onHitBy

public void onHitBy(Event event,
                    Cell agentLoc,
                    Agent agent,
                    Direction dir)
Description copied from interface: Agent
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.

Specified by:
onHitBy in interface Agent

onHitBy

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

Specified by:
onHitBy in interface Agent

0.7

© 2009 Alx Dark