69 lines
1.6 KiB
C++
69 lines
1.6 KiB
C++
#ifndef MAP_H
|
|
#define MAP_H
|
|
|
|
#include "base_types.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
|
|
{
|
|
Free = 0,
|
|
Player = 1,
|
|
AlienPath = 1000,
|
|
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
|
|
|
|
|
|
explicit Map(QByteArray data, QSize size, QString name, int maxPlayers, int image, QObject *parent = 0);
|
|
bool addTowerOnMap(int playerId, QPoint pos);
|
|
bool isFreePlace(QPoint pos);
|
|
void delTowerOnMap(QPoint pos);
|
|
void removeAliensPath();
|
|
QVector <QPointF> createPath(QPoint start, QPoint finish);
|
|
QRect rect() const {return QRect(QPoint(),mapSize);}
|
|
// QString name() const {return mapName;}
|
|
QList <QPoint> starts() const {return Starts;}
|
|
QList <QPoint> finishs() const {return Finishs;}
|
|
QVector < QVector <int> > cells() const {return Cells;}
|
|
int image() const {return imageType;}
|
|
signals:
|
|
void recreateAlienPath(bool * pathOK);
|
|
public slots:
|
|
void printMap();
|
|
|
|
private:
|
|
QSize mapSize;
|
|
QString mapName;
|
|
int players;
|
|
int imageType;
|
|
QVector < QVector <int> > Cells;
|
|
QList <QPoint> Starts;
|
|
QList <QPoint> Finishs;
|
|
|
|
QVector < QVector <int> > TmpCells;
|
|
|
|
QVector<QPoint> invWaveTrace(QPoint finish, int cnt);
|
|
int waveTrace(QPoint start, QPoint finish);
|
|
//void CreateMapExample();
|
|
//void ReadSettings();
|
|
};
|
|
|
|
#endif // MAP_H
|