us.asciiroth.client.agents
Class LavaWorm

java.lang.Object
  extended by us.asciiroth.client.core.AbstractPiece
      extended by us.asciiroth.client.agents.AbstractAgent
          extended by us.asciiroth.client.agents.AbstractAnimatedAgent
              extended by us.asciiroth.client.agents.LavaWorm
All Implemented Interfaces:
Agent, Animated, Piece

public class LavaWorm
extends AbstractAnimatedAgent
implements Animated

An agent that lives and fights in lava (it should not be placed outside of lava, or it won't be able to move). Fires a color event when it dies.


Field Summary
static Serializer<LavaWorm> SERIALIZER
          Type serializer.
 
Constructor Summary
LavaWorm(Color color)
          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.
 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).
 
Methods inherited from class us.asciiroth.client.agents.AbstractAnimatedAgent
randomSeed
 
Methods inherited from class us.asciiroth.client.agents.AbstractAgent
changeHealth, onDie, onHitBy
 
Methods inherited from class us.asciiroth.client.core.AbstractPiece
getColor, getName, getSymbol, is, not
 
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
 
Methods inherited from interface us.asciiroth.client.core.Piece
getColor, getName, getSymbol, is, not
 

Field Detail

SERIALIZER

public static final Serializer<LavaWorm> SERIALIZER
Type serializer.

Constructor Detail

LavaWorm

public LavaWorm(Color color)
Constructor

Parameters:
color - color of event fired when this agent dies
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
Overrides:
canEnter in class AbstractAgent
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)

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
Overrides:
onHit in class AbstractAgent

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
Overrides:
onHitBy in class AbstractAgent

0.7

© 2009 Alx Dark