Files
aliendefender/map.h
buull 0a9679fd99 some bugfix in ADeditor
memory optimization in AD
2010-09-18 00:00:32 +04:00

76 lines
2.1 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, // FIXME: not worked yet!!
// FIXME: must add Free cell to all functions
Player = 1, // use Player + playerId for multiplayer
AlienPath = 1000, // use AlienPath + Player and + playerId
PlayerTower = -1, // use PlayerTower - Player - playerId
Wall = -1000,
Start = 9999,
Finish = 8888
};
// 0 - free for any player
// 1 - free for player 1
// 2 - free for player 2
// 3 - -/-
// 1001 - player 1, free, but it is alien path (for optimization)
// 1001 - player 2, free, but it is alien path (for optimization)
// 1003 - -/-
// 9999 - start field
// 8888 - finish field
// -1 - tower on free cell
// -2 - player 1 tower
// -3 - player 2 tower
// -4 - -/-
// -1000 - it is wall or some place where you can't build any towers
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(int playerId, 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;}
int maxPlayers() const {return players;}
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);
bool isReachable(int playerId, QPoint pos);
//void CreateMapExample();
//void ReadSettings();
};
#endif // MAP_H