|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--gecco.server.core.Unit
This class represents a unit in the game, and must be subclassed by every game implementation. Most of the attributes is set up in configuration files, and the things to be done for the game programmer is to initialize all properties in a constructor, using the method setProperty.
Field Summary | |
protected Action |
activeAction
This is the action that the unit is currently executing. |
protected HashSet |
blockedActions
Contains all Actions that have been blocked, that is, have been stopped during execution for some reason. |
protected String |
commander
The name of the role that commands this unit, that is, the role that has the right to execute actions with the unit. |
protected int |
handle
The handle identifies the unit during communication with clients. |
protected int |
intX
The x-coordinate of the unit's position as an integer. |
protected int |
intY
The y-coordinate of the unit's position as an integer. |
protected boolean |
isDestroyed
Flag to indicate if the unit is destroyed. |
protected String |
name
The name of the unit appears in the client, and is set up in a configuration file. |
protected HashSet |
observers
The set of observers contains the names of all roles that has observing rights on this unit, that is, that sees everything this unit sees. |
protected TypedProperties |
properties
Container for the properties of the unit. |
protected String |
type
The type of the unit appears in the client, and is set up in a configuration file. |
protected UnitType |
unitType
An instance of the unit type of this unit. |
protected HashSet |
updatedActions
??? |
protected HashMap |
updatedProperties
Contains all properties that have been updated during the current tick, and the new values. |
protected double |
x
The x-coordinate of the unit's position. |
protected double |
y
The y-coordinate of the unit's position. |
Constructor Summary | |
Unit()
Constructor for the Unit object |
Method Summary | |
void |
abortAllActions()
|
void |
addBlockedAction(String actionName)
Block an action. |
void |
addObserver(String role)
Adds a new observer of the unit. |
boolean |
canSeeAutomatonAtPosition(int _x,
int _y)
Determines if the unit can see a specific automaton, that is, if the given position is inside the units visibility range. |
int |
compareTo(Object o)
Compares the unit to a given unit. |
boolean |
equals(Object o)
Determines if the unit is the same as a given unit. |
Action |
getActiveAction()
Gets the currently executing Action. |
Set |
getBlockedActions()
Gets the set of actions that have been blocked during the last tick. |
String |
getCommander()
Gets the name of the role of the commander of the unit. |
double |
getDoubleProperty(String name)
Gets a specific property value that is known to be a double value. |
int |
getHandle()
Gets the handle of the unit. |
int |
getIntProperty(String name)
Gets a specific property value that is known to be an integer value. |
int |
getIntX()
Gets the x coordinate of the unit's position, cast as an integer, using the floor function |
int |
getIntY()
Gets the y coordinate of the unit's position, cast as an integer, using the floor function. |
String |
getName()
Gets the name of the unit. |
Set |
getObservers()
Gets the set of observers of the unit. |
Map |
getProperties()
Gets the map of properties of the unit. |
Object |
getProperty(String name)
Gets a specific property value, given the property name. |
String |
getPropertyType(String name)
Gets the PropertyType attribute of the Unit object |
String |
getStringProperty(String name)
Gets a specific property value that is known to be a String. |
UnitType |
getUnitType()
Gets the unit type of the unit. |
Set |
getUpdatedActions()
Gets the set of all actions that have been updated. |
HashMap |
getUpdatedProperties()
Gets the map of all properties that have been updated during the current tick. |
double |
getX()
Gets the x coordinate of the unit's position. |
double |
getY()
Gets the y coordinate of the unit's position. |
int |
hashCode()
Returns a hash code of the unit. |
void |
init()
This method is called once before the game starts. |
boolean |
isDestroyed()
Determines if the unit has been destroyed. |
boolean |
isObserver(String role)
Determines if a given role is an observer of the unit. |
void |
markAsDestroyed()
Mark the unit as destroyed. |
void |
printWriteMe(PrintWriter out)
|
void |
removeBlockedAction(String actionName)
Unblock an action. |
boolean |
removeObserver(String role)
Remove a role from the set of observers of the unit, so the role is no longer an observer. |
void |
removeProperty(String name)
|
void |
resetUpdatedActions()
Clears the set of updates actions. |
void |
resetUpdatedProperties()
Clears the set of updated properties. |
protected void |
sendUnitMessage(String message)
Sends a message to all observers of the unit (as well as to all God's Eye roles). |
void |
setActiveAction(Action action)
Sets the ActiveAction attribute of the Unit object |
void |
setCommander(String _commander)
Sets the Commander attribute of the Unit object |
void |
setHandle(int _handle)
Sets the Handle attribute of the Unit object |
void |
setName(String _name)
Sets the Name attribute of the Unit object |
void |
setPosition(double _x,
double _y)
Sets the Position attribute of the Unit object |
void |
setProperty(String name,
double value)
Sets a property to a Double value. |
void |
setProperty(String name,
int value)
Sets a property to an Integer value. |
void |
setProperty(String name,
String value)
Sets a property to a String value. |
void |
setUnitType(String _type)
Sets the UnitType attribute of the Unit object |
String |
toString()
|
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
protected int handle
protected Action activeAction
protected String name
protected String type
protected UnitType unitType
protected boolean isDestroyed
protected String commander
protected HashSet observers
protected double x
protected double y
protected int intX
protected int intY
protected TypedProperties properties
protected HashMap updatedProperties
protected HashSet blockedActions
protected HashSet updatedActions
Constructor Detail |
public Unit()
Method Detail |
public void setName(String _name)
_name
- The new Name valuepublic void setUnitType(String _type)
_type
- The new unit typepublic void setHandle(int _handle)
_handle
- The new handlepublic void setPosition(double _x, double _y)
_x
- The x coordinate of the new position_y
- The y coordinate of the new positionpublic void setCommander(String _commander)
_commander
- The new Commander valuepublic void setActiveAction(Action action)
action
- The new ActiveAction valuepublic void setProperty(String name, double value)
name
- The name of the property.value
- The value of the property.public void setProperty(String name, int value)
name
- The name of the property.value
- The value of the property.public void setProperty(String name, String value)
name
- The name of the property.value
- The value of the property.public String getName()
public UnitType getUnitType()
public int getHandle()
public double getX()
public double getY()
public int getIntX()
public int getIntY()
public String getCommander()
public Action getActiveAction()
public boolean isObserver(String role)
role
- The name of the role.
public Set getObservers()
public Map getProperties()
public Object getProperty(String name)
name
- The property name.
public String getPropertyType(String name)
name
- Description of Parameter
public double getDoubleProperty(String name)
name
- The property name.
public int getIntProperty(String name)
name
- The property name.
public String getStringProperty(String name)
name
- The property name.
public HashMap getUpdatedProperties()
public Set getUpdatedActions()
public Set getBlockedActions()
public boolean isDestroyed()
public void addObserver(String role)
role
- The name of the role that is to be an observer of the unit.public boolean removeObserver(String role)
role
- The name of the role.
public void resetUpdatedProperties()
public void resetUpdatedActions()
public void addBlockedAction(String actionName)
actionName
- The name of the action.public void removeBlockedAction(String actionName)
actionName
- The name of the action.public boolean canSeeAutomatonAtPosition(int _x, int _y)
_x
- The x coordinate of the position._y
- The x coordinate of the position.
public void markAsDestroyed()
protected void sendUnitMessage(String message)
message
- The message to be sent.public void abortAllActions()
public void init()
public boolean equals(Object o)
equals
in class Object
o
- The given object, possibly a unit.
public int compareTo(Object o)
compareTo
in interface Comparable
o
- The given object, possibly a unit.
public int hashCode()
hashCode
in class Object
public void removeProperty(String name)
public String toString()
toString
in class Object
public void printWriteMe(PrintWriter out)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |