ballwar.model.strategy
Class UpdateStrategySet

java.lang.Object
  extended by ballwar.model.strategy.UpdateStrategySet
All Implemented Interfaces:
IUpdateStrategy

public class UpdateStrategySet
extends Object
implements IUpdateStrategy


Field Summary
private  IAlgo _collideAlgo
           
private  IAlgo _initAlgo
           
private  IAlgo _killAlgo
           
private  IAlgo _remStrategyAlgo
           
private  LRStruct _strategySet
           
private  IAlgo _updateAlgo
           
 
Fields inherited from interface ballwar.model.IUpdateStrategy
NullObject
 
Constructor Summary
UpdateStrategySet()
           
 
Method Summary
 void addCmd(IUpdateStrategy strategy)
           
 void clear()
           
 void init(Ball context)
          Initializes the given ball.
 void kill(Ball context)
          Processes a "killing" of a ball.
 IUpdateStrategy removeCmd(IUpdateStrategy strategy)
           
 void updateCollision(Ball context, Ball target)
          updates the state of the ball in response to a collision between the two balls.
 void updateState(Ball context)
          Updates the state of the given ball in response to the periodic repainting of the ball as a part of its animation..
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_strategySet

private LRStruct _strategySet

_updateAlgo

private IAlgo _updateAlgo

_collideAlgo

private IAlgo _collideAlgo

_initAlgo

private IAlgo _initAlgo

_killAlgo

private IAlgo _killAlgo

_remStrategyAlgo

private IAlgo _remStrategyAlgo
Constructor Detail

UpdateStrategySet

public UpdateStrategySet()
Method Detail

addCmd

public void addCmd(IUpdateStrategy strategy)

removeCmd

public IUpdateStrategy removeCmd(IUpdateStrategy strategy)

clear

public void clear()

updateState

public void updateState(Ball context)
Description copied from interface: IUpdateStrategy
Updates the state of the given ball in response to the periodic repainting of the ball as a part of its animation.. Used to modify the position, velocity, color, etc as the ball is moving.

Specified by:
updateState in interface IUpdateStrategy
Parameters:
context - The ball to update.

updateCollision

public void updateCollision(Ball context,
                            Ball target)
Description copied from interface: IUpdateStrategy
updates the state of the ball in response to a collision between the two balls. It is assumed that the context ball is the one that just moved and collided with the target ball.

Specified by:
updateCollision in interface IUpdateStrategy
Parameters:
context - The ball that just moved and collided with the target ball.
target - The ball that was not moving and was collided by the context.

init

public void init(Ball context)
Description copied from interface: IUpdateStrategy
Initializes the given ball. Called once by the ball when the strategy is first loaded.

Specified by:
init in interface IUpdateStrategy
Parameters:
context - The ball to initialize.

kill

public void kill(Ball context)
Description copied from interface: IUpdateStrategy
Processes a "killing" of a ball. Called when a ball's kill() method is called. A ball will only be removed from the system if its doKill() method is called, perhaps from the strategy's kill() method.

Specified by:
kill in interface IUpdateStrategy
Parameters:
context - The ball who's kill method was called.