1 | #ifndef _WORLDMAP_H
|
---|
2 | #define _WORLDMAP_H
|
---|
3 |
|
---|
4 | #include <string>
|
---|
5 | #include <vector>
|
---|
6 |
|
---|
7 | #include "Common.h"
|
---|
8 |
|
---|
9 | using namespace std;
|
---|
10 |
|
---|
11 | class WorldMap {
|
---|
12 | public:
|
---|
13 | enum TerrainType {
|
---|
14 | TERRAIN_NONE,
|
---|
15 | TERRAIN_GRASS,
|
---|
16 | TERRAIN_OCEAN,
|
---|
17 | TERRAIN_ROCK
|
---|
18 | };
|
---|
19 |
|
---|
20 | enum StructureType {
|
---|
21 | STRUCTURE_NONE,
|
---|
22 | STRUCTURE_BLUE_FLAG,
|
---|
23 | STRUCTURE_RED_FLAG
|
---|
24 | };
|
---|
25 |
|
---|
26 | enum ObjectType {
|
---|
27 | OBJECT_NONE,
|
---|
28 | OBJECT_BLUE_FLAG,
|
---|
29 | OBJECT_RED_FLAG
|
---|
30 | };
|
---|
31 |
|
---|
32 | class Object {
|
---|
33 | public:
|
---|
34 | int id;
|
---|
35 | ObjectType type;
|
---|
36 | POSITION pos;
|
---|
37 |
|
---|
38 | Object(int id, ObjectType type, int x, int y);
|
---|
39 | Object(int id, ObjectType type, POSITION pos);
|
---|
40 |
|
---|
41 | ~Object();
|
---|
42 |
|
---|
43 | void serialize(char* buffer);
|
---|
44 | void deserialize(char* buffer);
|
---|
45 | };
|
---|
46 |
|
---|
47 | int width, height;
|
---|
48 | vector<vector<TerrainType>*>* vctMap;
|
---|
49 | vector<vector<StructureType>*>* vctStructures;
|
---|
50 | vector<Object>* vctObjects;
|
---|
51 |
|
---|
52 | WorldMap(int width, int height);
|
---|
53 |
|
---|
54 | ~WorldMap();
|
---|
55 |
|
---|
56 | TerrainType getElement(int x, int y);
|
---|
57 | void setElement(int x, int y, TerrainType type);
|
---|
58 |
|
---|
59 | StructureType getStructure(int x, int y);
|
---|
60 | void setStructure(int x, int y, StructureType type);
|
---|
61 | POSITION getStructureLocation(StructureType type);
|
---|
62 |
|
---|
63 | vector<Object>* getObjects();
|
---|
64 | vector<Object> getObjects(int x, int y);
|
---|
65 |
|
---|
66 | void addObject(ObjectType type, int x, int y);
|
---|
67 | void updateObject(int id, WorldMap::ObjectType t, int x, int y);
|
---|
68 | bool removeObject(int id);
|
---|
69 |
|
---|
70 | static WorldMap* createDefaultMap();
|
---|
71 | static WorldMap* loadMapFromFile(string filename);
|
---|
72 | };
|
---|
73 |
|
---|
74 | #endif
|
---|