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 | unsigned int id;
|
---|
35 | ObjectType type;
|
---|
36 | POSITION pos;
|
---|
37 |
|
---|
38 | Object(unsigned int id, ObjectType type, int x, int y);
|
---|
39 | Object(unsigned 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 | void createObjectsFromStructures();
|
---|
57 |
|
---|
58 | TerrainType getElement(int x, int y);
|
---|
59 | void setElement(int x, int y, TerrainType type);
|
---|
60 |
|
---|
61 | StructureType getStructure(int x, int y);
|
---|
62 | void setStructure(int x, int y, StructureType type);
|
---|
63 | POSITION getStructureLocation(StructureType type);
|
---|
64 |
|
---|
65 | vector<Object>* getObjects();
|
---|
66 | vector<Object> getObjects(int x, int y);
|
---|
67 |
|
---|
68 | void addObject(ObjectType type, int x, int y);
|
---|
69 | void updateObject(unsigned int id, WorldMap::ObjectType t, int x, int y);
|
---|
70 | bool removeObject(unsigned int id);
|
---|
71 |
|
---|
72 | static WorldMap* createDefaultMap();
|
---|
73 | static WorldMap* loadMapFromFile(string filename);
|
---|
74 | };
|
---|
75 |
|
---|
76 | #endif
|
---|