|
Last change
on this file since 6e66ffd was 6e66ffd, checked in by dportnoy <dmp1488@…>, 13 years ago |
|
Add functions to the WorldMap class to allow the server to notify clients of object creation and movement
|
-
Property mode
set to
100644
|
|
File size:
1.3 KB
|
| Line | |
|---|
| 1 | #ifndef _WORLDMAP_H
|
|---|
| 2 | #define _WORLDMAP_H
|
|---|
| 3 |
|
|---|
| 4 | #include <string>
|
|---|
| 5 |
|
|---|
| 6 | #include <vector>
|
|---|
| 7 |
|
|---|
| 8 | #include "Common.h"
|
|---|
| 9 |
|
|---|
| 10 | using namespace std;
|
|---|
| 11 |
|
|---|
| 12 | class WorldMap {
|
|---|
| 13 | public:
|
|---|
| 14 | enum TerrainType {
|
|---|
| 15 | TERRAIN_NONE,
|
|---|
| 16 | TERRAIN_GRASS,
|
|---|
| 17 | TERRAIN_OCEAN,
|
|---|
| 18 | TERRAIN_ROCK
|
|---|
| 19 | };
|
|---|
| 20 |
|
|---|
| 21 | enum StructureType {
|
|---|
| 22 | STRUCTURE_NONE,
|
|---|
| 23 | STRUCTURE_BLUE_FLAG,
|
|---|
| 24 | STRUCTURE_RED_FLAG
|
|---|
| 25 | };
|
|---|
| 26 |
|
|---|
| 27 | enum ObjectType {
|
|---|
| 28 | OBJECT_NONE,
|
|---|
| 29 | OBJECT_BLUE_FLAG,
|
|---|
| 30 | OBJECT_RED_FLAG
|
|---|
| 31 | };
|
|---|
| 32 |
|
|---|
| 33 | class Object {
|
|---|
| 34 | public:
|
|---|
| 35 | int id;
|
|---|
| 36 | ObjectType type;
|
|---|
| 37 | POSITION pos;
|
|---|
| 38 |
|
|---|
| 39 | Object(ObjectType type, int id, int x, int y);
|
|---|
| 40 | Object(ObjectType type, int id, POSITION pos);
|
|---|
| 41 |
|
|---|
| 42 | ~Object();
|
|---|
| 43 | };
|
|---|
| 44 |
|
|---|
| 45 | int width, height;
|
|---|
| 46 | vector<vector<TerrainType>*>* vctMap;
|
|---|
| 47 | vector<vector<StructureType>*>* vctStructures;
|
|---|
| 48 | vector<Object>* vctObjects;
|
|---|
| 49 |
|
|---|
| 50 | WorldMap(int width, int height);
|
|---|
| 51 |
|
|---|
| 52 | ~WorldMap();
|
|---|
| 53 |
|
|---|
| 54 | TerrainType getElement(int x, int y);
|
|---|
| 55 | void setElement(int x, int y, TerrainType type);
|
|---|
| 56 |
|
|---|
| 57 | StructureType getStructure(int x, int y);
|
|---|
| 58 | void setStructure(int x, int y, StructureType type);
|
|---|
| 59 |
|
|---|
| 60 | vector<Object> getObjects(int x, int y);
|
|---|
| 61 | void addObject(ObjectType type, int x, int y);
|
|---|
| 62 | void updateObject(int id, WorldMap::ObjectType t, int x, int y);
|
|---|
| 63 |
|
|---|
| 64 | static WorldMap* createDefaultMap();
|
|---|
| 65 | static WorldMap* loadMapFromFile(string filename);
|
|---|
| 66 | };
|
|---|
| 67 |
|
|---|
| 68 | #endif
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.