Unit Class Reference

#include <Unit.h>

Inherits GameEntity.

Inheritance diagram for Unit:

Inheritance graph
[legend]
List of all members.

Detailed Description

Definition at line 13 of file Unit.h.

Public Member Functions

bool canMoveInDirection (Direction dir)
void clearMovePath ()
void computeMovePath (spMapTile dest)
void draw (Point offset, Point dimensions) const
void drawMovePath (Point offset) const
const spMapTile getDestination () const
int getPlayerID () const
map< spMapTile, int > getPossibleMoves ()
int getX () const
int getY () const
bool hasMaxActionPoints () const
bool hasMovePath () const
bool hasTurnBefore (spUnit u) const
bool isPassable () const
void markActive ()
void markSelected ()
void move (spMapTile tile)
void move (Direction dir)
void moveAlongPath (bool teleport=false)
void regenActionPoints ()
void updatePossibleMoves ()
void wait ()
virtual ~Unit ()

Static Public Member Functions

static void clearActive ()
static void clearSelected ()
static spUnit getSelectedUnit ()
static spUnit makeUnit (int playerID, spMapTile)
static spUnit makeUnit (int playerID)

Private Member Functions

bool canMoveInDirection (spMapTile tile, Direction dir, int points)
pair< spMapTile, int > computeMovePathHelper (spMapTile current)
 Unit (int playerID, spMapTile tile)

Private Attributes

int _actionPoints
list< pair< spMapTile, int > > _movementPath
int _playerID
map< spMapTile, int > _possibleMoves
int _regenRate
spMapTile _tile
wpUnit _weak

Static Private Attributes

static SDL_Surface * _activeImage = NULL
static spUnit _activeUnit
static SDL_Surface * _image = NULL
static int _maxActionPoints = 50
static SDL_Surface * _pathEndImage = NULL
static SDL_Surface * _pathImage = NULL
static SDL_Surface * _selectedImage = NULL
static spUnit _selectedUnit


Constructor & Destructor Documentation

Unit::~Unit (  )  [virtual]

Definition at line 61 of file Unit.cpp.

Unit::Unit ( int  playerID,
spMapTile  tile 
) [private]

Definition at line 42 of file Unit.cpp.

References _activeImage, _image, _pathEndImage, _pathImage, _selectedImage, _tile, Singleton< T >::instance(), UNIT_ACTIVE_IMAGE, UNIT_IMAGE, UNIT_PATH_END_IMAGE, UNIT_PATH_IMAGE, and UNIT_SELECTED_IMAGE.

Referenced by makeUnit().

Here is the call graph for this function:

Here is the caller graph for this function:


Member Function Documentation

bool Unit::canMoveInDirection ( spMapTile  tile,
Direction  dir,
int  points 
) [private]

Definition at line 140 of file Unit.cpp.

References _tile, Direction::E, getX(), getY(), Direction::N, Direction::NE, Direction::NW, Direction::S, Direction::SE, Direction::SW, and Direction::W.

Here is the call graph for this function:

bool Unit::canMoveInDirection ( Direction  dir  ) 

Definition at line 135 of file Unit.cpp.

References _actionPoints, and _tile.

Referenced by computeMovePathHelper(), move(), and updatePossibleMoves().

Here is the caller graph for this function:

void Unit::clearActive (  )  [static]

Definition at line 435 of file Unit.cpp.

References _activeUnit.

void Unit::clearMovePath (  ) 

Definition at line 389 of file Unit.cpp.

References _movementPath.

Referenced by moveAlongPath().

Here is the caller graph for this function:

void Unit::clearSelected (  )  [static]

Definition at line 445 of file Unit.cpp.

References _selectedUnit.

void Unit::computeMovePath ( spMapTile  dest  ) 

Definition at line 296 of file Unit.cpp.

References _movementPath, _possibleMoves, _tile, and computeMovePathHelper().

Here is the call graph for this function:

pair< spMapTile, int > Unit::computeMovePathHelper ( spMapTile  current  )  [private]

Definition at line 319 of file Unit.cpp.

References _possibleMoves, canMoveInDirection(), and Direction::getAllDirections().

Referenced by computeMovePath().

Here is the call graph for this function:

Here is the caller graph for this function:

void Unit::draw ( Point  offset,
Point  dimensions 
) const [virtual]

Implements GameEntity.

Definition at line 80 of file Unit.cpp.

References _actionPoints, _activeImage, _activeUnit, _image, _selectedImage, _selectedUnit, Display::draw(), Display::getScreenWidth(), Singleton< T >::instance(), Point::x, and Point::y.

Here is the call graph for this function:

void Unit::drawMovePath ( Point  offset  )  const

Definition at line 368 of file Unit.cpp.

References _movementPath, _pathEndImage, _pathImage, Singleton< T >::instance(), Point::x, and Point::y.

Here is the call graph for this function:

const spMapTile Unit::getDestination (  )  const

Definition at line 394 of file Unit.cpp.

References _movementPath, and hasMovePath().

Here is the call graph for this function:

int Unit::getPlayerID (  )  const

Definition at line 65 of file Unit.cpp.

References _playerID.

map< spMapTile, int > Unit::getPossibleMoves (  ) 

Definition at line 246 of file Unit.cpp.

References _possibleMoves.

spUnit Unit::getSelectedUnit (  )  [static]

Definition at line 450 of file Unit.cpp.

References _selectedUnit.

Referenced by MainGameState::processSDLEvent(), and MainGameState::update().

Here is the caller graph for this function:

int Unit::getX (  )  const

Definition at line 70 of file Unit.cpp.

References _tile.

Referenced by canMoveInDirection().

Here is the caller graph for this function:

int Unit::getY (  )  const

Definition at line 75 of file Unit.cpp.

References _tile.

Referenced by canMoveInDirection().

Here is the caller graph for this function:

bool Unit::hasMaxActionPoints (  )  const

Definition at line 406 of file Unit.cpp.

References _actionPoints, and _maxActionPoints.

bool Unit::hasMovePath (  )  const

Definition at line 342 of file Unit.cpp.

References _movementPath.

Referenced by getDestination(), and moveAlongPath().

Here is the caller graph for this function:

bool Unit::hasTurnBefore ( spUnit  u  )  const

Definition at line 421 of file Unit.cpp.

References _actionPoints, _maxActionPoints, and _regenRate.

Referenced by MainGameState::endActiveUnitTurn().

Here is the caller graph for this function:

bool Unit::isPassable (  )  const [virtual]

Implements GameEntity.

Definition at line 106 of file Unit.cpp.

spUnit Unit::makeUnit ( int  playerID,
spMapTile   
) [static]

Definition at line 30 of file Unit.cpp.

References Unit().

Here is the call graph for this function:

spUnit Unit::makeUnit ( int  playerID  )  [static]

Definition at line 25 of file Unit.cpp.

Referenced by MainGameState::createUnit().

Here is the caller graph for this function:

void Unit::markActive (  ) 

Definition at line 430 of file Unit.cpp.

References _activeUnit, and _weak.

void Unit::markSelected (  ) 

Definition at line 440 of file Unit.cpp.

References _selectedUnit, and _weak.

void Unit::move ( spMapTile  tile  ) 

Definition at line 124 of file Unit.cpp.

References _tile, _weak, and updatePossibleMoves().

Here is the call graph for this function:

void Unit::move ( Direction  dir  ) 

Definition at line 116 of file Unit.cpp.

References _tile, and canMoveInDirection().

Referenced by moveAlongPath().

Here is the call graph for this function:

Here is the caller graph for this function:

void Unit::moveAlongPath ( bool  teleport = false  ) 

Definition at line 347 of file Unit.cpp.

References _actionPoints, _maxActionPoints, _movementPath, clearMovePath(), hasMovePath(), and move().

Here is the call graph for this function:

void Unit::regenActionPoints (  ) 

Definition at line 411 of file Unit.cpp.

References _actionPoints, _maxActionPoints, and _regenRate.

Referenced by MainGameState::endActiveUnitTurn().

Here is the caller graph for this function:

void Unit::updatePossibleMoves (  ) 

Definition at line 251 of file Unit.cpp.

References _actionPoints, _possibleMoves, _tile, canMoveInDirection(), and Direction::getAllDirections().

Referenced by move().

Here is the call graph for this function:

Here is the caller graph for this function:

void Unit::wait (  ) 

Definition at line 111 of file Unit.cpp.

References _actionPoints.


Member Data Documentation

int Unit::_actionPoints [private]

Definition at line 68 of file Unit.h.

Referenced by canMoveInDirection(), draw(), hasMaxActionPoints(), hasTurnBefore(), moveAlongPath(), regenActionPoints(), updatePossibleMoves(), and wait().

SDL_Surface * Unit::_activeImage = NULL [static, private]

Definition at line 80 of file Unit.h.

Referenced by draw(), and Unit().

spUnit Unit::_activeUnit [static, private]

Definition at line 73 of file Unit.h.

Referenced by clearActive(), draw(), and markActive().

SDL_Surface * Unit::_image = NULL [static, private]

Definition at line 76 of file Unit.h.

Referenced by draw(), and Unit().

int Unit::_maxActionPoints = 50 [static, private]

Definition at line 82 of file Unit.h.

Referenced by hasMaxActionPoints(), hasTurnBefore(), moveAlongPath(), and regenActionPoints().

list<pair<spMapTile, int> > Unit::_movementPath [private]

Definition at line 67 of file Unit.h.

Referenced by clearMovePath(), computeMovePath(), drawMovePath(), getDestination(), hasMovePath(), and moveAlongPath().

SDL_Surface * Unit::_pathEndImage = NULL [static, private]

Definition at line 78 of file Unit.h.

Referenced by drawMovePath(), and Unit().

SDL_Surface * Unit::_pathImage = NULL [static, private]

Definition at line 77 of file Unit.h.

Referenced by drawMovePath(), and Unit().

int Unit::_playerID [private]

Definition at line 70 of file Unit.h.

Referenced by getPlayerID().

map<spMapTile, int> Unit::_possibleMoves [private]

Definition at line 66 of file Unit.h.

Referenced by computeMovePath(), computeMovePathHelper(), getPossibleMoves(), and updatePossibleMoves().

int Unit::_regenRate [private]

Definition at line 69 of file Unit.h.

Referenced by hasTurnBefore(), and regenActionPoints().

SDL_Surface * Unit::_selectedImage = NULL [static, private]

Definition at line 79 of file Unit.h.

Referenced by draw(), and Unit().

spUnit Unit::_selectedUnit [static, private]

Definition at line 74 of file Unit.h.

Referenced by clearSelected(), draw(), getSelectedUnit(), and markSelected().

spMapTile Unit::_tile [private]

Definition at line 71 of file Unit.h.

Referenced by canMoveInDirection(), computeMovePath(), getX(), getY(), move(), Unit(), and updatePossibleMoves().

wpUnit Unit::_weak [private]

Definition at line 64 of file Unit.h.

Referenced by markActive(), markSelected(), and move().


The documentation for this class was generated from the following files:
Generated on Fri Sep 22 06:00:27 2006 for X-CLONE by  doxygen 1.4.7