|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--gecco.server.core.Action
This class represents an Action that a unit can execute, and every real action should be a subclass of this class. There are several kinds of actions. First, there is normal actions, that are executed one after another in a queue, only one at a time, and there are instantaneous actions, that are executed at once, even if there are some other normal action ongoing. The normal actions typically span some interval in time, like movement of units, and the instantaneous don't, they are just instantaneous. :) Second, actions can have different arguments. At the moment, the arguments can be a unit, a point on the map, or nothing. Normal actions are executed over a time interval, and at some points in time the action has checkpoints when the method with the same name is called by the game engine. That method is where most of the code of the action is placed, for example code to check if the action is completed, and code to update any status of the unit executing the action, and so on.
Field Summary | |
private int |
actionHandle
The unique handle of the action. |
private Unit |
argUnit
The unit that is the target of the action, if appropriate. |
private double |
argX
The coordinates of the point that is the target of this action, if appropriate. |
private double |
argY
Description of the Field |
private boolean |
isInstantaneous
Flag to indicate if this action is instantaneous. |
private Unit |
unit
The unit that executes the action. |
Constructor Summary | |
Action()
Constructor for the Action object |
Method Summary | |
protected boolean |
canSeePosition(double x,
double y)
Determines if the unit that executes the action can see a certain position, that is, if the position is inside the units visibility range. |
abstract ActionReturn |
checkPoint()
This method is called periodically by the game engine. |
int |
getActionHandle()
Gets the handle of the Action object |
Unit |
getArgumentUnit()
Gets the unit that is the target of this action. |
double |
getArgumentX()
Gets the x coordinate of the point that is the target of this action. |
double |
getArgumentY()
Gets the y coordinate of the point that is the target of this action. |
protected int |
getAutomatonState(int x,
int y)
Gets the state of the given automaton. |
Unit |
getUnit()
Gets the unit that executes this action |
int |
getUnitHandle()
Gets the handle of the unit that executes this action |
void |
initiate(int _actionHandle,
int _unitHandle)
Initialise the action without any arguments. |
void |
initiate(int _actionHandle,
int _unitHandle,
double _argX,
double _argY)
Initialise the action with a point as argument. |
void |
initiate(int _actionHandle,
int _unitHandle,
int _argUnitHandle)
Initialise the action with a unit as argument. |
boolean |
isInstantaneous()
Gets the Instantaneous flag of the Action object |
protected void |
sendEventToAutomaton(int x,
int y,
String eventName,
int factor)
Sends an event to a given automaton. |
protected void |
sendEventToUnit(Unit unit,
String eventName,
int factor)
Sends an event to a given unit. |
void |
setInstantaneous(boolean b)
Sets the Instantaneous flag of the Action object |
Methods inherited from class java.lang.Object |
|
Field Detail |
private int actionHandle
private Unit unit
private Unit argUnit
private double argX
private double argY
private boolean isInstantaneous
Constructor Detail |
public Action()
Method Detail |
public void setInstantaneous(boolean b)
b
- The new Instantaneous valuepublic boolean isInstantaneous()
public int getActionHandle()
public int getUnitHandle()
public Unit getUnit()
public Unit getArgumentUnit()
public double getArgumentX()
public double getArgumentY()
public void initiate(int _actionHandle, int _unitHandle)
_actionHandle
- A unique handle that should identify this action._unitHandle
- The handle of the executing unit.public void initiate(int _actionHandle, int _unitHandle, double _argX, double _argY)
_actionHandle
- A unique handle that should identify this action._unitHandle
- The handle of the executing unit._argX
- The x coordinate of the target point._argY
- The y coordinate of the target point.public void initiate(int _actionHandle, int _unitHandle, int _argUnitHandle)
_actionHandle
- A unique handle that should identify this action._unitHandle
- The handle of the executing unit._argUnitHandle
- The handle of the target unit.public abstract ActionReturn checkPoint()
protected int getAutomatonState(int x, int y)
x
- The x coordinate of the automaton.y
- The y coordinate of the automaton.protected void sendEventToAutomaton(int x, int y, String eventName, int factor)
x
- The x coordinate of the automaton.y
- The y coordinate of the automaton.eventName
- The name of the event.factor
- The factor of the event.protected void sendEventToUnit(Unit unit, String eventName, int factor)
unit
- The unit that should recieve the event.eventName
- The name of the event.factor
- The factor of the event.protected boolean canSeePosition(double x, double y)
x
- The x coordinate of the position.y
- The y coordinate of the position.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |