Files
aliendefender/map.h

68 lines
1.3 KiB
C++

#ifndef MAP_H
#define MAP_H
#include <QObject>
#include <QSize>
#include <QVector>
#include <QPointF>
#include <QRect>
#include <QFile>
#include "base_types.h"
#include "settreader.h"
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;
QVector < QVector <int> > TmpCells;
QVector <QPoint> starts;
QVector <QPoint> finishs;
QSize mapsize;
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 ReadSettings();
signals:
void RecreateAlienPath(bool * pathOK);
public slots:
void printMap();
private:
int mapId;
QVector<QPoint> InvWaveTrace(QPoint finish, int cnt);
int WaveTrace(QPoint start, QPoint finish);
void CreateMapExample();
};
#endif // MAP_H