Last change
on this file since 6e66ffd was 6e66ffd, checked in by dportnoy <dmp1488@…>, 12 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
|
Rev | Line | |
---|
[62ee2ce] | 1 | #ifndef _WORLDMAP_H
|
---|
| 2 | #define _WORLDMAP_H
|
---|
[60b77d2] | 3 |
|
---|
[f401cac] | 4 | #include <string>
|
---|
| 5 |
|
---|
[60b77d2] | 6 | #include <vector>
|
---|
| 7 |
|
---|
[05051c7] | 8 | #include "Common.h"
|
---|
| 9 |
|
---|
[60b77d2] | 10 | using namespace std;
|
---|
| 11 |
|
---|
[62ee2ce] | 12 | class WorldMap {
|
---|
[60b77d2] | 13 | public:
|
---|
| 14 | enum TerrainType {
|
---|
| 15 | TERRAIN_NONE,
|
---|
| 16 | TERRAIN_GRASS,
|
---|
[62ee2ce] | 17 | TERRAIN_OCEAN,
|
---|
| 18 | TERRAIN_ROCK
|
---|
[60b77d2] | 19 | };
|
---|
| 20 |
|
---|
[05051c7] | 21 | enum StructureType {
|
---|
| 22 | STRUCTURE_NONE,
|
---|
| 23 | STRUCTURE_BLUE_FLAG,
|
---|
| 24 | STRUCTURE_RED_FLAG
|
---|
| 25 | };
|
---|
| 26 |
|
---|
[a1a3bd5] | 27 | enum ObjectType {
|
---|
| 28 | OBJECT_NONE,
|
---|
[e76055f] | 29 | OBJECT_BLUE_FLAG,
|
---|
| 30 | OBJECT_RED_FLAG
|
---|
[a1a3bd5] | 31 | };
|
---|
| 32 |
|
---|
[05051c7] | 33 | class Object {
|
---|
| 34 | public:
|
---|
[6e66ffd] | 35 | int id;
|
---|
[05051c7] | 36 | ObjectType type;
|
---|
| 37 | POSITION pos;
|
---|
| 38 |
|
---|
[6e66ffd] | 39 | Object(ObjectType type, int id, int x, int y);
|
---|
| 40 | Object(ObjectType type, int id, POSITION pos);
|
---|
[05051c7] | 41 |
|
---|
| 42 | ~Object();
|
---|
| 43 | };
|
---|
| 44 |
|
---|
[60b77d2] | 45 | int width, height;
|
---|
| 46 | vector<vector<TerrainType>*>* vctMap;
|
---|
[05051c7] | 47 | vector<vector<StructureType>*>* vctStructures;
|
---|
| 48 | vector<Object>* vctObjects;
|
---|
[60b77d2] | 49 |
|
---|
[62ee2ce] | 50 | WorldMap(int width, int height);
|
---|
[60b77d2] | 51 |
|
---|
[62ee2ce] | 52 | ~WorldMap();
|
---|
[60b77d2] | 53 |
|
---|
[62ee2ce] | 54 | TerrainType getElement(int x, int y);
|
---|
[60b77d2] | 55 | void setElement(int x, int y, TerrainType type);
|
---|
| 56 |
|
---|
[05051c7] | 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);
|
---|
[6e66ffd] | 61 | void addObject(ObjectType type, int x, int y);
|
---|
| 62 | void updateObject(int id, WorldMap::ObjectType t, int x, int y);
|
---|
[a1a3bd5] | 63 |
|
---|
[62ee2ce] | 64 | static WorldMap* createDefaultMap();
|
---|
[384b7e0] | 65 | static WorldMap* loadMapFromFile(string filename);
|
---|
[60b77d2] | 66 | };
|
---|
| 67 |
|
---|
[f401cac] | 68 | #endif
|
---|
Note:
See
TracBrowser
for help on using the repository browser.