|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--gecco.server.unitmanager.UnitManager
This class acts as a container for all units in the game. It keeps track all units and unit types, the observers of all units, and certain things.
Field Summary | |
protected HashMap |
activeUnits
All active units for each role, hashed on the role name. |
protected HashSet |
godseyeRoles
All gods eye roles! |
protected String[] |
roles
Array containing _all_ roles, including the gods eye roles! |
protected HashMap |
rolesToAlienUnitsMap
For each role, the set of units alien to that role, hashed on the role name. |
protected HashMap |
rolesToObserverUnitsMap
For each role, the set of units that the role observes, hashed on the role name. |
protected HashMap |
units
Contains all units, hashed on their handles. |
protected HashMap |
unitTypes
All unit types in the game, hashed on their names. |
protected HashSet[] |
xArray
An array of sets, one set for each x coordinate on the map. |
protected HashSet[] |
yArray
An array of sets, one set for each y coordinate on the map. |
Constructor Summary | |
UnitManager(Set roles,
Set godseyeRoles)
Constructor for the UnitManager object |
Method Summary | |
boolean |
activateUnit(String role,
Unit unit)
Mark a unit as active for a given role. |
void |
addUnitType(UnitType unitType)
Adds a new unit type. |
Unit |
createUnit(String unitTypeName)
Creates a unit of a given unit type. |
boolean |
deactivateUnit(String role,
Unit unit)
Mark a unit as non-active for a given role. |
void |
deleteUnit(Unit unit,
double lastKnownX,
double lastKnownY)
Delete a unit from the game. |
Set |
getAlienUnits(String role)
Gets the set of units that is alien to a given role. |
Collection |
getAllUnits()
Gets all units in the game. |
Set |
getBlockedActions(Unit u)
Gets the set of blocked actions of a given unit. |
int[] |
getCommandingUnits(String role)
Gets the handles of all units that a given role commands. |
Set |
getGodsEyeRoles()
Gets the GodsEyeRoles attribute of the UnitManager object |
int[] |
getHandles()
Gets the BlockedActionStrings attribute of the UnitManager object Gets the UnblockedActionStrings attribute of the UnitManager object Gets the handles of all units in the game. |
Set |
getObservingUnits(String role)
Gets the set of units that a given role observes. |
int |
getRange(Unit u)
Gets the visibility range of a given unit. |
String[] |
getRoles()
Gets the Roles attribute of the UnitManager object |
String[] |
getRolesAlienToUnit(Unit unit)
Gets the names of all roles that is alien to a given unit. |
String[] |
getRolesObservingUnit(Unit unit)
Gets the names of all roles that observes a given unit. |
Set |
getUnblockedActions(Unit u)
Gets the set of non-blocked actions of a given unit. |
Unit |
getUnit(int handle)
Gets a unit, given its handle. |
Set |
getUnitsAtAutomatonPosition(int x,
int y)
Gets the set of units at a given position. |
UnitType |
getUnitType(String unitType)
Gets a unit type, given its name. |
Collection |
getUnitTypes()
Gets all unit types in the game. |
void |
initializeUnitPosition(Unit unit)
Initialises a unit. |
boolean |
isGodseye(String role)
Determines if a given role has status as god's eye. |
boolean |
isRoleCommander(String role)
Determines if a given role commands any unit. |
boolean |
isUnitActive(String role,
int unit)
Determines if a given is active for a given role. |
void |
reportObserverForUnit(String role,
Unit u)
Mark a given role as observer for a given unit. |
void |
reportUpdatedUnitPosition(Unit unit,
int oldX,
int oldY)
Report that a units position has been updated. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected HashMap units
protected String[] roles
protected HashSet godseyeRoles
protected HashMap activeUnits
protected HashMap unitTypes
protected HashMap rolesToObserverUnitsMap
protected HashMap rolesToAlienUnitsMap
protected HashSet[] xArray
protected HashSet[] yArray
Constructor Detail |
public UnitManager(Set roles, Set godseyeRoles)
roles
- The roles in the game.godseyeRoles
- The roles with god's eye status.Method Detail |
public String[] getRoles()
public Set getGodsEyeRoles()
public boolean isGodseye(String role)
role
- A role name.
public Collection getAllUnits()
public Unit getUnit(int handle)
handle
- A handle of a unit.
public UnitType getUnitType(String unitType)
unitType
- The name of the unit type.
public Set getBlockedActions(Unit u)
u
- The unit.
public Set getUnblockedActions(Unit u)
u
- The unit.
public int[] getHandles()
public int[] getCommandingUnits(String role)
role
- The name of the role.
public int getRange(Unit u)
u
- The unit.
public String[] getRolesObservingUnit(Unit unit)
unit
- The unit.
public String[] getRolesAlienToUnit(Unit unit)
unit
- A unit.
public Set getObservingUnits(String role)
role
- The role name.
public Set getAlienUnits(String role)
role
- The role name.
public Set getUnitsAtAutomatonPosition(int x, int y)
x
- The x coordinate of the position.y
- The y coordinate of the position.
public boolean isUnitActive(String role, int unit)
role
- The name of the role.unit
- The handle of the unit.
public boolean isRoleCommander(String role)
role
- The name of the role.
public Collection getUnitTypes()
public Unit createUnit(String unitTypeName)
unitTypeName
- The name of the unit type.
public void reportObserverForUnit(String role, Unit u)
role
- The role name.u
- The unit.public void addUnitType(UnitType unitType)
unitType
- The unit type to be added.public void initializeUnitPosition(Unit unit)
unit
- The unit.public void reportUpdatedUnitPosition(Unit unit, int oldX, int oldY)
unit
- The unit.oldX
- The x coordinate of the old position.oldY
- The y coordinate of the old position.public boolean activateUnit(String role, Unit unit)
role
- The name of the role.unit
- The unit.
public boolean deactivateUnit(String role, Unit unit)
role
- The name of the role.unit
- The unit.
public void deleteUnit(Unit unit, double lastKnownX, double lastKnownY)
unit
- The unit to be deleted.lastKnownX
- The x coordinate of the last position of the unit.lastKnownY
- The y coordinate of the last position of the unit.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |