|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--gecco.server.automaton.Automaton
The superclass for the automaton used in a game. This class should be subclassed by every game implementation. For each point on the map, one instance of this class is instanciated. Concrete subclasses should implement all states of the automaton and the different events that should be sent from or to the automaton. In particular, the subclasses should determine what colour the automaton should have, because that will be the colour of that pixel on the map. It is to subclass this class that the game designer can make the map dynamic in many ways, for example to let a fire spread across the map.
Field Summary | |
private boolean |
changed
Flag to indicate if the state of the automaton has changed. |
protected Color |
currentColor
The current color which is to be sent to the client in a given state. |
private int |
currentState
The current state of the automaton. |
Constructor Summary | |
Automaton()
Constructor for the Automaton object |
Method Summary | |
Color |
getCurrentColor()
Gets the CurrentColor attribute of the Automaton object |
int |
getState()
Gets the State attribute of the Automaton object |
abstract UnitEvent |
getUnitEventForCurrentState(String unitType)
Gets the UnitEvent for the current state of the automaton. |
abstract AutomatonReturn |
handleEvent(AutomatonEvent event)
Handles incoming event to the automaton. |
boolean |
hasChanged()
Indicates if the automaton has changed state since the last call to this method. |
void |
initialize(int initialState)
Initialises the automaton. |
void |
setCurrentColor(int r,
int g,
int b)
Sets the current color for the automaton. |
protected void |
setState(int newState)
Sets the State attribute of the Automaton object |
abstract AutomatonReturn |
update(int[][] neighbourStates)
The update method of the automaton. |
Methods inherited from class java.lang.Object |
|
Field Detail |
protected Color currentColor
private boolean changed
private int currentState
Constructor Detail |
public Automaton()
Method Detail |
public void setCurrentColor(int r, int g, int b)
r
- The red component of the new color.g
- The gree component of the new color.b
- The blue component of the new color.public abstract UnitEvent getUnitEventForCurrentState(String unitType)
unitType
- The name of the UnitType of the unit that has moved
over the automatonpublic Color getCurrentColor()
public int getState()
public void initialize(int initialState)
initialState
- Description of Parameterpublic abstract AutomatonReturn update(int[][] neighbourStates)
neighbourStates
- The states of the surrounding automatons, given
in a 3x3 integer grid.public abstract AutomatonReturn handleEvent(AutomatonEvent event)
event
- The AutomatonEventpublic boolean hasChanged()
protected void setState(int newState)
newState
- The new State value
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |