ballwar.model.strategy
Class LightUpStrategy

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

public class LightUpStrategy
extends ANoOpStrategy

An ANoOpStrategy-based strategy that switches its color to a preset "lit up" color for a while after a collision.


Field Summary
private  int _count
          The count of how many cycles have passed since initially being lit up.
private static Color _LitUpColor
          The color when "lit up"
private static int _LitUpDuration
          The number of update cycles to remain "lit up".
private  Color _oldColor
          The pre-lit-up color.
 
Fields inherited from interface ballwar.model.IUpdateStrategy
NullObject
 
Constructor Summary
LightUpStrategy()
           
 
Method Summary
 void init(Ball context)
          Saves the context's current color.
 void updateCollision(Ball context, Ball target)
          I the count is non-positive, saves the color of the context, sets the count to a preset value and sets the color of the context to a preset "lit up" value.
 void updateState(Ball context)
          Updates the state of the context.
 
Methods inherited from class ballwar.model.strategy.ANoOpStrategy
kill
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_LitUpDuration

private static int _LitUpDuration
The number of update cycles to remain "lit up".


_LitUpColor

private static Color _LitUpColor
The color when "lit up"


_count

private int _count
The count of how many cycles have passed since initially being lit up.


_oldColor

private Color _oldColor
The pre-lit-up color.

Constructor Detail

LightUpStrategy

public LightUpStrategy()
Method Detail

updateState

public void updateState(Ball context)
Updates the state of the context. If the count is not positive, set the color of the context back to what it was before the collision.

Specified by:
updateState in interface IUpdateStrategy
Overrides:
updateState in class ANoOpStrategy
Parameters:
context - The stategy's context.

updateCollision

public void updateCollision(Ball context,
                            Ball target)
I the count is non-positive, saves the color of the context, sets the count to a preset value and sets the color of the context to a preset "lit up" value.

Specified by:
updateCollision in interface IUpdateStrategy
Overrides:
updateCollision in class ANoOpStrategy
Parameters:
context - The strategy's context.
target - The target ball that the context hit.

init

public void init(Ball context)
Saves the context's current color.

Specified by:
init in interface IUpdateStrategy
Overrides:
init in class ANoOpStrategy
Parameters:
context - The context of the strategy