D:/Development/Projects/X-Clone/X-Clone/trunk/Unit.h

Go to the documentation of this file.
00001 #ifndef XCLONE_UNIT_H
00002 #define XCLONE_UNIT_H
00003 
00004 #include "includes.h"
00005 
00006 class Unit;
00007 typedef boost::shared_ptr<Unit> spUnit;
00008 typedef boost::weak_ptr<Unit> wpUnit;
00009 
00010 #include "GameEntity.h"
00011 #include "MapTile.h"
00012 
00013 class Unit : public GameEntity
00014 {
00015    public:
00016       static spUnit makeUnit(int playerID);
00017       static spUnit makeUnit(int playerID, spMapTile);
00018       virtual ~Unit();
00019 
00020       int getPlayerID() const;
00021       int getX() const;
00022       int getY() const;
00023 
00024       void draw(Point offset, Point dimensions) const;
00025 
00026       bool isPassable() const;
00027  
00028       void wait();
00029 
00030       void move( Direction dir );
00031       void move( spMapTile tile );
00032 
00033       void moveAlongPath( bool teleport = false );
00034 
00035       map<spMapTile, int> getPossibleMoves();
00036       void updatePossibleMoves();
00037       bool canMoveInDirection(Direction dir);
00038 
00039       void computeMovePath(spMapTile dest);
00040       void drawMovePath(Point offset) const;
00041       bool hasMovePath() const;
00042       void clearMovePath();
00043       const spMapTile getDestination() const;
00044 
00045       bool hasMaxActionPoints() const;
00046       void regenActionPoints();
00047 
00048       bool hasTurnBefore(spUnit u) const;
00049      
00050       void markActive();
00051       static void clearActive();
00052 
00053       void markSelected();
00054       static void clearSelected();
00055 
00056       static spUnit getSelectedUnit();
00057 
00058    private:
00059       Unit(int playerID, spMapTile tile);
00060 
00061       bool canMoveInDirection(spMapTile tile, Direction dir, int points);
00062       pair<spMapTile, int> computeMovePathHelper(spMapTile current);
00063 
00064       wpUnit _weak;
00065 
00066       map<spMapTile, int> _possibleMoves;
00067       list<pair<spMapTile, int> > _movementPath;
00068       int _actionPoints;
00069       int _regenRate;
00070       int _playerID;
00071       spMapTile _tile;
00072 
00073       static spUnit _activeUnit;
00074       static spUnit _selectedUnit;
00075 
00076       static SDL_Surface* _image;
00077       static SDL_Surface* _pathImage;
00078       static SDL_Surface* _pathEndImage;
00079       static SDL_Surface* _selectedImage;
00080       static SDL_Surface* _activeImage;
00081 
00082       static int _maxActionPoints;
00083 };
00084 
00085 #endif

Generated on Fri Sep 22 06:00:26 2006 for X-CLONE by  doxygen 1.4.7