RTS2D
|
00001 #ifndef GAME_H 00002 00003 #include <vector> 00004 #include <algorithm> 00005 #include <queue> 00006 #include <set> 00007 #include <cmath> 00008 #include "Define.h" 00009 #include "Map.h" 00010 #include "Unit.h" 00011 #include "Building.h" 00012 #include "Node.h" 00013 #include "Graph.h" 00014 #include "UnitProperty.h" 00015 #include "TileProperty.h" 00016 #include "Mymath.h" 00017 #include "Quadtree.h" 00018 #include "Rect.h" 00019 #include "Player.h" 00020 #include "Pathfinding.h" 00021 #include "Projectile.h" 00022 00023 #define GAME_H 00024 00028 class Game { 00029 public: 00030 Game(Map* map); 00031 virtual ~Game(); 00032 std::vector<Unit*> getUnitSet(); 00033 void setUnitSet(std::vector<Unit*> unitSet); 00034 std::vector<Building*> getBuildingSet(); 00035 std::vector<Player*> getPlayer(); 00036 std::vector<Projectile*> getProjectileSet(); 00037 void setProjectileSet(std::vector<Projectile*> projectileSet); 00038 void setBuildingSet(std::vector<Building*> buildingSet); 00039 void insertUnit(Unit* unit); 00040 bool removeUnit(Unit* unit); 00041 bool isInsertBuildingValid(float px, float py, int buildType); 00042 void insertBuilding(Building* building); 00043 bool removeBuilding(Building* building); 00044 bool setBuildingWalkable(Building* building, bool boolean); 00045 Graph* getGraph(); 00046 void setGraph(Graph* Graph); 00047 Map* getMap(); 00048 void setMap(Map* map); 00049 bool unitMove(Unit* unit, float px, float py); 00050 00051 bool selectStop(std::vector<Unit*> select); 00052 bool selectMove(std::vector<Unit*> select, float px, float py); 00053 bool selectMoveAttack(std::vector<Unit*> select, float px, float py); 00054 bool selectMoveBuild(std::vector<Unit*> select, float px, float py, int buildType); 00055 bool selectMoveGather(std::vector<Unit*> select, float px, float py); 00056 bool buildingPath(Building* building, float px, float py); 00057 00058 Unit* getEnemyUnit(Unit* unit); 00059 Building* getEnemyBuilding(Unit* unit); 00060 bool hasUnitInBuilding(int x, int y, int buildType); 00061 bool insertBuildingQueue(Building* building, int unitType); 00062 bool cancelBuildingQueue(Building* building); 00063 bool insertUnitBuild(Unit* unit, int buildType); 00064 bool removeUnitBuild(Unit* unit); 00065 void multiAction(std::vector<Unit*> select, float px, float py); 00066 Entity* getEntity(float px, float py); 00067 void setBuildType(Building* building); 00068 void resetBuildType(Building* building); 00069 bool insertGoldSlot(Building* building, Unit* unit); 00070 bool unloadGoldSlot(Building* building); 00071 00072 void aFollowb(Unit* a, Entity* b); 00073 void stopFollow(Unit* unit); 00074 00075 void insertProjectile(Projectile* p); 00076 bool removeProjectile(Projectile* p); 00077 00078 bool executeCommand(std::string com, std::vector<Unit*> select); 00079 bool executeCommand(std::string com, Building* select); 00080 bool executeCommand(std::string com, std::vector<Unit*> select, float px, float py); 00081 bool executeCommand(std::string com, Building* select, float px, float py); 00082 00083 00084 protected: 00085 private: 00086 Map* map_; 00087 Graph* graph_; 00088 ALLEGRO_DISPLAY *display; 00089 ALLEGRO_TIMER *timer; 00090 ALLEGRO_EVENT_QUEUE *queue; 00091 std::vector<Unit*> unitSet_; 00092 std::vector<Building*> buildingSet_; 00093 std::vector<Projectile*> projectileSet_; 00094 std::vector<Player*> player_; 00095 Pathfinding* pf_; 00096 bool isInMapDimension(float px, float py); 00097 bool isPathBlocked(std::vector<std::pair<float,float>> pixelPath); 00098 void repath(); 00099 void readConfig(); 00100 }; 00101 00102 #endif // GAME_H 00103