source: network-game/common/WorldMap.h@ 4dbac87

Last change on this file since 4dbac87 was e4c60ba, checked in by dportnoy <dmp1488@…>, 11 years ago

Players can turn in flags they have picked up to their own flag sites

  • Property mode set to 100644
File size: 1.5 KB
RevLine 
[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]10using namespace std;
11
[62ee2ce]12class WorldMap {
[60b77d2]13public:
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
[5f868c0]39 Object(int id, ObjectType type, int x, int y);
40 Object(int id, ObjectType type, POSITION pos);
[05051c7]41
42 ~Object();
[5f868c0]43
44 void serialize(char* buffer);
45 void deserialize(char* buffer);
[05051c7]46 };
47
[60b77d2]48 int width, height;
49 vector<vector<TerrainType>*>* vctMap;
[05051c7]50 vector<vector<StructureType>*>* vctStructures;
51 vector<Object>* vctObjects;
[60b77d2]52
[62ee2ce]53 WorldMap(int width, int height);
[60b77d2]54
[62ee2ce]55 ~WorldMap();
[60b77d2]56
[62ee2ce]57 TerrainType getElement(int x, int y);
[60b77d2]58 void setElement(int x, int y, TerrainType type);
59
[05051c7]60 StructureType getStructure(int x, int y);
61 void setStructure(int x, int y, StructureType type);
[e4c60ba]62 POSITION getStructureLocation(StructureType type);
[05051c7]63
[e487381]64 vector<Object>* getObjects();
[05051c7]65 vector<Object> getObjects(int x, int y);
[5f868c0]66
[6e66ffd]67 void addObject(ObjectType type, int x, int y);
68 void updateObject(int id, WorldMap::ObjectType t, int x, int y);
[5f868c0]69 bool removeObject(int id);
[a1a3bd5]70
[62ee2ce]71 static WorldMap* createDefaultMap();
[384b7e0]72 static WorldMap* loadMapFromFile(string filename);
[60b77d2]73};
74
[f401cac]75#endif
Note: See TracBrowser for help on using the repository browser.