Files
aliendefender/map.h
buull da42fe8f58 add loader
add schema
new loader model using xml
separated work and load data
validation using schema
map data in xml
new core model... proecting
2010-08-19 20:52:32 +03:00

71 lines
1.4 KiB
C++

#ifndef MAP_H
#define MAP_H
#include <QObject>
#include <QSize>
#include <QList>
#include <QPointF>
#include <QRect>
#include <QFile>
#include "base_types.h"
#include "settreader.h"
// Maximum map is 65530 x 65530 because qHash may be repeat and towers has same Id
class Map : public QObject
{
Q_OBJECT
public:
enum CellType
{
Player = 1,
PlayerAlien = 1001,
PlayerTower = -1,
Wall = -1000,
Start = 9999,
Finish = 8888
};
// 1 - free for player 1
// 2 - free for player 2
// 3 - -/-
// 1001 - player 1, free, but it is alien path (for optimization)
// 1002 - -/-
// 99999 - start field or finish field
// -1 - player 1 tower
// -2 - player 2 tower
// -3 - -/-
// -1000 - it is wall or some place where you can't build
QVector < QVector <int> > Cells;
QList <QPoint> starts;
QList <QPoint> finishs;
int maxPlayers;
explicit Map(int Id, QObject *parent = 0);
int Id() const {return mapId;}
bool addTowerOnMap(int playerId, QPoint pos);
void delTowerOnMap(QPoint pos);
void removeAliensPath();
QVector <QPointF> CreatePath(QPoint start, QPoint finish);
QSize size() const {return mapsize;}
void load();
signals:
void RecreateAlienPath(bool * pathOK);
public slots:
void printMap();
private:
int mapId;
QSize mapsize;
QVector < QVector <int> > TmpCells;
QVector<QPoint> InvWaveTrace(QPoint finish, int cnt);
int WaveTrace(QPoint start, QPoint finish);
void CreateMapExample();
void ReadSettings();
};
#endif // MAP_H