source: network-game/common/WorldMap.h@ 0065962

Last change on this file since 0065962 was 7f884ea, checked in by dportnoy <dmp1488@…>, 11 years ago

Map-related structs are now outside of the WorldMap class

  • 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>
[60b77d2]5#include <vector>
6
[05051c7]7#include "Common.h"
8
[60b77d2]9using namespace std;
10
[7f884ea]11enum TerrainType {
12 TERRAIN_NONE,
13 TERRAIN_GRASS,
14 TERRAIN_OCEAN,
15 TERRAIN_ROCK
16};
[60b77d2]17
[7f884ea]18enum StructureType {
19 STRUCTURE_NONE,
20 STRUCTURE_BLUE_FLAG,
21 STRUCTURE_RED_FLAG
22};
[05051c7]23
[7f884ea]24enum ObjectType {
25 OBJECT_NONE,
26 OBJECT_BLUE_FLAG,
27 OBJECT_RED_FLAG
28};
[a1a3bd5]29
[7f884ea]30class WorldMap {
31public:
[05051c7]32 class Object {
33 public:
[9ba9b96]34 unsigned int id;
[05051c7]35 ObjectType type;
36 POSITION pos;
37
[9ba9b96]38 Object(unsigned int id, ObjectType type, int x, int y);
39 Object(unsigned int id, ObjectType type, POSITION pos);
[05051c7]40
41 ~Object();
[5f868c0]42
43 void serialize(char* buffer);
44 void deserialize(char* buffer);
[05051c7]45 };
46
[60b77d2]47 int width, height;
48 vector<vector<TerrainType>*>* vctMap;
[05051c7]49 vector<vector<StructureType>*>* vctStructures;
50 vector<Object>* vctObjects;
[60b77d2]51
[62ee2ce]52 WorldMap(int width, int height);
[60b77d2]53
[62ee2ce]54 ~WorldMap();
[60b77d2]55
[0678d60]56 void createObjectsFromStructures();
57
[62ee2ce]58 TerrainType getElement(int x, int y);
[60b77d2]59 void setElement(int x, int y, TerrainType type);
60
[05051c7]61 StructureType getStructure(int x, int y);
62 void setStructure(int x, int y, StructureType type);
[e4c60ba]63 POSITION getStructureLocation(StructureType type);
[05051c7]64
[e487381]65 vector<Object>* getObjects();
[05051c7]66 vector<Object> getObjects(int x, int y);
[5f868c0]67
[6e66ffd]68 void addObject(ObjectType type, int x, int y);
[7f884ea]69 void updateObject(unsigned int id, ObjectType t, int x, int y);
[9ba9b96]70 bool removeObject(unsigned int id);
[a1a3bd5]71
[62ee2ce]72 static WorldMap* createDefaultMap();
[384b7e0]73 static WorldMap* loadMapFromFile(string filename);
[60b77d2]74};
75
[f401cac]76#endif
Note: See TracBrowser for help on using the repository browser.