changes in arhitecture, some improvments, much optimising and simplify,
many bagfixes and new graphics engine
This commit is contained in:
198
ad_graphics.cpp
198
ad_graphics.cpp
@@ -1,21 +1,23 @@
|
|||||||
#include "ad_graphics.h"
|
#include "ad_graphics.h"
|
||||||
#include <QGLWidget>
|
#include <QGLWidget>
|
||||||
|
#include <QGraphicsItem>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
AD_Graphics::AD_Graphics(AD_Core *adcore, QWidget *parent) : QGraphicsView(parent)
|
AD_Graphics::AD_Graphics(AD_Core *adcore, QWidget *parent) : QGraphicsView(parent)
|
||||||
{
|
{
|
||||||
data = adcore->addata;
|
data = adcore->addata;
|
||||||
core = adcore;
|
core = adcore;
|
||||||
//scale(cellSize, cellSize);
|
setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
|
||||||
setAlignment(Qt::AlignLeft | Qt::AlignTop);
|
setAlignment(Qt::AlignLeft | Qt::AlignTop);
|
||||||
scene = new QGraphicsScene();
|
scene = new QGraphicsScene();
|
||||||
|
scene->setItemIndexMethod(QGraphicsScene::NoIndex);
|
||||||
|
core->setScene(scene);
|
||||||
setScene(scene);
|
setScene(scene);
|
||||||
//setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
|
//setCacheMode();
|
||||||
setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
|
//setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
|
||||||
mapimg = new QImage(data->map->rect().size()*cellSize,QImage::Format_ARGB32);
|
mapimg = new QImage(data->map->rect().size()*cellSize,QImage::Format_ARGB32);
|
||||||
//setDragMode(RubberBandDrag);
|
//setDragMode(RubberBandDrag);
|
||||||
//gsw = new QGraphicsWidget();
|
|
||||||
//scene->addWidget(new QPushButton());
|
|
||||||
QPainter p(mapimg);
|
QPainter p(mapimg);
|
||||||
for (int i=0; i<data->map->cells().size(); i++) {
|
for (int i=0; i<data->map->cells().size(); i++) {
|
||||||
for (int j=0; j<data->map->cells().at(i).size(); j++) {
|
for (int j=0; j<data->map->cells().at(i).size(); j++) {
|
||||||
@@ -30,14 +32,6 @@ AD_Graphics::AD_Graphics(AD_Core *adcore, QWidget *parent) : QGraphicsView(paren
|
|||||||
pen.setColor(Qt::black);
|
pen.setColor(Qt::black);
|
||||||
brush.setColor(Qt::black);
|
brush.setColor(Qt::black);
|
||||||
}
|
}
|
||||||
// if (cel <= Map::PlayerTower && cel !=Map::Wall) {
|
|
||||||
// pen.setColor(QColor(cel%255,(cel*100)%255,(cel+100)%255));
|
|
||||||
// brush.setColor(QColor(cel%255,(cel*100)%255,(cel+100)%255));
|
|
||||||
// }
|
|
||||||
// if (cel >= Map::PlayerAlien) {
|
|
||||||
// pen.setColor(Qt::yellow);
|
|
||||||
// brush.setColor(Qt::yellow);
|
|
||||||
// }
|
|
||||||
if (cel >= Map::Free || (cel <= Map::PlayerTower && cel !=Map::Wall))
|
if (cel >= Map::Free || (cel <= Map::PlayerTower && cel !=Map::Wall))
|
||||||
{
|
{
|
||||||
pen.setColor(QColor(qAbs(cel+2)*345%255,(qAbs(cel+2)*721)%255,(qAbs(cel+2)*75)%255,150));
|
pen.setColor(QColor(qAbs(cel+2)*345%255,(qAbs(cel+2)*721)%255,(qAbs(cel+2)*75)%255,150));
|
||||||
@@ -48,152 +42,82 @@ AD_Graphics::AD_Graphics(AD_Core *adcore, QWidget *parent) : QGraphicsView(paren
|
|||||||
p.drawRect(i*cellSize,j*cellSize,cellSize,cellSize);
|
p.drawRect(i*cellSize,j*cellSize,cellSize,cellSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
p.end();
|
||||||
startTimer(50);
|
scene->setSceneRect(mapimg->rect());
|
||||||
show();
|
scene->setBackgroundBrush(*mapimg);
|
||||||
|
setCacheMode(QGraphicsView::CacheBackground);
|
||||||
|
resize(mapimg->size());
|
||||||
|
// startTimer(50);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
AD_Graphics::~AD_Graphics()
|
AD_Graphics::~AD_Graphics()
|
||||||
{
|
{
|
||||||
//delete gsw;
|
|
||||||
delete scene;
|
delete scene;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AD_Graphics::mouseDoubleClickEvent(QMouseEvent *)
|
|
||||||
{
|
|
||||||
core->nextWave();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void AD_Graphics::mousePressEvent(QMouseEvent *event)
|
void AD_Graphics::mousePressEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
|
scene->clearSelection();
|
||||||
if (event->button() == Qt::LeftButton)
|
if (event->button() == Qt::LeftButton)
|
||||||
core->adtowers->addTower(0,1,(QPointF(event->pos())/cellSize-QPointF(0.5,0.5)).toPoint());
|
{
|
||||||
|
if (m_building) emit add_tow((QPointF(event->pos())/cellSize).toPoint());
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QList<QGraphicsItem*> list = scene->items(event->pos(), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder);
|
||||||
|
ADItem * al = 0;
|
||||||
|
foreach(QGraphicsItem* x, list)
|
||||||
|
{
|
||||||
|
ADItem * i = qgraphicsitem_cast<ADItem*>(x);
|
||||||
|
if (i->itemType() == ADItem::Tower)
|
||||||
|
{
|
||||||
|
i->setSelected(true);
|
||||||
|
emit tower_select(i->tid());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (i->itemType() == ADItem::Alien)
|
||||||
|
{
|
||||||
|
al = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (al != 0)
|
||||||
|
{
|
||||||
|
al->setSelected(true);
|
||||||
|
emit alien_select(al->id());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (event->button() == Qt::RightButton)
|
if (event->button() == Qt::RightButton)
|
||||||
core->adtowers->addTower(0,0,(QPointF(event->pos())/cellSize-QPointF(0.5,0.5)).toPoint());
|
emit cancel();
|
||||||
if (event->button() == Qt::MidButton)
|
|
||||||
core->adtowers->delTower((QPointF(event->pos())/cellSize-QPointF(0.5,0.5)).toPoint());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AD_Graphics::timerEvent(QTimerEvent * )
|
//void AD_Graphics::timerEvent(QTimerEvent * )
|
||||||
{
|
//{
|
||||||
//qDebug() << data->curAliens.size();
|
// scene->update();
|
||||||
draw();
|
//}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void AD_Graphics::drawBackground(QPainter * p, const QRectF & )
|
void AD_Graphics::drawBackground(QPainter * p, const QRectF & )
|
||||||
{
|
{
|
||||||
p->drawImage(0,0,*mapimg);
|
p->drawImage(0,0,*mapimg);
|
||||||
// for (int i=0; i<data->map->cells().size(); i++) {
|
|
||||||
// for (int j=0; j<data->map->cells().at(i).size(); j++) {
|
|
||||||
// QPen pen;
|
|
||||||
// QBrush brush;
|
|
||||||
// pen.setColor(Qt::white);
|
|
||||||
// brush.setColor(Qt::white);
|
|
||||||
// brush.setStyle(Qt::SolidPattern);
|
|
||||||
// int cel = data->map->cells().at(i).at(j);
|
|
||||||
// if (cel == Map::Wall)
|
|
||||||
// {
|
|
||||||
// pen.setColor(Qt::black);
|
|
||||||
// brush.setColor(Qt::black);
|
|
||||||
// }
|
|
||||||
// // if (cel <= Map::PlayerTower && cel !=Map::Wall) {
|
|
||||||
// // pen.setColor(QColor(cel%255,(cel*100)%255,(cel+100)%255));
|
|
||||||
// // brush.setColor(QColor(cel%255,(cel*100)%255,(cel+100)%255));
|
|
||||||
// // }
|
|
||||||
// // if (cel >= Map::PlayerAlien) {
|
|
||||||
// // pen.setColor(Qt::yellow);
|
|
||||||
// // brush.setColor(Qt::yellow);
|
|
||||||
// // }
|
|
||||||
// if (cel >= Map::Free || (cel <= Map::PlayerTower && cel !=Map::Wall))
|
|
||||||
// {
|
|
||||||
// pen.setColor(QColor(qAbs(cel+2)*345%255,(qAbs(cel+2)*721)%255,(qAbs(cel+2)*75)%255,50));
|
|
||||||
// brush.setColor(QColor(qAbs(cel+2)*345%255,(qAbs(cel+2)*721)%255,(qAbs(cel+2)*75)%255,50));
|
|
||||||
// }
|
|
||||||
// p->setPen(pen);
|
|
||||||
// p->setBrush(brush);
|
|
||||||
// p->drawRect(i*cellSize,j*cellSize,cellSize,cellSize);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
//qDebug() << "t:" << data->curTowers.size();
|
|
||||||
for (QHash<QPoint, TowerType>::iterator i = data->curTowers.begin(); i != data->curTowers.end(); ++i)
|
|
||||||
{
|
|
||||||
//qDebug() << "draw alien";
|
|
||||||
//p->rotate(-90);
|
|
||||||
//p->scale(cellSize, cellSize);
|
|
||||||
//p->translate(rec.width()/2, rec.height()/2);
|
|
||||||
//p->rotate(-90);
|
|
||||||
//p->translate(-rec.height()/2, -rec.width()/2);
|
|
||||||
p->translate((*i).pos * cellSize+QPointF(20,20));
|
|
||||||
p->rotate((*i).angle);
|
|
||||||
//p->setPen(QColor(0,0,0,0));
|
|
||||||
//p->setBrush(brush);
|
|
||||||
//p->drawRect(QRect(-10,-10,20,20));
|
|
||||||
if ((*i).build < data->players.at((*i).PlayerId)->srcTowers.at((*i).src).buildTime)
|
|
||||||
{
|
|
||||||
QBrush brush;
|
|
||||||
brush.setColor(Qt::darkRed);
|
|
||||||
brush.setStyle(Qt::DiagCrossPattern);
|
|
||||||
p->setBrush(brush);
|
|
||||||
p->drawRect(-20,-20,40,40);
|
|
||||||
} else {
|
|
||||||
p->drawImage(QRect(-20,-20,40,40), *data->curAnimations.at((*i).imgType).images.at((*i).animIndex));
|
|
||||||
}
|
|
||||||
p->resetTransform();
|
|
||||||
}
|
|
||||||
//qDebug() << "a:" << data->curAliens.size();
|
|
||||||
for (QHash<int, AlienType>::iterator i = data->curAliens.begin(); i != data->curAliens.end(); ++i)
|
|
||||||
{
|
|
||||||
//qDebug() << "draw alien";
|
|
||||||
//p->rotate(-90);
|
|
||||||
//p->scale(cellSize, cellSize);
|
|
||||||
//p->translate(rec.width()/2, rec.height()/2);
|
|
||||||
//p->rotate(-90);
|
|
||||||
//p->translate(-rec.height()/2, -rec.width()/2);
|
|
||||||
p->translate((*i).pos * cellSize+QPointF(10,10));
|
|
||||||
p->rotate((*i).angle);
|
|
||||||
p->drawImage(QRect(-20,-20,40,40), *data->curAnimations.at((*i).imgType).images.at((*i).animIndex));
|
|
||||||
(*i).animIndex++;
|
|
||||||
if ((*i).animIndex >= data->curAnimations.at((*i).imgType).images.size())
|
|
||||||
(*i).animIndex = 0;
|
|
||||||
p->resetTransform();
|
|
||||||
}
|
|
||||||
//qDebug() << "s:" << data->curSplashes.size();
|
|
||||||
for (QHash<int, SplashType>::iterator i = data->curSplashes.begin(); i != data->curSplashes.end(); ++i)
|
|
||||||
{
|
|
||||||
//qDebug() << "draw alien";
|
|
||||||
//p->rotate(-90);
|
|
||||||
//p->scale(cellSize, cellSize);
|
|
||||||
//p->translate(rec.width()/2, rec.height()/2);
|
|
||||||
//p->rotate(-90);
|
|
||||||
//p->translate(-rec.height()/2, -rec.width()/2);
|
|
||||||
//QBrush brush;
|
|
||||||
//brush.setColor(Qt::red);
|
|
||||||
//brush.setStyle(Qt::SolidPattern);
|
|
||||||
p->translate((*i).pos * cellSize);
|
|
||||||
p->rotate((*i).angle);
|
|
||||||
//p->setBrush(brush);
|
|
||||||
//p->setPen(QColor(0,0,0,0));
|
|
||||||
//p->drawEllipse(QPoint(),5,5);
|
|
||||||
QImage img;
|
|
||||||
img = *data->curAnimations.at((*i).imgType).images.at((*i).animIndex);
|
|
||||||
p->drawImage(QPoint(-(img.size().width()/2),-(img.size().height()/2)), img);
|
|
||||||
(*i).animIndex++;
|
|
||||||
if ((*i).animIndex >= data->curAnimations.at((*i).imgType).images.size())
|
|
||||||
(*i).animIndex = 0;
|
|
||||||
p->resetTransform();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AD_Graphics::draw()
|
void AD_Graphics::drawForeground(QPainter *p, const QRectF &rect)
|
||||||
{
|
{
|
||||||
scene->update();
|
QList <QGraphicsItem *> l = scene->items();
|
||||||
//resetCachedContent();
|
foreach(QGraphicsItem * g,l)
|
||||||
//repaint();
|
{
|
||||||
|
ADItem * i = qgraphicsitem_cast<ADItem *>(g);
|
||||||
|
if (i->isBarVisible())
|
||||||
|
{
|
||||||
|
p->setPen(Qt::black);
|
||||||
|
p->setBrush(QBrush(QColor(qRound(255*(1-i->value())),qRound(255*i->value()),0)));
|
||||||
|
p->drawRect(i->pos().x()-cellSize,i->pos().y()-cellSize*1.25,cellSize*2*i->value(),cellSize/4);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,29 +7,49 @@
|
|||||||
|
|
||||||
#include "adcore.h"
|
#include "adcore.h"
|
||||||
|
|
||||||
const float cellSize = 20.f;
|
|
||||||
|
|
||||||
class AD_Graphics: public QGraphicsView
|
class AD_Graphics: public QGraphicsView
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(bool building READ building WRITE setBuilding)
|
||||||
public:
|
public:
|
||||||
explicit AD_Graphics(AD_Core * core, QWidget * parent = 0);
|
explicit AD_Graphics(AD_Core * core, QWidget * parent = 0);
|
||||||
~AD_Graphics();
|
~AD_Graphics();
|
||||||
|
|
||||||
|
bool building() const
|
||||||
|
{
|
||||||
|
return m_building;
|
||||||
|
}
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void setBuilding(bool arg)
|
||||||
|
{
|
||||||
|
m_building = arg;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void draw();
|
void drawBackground(QPainter * p, const QRectF &);
|
||||||
void drawBackground(QPainter * p, const QRectF &);
|
void drawForeground(QPainter *painter, const QRectF &rect);
|
||||||
void mouseDoubleClickEvent(QMouseEvent *);
|
|
||||||
void mousePressEvent(QMouseEvent *event);
|
void mousePressEvent(QMouseEvent *event);
|
||||||
|
|
||||||
QGraphicsScene * scene;
|
QGraphicsScene * scene;
|
||||||
Game_Data * data;
|
|
||||||
AD_Core * core;
|
AD_Core * core;
|
||||||
QImage * mapimg;
|
QImage * mapimg;
|
||||||
//QGraphicsWidget * gsw;
|
Game_Data * data;
|
||||||
|
|
||||||
|
bool m_building;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void timerEvent(QTimerEvent * );
|
|
||||||
|
// void timerEvent(QTimerEvent * );
|
||||||
|
signals:
|
||||||
|
|
||||||
|
void cancel();
|
||||||
|
void add_tow(QPoint pnt);
|
||||||
|
void tower_select(QPoint id);
|
||||||
|
void alien_select(int id);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // AD_GRAPHICS_H
|
#endif // AD_GRAPHICS_H
|
||||||
|
|||||||
52
adcore.cpp
52
adcore.cpp
@@ -4,36 +4,20 @@ AD_Core::AD_Core(QObject *parent) :
|
|||||||
QThread(parent)
|
QThread(parent)
|
||||||
{
|
{
|
||||||
step = 0;
|
step = 0;
|
||||||
//admap = new Map(1);
|
|
||||||
//addata = new Game_Data(admap);
|
|
||||||
Loader * adloader = new Loader();
|
Loader * adloader = new Loader();
|
||||||
adloader->load("data2.xml");
|
adloader->load("data2.xml");
|
||||||
//adloader->save("data2.xml");
|
|
||||||
addata = adloader->loadlevel(1);
|
addata = adloader->loadlevel(1);
|
||||||
delete adloader;
|
delete adloader;
|
||||||
if (addata != 0) qDebug("Sucsess");
|
if (addata != 0) qDebug("Sucsess");
|
||||||
else qFatal("Error");
|
else qFatal("Error");
|
||||||
//Player * pl1 = new Player(0);
|
|
||||||
// Player * pl2 = new Player(0);
|
|
||||||
//addata->players.push_back(pl1);
|
|
||||||
// addata->players.push_back(pl2);
|
|
||||||
adaliens = new Aliens(addata);
|
|
||||||
adtowers = new Towers(addata);
|
adtowers = new Towers(addata);
|
||||||
adsplashes = new Splashes(addata);
|
adsplashes = new Splashes(addata);
|
||||||
connect(addata->map,SIGNAL(recreateAlienPath(bool*)),adaliens,SLOT(retrace(bool*)));
|
connect(addata->map,SIGNAL(recreateAlienPath(bool*)),addata->aliens,SLOT(retrace(bool*)));
|
||||||
connect(adtowers,SIGNAL(shot(QPoint)),adsplashes,SLOT(addSplash(QPoint)));
|
connect(adtowers,SIGNAL(shot(TowerType)),adsplashes,SLOT(addSplash(TowerType)));
|
||||||
// adaliens->addAlien(0);
|
connect(adsplashes,SIGNAL(killAlien(int,int)),this,SLOT(killAlien(int,int)));
|
||||||
// adaliens->AddAlien(0);
|
|
||||||
// adaliens->AddAlien(0);
|
|
||||||
//adtowers->addTower(0,2,QPoint(15,1));
|
|
||||||
for (int i=0; i<20;i++)
|
|
||||||
// adtowers->addTower(0,1,QPoint(8,20-i));
|
|
||||||
// for (int i=0; i<20; i++)
|
|
||||||
// adtowers->addTower(0,0,QPoint(12,i));
|
|
||||||
// for (int i=0; i<20;i++)
|
|
||||||
// adtowers->addTower(0,1,QPoint(16,20-i));
|
|
||||||
waveInProgress = false;
|
waveInProgress = false;
|
||||||
startTimer(20);
|
waveEnd = false;
|
||||||
|
startTimer(50);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -41,7 +25,7 @@ void AD_Core::next()
|
|||||||
{
|
{
|
||||||
adtowers->update();
|
adtowers->update();
|
||||||
adsplashes->update();
|
adsplashes->update();
|
||||||
adaliens->update();
|
addata->aliens->update();
|
||||||
waveProcessing();
|
waveProcessing();
|
||||||
step++;
|
step++;
|
||||||
}
|
}
|
||||||
@@ -58,6 +42,7 @@ void AD_Core::nextWave()
|
|||||||
if (waveInProgress) return;
|
if (waveInProgress) return;
|
||||||
if (addata->curWave >= addata->waves.size()) {
|
if (addata->curWave >= addata->waves.size()) {
|
||||||
qDebug("level finished");
|
qDebug("level finished");
|
||||||
|
waveEnd = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//wavetime = addata->waves.at(addata->curWave).timeout;
|
//wavetime = addata->waves.at(addata->curWave).timeout;
|
||||||
@@ -69,13 +54,19 @@ void AD_Core::nextWave()
|
|||||||
|
|
||||||
void AD_Core::waveProcessing()
|
void AD_Core::waveProcessing()
|
||||||
{
|
{
|
||||||
|
if (addata->aliens->curAliens.isEmpty() && waveEnd)
|
||||||
|
{
|
||||||
|
addata->players.at(0)->money += addata->waves.at(addata->curWave-1).prise;
|
||||||
|
waveEnd = false;
|
||||||
|
}
|
||||||
if (!waveInProgress) return;
|
if (!waveInProgress) return;
|
||||||
if (wavetime <= 0) {
|
if (wavetime <= 0) {
|
||||||
for (int i=0; i<addata->waves.at(addata->curWave).counts.size(); i++) {
|
for (int i=0; i<addata->waves.at(addata->curWave).counts.size(); i++) {
|
||||||
if (addata->waves.at(addata->curWave).counts.at(i) > 0) {
|
if (addata->waves.at(addata->curWave).counts.at(i) > 0) {
|
||||||
adaliens->addAlien(addata->waves.at(addata->curWave).types.at(i));
|
addata->aliens->addAlien(addata->waves.at(addata->curWave).types.at(i));
|
||||||
addata->waves[addata->curWave].counts[i]--;
|
addata->waves[addata->curWave].counts[i]--;
|
||||||
wavetime = addata->waves.at(addata->curWave).timeout;
|
wavetime = addata->waves.at(addata->curWave).timeout;
|
||||||
|
waveEnd = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -85,3 +76,18 @@ void AD_Core::waveProcessing()
|
|||||||
wavetime--;
|
wavetime--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AD_Core::killAlien(int playerId, int alienId)
|
||||||
|
{
|
||||||
|
addata->players.at(playerId)->money += addata->aliens->curAliens[alienId].src->prise;
|
||||||
|
addata->aliens->delAlien(alienId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AD_Core::setScene(QGraphicsScene *scene)
|
||||||
|
{
|
||||||
|
addata->aliens->setScene(scene);
|
||||||
|
adtowers->setScene(scene);
|
||||||
|
adsplashes->setScene(scene);
|
||||||
|
}
|
||||||
|
|||||||
18
adcore.h
18
adcore.h
@@ -14,22 +14,26 @@ Q_OBJECT
|
|||||||
public:
|
public:
|
||||||
explicit AD_Core(QObject *parent = 0);
|
explicit AD_Core(QObject *parent = 0);
|
||||||
Game_Data * addata;
|
Game_Data * addata;
|
||||||
Aliens * adaliens;
|
|
||||||
Towers * adtowers;
|
Towers * adtowers;
|
||||||
Splashes * adsplashes;
|
Splashes * adsplashes;
|
||||||
//Loader * adloader;
|
long int step;
|
||||||
unsigned int step;
|
|
||||||
|
void setScene(QGraphicsScene * scene);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void next();
|
||||||
|
void nextWave();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void timerEvent(QTimerEvent * );
|
void timerEvent(QTimerEvent * );
|
||||||
void waveProcessing();
|
void waveProcessing();
|
||||||
|
|
||||||
bool waveInProgress;
|
bool waveInProgress;
|
||||||
|
bool waveEnd;
|
||||||
int wavetime;
|
int wavetime;
|
||||||
public slots:
|
|
||||||
void next();
|
private slots:
|
||||||
void nextWave();
|
void killAlien(int playerId, int alienId);
|
||||||
//void addTower(QPoint pos) {adtowers->addTower(0, 0, pos);};
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
};
|
};
|
||||||
|
|||||||
74
aditem.cpp
Normal file
74
aditem.cpp
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
#include "aditem.h"
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
|
||||||
|
ADItem::ADItem(int id, adType type, QList<QImage *> *images_, QRectF geometry, QGraphicsItem *parent) :
|
||||||
|
QGraphicsItem(parent)
|
||||||
|
{
|
||||||
|
m_id = id;
|
||||||
|
m_type = type;
|
||||||
|
anim = 0;
|
||||||
|
images = images_;
|
||||||
|
animcount = images->size();
|
||||||
|
QSize size = images->at(0)->size();
|
||||||
|
staticImage = false;
|
||||||
|
if (animcount == 1) staticImage = true;
|
||||||
|
if (geometry.isNull()) br = QRect(QPoint(-(size.width()/2), -(size.height()/2)), size);
|
||||||
|
else br = geometry;
|
||||||
|
if (type == Alien)
|
||||||
|
{
|
||||||
|
setFlag(QGraphicsItem::ItemIsSelectable);
|
||||||
|
barValue = 1.f;
|
||||||
|
hasBar = true;
|
||||||
|
} else hasBar = false;
|
||||||
|
if (staticImage)
|
||||||
|
{
|
||||||
|
setCacheMode(QGraphicsItem::ItemCoordinateCache);
|
||||||
|
img = (*images)[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ADItem::ADItem(QPoint id, QImage *image, QRectF geometry, QGraphicsItem *parent) :
|
||||||
|
QGraphicsItem(parent)
|
||||||
|
{
|
||||||
|
hasBar = true;
|
||||||
|
barValue = 0.f;
|
||||||
|
m_type = Tower;
|
||||||
|
m_tid = id;
|
||||||
|
img = image;
|
||||||
|
QSize size = img->size();
|
||||||
|
if (geometry.isNull()) br = QRect(QPoint(-(size.width()/2),-(size.height()/2)),size);
|
||||||
|
else br = geometry;
|
||||||
|
staticImage = true;
|
||||||
|
setFlag(QGraphicsItem::ItemIsSelectable);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ADItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
|
||||||
|
{
|
||||||
|
if (staticImage)
|
||||||
|
painter->drawImage(br,*img);
|
||||||
|
else painter->drawImage(br, *(images->at(qRound(anim))));
|
||||||
|
if (isSelected())
|
||||||
|
{
|
||||||
|
painter->setPen(Qt::red);
|
||||||
|
painter->drawRect(br);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QRectF ADItem::boundingRect() const
|
||||||
|
{
|
||||||
|
return br;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ADItem::next(float step)
|
||||||
|
{
|
||||||
|
if (staticImage) return;
|
||||||
|
anim+=step;
|
||||||
|
if (qRound(anim) >= animcount)
|
||||||
|
anim = 0;
|
||||||
|
}
|
||||||
|
|
||||||
38
aditem.h
Normal file
38
aditem.h
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#ifndef ADITEM_H
|
||||||
|
#define ADITEM_H
|
||||||
|
|
||||||
|
#include <QGraphicsItem>
|
||||||
|
|
||||||
|
class ADItem : public QGraphicsItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum adType {Alien, Tower, Splash};
|
||||||
|
explicit ADItem(int id, adType type, QList<QImage *> *images, QRectF geometry = QRectF(), QGraphicsItem *parent = 0);
|
||||||
|
explicit ADItem(QPoint id, QImage * image, QRectF geometry = QRectF(), QGraphicsItem *parent = 0);
|
||||||
|
void setBarValue(float val) {barValue = val;}
|
||||||
|
void setBarVisible(bool visible = true) {hasBar = visible;}
|
||||||
|
void hideBar() {hasBar = false; setCacheMode(QGraphicsItem::ItemCoordinateCache);}
|
||||||
|
float value() {return barValue;}
|
||||||
|
bool isBarVisible() {return hasBar;}
|
||||||
|
void next(float step);
|
||||||
|
QPoint tid() {return m_tid;}
|
||||||
|
int id() {return m_id;}
|
||||||
|
adType itemType() {return m_type;}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
|
QRectF boundingRect() const;
|
||||||
|
QList<QImage *> * images;
|
||||||
|
QImage * img;
|
||||||
|
float anim;
|
||||||
|
adType m_type;
|
||||||
|
int m_id;
|
||||||
|
QPoint m_tid;
|
||||||
|
int animcount;
|
||||||
|
bool staticImage;
|
||||||
|
bool hasBar;
|
||||||
|
float barValue;
|
||||||
|
QRectF br;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ADITEM_H
|
||||||
@@ -7,7 +7,11 @@ HEADERS += base_types.h \
|
|||||||
adcore.h \
|
adcore.h \
|
||||||
player.h \
|
player.h \
|
||||||
loader.h \
|
loader.h \
|
||||||
ad_graphics.h
|
ad_graphics.h \
|
||||||
|
form.h \
|
||||||
|
aditem.h \
|
||||||
|
touchbuttframe.h \
|
||||||
|
touch_butt.h
|
||||||
SOURCES += map.cpp \
|
SOURCES += map.cpp \
|
||||||
game_data.cpp \
|
game_data.cpp \
|
||||||
aliens.cpp \
|
aliens.cpp \
|
||||||
@@ -17,7 +21,11 @@ SOURCES += map.cpp \
|
|||||||
adcore.cpp \
|
adcore.cpp \
|
||||||
player.cpp \
|
player.cpp \
|
||||||
loader.cpp \
|
loader.cpp \
|
||||||
ad_graphics.cpp
|
ad_graphics.cpp \
|
||||||
|
form.cpp \
|
||||||
|
aditem.cpp \
|
||||||
|
touchbuttframe.cpp \
|
||||||
|
touch_butt.cpp
|
||||||
RESOURCES += images.qrc
|
RESOURCES += images.qrc
|
||||||
OTHER_FILES += schema.xml \
|
OTHER_FILES += schema.xml \
|
||||||
data2.xml
|
data2.xml
|
||||||
@@ -27,3 +35,6 @@ QT += core \
|
|||||||
opengl \
|
opengl \
|
||||||
xml \
|
xml \
|
||||||
xmlpatterns
|
xmlpatterns
|
||||||
|
|
||||||
|
FORMS += \
|
||||||
|
form.ui
|
||||||
|
|||||||
@@ -1,243 +1,184 @@
|
|||||||
<!DOCTYPE QtCreatorProject>
|
<!DOCTYPE QtCreatorProject>
|
||||||
<qtcreator>
|
<qtcreator>
|
||||||
<data>
|
<data>
|
||||||
<variable>RunConfiguration0-BaseEnvironmentBase</variable>
|
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||||
<value type="int">2</value>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>RunConfiguration0-CommandLineArguments</variable>
|
|
||||||
<valuelist type="QVariantList"/>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>RunConfiguration0-ProFile</variable>
|
|
||||||
<value type="QString">aliendefender.pro</value>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>RunConfiguration0-RunConfiguration.name</variable>
|
|
||||||
<value type="QString">aliendefender</value>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>RunConfiguration0-UseDyldImageSuffix</variable>
|
|
||||||
<value type="bool">false</value>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>RunConfiguration0-UseTerminal</variable>
|
|
||||||
<value type="bool">false</value>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>RunConfiguration0-UserEnvironmentChanges</variable>
|
|
||||||
<valuelist type="QVariantList"/>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>RunConfiguration0-UserSetName</variable>
|
|
||||||
<value type="bool">false</value>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>RunConfiguration0-UserSetWorkingDirectory</variable>
|
|
||||||
<value type="bool">false</value>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>RunConfiguration0-UserWorkingDirectory</variable>
|
|
||||||
<value type="QString"></value>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>RunConfiguration0-type</variable>
|
|
||||||
<value type="QString">Qt4ProjectManager.Qt4RunConfiguration</value>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>activeRunConfiguration</variable>
|
|
||||||
<value type="int">0</value>
|
<value type="int">0</value>
|
||||||
</data>
|
</data>
|
||||||
<data>
|
<data>
|
||||||
<variable>activebuildconfiguration</variable>
|
<variable>ProjectExplorer.Project.EditorSettings</variable>
|
||||||
<value type="QString">Debug</value>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>buildConfiguration-Debug</variable>
|
|
||||||
<valuemap type="QVariantMap">
|
<valuemap type="QVariantMap">
|
||||||
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
|
<value key="EditorConfiguration.AutoIndent" type="bool">true</value>
|
||||||
<value key="QtVersionId" type="int">0</value>
|
<value key="EditorConfiguration.AutoSpacesForTabs" type="bool">false</value>
|
||||||
<value key="ToolChain" type="int">0</value>
|
<value key="EditorConfiguration.Codec" type="QByteArray">System</value>
|
||||||
<value key="addQDumper" type=""></value>
|
<value key="EditorConfiguration.DoubleIndentBlocks" type="bool">false</value>
|
||||||
<value key="buildConfiguration" type="int">2</value>
|
<value key="EditorConfiguration.IndentBraces" type="bool">false</value>
|
||||||
|
<value key="EditorConfiguration.IndentSize" type="int">4</value>
|
||||||
|
<value key="EditorConfiguration.MouseNavigation" type="bool">true</value>
|
||||||
|
<value key="EditorConfiguration.PaddingMode" type="int">1</value>
|
||||||
|
<value key="EditorConfiguration.ScrollWheelZooming" type="bool">true</value>
|
||||||
|
<value key="EditorConfiguration.SmartBackspace" type="bool">false</value>
|
||||||
|
<value key="EditorConfiguration.SpacesForTabs" type="bool">false</value>
|
||||||
|
<value key="EditorConfiguration.TabKeyBehavior" type="int">0</value>
|
||||||
|
<value key="EditorConfiguration.TabSize" type="int">4</value>
|
||||||
|
<value key="EditorConfiguration.UseGlobal" type="bool">true</value>
|
||||||
|
<value key="EditorConfiguration.Utf8BomBehavior" type="int">1</value>
|
||||||
|
<value key="EditorConfiguration.addFinalNewLine" type="bool">true</value>
|
||||||
|
<value key="EditorConfiguration.cleanIndentation" type="bool">true</value>
|
||||||
|
<value key="EditorConfiguration.cleanWhitespace" type="bool">true</value>
|
||||||
|
<value key="EditorConfiguration.inEntireDocument" type="bool">false</value>
|
||||||
</valuemap>
|
</valuemap>
|
||||||
</data>
|
</data>
|
||||||
<data>
|
<data>
|
||||||
<variable>buildConfiguration-Release</variable>
|
<variable>ProjectExplorer.Project.Target.0</variable>
|
||||||
<valuemap type="QVariantMap">
|
<valuemap type="QVariantMap">
|
||||||
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value>
|
<value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString"></value>
|
||||||
<value key="QtVersionId" type="int">0</value>
|
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
|
||||||
<value key="addQDumper" type=""></value>
|
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Target.DesktopTarget</value>
|
||||||
<value key="buildConfiguration" type="int">0</value>
|
<value key="ProjectExplorer.Target.ActiveBuildConfiguration" type="int">0</value>
|
||||||
|
<value key="ProjectExplorer.Target.ActiveDeployConfiguration" type="int">0</value>
|
||||||
|
<value key="ProjectExplorer.Target.ActiveRunConfiguration" type="int">0</value>
|
||||||
|
<valuemap key="ProjectExplorer.Target.BuildConfiguration.0" type="QVariantMap">
|
||||||
|
<value key="ProjectExplorer.BuildCOnfiguration.ToolChain" type="QString">ProjectExplorer.ToolChain.Mingw:D:/Qt/2010.04/mingw/bin/g++.exe.x86-windows-msys-pe-32bit.C:/Qt/qtcreator-2.2.0/pythongdb/gdb-i686-pc-mingw32.exe</value>
|
||||||
|
<valuemap key="ProjectExplorer.BuildConfiguration.BuildStepList.0" type="QVariantMap">
|
||||||
|
<valuemap key="ProjectExplorer.BuildStepList.Step.0" type="QVariantMap">
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">qmake</value>
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">QtProjectManager.QMakeBuildStep</value>
|
||||||
|
<value key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary" type="bool">false</value>
|
||||||
|
<value key="QtProjectManager.QMakeBuildStep.QMakeArguments" type="QString"></value>
|
||||||
|
<value key="QtProjectManager.QMakeBuildStep.QMakeForced" type="bool">false</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap key="ProjectExplorer.BuildStepList.Step.1" type="QVariantMap">
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Сборка</value>
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
|
||||||
|
<value key="Qt4ProjectManager.MakeStep.Clean" type="bool">false</value>
|
||||||
|
<value key="Qt4ProjectManager.MakeStep.MakeArguments" type="QString"></value>
|
||||||
|
<value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
|
||||||
|
</valuemap>
|
||||||
|
<value key="ProjectExplorer.BuildStepList.StepsCount" type="int">2</value>
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Build</value>
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Build</value>
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">ProjectExplorer.BuildSteps.Build</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap key="ProjectExplorer.BuildConfiguration.BuildStepList.1" type="QVariantMap">
|
||||||
|
<valuemap key="ProjectExplorer.BuildStepList.Step.0" type="QVariantMap">
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Сборка</value>
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
|
||||||
|
<value key="Qt4ProjectManager.MakeStep.Clean" type="bool">true</value>
|
||||||
|
<value key="Qt4ProjectManager.MakeStep.MakeArguments" type="QString">clean</value>
|
||||||
|
<value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
|
||||||
|
</valuemap>
|
||||||
|
<value key="ProjectExplorer.BuildStepList.StepsCount" type="int">1</value>
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Clean</value>
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Clean</value>
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">ProjectExplorer.BuildSteps.Clean</value>
|
||||||
|
</valuemap>
|
||||||
|
<value key="ProjectExplorer.BuildConfiguration.BuildStepListCount" type="int">2</value>
|
||||||
|
<value key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment" type="bool">false</value>
|
||||||
|
<valuelist key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges" type="QVariantList"/>
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Debug</value>
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Debug</value>
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||||
|
<value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration" type="int">2</value>
|
||||||
|
<value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory" type="QString">D:/Dropbox/My Dropbox/projects/aliendefender-build-desktop</value>
|
||||||
|
<value key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId" type="int">7</value>
|
||||||
|
<value key="Qt4ProjectManager.Qt4BuildConfiguration.ToolChain" type="QString">ProjectExplorer.ToolChain.Mingw:D:/Qt/2010.04/mingw/bin/g++.exe.x86-windows-msys-pe-32bit.C:/Qt/qtcreator-2.2.0/pythongdb/gdb-i686-pc-mingw32.exe</value>
|
||||||
|
<value key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild" type="bool">false</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap key="ProjectExplorer.Target.BuildConfiguration.1" type="QVariantMap">
|
||||||
|
<value key="ProjectExplorer.BuildCOnfiguration.ToolChain" type="QString">ProjectExplorer.ToolChain.Mingw:C:/Qt/qtcreator-2.2.0/mingw/bin/gcc.exe.x86-windows-msys-pe-32bit.C:/Qt/qtcreator-2.2.0/pythongdb/gdb-i686-pc-mingw32.exe</value>
|
||||||
|
<valuemap key="ProjectExplorer.BuildConfiguration.BuildStepList.0" type="QVariantMap">
|
||||||
|
<valuemap key="ProjectExplorer.BuildStepList.Step.0" type="QVariantMap">
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">qmake</value>
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">QtProjectManager.QMakeBuildStep</value>
|
||||||
|
<value key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary" type="bool">false</value>
|
||||||
|
<value key="QtProjectManager.QMakeBuildStep.QMakeArguments" type="QString"></value>
|
||||||
|
<value key="QtProjectManager.QMakeBuildStep.QMakeForced" type="bool">false</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap key="ProjectExplorer.BuildStepList.Step.1" type="QVariantMap">
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Сборка</value>
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
|
||||||
|
<value key="Qt4ProjectManager.MakeStep.Clean" type="bool">false</value>
|
||||||
|
<value key="Qt4ProjectManager.MakeStep.MakeArguments" type="QString"></value>
|
||||||
|
<value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
|
||||||
|
</valuemap>
|
||||||
|
<value key="ProjectExplorer.BuildStepList.StepsCount" type="int">2</value>
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Build</value>
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Build</value>
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">ProjectExplorer.BuildSteps.Build</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap key="ProjectExplorer.BuildConfiguration.BuildStepList.1" type="QVariantMap">
|
||||||
|
<valuemap key="ProjectExplorer.BuildStepList.Step.0" type="QVariantMap">
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Сборка</value>
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
|
||||||
|
<value key="Qt4ProjectManager.MakeStep.Clean" type="bool">true</value>
|
||||||
|
<value key="Qt4ProjectManager.MakeStep.MakeArguments" type="QString"></value>
|
||||||
|
<value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
|
||||||
|
</valuemap>
|
||||||
|
<value key="ProjectExplorer.BuildStepList.StepsCount" type="int">1</value>
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Clean</value>
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Clean</value>
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">ProjectExplorer.BuildSteps.Clean</value>
|
||||||
|
</valuemap>
|
||||||
|
<value key="ProjectExplorer.BuildConfiguration.BuildStepListCount" type="int">2</value>
|
||||||
|
<value key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment" type="bool">false</value>
|
||||||
|
<valuelist key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges" type="QVariantList"/>
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Release</value>
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Release</value>
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||||
|
<value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration" type="int">0</value>
|
||||||
|
<value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory" type="QString">D:/Dropbox/My Dropbox/projects/aliendefender-build-desktop</value>
|
||||||
|
<value key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId" type="int">2</value>
|
||||||
|
<value key="Qt4ProjectManager.Qt4BuildConfiguration.ToolChain" type="QString">ProjectExplorer.ToolChain.Mingw:C:/Qt/qtcreator-2.2.0/mingw/bin/gcc.exe.x86-windows-msys-pe-32bit.C:/Qt/qtcreator-2.2.0/pythongdb/gdb-i686-pc-mingw32.exe</value>
|
||||||
|
<value key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild" type="bool">false</value>
|
||||||
|
</valuemap>
|
||||||
|
<value key="ProjectExplorer.Target.BuildConfigurationCount" type="int">2</value>
|
||||||
|
<valuemap key="ProjectExplorer.Target.DeployConfiguration.0" type="QVariantMap">
|
||||||
|
<valuemap key="ProjectExplorer.BuildConfiguration.BuildStepList.0" type="QVariantMap">
|
||||||
|
<value key="ProjectExplorer.BuildStepList.StepsCount" type="int">0</value>
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Установка</value>
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Deploy</value>
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">ProjectExplorer.BuildSteps.Deploy</value>
|
||||||
|
</valuemap>
|
||||||
|
<value key="ProjectExplorer.BuildConfiguration.BuildStepListCount" type="int">1</value>
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Без установки</value>
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Без установки</value>
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">ProjectExplorer.DefaultDeployConfiguration</value>
|
||||||
|
</valuemap>
|
||||||
|
<value key="ProjectExplorer.Target.DeployConfigurationCount" type="int">1</value>
|
||||||
|
<valuemap key="ProjectExplorer.Target.RunConfiguration.0" type="QVariantMap">
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Конфигурация запуска Qt4</value>
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">aliendefender</value>
|
||||||
|
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4RunConfiguration</value>
|
||||||
|
<value key="Qt4ProjectManager.Qt4RunConfiguration.BaseEnvironmentBase" type="int">2</value>
|
||||||
|
<value key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments" type="QString"></value>
|
||||||
|
<value key="Qt4ProjectManager.Qt4RunConfiguration.ProFile" type="QString">aliendefender.pro</value>
|
||||||
|
<value key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix" type="bool">false</value>
|
||||||
|
<value key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal" type="bool">false</value>
|
||||||
|
<valuelist key="Qt4ProjectManager.Qt4RunConfiguration.UserEnvironmentChanges" type="QVariantList"/>
|
||||||
|
<value key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory" type="QString"></value>
|
||||||
|
<value key="RunConfiguration.QmlDebugServerPort" type="uint">3768</value>
|
||||||
|
<value key="RunConfiguration.UseCppDebugger" type="bool">true</value>
|
||||||
|
<value key="RunConfiguration.UseQmlDebugger" type="bool">false</value>
|
||||||
|
</valuemap>
|
||||||
|
<value key="ProjectExplorer.Target.RunConfigurationCount" type="int">1</value>
|
||||||
</valuemap>
|
</valuemap>
|
||||||
</data>
|
</data>
|
||||||
<data>
|
<data>
|
||||||
<variable>buildconfiguration-Debug-buildstep0</variable>
|
<variable>ProjectExplorer.Project.TargetCount</variable>
|
||||||
<valuemap type="QVariantMap">
|
<value type="int">1</value>
|
||||||
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
|
|
||||||
<valuelist key="abstractProcess.Environment" type="QVariantList">
|
|
||||||
<value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-2HAd2azpnh,guid=fd81c6d6610b4c57717ec20c4c90d3de</value>
|
|
||||||
<value type="QString">DEFAULTS_PATH=/usr/share/gconf/gnome.default.path</value>
|
|
||||||
<value type="QString">DESKTOP_SESSION=gnome</value>
|
|
||||||
<value type="QString">DISPLAY=:0.0</value>
|
|
||||||
<value type="QString">GDMSESSION=gnome</value>
|
|
||||||
<value type="QString">GDM_KEYBOARD_LAYOUT=us</value>
|
|
||||||
<value type="QString">GDM_LANG=ru_RU.UTF-8</value>
|
|
||||||
<value type="QString">GNOME_DESKTOP_SESSION_ID=this-is-deprecated</value>
|
|
||||||
<value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-vNW3fv</value>
|
|
||||||
<value type="QString">GTK_MODULES=canberra-gtk-module</value>
|
|
||||||
<value type="QString">HOME=/home/andrey</value>
|
|
||||||
<value type="QString">LANG=ru_RU.UTF-8</value>
|
|
||||||
<value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator:</value>
|
|
||||||
<value type="QString">LOGNAME=andrey</value>
|
|
||||||
<value type="QString">MANDATORY_PATH=/usr/share/gconf/gnome.mandatory.path</value>
|
|
||||||
<value type="QString">ORBIT_SOCKETDIR=/tmp/orbit-andrey</value>
|
|
||||||
<value type="QString">PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games</value>
|
|
||||||
<value type="QString">PWD=/home/andrey</value>
|
|
||||||
<value type="QString">QTDIR=/usr/share/qt4</value>
|
|
||||||
<value type="QString">SESSION_MANAGER=local/buull-eeePC:@/tmp/.ICE-unix/1158,unix/buull-eeePC:/tmp/.ICE-unix/1158</value>
|
|
||||||
<value type="QString">SHELL=/bin/bash</value>
|
|
||||||
<value type="QString">SPEECHD_PORT=6561</value>
|
|
||||||
<value type="QString">SSH_AGENT_PID=1195</value>
|
|
||||||
<value type="QString">SSH_AUTH_SOCK=/tmp/keyring-vNW3fv/ssh</value>
|
|
||||||
<value type="QString">USER=andrey</value>
|
|
||||||
<value type="QString">USERNAME=andrey</value>
|
|
||||||
<value type="QString">XAUTHORITY=/var/run/gdm/auth-for-andrey-Len9P0/database</value>
|
|
||||||
<value type="QString">XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg</value>
|
|
||||||
<value type="QString">XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/</value>
|
|
||||||
<value type="QString">XDG_SESSION_COOKIE=f0649decca52f2beb55c9ea74ad1d028-1284559837.801731-819619931</value>
|
|
||||||
</valuelist>
|
|
||||||
<valuelist key="abstractProcess.arguments" type="QVariantList">
|
|
||||||
<value type="QString">/home/andrey/AD/aliendefender/aliendefender.pro</value>
|
|
||||||
<value type="QString">-spec</value>
|
|
||||||
<value type="QString">linux-g++</value>
|
|
||||||
<value type="QString">-r</value>
|
|
||||||
<value type="QString">CONFIG+=debug</value>
|
|
||||||
</valuelist>
|
|
||||||
<value key="abstractProcess.command" type="QString">/usr/bin/qmake-qt4</value>
|
|
||||||
<value key="abstractProcess.enabled" type="bool">false</value>
|
|
||||||
<value key="abstractProcess.workingDirectory" type="QString">/home/andrey/AD/aliendefender</value>
|
|
||||||
</valuemap>
|
|
||||||
</data>
|
</data>
|
||||||
<data>
|
<data>
|
||||||
<variable>buildconfiguration-Debug-buildstep1</variable>
|
<variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
|
||||||
<valuemap type="QVariantMap">
|
<value type="QString">{00000000-0000-0000-0000-000000000000}</value>
|
||||||
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
|
|
||||||
<valuelist key="abstractProcess.Environment" type="QVariantList">
|
|
||||||
<value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-2HAd2azpnh,guid=fd81c6d6610b4c57717ec20c4c90d3de</value>
|
|
||||||
<value type="QString">DEFAULTS_PATH=/usr/share/gconf/gnome.default.path</value>
|
|
||||||
<value type="QString">DESKTOP_SESSION=gnome</value>
|
|
||||||
<value type="QString">DISPLAY=:0.0</value>
|
|
||||||
<value type="QString">GDMSESSION=gnome</value>
|
|
||||||
<value type="QString">GDM_KEYBOARD_LAYOUT=us</value>
|
|
||||||
<value type="QString">GDM_LANG=ru_RU.UTF-8</value>
|
|
||||||
<value type="QString">GNOME_DESKTOP_SESSION_ID=this-is-deprecated</value>
|
|
||||||
<value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-vNW3fv</value>
|
|
||||||
<value type="QString">GTK_MODULES=canberra-gtk-module</value>
|
|
||||||
<value type="QString">HOME=/home/andrey</value>
|
|
||||||
<value type="QString">LANG=ru_RU.UTF-8</value>
|
|
||||||
<value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator:</value>
|
|
||||||
<value type="QString">LOGNAME=andrey</value>
|
|
||||||
<value type="QString">MANDATORY_PATH=/usr/share/gconf/gnome.mandatory.path</value>
|
|
||||||
<value type="QString">ORBIT_SOCKETDIR=/tmp/orbit-andrey</value>
|
|
||||||
<value type="QString">PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games</value>
|
|
||||||
<value type="QString">PWD=/home/andrey</value>
|
|
||||||
<value type="QString">QTDIR=/usr/share/qt4</value>
|
|
||||||
<value type="QString">SESSION_MANAGER=local/buull-eeePC:@/tmp/.ICE-unix/1158,unix/buull-eeePC:/tmp/.ICE-unix/1158</value>
|
|
||||||
<value type="QString">SHELL=/bin/bash</value>
|
|
||||||
<value type="QString">SPEECHD_PORT=6561</value>
|
|
||||||
<value type="QString">SSH_AGENT_PID=1195</value>
|
|
||||||
<value type="QString">SSH_AUTH_SOCK=/tmp/keyring-vNW3fv/ssh</value>
|
|
||||||
<value type="QString">USER=andrey</value>
|
|
||||||
<value type="QString">USERNAME=andrey</value>
|
|
||||||
<value type="QString">XAUTHORITY=/var/run/gdm/auth-for-andrey-Len9P0/database</value>
|
|
||||||
<value type="QString">XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg</value>
|
|
||||||
<value type="QString">XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/</value>
|
|
||||||
<value type="QString">XDG_SESSION_COOKIE=f0649decca52f2beb55c9ea74ad1d028-1284559837.801731-819619931</value>
|
|
||||||
</valuelist>
|
|
||||||
<value key="abstractProcess.IgnoreReturnValue" type="bool">false</value>
|
|
||||||
<valuelist key="abstractProcess.arguments" type="QVariantList">
|
|
||||||
<value type="QString">-w</value>
|
|
||||||
</valuelist>
|
|
||||||
<value key="abstractProcess.command" type="QString">/usr/bin/make</value>
|
|
||||||
<value key="abstractProcess.enabled" type="bool">true</value>
|
|
||||||
<value key="abstractProcess.workingDirectory" type="QString">/home/andrey/AD/aliendefender</value>
|
|
||||||
</valuemap>
|
|
||||||
</data>
|
</data>
|
||||||
<data>
|
<data>
|
||||||
<variable>buildconfiguration-Debug-cleanstep0</variable>
|
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
|
||||||
<valuemap type="QVariantMap">
|
<value type="int">9</value>
|
||||||
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
|
|
||||||
<value key="cleanConfig" type="bool">true</value>
|
|
||||||
<valuelist key="makeargs" type="QVariantList">
|
|
||||||
<value type="QString">clean</value>
|
|
||||||
</valuelist>
|
|
||||||
</valuemap>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>buildconfiguration-Release-buildstep0</variable>
|
|
||||||
<valuemap type="QVariantMap">
|
|
||||||
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value>
|
|
||||||
</valuemap>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>buildconfiguration-Release-buildstep1</variable>
|
|
||||||
<valuemap type="QVariantMap">
|
|
||||||
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value>
|
|
||||||
</valuemap>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>buildconfiguration-Release-cleanstep0</variable>
|
|
||||||
<valuemap type="QVariantMap">
|
|
||||||
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value>
|
|
||||||
</valuemap>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>buildconfigurations</variable>
|
|
||||||
<valuelist type="QVariantList">
|
|
||||||
<value type="QString">Debug</value>
|
|
||||||
<value type="QString">Release</value>
|
|
||||||
</valuelist>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>buildstep0</variable>
|
|
||||||
<valuemap type="QVariantMap">
|
|
||||||
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString"></value>
|
|
||||||
<value key="mkspec" type="QString"></value>
|
|
||||||
</valuemap>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>buildstep1</variable>
|
|
||||||
<valuemap type="QVariantMap">
|
|
||||||
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString"></value>
|
|
||||||
</valuemap>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>buildsteps</variable>
|
|
||||||
<valuelist type="QVariantList">
|
|
||||||
<value type="QString">trolltech.qt4projectmanager.qmake</value>
|
|
||||||
<value type="QString">trolltech.qt4projectmanager.make</value>
|
|
||||||
</valuelist>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>cleanstep0</variable>
|
|
||||||
<valuemap type="QVariantMap">
|
|
||||||
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString"></value>
|
|
||||||
<value key="clean" type="bool">true</value>
|
|
||||||
</valuemap>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>cleansteps</variable>
|
|
||||||
<valuelist type="QVariantList">
|
|
||||||
<value type="QString">trolltech.qt4projectmanager.make</value>
|
|
||||||
</valuelist>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>defaultFileEncoding</variable>
|
|
||||||
<value type="QByteArray">System</value>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>project</variable>
|
|
||||||
<valuemap type="QVariantMap"/>
|
|
||||||
</data>
|
</data>
|
||||||
</qtcreator>
|
</qtcreator>
|
||||||
|
|||||||
@@ -76,7 +76,7 @@
|
|||||||
<valuemap type="QVariantMap">
|
<valuemap type="QVariantMap">
|
||||||
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
|
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
|
||||||
<valuelist key="abstractProcess.Environment" type="QVariantList">
|
<valuelist key="abstractProcess.Environment" type="QVariantList">
|
||||||
<value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-wExeabp7q4,guid=18815993df3603fdc64a3f6d4c7b5822</value>
|
<value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-2HAd2azpnh,guid=fd81c6d6610b4c57717ec20c4c90d3de</value>
|
||||||
<value type="QString">DEFAULTS_PATH=/usr/share/gconf/gnome.default.path</value>
|
<value type="QString">DEFAULTS_PATH=/usr/share/gconf/gnome.default.path</value>
|
||||||
<value type="QString">DESKTOP_SESSION=gnome</value>
|
<value type="QString">DESKTOP_SESSION=gnome</value>
|
||||||
<value type="QString">DISPLAY=:0.0</value>
|
<value type="QString">DISPLAY=:0.0</value>
|
||||||
@@ -84,7 +84,7 @@
|
|||||||
<value type="QString">GDM_KEYBOARD_LAYOUT=us</value>
|
<value type="QString">GDM_KEYBOARD_LAYOUT=us</value>
|
||||||
<value type="QString">GDM_LANG=ru_RU.UTF-8</value>
|
<value type="QString">GDM_LANG=ru_RU.UTF-8</value>
|
||||||
<value type="QString">GNOME_DESKTOP_SESSION_ID=this-is-deprecated</value>
|
<value type="QString">GNOME_DESKTOP_SESSION_ID=this-is-deprecated</value>
|
||||||
<value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-4vN5uf</value>
|
<value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-vNW3fv</value>
|
||||||
<value type="QString">GTK_MODULES=canberra-gtk-module</value>
|
<value type="QString">GTK_MODULES=canberra-gtk-module</value>
|
||||||
<value type="QString">HOME=/home/andrey</value>
|
<value type="QString">HOME=/home/andrey</value>
|
||||||
<value type="QString">LANG=ru_RU.UTF-8</value>
|
<value type="QString">LANG=ru_RU.UTF-8</value>
|
||||||
@@ -95,17 +95,17 @@
|
|||||||
<value type="QString">PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games</value>
|
<value type="QString">PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games</value>
|
||||||
<value type="QString">PWD=/home/andrey</value>
|
<value type="QString">PWD=/home/andrey</value>
|
||||||
<value type="QString">QTDIR=/usr/share/qt4</value>
|
<value type="QString">QTDIR=/usr/share/qt4</value>
|
||||||
<value type="QString">SESSION_MANAGER=local/buull-eeePC:@/tmp/.ICE-unix/1205,unix/buull-eeePC:/tmp/.ICE-unix/1205</value>
|
<value type="QString">SESSION_MANAGER=local/buull-eeePC:@/tmp/.ICE-unix/1158,unix/buull-eeePC:/tmp/.ICE-unix/1158</value>
|
||||||
<value type="QString">SHELL=/bin/bash</value>
|
<value type="QString">SHELL=/bin/bash</value>
|
||||||
<value type="QString">SPEECHD_PORT=6561</value>
|
<value type="QString">SPEECHD_PORT=6561</value>
|
||||||
<value type="QString">SSH_AGENT_PID=1239</value>
|
<value type="QString">SSH_AGENT_PID=1195</value>
|
||||||
<value type="QString">SSH_AUTH_SOCK=/tmp/keyring-4vN5uf/ssh</value>
|
<value type="QString">SSH_AUTH_SOCK=/tmp/keyring-vNW3fv/ssh</value>
|
||||||
<value type="QString">USER=andrey</value>
|
<value type="QString">USER=andrey</value>
|
||||||
<value type="QString">USERNAME=andrey</value>
|
<value type="QString">USERNAME=andrey</value>
|
||||||
<value type="QString">XAUTHORITY=/var/run/gdm/auth-for-andrey-x9URui/database</value>
|
<value type="QString">XAUTHORITY=/var/run/gdm/auth-for-andrey-Len9P0/database</value>
|
||||||
<value type="QString">XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg</value>
|
<value type="QString">XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg</value>
|
||||||
<value type="QString">XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/</value>
|
<value type="QString">XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/</value>
|
||||||
<value type="QString">XDG_SESSION_COOKIE=f0649decca52f2beb55c9ea74ad1d028-1283151906.338331-318132279</value>
|
<value type="QString">XDG_SESSION_COOKIE=f0649decca52f2beb55c9ea74ad1d028-1284559837.801731-819619931</value>
|
||||||
</valuelist>
|
</valuelist>
|
||||||
<valuelist key="abstractProcess.arguments" type="QVariantList">
|
<valuelist key="abstractProcess.arguments" type="QVariantList">
|
||||||
<value type="QString">/home/andrey/AD/aliendefender/aliendefender.pro</value>
|
<value type="QString">/home/andrey/AD/aliendefender/aliendefender.pro</value>
|
||||||
@@ -124,7 +124,7 @@
|
|||||||
<valuemap type="QVariantMap">
|
<valuemap type="QVariantMap">
|
||||||
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
|
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
|
||||||
<valuelist key="abstractProcess.Environment" type="QVariantList">
|
<valuelist key="abstractProcess.Environment" type="QVariantList">
|
||||||
<value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-wExeabp7q4,guid=18815993df3603fdc64a3f6d4c7b5822</value>
|
<value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-2HAd2azpnh,guid=fd81c6d6610b4c57717ec20c4c90d3de</value>
|
||||||
<value type="QString">DEFAULTS_PATH=/usr/share/gconf/gnome.default.path</value>
|
<value type="QString">DEFAULTS_PATH=/usr/share/gconf/gnome.default.path</value>
|
||||||
<value type="QString">DESKTOP_SESSION=gnome</value>
|
<value type="QString">DESKTOP_SESSION=gnome</value>
|
||||||
<value type="QString">DISPLAY=:0.0</value>
|
<value type="QString">DISPLAY=:0.0</value>
|
||||||
@@ -132,7 +132,7 @@
|
|||||||
<value type="QString">GDM_KEYBOARD_LAYOUT=us</value>
|
<value type="QString">GDM_KEYBOARD_LAYOUT=us</value>
|
||||||
<value type="QString">GDM_LANG=ru_RU.UTF-8</value>
|
<value type="QString">GDM_LANG=ru_RU.UTF-8</value>
|
||||||
<value type="QString">GNOME_DESKTOP_SESSION_ID=this-is-deprecated</value>
|
<value type="QString">GNOME_DESKTOP_SESSION_ID=this-is-deprecated</value>
|
||||||
<value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-4vN5uf</value>
|
<value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-vNW3fv</value>
|
||||||
<value type="QString">GTK_MODULES=canberra-gtk-module</value>
|
<value type="QString">GTK_MODULES=canberra-gtk-module</value>
|
||||||
<value type="QString">HOME=/home/andrey</value>
|
<value type="QString">HOME=/home/andrey</value>
|
||||||
<value type="QString">LANG=ru_RU.UTF-8</value>
|
<value type="QString">LANG=ru_RU.UTF-8</value>
|
||||||
@@ -143,17 +143,17 @@
|
|||||||
<value type="QString">PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games</value>
|
<value type="QString">PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games</value>
|
||||||
<value type="QString">PWD=/home/andrey</value>
|
<value type="QString">PWD=/home/andrey</value>
|
||||||
<value type="QString">QTDIR=/usr/share/qt4</value>
|
<value type="QString">QTDIR=/usr/share/qt4</value>
|
||||||
<value type="QString">SESSION_MANAGER=local/buull-eeePC:@/tmp/.ICE-unix/1205,unix/buull-eeePC:/tmp/.ICE-unix/1205</value>
|
<value type="QString">SESSION_MANAGER=local/buull-eeePC:@/tmp/.ICE-unix/1158,unix/buull-eeePC:/tmp/.ICE-unix/1158</value>
|
||||||
<value type="QString">SHELL=/bin/bash</value>
|
<value type="QString">SHELL=/bin/bash</value>
|
||||||
<value type="QString">SPEECHD_PORT=6561</value>
|
<value type="QString">SPEECHD_PORT=6561</value>
|
||||||
<value type="QString">SSH_AGENT_PID=1239</value>
|
<value type="QString">SSH_AGENT_PID=1195</value>
|
||||||
<value type="QString">SSH_AUTH_SOCK=/tmp/keyring-4vN5uf/ssh</value>
|
<value type="QString">SSH_AUTH_SOCK=/tmp/keyring-vNW3fv/ssh</value>
|
||||||
<value type="QString">USER=andrey</value>
|
<value type="QString">USER=andrey</value>
|
||||||
<value type="QString">USERNAME=andrey</value>
|
<value type="QString">USERNAME=andrey</value>
|
||||||
<value type="QString">XAUTHORITY=/var/run/gdm/auth-for-andrey-x9URui/database</value>
|
<value type="QString">XAUTHORITY=/var/run/gdm/auth-for-andrey-Len9P0/database</value>
|
||||||
<value type="QString">XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg</value>
|
<value type="QString">XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg</value>
|
||||||
<value type="QString">XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/</value>
|
<value type="QString">XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/</value>
|
||||||
<value type="QString">XDG_SESSION_COOKIE=f0649decca52f2beb55c9ea74ad1d028-1283151906.338331-318132279</value>
|
<value type="QString">XDG_SESSION_COOKIE=f0649decca52f2beb55c9ea74ad1d028-1284559837.801731-819619931</value>
|
||||||
</valuelist>
|
</valuelist>
|
||||||
<value key="abstractProcess.IgnoreReturnValue" type="bool">false</value>
|
<value key="abstractProcess.IgnoreReturnValue" type="bool">false</value>
|
||||||
<valuelist key="abstractProcess.arguments" type="QVariantList">
|
<valuelist key="abstractProcess.arguments" type="QVariantList">
|
||||||
@@ -168,46 +168,6 @@
|
|||||||
<variable>buildconfiguration-Debug-cleanstep0</variable>
|
<variable>buildconfiguration-Debug-cleanstep0</variable>
|
||||||
<valuemap type="QVariantMap">
|
<valuemap type="QVariantMap">
|
||||||
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
|
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
|
||||||
<valuelist key="abstractProcess.Environment" type="QVariantList">
|
|
||||||
<value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-wExeabp7q4,guid=18815993df3603fdc64a3f6d4c7b5822</value>
|
|
||||||
<value type="QString">DEFAULTS_PATH=/usr/share/gconf/gnome.default.path</value>
|
|
||||||
<value type="QString">DESKTOP_SESSION=gnome</value>
|
|
||||||
<value type="QString">DISPLAY=:0.0</value>
|
|
||||||
<value type="QString">GDMSESSION=gnome</value>
|
|
||||||
<value type="QString">GDM_KEYBOARD_LAYOUT=us</value>
|
|
||||||
<value type="QString">GDM_LANG=ru_RU.UTF-8</value>
|
|
||||||
<value type="QString">GNOME_DESKTOP_SESSION_ID=this-is-deprecated</value>
|
|
||||||
<value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-4vN5uf</value>
|
|
||||||
<value type="QString">GTK_MODULES=canberra-gtk-module</value>
|
|
||||||
<value type="QString">HOME=/home/andrey</value>
|
|
||||||
<value type="QString">LANG=ru_RU.UTF-8</value>
|
|
||||||
<value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator:</value>
|
|
||||||
<value type="QString">LOGNAME=andrey</value>
|
|
||||||
<value type="QString">MANDATORY_PATH=/usr/share/gconf/gnome.mandatory.path</value>
|
|
||||||
<value type="QString">ORBIT_SOCKETDIR=/tmp/orbit-andrey</value>
|
|
||||||
<value type="QString">PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games</value>
|
|
||||||
<value type="QString">PWD=/home/andrey</value>
|
|
||||||
<value type="QString">QTDIR=/usr/share/qt4</value>
|
|
||||||
<value type="QString">SESSION_MANAGER=local/buull-eeePC:@/tmp/.ICE-unix/1205,unix/buull-eeePC:/tmp/.ICE-unix/1205</value>
|
|
||||||
<value type="QString">SHELL=/bin/bash</value>
|
|
||||||
<value type="QString">SPEECHD_PORT=6561</value>
|
|
||||||
<value type="QString">SSH_AGENT_PID=1239</value>
|
|
||||||
<value type="QString">SSH_AUTH_SOCK=/tmp/keyring-4vN5uf/ssh</value>
|
|
||||||
<value type="QString">USER=andrey</value>
|
|
||||||
<value type="QString">USERNAME=andrey</value>
|
|
||||||
<value type="QString">XAUTHORITY=/var/run/gdm/auth-for-andrey-x9URui/database</value>
|
|
||||||
<value type="QString">XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg</value>
|
|
||||||
<value type="QString">XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/</value>
|
|
||||||
<value type="QString">XDG_SESSION_COOKIE=f0649decca52f2beb55c9ea74ad1d028-1283151906.338331-318132279</value>
|
|
||||||
</valuelist>
|
|
||||||
<value key="abstractProcess.IgnoreReturnValue" type="bool">true</value>
|
|
||||||
<valuelist key="abstractProcess.arguments" type="QVariantList">
|
|
||||||
<value type="QString">clean</value>
|
|
||||||
<value type="QString">-w</value>
|
|
||||||
</valuelist>
|
|
||||||
<value key="abstractProcess.command" type="QString">/usr/bin/make</value>
|
|
||||||
<value key="abstractProcess.enabled" type="bool">true</value>
|
|
||||||
<value key="abstractProcess.workingDirectory" type="QString">/home/andrey/AD/aliendefender</value>
|
|
||||||
<value key="cleanConfig" type="bool">true</value>
|
<value key="cleanConfig" type="bool">true</value>
|
||||||
<valuelist key="makeargs" type="QVariantList">
|
<valuelist key="makeargs" type="QVariantList">
|
||||||
<value type="QString">clean</value>
|
<value type="QString">clean</value>
|
||||||
|
|||||||
109
aliens.cpp
109
aliens.cpp
@@ -1,54 +1,55 @@
|
|||||||
#include "aliens.h"
|
#include "aliens.h"
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
Aliens::Aliens(Game_Data *gd, QObject *parent) :
|
Aliens::Aliens(Map * map_, QObject *parent) :
|
||||||
QObject(parent)
|
QObject(parent)
|
||||||
{
|
{
|
||||||
gameData = gd;
|
map = map_;
|
||||||
nextId = 1;
|
nextId = 1;
|
||||||
|
m_missingAliens = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Aliens::addAlien(int srcId)
|
void Aliens::addAlien(int srcId)
|
||||||
{
|
{
|
||||||
if (srcId < 0 || srcId >= gameData->srcAliens.size())
|
if (srcId < 0 || srcId >= srcAliens.size())
|
||||||
{
|
{
|
||||||
qCritical("ERROR out of aliens range");
|
qCritical("ERROR out of aliens range");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
AlienType al;// = gameData->srcAliens.at(srcId);
|
AlienType al;
|
||||||
al.id = nextId;
|
al.id = nextId;
|
||||||
al.src = srcId;
|
al.src = &(srcAliens[srcId]);
|
||||||
al.finish = gameData->map->finishs().at(qrand()%gameData->map->finishs().size());
|
al.finish = map->finishs().at(qrand()%map->finishs().size());
|
||||||
al.pos = QPointF(gameData->map->starts().at(qrand()%gameData->map->starts().size()));
|
al.pos = QPointF(map->starts().at(qrand()%map->starts().size()));
|
||||||
al.path = gameData->map->createPath(al.pos.toPoint(),al.finish);
|
al.path = map->createPath(al.pos.toPoint(),al.finish);
|
||||||
al.pathIndex = 1;
|
al.pathIndex = 1;
|
||||||
al.angle = 180.0f*(- std::atan2( al.pos.x() - al.path.at(al.pathIndex).x(),al.pos.y() - al.path.at(al.pathIndex).y()))/M_PI;
|
al.angle = 180.0f*(- std::atan2( al.pos.x() - al.path.at(al.pathIndex).x(),al.pos.y() - al.path.at(al.pathIndex).y()))/M_PI;
|
||||||
al.animIndex = 0;
|
|
||||||
if (al.path.isEmpty())
|
if (al.path.isEmpty())
|
||||||
{
|
{
|
||||||
qCritical("ERROR create path");
|
qCritical("ERROR create path");
|
||||||
return; // FIXME: this
|
return; // FIXME: this
|
||||||
}
|
}
|
||||||
//qDebug() << al.path;
|
//qDebug() << al.path;
|
||||||
al.health = gameData->srcAliens.at(srcId).health;
|
al.health = al.src->health;
|
||||||
al.speed = gameData->srcAliens.at(srcId).speed;
|
al.speed = al.src->speed;
|
||||||
al.imgType = gameData->srcAliens.at(srcId).imgType;
|
al.item = new ADItem(al.id,ADItem::Alien,al.src->images,QRectF(-cellSize,-cellSize,cellSize*2,cellSize*2));
|
||||||
//gameData->map->printMap();
|
al.item->setPos(al.pos*cellSize+QPointF(cellSize/2,cellSize/2));
|
||||||
gameData->curAliens.insert(al.id,al);
|
al.item->setRotation(al.angle);
|
||||||
|
curAliens.insert(al.id,al);
|
||||||
|
scene->addItem(al.item);
|
||||||
nextId++;
|
nextId++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Aliens::retrace(bool * OK)
|
void Aliens::retrace(bool * OK)
|
||||||
{
|
{
|
||||||
//qDebug("re-trace!");
|
map->removeAliensPath();
|
||||||
gameData->map->removeAliensPath();
|
for (QHash<int, AlienType>::iterator i = curAliens.begin(); i != curAliens.end(); ++i)
|
||||||
for (QHash<int, AlienType>::iterator i = gameData->curAliens.begin(); i != gameData->curAliens.end(); ++i)
|
|
||||||
{
|
{
|
||||||
(*i).path = gameData->map->createPath((*i).pos.toPoint(),(*i).finish);
|
i->path = map->createPath(i->pos.toPoint(),i->finish);
|
||||||
(*i).pathIndex = 1;
|
i->pathIndex = 1;
|
||||||
if ((*i).path.isEmpty())
|
if (i->path.isEmpty())
|
||||||
{
|
{
|
||||||
*OK = false;
|
*OK = false;
|
||||||
qDebug("Aliens retrace = false");
|
qDebug("Aliens retrace = false");
|
||||||
@@ -57,70 +58,52 @@ void Aliens::retrace(bool * OK)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Aliens::delAlien(int Id)
|
void Aliens::delAlien(int id, bool missed)
|
||||||
{
|
{
|
||||||
gameData->curAliens.remove(Id);
|
if (missed)
|
||||||
|
{
|
||||||
|
m_missingAliens++;
|
||||||
|
qDebug() << tr("Missing aliens = %1!").arg(m_missingAliens);
|
||||||
|
}
|
||||||
|
scene->removeItem(curAliens[id].item);
|
||||||
|
delete curAliens[id].item;
|
||||||
|
curAliens.remove(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Aliens::update()
|
void Aliens::update()
|
||||||
{
|
{
|
||||||
QList <int> missIndex;
|
QList <int> missIndex;
|
||||||
for (QHash<int, AlienType>::iterator i = gameData->curAliens.begin(); i != gameData->curAliens.end(); ++i)
|
for (QHash<int, AlienType>::iterator i = curAliens.begin(); i != curAliens.end(); ++i)
|
||||||
{
|
{
|
||||||
//AlienType al = (*i);
|
|
||||||
//qDebug() << i;
|
|
||||||
//if (al.health < 0) emit AlienKill();
|
|
||||||
float angl,arctg = 0;
|
float angl,arctg = 0;
|
||||||
int curMiss = -1;
|
int curMiss = -1;
|
||||||
while (distance2((*i).pos, (*i).path.at((*i).pathIndex)) < (*i).speed*(*i).speed)
|
while (distance2(i->pos, i->path.at(i->pathIndex)) < i->speed * i->speed)
|
||||||
{
|
{
|
||||||
(*i).pathIndex++;
|
i->pathIndex++;
|
||||||
if ((*i).pathIndex >= (*i).path.size())
|
if (i->pathIndex >= i->path.size())
|
||||||
{
|
{
|
||||||
missIndex.push_back((*i).id);
|
missIndex.push_back(i->id);
|
||||||
curMiss = (*i).id;
|
curMiss = i->id;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/*{
|
|
||||||
PathIndex = 0;
|
|
||||||
position = game->start*game->cellsize;
|
|
||||||
}*/
|
|
||||||
// tmpdx = (*i).pos.x() - (*i).path.at((*i).pathIndex).x();
|
|
||||||
// tmpdy = (*i).pos.y() - (*i).path.at((*i).pathIndex).y();
|
|
||||||
//qDebug() << "next";
|
|
||||||
}
|
}
|
||||||
if (curMiss < 0)
|
if (curMiss < 0)
|
||||||
{
|
{
|
||||||
// TODO: smooth rotate (how???)
|
// TODO: smooth rotate (how???)
|
||||||
arctg = std::atan2((*i).pos.x() - (*i).path.at((*i).pathIndex).x(),(*i).pos.y() - (*i).path.at((*i).pathIndex).y());
|
arctg = std::atan2(i->pos.x() - i->path.at(i->pathIndex).x(),i->pos.y() - i->path.at(i->pathIndex).y());
|
||||||
//if (tmpdy < 0) arctg=arctg+M_PI;
|
|
||||||
angl = 180.0f*(-arctg)/M_PI;
|
angl = 180.0f*(-arctg)/M_PI;
|
||||||
/*if (PathIndex > 1)
|
i->angle = angl;
|
||||||
{
|
i->pos.rx() -= i->speed*std::sin(arctg);
|
||||||
if ((Position.angle-angl < -5 || Position.angle-angl > 5) && angl < 175 && angl > -175)
|
i->pos.ry() -= i->speed*std::cos(arctg);
|
||||||
{
|
|
||||||
if (angl > Position.angle) Position.angle += 5;
|
|
||||||
else Position.angle -= 5;
|
|
||||||
}
|
|
||||||
else Position.angle = angl;
|
|
||||||
}
|
|
||||||
else*/
|
|
||||||
(*i).angle = angl;
|
|
||||||
//qDebug() << "[" << PathIndex << ";" << PicIndex << "]" << "angle:" << Position.angle << "arctg:" << arctg << "Pos:" << Position.pnt;
|
|
||||||
(*i).pos.setX((*i).pos.x()
|
|
||||||
-(*i).speed*std::sin(arctg));
|
|
||||||
(*i).pos.setY((*i).pos.y()
|
|
||||||
-(*i).speed*std::cos(arctg));
|
|
||||||
//return true;
|
|
||||||
//gameData->curAliens.insert(al.id,al);
|
|
||||||
//qDebug() <<"alien"<< i << " path index=" << al.pathIndex << ", pos=" << al.pos;
|
|
||||||
}
|
}
|
||||||
|
i->item->setPos(i->pos*cellSize+QPointF(cellSize/2,cellSize/2));
|
||||||
|
i->item->setRotation(i->angle);
|
||||||
|
i->item->setBarValue(i->health/i->src->health);
|
||||||
|
i->item->next(i->speed*cellSize);
|
||||||
}
|
}
|
||||||
for (int j=0; j<missIndex.size(); j++)
|
for (int j=0; j<missIndex.size(); j++)
|
||||||
{
|
{
|
||||||
gameData->missingAliens++;
|
delAlien(missIndex.at(j),true);
|
||||||
qDebug() << tr("Missing aliens = %1!").arg(gameData->missingAliens);
|
|
||||||
delAlien(missIndex.at(j));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
21
aliens.h
21
aliens.h
@@ -1,26 +1,39 @@
|
|||||||
#ifndef ALIENS_H
|
#ifndef ALIENS_H
|
||||||
#define ALIENS_H
|
#define ALIENS_H
|
||||||
|
|
||||||
#include "game_data.h"
|
#include "base_types.h"
|
||||||
|
#include "map.h"
|
||||||
|
|
||||||
|
#include <QGraphicsScene>
|
||||||
|
#include <QGraphicsItemGroup>
|
||||||
|
|
||||||
class Aliens : public QObject
|
class Aliens : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit Aliens(Game_Data * gd, QObject *parent = 0);
|
explicit Aliens(Map * map, QObject *parent = 0);
|
||||||
void addAlien(int srcId);
|
void addAlien(int srcId);
|
||||||
void update();
|
void update();
|
||||||
|
void setScene(QGraphicsScene * scene_) {scene = scene_;}
|
||||||
|
QList <srcAlienType> srcAliens;
|
||||||
|
QHash <int,AlienType> curAliens;
|
||||||
|
int missingAliens() {return m_missingAliens;}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void delAlien(int Id);
|
void delAlien(int id, bool missed = false);
|
||||||
void retrace(bool * OK);
|
void retrace(bool * OK);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Game_Data * gameData;
|
Map * map;
|
||||||
|
QGraphicsScene * scene;
|
||||||
|
|
||||||
QPointF globStart;
|
QPointF globStart;
|
||||||
QPointF globFinish;
|
QPointF globFinish;
|
||||||
int nextId;
|
int nextId;
|
||||||
|
int m_missingAliens;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ALIENS_H
|
#endif // ALIENS_H
|
||||||
|
|||||||
92
base_types.h
92
base_types.h
@@ -15,6 +15,9 @@
|
|||||||
#include <QRectF>
|
#include <QRectF>
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
#include "aditem.h"
|
||||||
|
|
||||||
|
const float cellSize = 20.f;
|
||||||
|
|
||||||
|
|
||||||
struct srcAlienType
|
struct srcAlienType
|
||||||
@@ -27,6 +30,7 @@ struct srcAlienType
|
|||||||
bool isFlying;
|
bool isFlying;
|
||||||
unsigned int score;
|
unsigned int score;
|
||||||
int imgType;
|
int imgType;
|
||||||
|
QList<QImage *> * images;
|
||||||
unsigned int prise;
|
unsigned int prise;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -34,7 +38,7 @@ struct srcAlienType
|
|||||||
struct AlienType
|
struct AlienType
|
||||||
{
|
{
|
||||||
int id; // uses for QHash
|
int id; // uses for QHash
|
||||||
int src;
|
srcAlienType * src;
|
||||||
QPointF pos;
|
QPointF pos;
|
||||||
float angle; // -180 .. 180
|
float angle; // -180 .. 180
|
||||||
float speed; // cells per tick (speed=1 is 60cells by 1 sec for 60fps e.g.)
|
float speed; // cells per tick (speed=1 is 60cells by 1 sec for 60fps e.g.)
|
||||||
@@ -42,8 +46,7 @@ struct AlienType
|
|||||||
QPoint finish;
|
QPoint finish;
|
||||||
QVector <QPointF> path;
|
QVector <QPointF> path;
|
||||||
int pathIndex;
|
int pathIndex;
|
||||||
int imgType;
|
ADItem * item;
|
||||||
int animIndex;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -77,58 +80,30 @@ struct srcTriggerType
|
|||||||
|
|
||||||
struct TriggerOnDest
|
struct TriggerOnDest
|
||||||
{
|
{
|
||||||
int src;
|
srcTriggerType * src;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct TriggerOnTimer
|
struct TriggerOnTimer
|
||||||
{
|
{
|
||||||
int src;
|
srcTriggerType * src;
|
||||||
unsigned int timer;
|
unsigned int timer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct TriggerOnAlien
|
struct TriggerOnAlien
|
||||||
{
|
{
|
||||||
int src;
|
srcTriggerType * src;
|
||||||
QList <int> triggerAliens;
|
QList <int> triggerAliens;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct srcSplashType
|
struct srcSplashType;
|
||||||
{
|
|
||||||
QString name;
|
|
||||||
int imgType;
|
|
||||||
float speed; // in cells
|
|
||||||
int lifetime;
|
|
||||||
bool autoControl;
|
|
||||||
QList <int> triggerIndexes;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
struct SplashType
|
|
||||||
{
|
|
||||||
int id;
|
|
||||||
int imgType;
|
|
||||||
int animIndex;
|
|
||||||
int src;
|
|
||||||
QPoint TowerId; // parent tower (-1;-1) for null parent
|
|
||||||
int srcTower;
|
|
||||||
int PlayerId;
|
|
||||||
int AlienId; // aim alien (different from tower.AlienId)
|
|
||||||
QPointF destination;
|
|
||||||
int life; // in ticks
|
|
||||||
float angle; // -180 .. 180
|
|
||||||
QPointF pos;
|
|
||||||
QList <TriggerOnAlien> trigsOnAlien;
|
|
||||||
QList <TriggerOnDest> trigsOnDest;
|
|
||||||
QList <TriggerOnTimer> trigsOnTimer;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
struct srcTowerType
|
struct srcTowerType
|
||||||
{
|
{
|
||||||
QString name;
|
QString name;
|
||||||
|
QImage * image;
|
||||||
int imgType;
|
int imgType;
|
||||||
int PlayerId; // tower's owner
|
int PlayerId; // tower's owner
|
||||||
unsigned int cost;
|
unsigned int cost;
|
||||||
@@ -145,24 +120,55 @@ struct srcTowerType
|
|||||||
|
|
||||||
struct TowerType
|
struct TowerType
|
||||||
{
|
{
|
||||||
int src;
|
srcTowerType * src;
|
||||||
int aim; // aim alien Id
|
int aim; // aim alien Id
|
||||||
int oldAim;
|
|
||||||
int PlayerId; // tower's owner
|
int PlayerId; // tower's owner
|
||||||
int imgType;
|
QPoint pos; // same as Id; not QPointF because tower fixed on grid
|
||||||
int animIndex;
|
|
||||||
QPoint pos; // not QPointF because tower fixed on grid
|
|
||||||
float angle; // -180 .. 180
|
float angle; // -180 .. 180
|
||||||
unsigned int reload; // time for reload in ticks
|
unsigned int reload; // time for reload in ticks
|
||||||
unsigned int build;
|
unsigned int build;
|
||||||
float experience;
|
float experience;
|
||||||
|
ADItem * item;
|
||||||
|
bool isBilding;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct srcSplashType
|
||||||
|
{
|
||||||
|
QString name;
|
||||||
|
int imgType;
|
||||||
|
float speed; // in cells
|
||||||
|
int lifetime;
|
||||||
|
bool autoControl;
|
||||||
|
QList <int> triggerIndexes;
|
||||||
|
QList<QImage *> * images;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct SplashType
|
||||||
|
{
|
||||||
|
int id;
|
||||||
|
srcSplashType * src;
|
||||||
|
srcTowerType * srcTow;
|
||||||
|
QPoint towerId; // parent tower, (0,0) or null for non parent
|
||||||
|
int PlayerId;
|
||||||
|
int AlienId; // aim alien (different from tower.AlienId)
|
||||||
|
QPointF destination;
|
||||||
|
int life; // in ticks
|
||||||
|
float angle; // -180 .. 180
|
||||||
|
QPointF pos;
|
||||||
|
QList <TriggerOnAlien> trigsOnAlien;
|
||||||
|
QList <TriggerOnDest> trigsOnDest;
|
||||||
|
QList <TriggerOnTimer> trigsOnTimer;
|
||||||
|
ADItem * item;
|
||||||
|
};
|
||||||
|
|
||||||
|
/// DEPRECATED !!!
|
||||||
struct AnimationType
|
struct AnimationType
|
||||||
{
|
{
|
||||||
QList<QImage * > images;
|
QList<QImage * > * images;
|
||||||
};
|
};
|
||||||
|
/// DEPRECATED !!!
|
||||||
|
|
||||||
|
|
||||||
struct WaveType
|
struct WaveType
|
||||||
@@ -176,7 +182,7 @@ struct WaveType
|
|||||||
|
|
||||||
inline uint qHash(const QPoint &pos)
|
inline uint qHash(const QPoint &pos)
|
||||||
{
|
{
|
||||||
return qHash(pos.x()) + (qHash(pos.y()) << 16);
|
return qHash(pos.x() + (pos.y() << 16));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
72
data2.xml
72
data2.xml
@@ -1,41 +1,41 @@
|
|||||||
<!DOCTYPE data>
|
<!DOCTYPE data>
|
||||||
<ADdata>
|
<ADdata>
|
||||||
<aliens>
|
<aliens>
|
||||||
<alien speed="0.08" imageType="1" prise="15" id="2" score="12" name="Monstr" health="33"/>
|
<alien speed="0.03" imageType="1" prise="1" id="1" score="12" name="Monstr 1" health="15"/>
|
||||||
<alien speed="0.05" imageType="1" prise="1" id="4" score="10" name="test" health="100"/>
|
<alien speed="0.01" imageType="1" prise="100" id="4" score="10" name="test" health="1000"/>
|
||||||
<alien speed="0.03" imageType="1" prise="4" id="10" score="99" name="first" health="50"/>
|
<alien speed="0.03" imageType="1" prise="4" id="10" score="99" name="first" health="50"/>
|
||||||
<alien regeneration="3" speed="0.01" imageType="1" prise="10" armor="1.5" id="12" score="99" name="MONSTR" health="200"/>
|
<alien regeneration="3" speed="0.01" imageType="1" prise="10" armor="1.5" id="12" score="99" name="MMMM" health="200"/>
|
||||||
<alien speed="0.05" imageType="1" prise="10" id="33" score="99" name="Mega Alien" health="888"/>
|
<alien speed="0.05" imageType="1" prise="10" id="33" score="99" name="Mega Alien" health="888"/>
|
||||||
</aliens>
|
</aliens>
|
||||||
<maps>
|
<maps>
|
||||||
<map width="16" imageType="10" height="16" id="1" data="AAAERHicY2BgEGAA4v///0hQgmFmAGlGcjCxZuCTHzUDuxkMDOr85JrBwKC0A8kMJlwYagYOeYgZ+NXgNwMtPEbNINIMIsynOO8DAG0r1Q0=" name="My Map" maxPlayers="2"/>
|
<map width="16" imageType="10" height="16" id="1" data="AAAERHicY2BgEGAA4v///0hQgmFmAGlGcjCxZuCTHzUDuxkMDOr85JrBwKC0A8kMJlwYagYOeYgZ+NXgNwMtPEbNINIMIsynOO8DAG0r1Q0=" name="My Map" maxPlayers="2"/>
|
||||||
<map width="30" imageType="20" height="20" id="2" data="AAAJ3HicY2BgkGNgYBD5//+PBDGYgUGdnzh1EDOBNCM1MKlmEqNu1MxRM0fNHNxmgsobapnJwKC0Yyj5fdTMUTNHzRzaZpJgLwltMKUdxKgDADpycNA=" name="map2" maxPlayers="1"/>
|
<map width="30" imageType="20" height="20" id="2" data="AAAJ3HicY2BgkGNgYBD5//+PBDGYgUGdnzh1EDOBNCM1MKlmEqNu1MxRM0fNHNxmgsobapnJwKC0Yyj5fdTMUTNHzRzaZpJgLwltMKUdxKgDADpycNA=" name="map2" maxPlayers="1"/>
|
||||||
|
<map width="25" imageType="20" height="11" id="3" data="AAAEtHicY2BgkGRgYOD+//+PBDpmYFDnxy4OUQ+kGQnhUfWj6kfVj6onRj1mOaO0A5s4ADeqzbA=" name="map" maxPlayers="1"/>
|
||||||
</maps>
|
</maps>
|
||||||
<waves>
|
<waves>
|
||||||
<wave prise="100" timeout="10" id="1"/>
|
<wave prise="5" timeout="50" id="1"/>
|
||||||
<wave prise="200" timeout="10" id="2"/>
|
<wave prise="7" timeout="50" id="2"/>
|
||||||
<wave prise="220" timeout="20" id="3"/>
|
<wave prise="10" timeout="50" id="3"/>
|
||||||
<wave prise="220" timeout="5" id="4"/>
|
<wave prise="20" timeout="50" id="4"/>
|
||||||
<wave prise="220" timeout="2" id="5"/>
|
<wave prise="220" timeout="20" id="5"/>
|
||||||
<wave prise="220" timeout="20" id="6"/>
|
<wave prise="220" timeout="200" id="6"/>
|
||||||
<wave prise="220" timeout="25" id="7"/>
|
<!--<wave prise="220" timeout="250" id="7"/>
|
||||||
<wave prise="220" timeout="5" id="8"/>
|
<wave prise="220" timeout="500" id="8"/>
|
||||||
<wave prise="220" timeout="1" id="9"/>
|
<wave prise="220" timeout="100" id="9"/>
|
||||||
<wave prise="220" timeout="1" id="10"/>
|
<wave prise="220" timeout="1" id="10"/>
|
||||||
<wave prise="220" timeout="5" id="11"/>
|
<wave prise="220" timeout="5" id="11"/>-->
|
||||||
</waves>
|
</waves>
|
||||||
<levels>
|
<levels>
|
||||||
<level map="2" id="1" score="138887032" name="First Level"/>
|
<level map="3" id="1" score="138887032" name="First Level"/>
|
||||||
</levels>
|
</levels>
|
||||||
<waveParts>
|
<waveParts>
|
||||||
<wavePart alien="10" count="10" wave="1"/>
|
<wavePart alien="1" count="1" wave="1"/>
|
||||||
<wavePart alien="10" count="5" wave="2"/>
|
<wavePart alien="1" count="2" wave="2"/>
|
||||||
<wavePart alien="12" count="5" wave="2"/>
|
<wavePart alien="1" count="3" wave="3"/>
|
||||||
<wavePart alien="12" count="4" wave="3"/>
|
<wavePart alien="1" count="5" wave="4"/>
|
||||||
<wavePart alien="12" count="3" wave="3"/>
|
<wavePart alien="1" count="200" wave="5"/>
|
||||||
<wavePart alien="10" count="2" wave="3"/>
|
<wavePart alien="4" count="1" wave="6"/>
|
||||||
<wavePart alien="10" count="1" wave="3"/>
|
<!--<wavePart alien="4" count="60" wave="4"/>
|
||||||
<wavePart alien="4" count="60" wave="4"/>
|
|
||||||
<wavePart alien="2" count="20" wave="4"/>
|
<wavePart alien="2" count="20" wave="4"/>
|
||||||
<wavePart alien="4" count="26" wave="5"/>
|
<wavePart alien="4" count="26" wave="5"/>
|
||||||
<wavePart alien="10" count="26" wave="5"/>
|
<wavePart alien="10" count="26" wave="5"/>
|
||||||
@@ -60,40 +60,42 @@
|
|||||||
<wavePart alien="10" count="1" wave="6"/>
|
<wavePart alien="10" count="1" wave="6"/>
|
||||||
<wavePart alien="4" count="1" wave="6"/>
|
<wavePart alien="4" count="1" wave="6"/>
|
||||||
<wavePart alien="33" count="2" wave="7"/>
|
<wavePart alien="33" count="2" wave="7"/>
|
||||||
<wavePart alien="33" count="50" wave="8"/>
|
<wavePart alien="33" count="50" wave="8"/>-->
|
||||||
</waveParts>
|
</waveParts>
|
||||||
<wavesOnLevels>
|
<wavesOnLevels>
|
||||||
<waveOnLevel wave="8" level="1"/>
|
|
||||||
<waveOnLevel wave="7" level="1"/>
|
|
||||||
<waveOnLevel wave="6" level="1"/>
|
|
||||||
<waveOnLevel wave="5" level="1"/>
|
|
||||||
<waveOnLevel wave="4" level="1"/>
|
|
||||||
<waveOnLevel wave="3" level="1"/>
|
|
||||||
<waveOnLevel wave="2" level="1"/>
|
|
||||||
<waveOnLevel wave="1" level="1"/>
|
<waveOnLevel wave="1" level="1"/>
|
||||||
|
<waveOnLevel wave="2" level="1"/>
|
||||||
|
<waveOnLevel wave="3" level="1"/>
|
||||||
|
<waveOnLevel wave="4" level="1"/>
|
||||||
|
<waveOnLevel wave="5" level="1"/>
|
||||||
|
<waveOnLevel wave="6" level="1"/>
|
||||||
</wavesOnLevels>
|
</wavesOnLevels>
|
||||||
<splashes>
|
<splashes>
|
||||||
<splash speed="0.2" imageType="5" lifetime="9999" id="1" name="rocket"/>
|
<splash speed="0.2" imageType="5" lifetime="9999" id="1" name="rocket"/>
|
||||||
<splash speed="0.2" imageType="5" lifetime="9999" autoControl="true" id="2" name="smart rocket"/>
|
<splash speed="0.2" imageType="5" lifetime="9999" autoControl="true" id="2" name="smart rocket"/>
|
||||||
<splash speed="1" imageType="7" lifetime="9999" autoControl="true" id="3" name="bullet"/>
|
<splash speed="0.5" imageType="7" lifetime="9999" autoControl="true" id="3" name="bullet"/>
|
||||||
|
<splash speed="0.5" imageType="7" lifetime="9999" autoControl="true" id="7" name="bullet"/>
|
||||||
<splash speed="0" imageType="4" lifetime="16" id="4" name="bum"/>
|
<splash speed="0" imageType="4" lifetime="16" id="4" name="bum"/>
|
||||||
<splash speed="0" imageType="6" lifetime="10" id="5" name="smoke"/>
|
<splash speed="0" imageType="6" lifetime="10" id="5" name="smoke"/>
|
||||||
<splash speed="0.1" imageType="5" lifetime="50" autoControl="true" id="6" name="Снаряд"/>
|
<splash speed="0.1" imageType="5" lifetime="50" autoControl="true" id="6" name="Снаряд"/>
|
||||||
</splashes>
|
</splashes>
|
||||||
<towers>
|
<towers>
|
||||||
<tower imageType="8" radius="12" expByKill="0.1" expByShot="0.15" buildTime="150" splash="2" reload="15" id="1" name="rocket launcher 2" cost="50" expByDamage="0.04"/>
|
<tower imageType="8" radius="12" expByKill="0.1" expByShot="0.15" buildTime="150" splash="2" reload="15" id="1" name="rocket launcher 2" cost="5" expByDamage="0.04"/>
|
||||||
<tower imageType="2" radius="3" expByKill="0.2" expByShot="0.1" buildTime="100" splash="3" reload="5" id="2" name="gun" cost="10" expByDamage="0.1"/>
|
<tower imageType="2" radius="3" expByKill="0.2" expByShot="0.1" buildTime="25" splash="3" reload="50" id="2" name="tower 1" cost="7" expByDamage="0.1"/>
|
||||||
<tower imageType="3" radius="5" expByKill="0.1" expByShot="0.15" buildTime="200" splash="1" reload="50" id="3" name="rocket launcher" cost="30" expByDamage="0.04"/>
|
<tower imageType="2" radius="3" expByKill="0.2" expByShot="0.1" buildTime="25" splash="3" reload="35" id="4" name="tower 1-2" cost="15" expByDamage="0.1"/>
|
||||||
|
<tower imageType="2" radius="2" expByKill="0.2" expByShot="0.1" buildTime="25" splash="3" reload="15" id="5" name="tower 1-3" cost="25" expByDamage="0.1"/>
|
||||||
|
<tower imageType="3" radius="5" expByKill="0.1" expByShot="0.15" buildTime="200" splash="1" reload="50" id="3" name="rocket launcher" cost="3" expByDamage="0.04"/>
|
||||||
</towers>
|
</towers>
|
||||||
<triggers>
|
<triggers>
|
||||||
<trigger damage="5" childAim="noAim" delParent="true" type="onDestination" id="2" name="shot"/>
|
<trigger damage="5" childAim="noAim" delParent="true" type="onDestination" id="2" name="shot"/>
|
||||||
<trigger damage="21" childAim="noAim" radius="2.5" delParent="true" count="1" type="onDestination" id="3" name="explosion"/>
|
<trigger damage="1" childAim="noAim" radius="2.5" delParent="true" count="1" type="onDestination" id="3" name="explosion"/>
|
||||||
<trigger childAim="noAim" count="1" type="onTimer" id="4" name="smoke" timer="2"/>
|
<trigger childAim="noAim" count="1" type="onTimer" id="4" name="smoke" timer="2"/>
|
||||||
</triggers>
|
</triggers>
|
||||||
<chains>
|
<chains>
|
||||||
<chain tower="1" trigger="4" child="5" parent="2"/>
|
<chain tower="1" trigger="4" child="5" parent="2"/>
|
||||||
<chain tower="1" trigger="3" child="4" parent="2"/>
|
<chain tower="1" trigger="3" child="4" parent="2"/>
|
||||||
<chain tower="2" trigger="2" parent="3"/>
|
<chain tower="2" trigger="2" parent="3"/>
|
||||||
|
<chain tower="4" trigger="2" parent="7"/>
|
||||||
<chain tower="3" trigger="4" child="5" parent="1"/>
|
<chain tower="3" trigger="4" child="5" parent="1"/>
|
||||||
<chain tower="3" trigger="3" child="4" parent="1"/>
|
<chain tower="3" trigger="3" child="4" parent="1"/>
|
||||||
</chains>
|
</chains>
|
||||||
|
|||||||
135
form.cpp
Normal file
135
form.cpp
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
#include "form.h"
|
||||||
|
#include "ui_form.h"
|
||||||
|
#include "touchbuttframe.h"
|
||||||
|
|
||||||
|
|
||||||
|
Form::Form(QWidget *parent) :
|
||||||
|
QWidget(parent),
|
||||||
|
ui(new Ui::Form)
|
||||||
|
{
|
||||||
|
buildTowerId = -1;
|
||||||
|
cur_tow = QPoint();
|
||||||
|
cur_al = -1;
|
||||||
|
ui->setupUi(this);
|
||||||
|
graphics = new AD_Graphics(&core);
|
||||||
|
ui->widget->layout()->addWidget(graphics);
|
||||||
|
TouchButtFrame * tbf = new TouchButtFrame();
|
||||||
|
tbf->addButton(tr("delete"));
|
||||||
|
foreach (srcTowerType i, core.addata->players.at(0)->srcTowers)
|
||||||
|
{
|
||||||
|
tbf->addButton(i.name);
|
||||||
|
//QPushButton * butt = new QPushButton(i.name);
|
||||||
|
//towerButtons << butt;
|
||||||
|
//butt->setAutoDefault(true);
|
||||||
|
//butt->setAutoExclusive(true);
|
||||||
|
//butt->setCheckable(true);
|
||||||
|
}
|
||||||
|
ui->gbTowers->layout()->addWidget(tbf);
|
||||||
|
connect(tbf,SIGNAL(click(int)),this,SLOT(towerBuild(int)));
|
||||||
|
connect(tbf,SIGNAL(click(int)),tbf,SLOT(set_green(int)));
|
||||||
|
connect(graphics,SIGNAL(add_tow(QPoint)),this,SLOT(add_tow(QPoint)));
|
||||||
|
connect(graphics,SIGNAL(tower_select(QPoint)),this,SLOT(towerSelected(QPoint)));
|
||||||
|
connect(graphics,SIGNAL(alien_select(int)),this,SLOT(alienSelected(int)));
|
||||||
|
connect(graphics,SIGNAL(cancel()),this,SLOT(cancel()));
|
||||||
|
this->startTimer(50);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Form::~Form()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Form::on_pbNextWave_clicked()
|
||||||
|
{
|
||||||
|
core.nextWave();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Form::towerBuild(int index)
|
||||||
|
{
|
||||||
|
buildTowerId = index-1;
|
||||||
|
if (index == 0) buildTowerId = -9;
|
||||||
|
graphics->setBuilding(true);
|
||||||
|
setCursor(Qt::CrossCursor);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Form::add_tow(QPoint pnt)
|
||||||
|
{
|
||||||
|
if (buildTowerId == -1) return;
|
||||||
|
if (buildTowerId == -9) {core.adtowers->delTower(pnt); return;}
|
||||||
|
core.adtowers->addTower(0,buildTowerId,pnt);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//void Form::del_tow(QPoint pnt)
|
||||||
|
//{
|
||||||
|
// core.adtowers->delTower(pnt);
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
void Form::cancel()
|
||||||
|
{
|
||||||
|
buildTowerId = -1;
|
||||||
|
graphics->setBuilding(false);
|
||||||
|
setCursor(Qt::ArrowCursor);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Form::timerEvent(QTimerEvent *)
|
||||||
|
{
|
||||||
|
QString twstr;
|
||||||
|
QString alstr;
|
||||||
|
if (!cur_tow.isNull())
|
||||||
|
{
|
||||||
|
if (core.addata->curTowers.contains(cur_tow))
|
||||||
|
{
|
||||||
|
TowerType tw = core.addata->curTowers.value(cur_tow);
|
||||||
|
twstr = "\n\n " + tw.src->name;
|
||||||
|
if (tw.isBilding) twstr += tr("\n build %1/%2").arg(tw.build).arg(tw.src->buildTime);
|
||||||
|
twstr += tr("\n player %1\n exp %2").arg(tw.PlayerId).arg(tw.experience);
|
||||||
|
twstr += tr("\n reload %1/%2\n alien %3").arg(tw.reload).arg(tw.src->reload).arg(tw.aim);
|
||||||
|
twstr += tr("\n cost %1\n radius %2").arg(tw.src->cost).arg(tw.src->radius);
|
||||||
|
} else {
|
||||||
|
cur_tow = QPoint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (cur_al != -1)
|
||||||
|
{
|
||||||
|
if (core.addata->aliens->curAliens.contains(cur_al))
|
||||||
|
{
|
||||||
|
AlienType al = core.addata->aliens->curAliens.value(cur_al);
|
||||||
|
alstr = "\n\n " + al.src->name;
|
||||||
|
if (al.src->isFlying) alstr += tr("\n flying");
|
||||||
|
else alstr += tr("\n ground");
|
||||||
|
alstr += tr("\n health %1/%2").arg(al.health).arg(al.src->health);
|
||||||
|
alstr += tr("\n speed %1/%2").arg(al.speed).arg(al.src->speed);
|
||||||
|
alstr += tr("\n armor %1\n regeneration %2").arg(al.src->armor).arg(al.src->regeneration);
|
||||||
|
alstr += tr("\n prise %1").arg(al.src->prise);
|
||||||
|
} else {
|
||||||
|
cur_al = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!core.addata->aliens->curAliens.contains(cur_al)) cur_al = -1;
|
||||||
|
ui->lbInfo->setText(tr(" money %1 \n missing %2").arg(core.addata->players.at(0)->money).arg(core.addata->aliens->missingAliens())
|
||||||
|
+ tr("\n aliens %1").arg(core.addata->aliens->curAliens.size())
|
||||||
|
+ tr("\n towers %1").arg(core.addata->curTowers.size())
|
||||||
|
+ tr("\n splashes %1").arg(core.addata->curSplashes.size())
|
||||||
|
+ twstr + alstr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Form::towerSelected(QPoint id)
|
||||||
|
{
|
||||||
|
cur_tow = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Form::alienSelected(int id)
|
||||||
|
{
|
||||||
|
cur_al = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
41
form.h
Normal file
41
form.h
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
#ifndef FORM_H
|
||||||
|
#define FORM_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include "adcore.h"
|
||||||
|
#include "ad_graphics.h"
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class Form;
|
||||||
|
}
|
||||||
|
|
||||||
|
class Form : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit Form(QWidget *parent = 0);
|
||||||
|
~Form();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void on_pbNextWave_clicked();
|
||||||
|
void towerBuild(int index);
|
||||||
|
void add_tow(QPoint pnt);
|
||||||
|
//void del_tow(QPoint pnt);
|
||||||
|
void cancel();
|
||||||
|
void towerSelected(QPoint id);
|
||||||
|
void alienSelected(int id);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void timerEvent(QTimerEvent *);
|
||||||
|
|
||||||
|
Ui::Form *ui;
|
||||||
|
int buildTowerId;
|
||||||
|
AD_Core core;
|
||||||
|
AD_Graphics * graphics;
|
||||||
|
QPoint cur_tow;
|
||||||
|
int cur_al;
|
||||||
|
//QList <QPushButton *> towerButtons;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // FORM_H
|
||||||
107
form.ui
Normal file
107
form.ui
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>Form</class>
|
||||||
|
<widget class="QWidget" name="Form">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>700</width>
|
||||||
|
<height>448</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout" stretch="4,1">
|
||||||
|
<property name="margin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QWidget" name="widget" native="true">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
|
<property name="margin">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="lbInfo">
|
||||||
|
<property name="text">
|
||||||
|
<string>TextLabel</string>
|
||||||
|
</property>
|
||||||
|
<property name="textFormat">
|
||||||
|
<enum>Qt::PlainText</enum>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QScrollArea" name="saTowers">
|
||||||
|
<property name="widgetResizable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>135</width>
|
||||||
|
<height>194</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
|
<property name="margin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="gbTowers">
|
||||||
|
<property name="title">
|
||||||
|
<string>Towers</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="margin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pbNextWave">
|
||||||
|
<property name="text">
|
||||||
|
<string>Next wave</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
@@ -5,5 +5,5 @@ Game_Data::Game_Data(Map *mapp, QObject *parent) :
|
|||||||
{
|
{
|
||||||
map = mapp;
|
map = mapp;
|
||||||
curWave = 0;
|
curWave = 0;
|
||||||
missingAliens = 0;
|
aliens = new Aliens(map);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,29 +2,32 @@
|
|||||||
#define GAME_DATA_H
|
#define GAME_DATA_H
|
||||||
|
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
|
#include "aliens.h"
|
||||||
#include "base_types.h"
|
#include "base_types.h"
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
|
#include <QGraphicsItemGroup>
|
||||||
|
|
||||||
class Game_Data : public QObject
|
class Game_Data : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit Game_Data(Map * map, QObject *parent = 0);
|
explicit Game_Data(Map * map, QObject *parent = 0);
|
||||||
QList <srcAlienType> srcAliens;
|
|
||||||
QHash <int,AlienType> curAliens;
|
|
||||||
QList <srcSplashType> srcSplashes;
|
QList <srcSplashType> srcSplashes;
|
||||||
QList <srcTriggerType> srTriggers;
|
QList <srcTriggerType> srcTriggers;
|
||||||
QHash <int,SplashType> curSplashes;
|
QHash <int,SplashType> curSplashes;
|
||||||
QHash <QPoint,TowerType> curTowers;
|
QHash <QPoint,TowerType> curTowers;
|
||||||
QList <WaveType> waves;
|
QList <WaveType> waves;
|
||||||
QList <Player *> players;
|
QList <Player *> players;
|
||||||
QList <AnimationType> curAnimations;
|
QList <AnimationType> curAnimations;
|
||||||
Map * map;
|
Map * map;
|
||||||
|
Aliens * aliens;
|
||||||
int curWave;
|
int curWave;
|
||||||
int missingAliens;
|
int missingAliens;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GAME_DATA_H
|
#endif // GAME_DATA_H
|
||||||
|
|||||||
39
loader.cpp
39
loader.cpp
@@ -1,12 +1,10 @@
|
|||||||
#include "loader.h"
|
#include "loader.h"
|
||||||
|
|
||||||
Loader::Loader(QObject *parent) :
|
Loader::Loader(QObject *parent) :
|
||||||
QObject(parent)
|
QObject(parent)
|
||||||
{
|
{
|
||||||
doc = new QDomDocument("data");
|
doc = new QDomDocument("data");
|
||||||
//create();
|
|
||||||
qDebug() << createMapExample();
|
qDebug() << createMapExample();
|
||||||
//load();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -266,11 +264,10 @@ Game_Data * Loader::loadlevel(int id)
|
|||||||
qDebug() << tr("Loading level %1 ...").arg(levels.value(id).name);
|
qDebug() << tr("Loading level %1 ...").arg(levels.value(id).name);
|
||||||
tbMap tbm = maps.value(levels.value(id).mapId);
|
tbMap tbm = maps.value(levels.value(id).mapId);
|
||||||
Map * map = new Map(tbm.data,tbm.size,tbm.name,tbm.maxPlayers,tbm.imgType);
|
Map * map = new Map(tbm.data,tbm.size,tbm.name,tbm.maxPlayers,tbm.imgType);
|
||||||
//int maxPlayers = map->maxPlayers();
|
|
||||||
Game_Data * gd = new Game_Data(map);
|
Game_Data * gd = new Game_Data(map);
|
||||||
for (int i=0; i<map->maxPlayers(); i++)
|
for (int i=0; i<map->maxPlayers(); i++)
|
||||||
{
|
{
|
||||||
Player * pl = new Player(0);
|
Player * pl = new Player(i);
|
||||||
gd->players.append(pl);
|
gd->players.append(pl);
|
||||||
}
|
}
|
||||||
qDebug() << gd->players.size();
|
qDebug() << gd->players.size();
|
||||||
@@ -312,10 +309,9 @@ Game_Data * Loader::loadlevel(int id)
|
|||||||
wt.counts.prepend(tbwpt.count);
|
wt.counts.prepend(tbwpt.count);
|
||||||
}
|
}
|
||||||
gd->waves.prepend(wt);
|
gd->waves.prepend(wt);
|
||||||
|
qDebug() << tr("load wave #%1 prise=%2 timeout=%3").arg(i+1).arg(wt.prise).arg(wt.timeout) << wt.types << wt.counts;
|
||||||
wplist.clear();
|
wplist.clear();
|
||||||
}
|
}
|
||||||
for (int i=0; i<gd->waves.size(); ++i)
|
|
||||||
qDebug() << tr("load wave #%1 prise=%2 timeout=%3").arg(i+1).arg(gd->waves.at(i).prise).arg(gd->waves.at(i).timeout) << gd->waves.at(i).types << gd->waves.at(i).counts;
|
|
||||||
wollist.clear();
|
wollist.clear();
|
||||||
for (int i=0; i<alienIds.size(); ++i)
|
for (int i=0; i<alienIds.size(); ++i)
|
||||||
{
|
{
|
||||||
@@ -332,7 +328,7 @@ Game_Data * Loader::loadlevel(int id)
|
|||||||
salt.regeneration = tbal.regeneration;
|
salt.regeneration = tbal.regeneration;
|
||||||
salt.score = tbal.score;
|
salt.score = tbal.score;
|
||||||
salt.speed = tbal.speed;
|
salt.speed = tbal.speed;
|
||||||
gd->srcAliens.append(salt);
|
gd->aliens->srcAliens.append(salt);
|
||||||
qDebug() << tr("Alien %1 #%2 ").arg(salt.name).arg(i);
|
qDebug() << tr("Alien %1 #%2 ").arg(salt.name).arg(i);
|
||||||
}
|
}
|
||||||
QList <tbTowerOnLevel> tollist = levTowers.values(id);
|
QList <tbTowerOnLevel> tollist = levTowers.values(id);
|
||||||
@@ -374,11 +370,21 @@ Game_Data * Loader::loadlevel(int id)
|
|||||||
for (int i=0; i<animIds.size(); i++)
|
for (int i=0; i<animIds.size(); i++)
|
||||||
{
|
{
|
||||||
AnimationType anim;
|
AnimationType anim;
|
||||||
|
anim.images = new QList<QImage *>;
|
||||||
for (int k=0; k<animations.value(animIds.at(i)).pathes.size(); k++)
|
for (int k=0; k<animations.value(animIds.at(i)).pathes.size(); k++)
|
||||||
anim.images.append(new QImage(animations.value(animIds.at(i))
|
anim.images->append(new QImage(animations.value(animIds.at(i))
|
||||||
.pathes.at(k)));
|
.pathes.at(k)));
|
||||||
gd->curAnimations.append(anim);
|
gd->curAnimations.append(anim);
|
||||||
}
|
}
|
||||||
|
for (int i=0; i<gd->aliens->srcAliens.size(); i++)
|
||||||
|
gd->aliens->srcAliens[i].images = gd->curAnimations.at(gd->aliens->srcAliens.at(i).imgType).images;
|
||||||
|
for (int i=0; i<gd->players.size(); i++)
|
||||||
|
for (int j=0; j<gd->players.at(i)->srcTowers.size(); j++)
|
||||||
|
{
|
||||||
|
gd->players[i]->srcTowers[j].image = gd->curAnimations.at(gd->players.at(i)->srcTowers.at(j).imgType).images->at(0);
|
||||||
|
for (int k=0; k<gd->players.at(i)->srcTowers.at(j).splashes.size(); k++)
|
||||||
|
gd->players[i]->srcTowers[j].splashes[k].images = gd->curAnimations.at(gd->players.at(i)->srcTowers.at(j).splashes.at(k).imgType).images;
|
||||||
|
}
|
||||||
return gd;
|
return gd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -436,13 +442,14 @@ void Loader::fillTowerChains(QList <int> * animIds, QList <tbChain> * chlist,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString Loader::createMapExample()
|
QString Loader::createMapExample()
|
||||||
{
|
{
|
||||||
QVector < QVector < int > > Cells;
|
QVector < QVector < int > > Cells;
|
||||||
Cells.resize(30);
|
Cells.resize(25);
|
||||||
for (int i=0; i<Cells.size(); i++)
|
for (int i=0; i<Cells.size(); i++)
|
||||||
{
|
{
|
||||||
Cells[i].resize(20);
|
Cells[i].resize(11);
|
||||||
Cells[i][0]=Map::Wall;
|
Cells[i][0]=Map::Wall;
|
||||||
Cells[i][Cells[i].size()-1]=Map::Wall;
|
Cells[i][Cells[i].size()-1]=Map::Wall;
|
||||||
}
|
}
|
||||||
@@ -457,12 +464,12 @@ QString Loader::createMapExample()
|
|||||||
for (int i=1; i<Cells.size()-1; i++)
|
for (int i=1; i<Cells.size()-1; i++)
|
||||||
for (int j=1; j<Cells[i].size()-1; j++)
|
for (int j=1; j<Cells[i].size()-1; j++)
|
||||||
Cells[i][j]=Map::Player;
|
Cells[i][j]=Map::Player;
|
||||||
for (int i=2; i<Cells.size()-2; i++)
|
//for (int i=2; i<Cells.size()-2; i++)
|
||||||
Cells[i][Cells[i].size()/2] = Map::Wall;
|
//Cells[i][Cells[i].size()/2] = Map::Wall;
|
||||||
Cells[0][Cells[0].size()/2]=Map::Start;
|
Cells[0][Cells[0].size()/2]=Map::Start;
|
||||||
Cells[Cells.size()/2-1][0]=Map::Start;
|
//Cells[Cells.size()/2-1][0]=Map::Start;
|
||||||
Cells[Cells.size()-1][Cells[Cells.size()-1].size()/2]=Map::Finish;
|
Cells[Cells.size()-1][Cells[Cells.size()-1].size()/2]=Map::Finish;
|
||||||
Cells[Cells.size()/2-1][Cells[Cells.size()/2].size()-1]=Map::Finish;
|
//Cells[Cells.size()/2-1][Cells[Cells.size()/2].size()-1]=Map::Finish;
|
||||||
QByteArray ba;
|
QByteArray ba;
|
||||||
QDataStream tmps(&ba,QIODevice::ReadWrite);
|
QDataStream tmps(&ba,QIODevice::ReadWrite);
|
||||||
tmps << Cells;
|
tmps << Cells;
|
||||||
|
|||||||
4
loader.h
4
loader.h
@@ -6,7 +6,7 @@
|
|||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QXmlSchema>
|
#include <QXmlSchema>
|
||||||
#include <QXmlSchemaValidator>
|
#include <QXmlSchemaValidator>
|
||||||
#include "game_data.h"
|
#include "adcore.h"
|
||||||
|
|
||||||
struct tbHeader
|
struct tbHeader
|
||||||
{
|
{
|
||||||
@@ -111,7 +111,6 @@ struct tbWaveOnLevel
|
|||||||
struct tbMap : tbHeader
|
struct tbMap : tbHeader
|
||||||
{
|
{
|
||||||
unsigned int maxPlayers;
|
unsigned int maxPlayers;
|
||||||
//QVector < QVector <int> > cells;
|
|
||||||
QByteArray data;
|
QByteArray data;
|
||||||
QSize size;
|
QSize size;
|
||||||
int imgType;
|
int imgType;
|
||||||
@@ -142,7 +141,6 @@ class Loader : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit Loader(QObject *parent = 0);
|
explicit Loader(QObject *parent = 0);
|
||||||
//void create();
|
|
||||||
void save(QString filename);
|
void save(QString filename);
|
||||||
void load(QString filename);
|
void load(QString filename);
|
||||||
Game_Data * loadlevel(int id);
|
Game_Data * loadlevel(int id);
|
||||||
|
|||||||
13
main.cpp
13
main.cpp
@@ -1,18 +1,15 @@
|
|||||||
#include <QtGui/QApplication>
|
#include <QtGui/QApplication>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
#include "adcore.h"
|
#include "form.h"
|
||||||
#include "ad_graphics.h"
|
#include "ui_form.h"
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
AD_Core core;
|
a.setStyle("cleanlooks");
|
||||||
AD_Graphics graphics(&core);
|
Form f;
|
||||||
graphics.resize(750,450);
|
f.show();
|
||||||
//QTimer * timer = new QTimer();
|
|
||||||
//QObject::connect(timer,SIGNAL(timeout()),&core,SLOT(next()));
|
|
||||||
//timer->start(100);
|
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
|||||||
109
map.cpp
109
map.cpp
@@ -39,28 +39,6 @@ Map::Map(QByteArray data, QSize size, QString name, int maxPlayers, int image, Q
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//void Map::ReadSettings()
|
|
||||||
//{
|
|
||||||
// QString str;
|
|
||||||
// SettingsReader * sreader = new SettingsReader("map.conf");
|
|
||||||
// str = sreader->getValue("cells path");
|
|
||||||
// maxPlayers = sreader->getValue("max players","1").toInt();
|
|
||||||
// QFile * f = new QFile(str);
|
|
||||||
// f->open(QIODevice::ReadOnly);
|
|
||||||
// QDataStream s(f);
|
|
||||||
// s >> Cells;
|
|
||||||
// if (Cells.size()>0)
|
|
||||||
// {
|
|
||||||
// mapsize.setWidth(Cells.size());
|
|
||||||
// mapsize.setHeight(Cells[0].size());
|
|
||||||
// //qDebug() << "Map size" << mapsize;
|
|
||||||
// //printMap();
|
|
||||||
// } else qDebug("invalid size");
|
|
||||||
// delete f;
|
|
||||||
// delete sreader;
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
void Map::printMap()
|
void Map::printMap()
|
||||||
{
|
{
|
||||||
for (int i=0; i<Cells.size(); i++) qDebug()<<Cells.at(i);
|
for (int i=0; i<Cells.size(); i++) qDebug()<<Cells.at(i);
|
||||||
@@ -82,9 +60,9 @@ void Map::removeAliensPath()
|
|||||||
void Map::delTowerOnMap(int playerId, QPoint pos)
|
void Map::delTowerOnMap(int playerId, QPoint pos)
|
||||||
{
|
{
|
||||||
Cells[pos.x()][pos.y()]=Player+playerId;
|
Cells[pos.x()][pos.y()]=Player+playerId;
|
||||||
Cells[pos.x()+1][pos.y()]=Player+playerId;
|
Cells[pos.x()-1][pos.y()]=Player+playerId;
|
||||||
Cells[pos.x()][pos.y()+1]=Player+playerId;
|
Cells[pos.x()][pos.y()-1]=Player+playerId;
|
||||||
Cells[pos.x()+1][pos.y()+1]=Player+playerId;
|
Cells[pos.x()-1][pos.y()-1]=Player+playerId;
|
||||||
emit recreateAlienPath(new bool());
|
emit recreateAlienPath(new bool());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,16 +70,16 @@ void Map::delTowerOnMap(int playerId, QPoint pos)
|
|||||||
bool Map::isReachable(int playerId, QPoint pos)
|
bool Map::isReachable(int playerId, QPoint pos)
|
||||||
{
|
{
|
||||||
Cells[pos.x()][pos.y()]=PlayerTower-Player-playerId;
|
Cells[pos.x()][pos.y()]=PlayerTower-Player-playerId;
|
||||||
Cells[pos.x()+1][pos.y()]=PlayerTower-Player-playerId;
|
Cells[pos.x()-1][pos.y()]=PlayerTower-Player-playerId;
|
||||||
Cells[pos.x()][pos.y()+1]=PlayerTower-Player-playerId;
|
Cells[pos.x()][pos.y()-1]=PlayerTower-Player-playerId;
|
||||||
Cells[pos.x()+1][pos.y()+1]=PlayerTower-Player-playerId;
|
Cells[pos.x()-1][pos.y()-1]=PlayerTower-Player-playerId;
|
||||||
for (int i=0; i<Starts.size(); i++) {
|
for (int i=0; i<Starts.size(); i++) {
|
||||||
for (int j=0; j<Finishs.size(); j++) {
|
for (int j=0; j<Finishs.size(); j++) {
|
||||||
if (waveTrace(Starts.at(i),Finishs.at(j))<0) {
|
if (waveTrace(Starts.at(i),Finishs.at(j))<0) {
|
||||||
Cells[pos.x()][pos.y()]=Player+playerId;
|
Cells[pos.x()][pos.y()]=Player+playerId;
|
||||||
Cells[pos.x()+1][pos.y()]=Player+playerId;
|
Cells[pos.x()-1][pos.y()]=Player+playerId;
|
||||||
Cells[pos.x()][pos.y()+1]=Player+playerId;
|
Cells[pos.x()][pos.y()-1]=Player+playerId;
|
||||||
Cells[pos.x()+1][pos.y()+1]=Player+playerId;
|
Cells[pos.x()-1][pos.y()-1]=Player+playerId;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -112,22 +90,21 @@ bool Map::isReachable(int playerId, QPoint pos)
|
|||||||
|
|
||||||
bool Map::addTowerOnMap(int playerId, QPoint pos)
|
bool Map::addTowerOnMap(int playerId, QPoint pos)
|
||||||
{
|
{
|
||||||
//qDebug() << pos;
|
|
||||||
if (playerId < 0 || playerId > players) return false;
|
if (playerId < 0 || playerId > players) return false;
|
||||||
QRect r(QPoint(),mapSize);
|
QRect r(QPoint(),mapSize);
|
||||||
if (!r.contains(pos) ||
|
if (!r.contains(pos) ||
|
||||||
!r.contains(pos+QPoint(1,0)) ||
|
!r.contains(pos-QPoint(1,0)) ||
|
||||||
!r.contains(pos+QPoint(0,1)) ||
|
!r.contains(pos-QPoint(0,1)) ||
|
||||||
!r.contains(pos+QPoint(1,1))) return false;
|
!r.contains(pos-QPoint(1,1))) return false;
|
||||||
if (Cells[pos.x()][pos.y()]==Player+playerId &&
|
if (Cells[pos.x()][pos.y()]==Player+playerId &&
|
||||||
Cells[pos.x()+1][pos.y()]==Player+playerId &&
|
Cells[pos.x()-1][pos.y()]==Player+playerId &&
|
||||||
Cells[pos.x()][pos.y()+1]==Player+playerId &&
|
Cells[pos.x()][pos.y()-1]==Player+playerId &&
|
||||||
Cells[pos.x()+1][pos.y()+1]==Player+playerId)
|
Cells[pos.x()-1][pos.y()-1]==Player+playerId)
|
||||||
return isReachable(playerId,pos);
|
return isReachable(playerId,pos);
|
||||||
if ((Cells[pos.x()][pos.y()]==AlienPath+Player+playerId || Cells[pos.x()][pos.y()]==Player+playerId) &&
|
if ((Cells[pos.x()][pos.y()]==AlienPath+Player+playerId || Cells[pos.x()][pos.y()]==Player+playerId) &&
|
||||||
(Cells[pos.x()+1][pos.y()]==AlienPath+Player+playerId || Cells[pos.x()+1][pos.y()]==Player+playerId) &&
|
(Cells[pos.x()-1][pos.y()]==AlienPath+Player+playerId || Cells[pos.x()-1][pos.y()]==Player+playerId) &&
|
||||||
(Cells[pos.x()][pos.y()+1]==AlienPath+Player+playerId || Cells[pos.x()][pos.y()+1]==Player+playerId) &&
|
(Cells[pos.x()][pos.y()-1]==AlienPath+Player+playerId || Cells[pos.x()][pos.y()-1]==Player+playerId) &&
|
||||||
(Cells[pos.x()+1][pos.y()+1]==AlienPath+Player+playerId || Cells[pos.x()+1][pos.y()+1]==Player+playerId))
|
(Cells[pos.x()-1][pos.y()-1]==AlienPath+Player+playerId || Cells[pos.x()-1][pos.y()-1]==Player+playerId))
|
||||||
{
|
{
|
||||||
if (!isReachable(playerId,pos)) return false;
|
if (!isReachable(playerId,pos)) return false;
|
||||||
bool * pathOK;
|
bool * pathOK;
|
||||||
@@ -144,59 +121,12 @@ bool Map::addTowerOnMap(int playerId, QPoint pos)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//void Map::CreateMapExample()
|
|
||||||
//{
|
|
||||||
// Cells.resize(16);
|
|
||||||
// for (int i=0; i<Cells.size(); i++)
|
|
||||||
// {
|
|
||||||
// Cells[i].resize(16);
|
|
||||||
// Cells[i][0]=Wall;
|
|
||||||
// Cells[i][Cells[i].size()-1]=Wall;
|
|
||||||
// }
|
|
||||||
// for (int i=0; i<Cells.size(); i++)
|
|
||||||
// {
|
|
||||||
// for (int j=0; j<Cells[i].size(); j++)
|
|
||||||
// {
|
|
||||||
// Cells[0][j]=Wall;
|
|
||||||
// Cells[Cells.size()-1][j]=Wall;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// for (int i=1; i<Cells.size()/2; i++)
|
|
||||||
// for (int j=1; j<Cells[i].size()-1; j++)
|
|
||||||
// Cells[i][j]=Player;
|
|
||||||
// for (int i=Cells.size()/2; i<Cells.size()-1; i++)
|
|
||||||
// for (int j=1; j<Cells[i].size()-1; j++)
|
|
||||||
// Cells[i][j]=Player+1;
|
|
||||||
// for (int i=2; i<Cells.size()-2; i++)
|
|
||||||
// Cells[i][Cells[i].size()/2] = Wall;
|
|
||||||
// Cells[Cells.size()/2][0]=Start;
|
|
||||||
// Cells[Cells.size()/2-1][0]=Start;
|
|
||||||
// Cells[Cells.size()/2][Cells[Cells.size()/2].size()-1]=Finish;
|
|
||||||
// Cells[Cells.size()/2-1][Cells[Cells.size()/2].size()-1]=Finish;
|
|
||||||
// QFile * f = new QFile("example16x16_64.map");
|
|
||||||
// f->open(QIODevice::ReadWrite);
|
|
||||||
// f->resize(0);
|
|
||||||
// QByteArray ba;
|
|
||||||
// QDataStream tmps(&ba,QIODevice::ReadWrite);
|
|
||||||
// tmps << Cells;
|
|
||||||
// ba = qCompress(ba);
|
|
||||||
// ba = ba.toBase64();
|
|
||||||
// QString str(ba);
|
|
||||||
//// QDataStream s(f);
|
|
||||||
//// s << ba;
|
|
||||||
// f->write(str.toUtf8());
|
|
||||||
// f->close();
|
|
||||||
// delete f;
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
QVector<QPointF> Map::createPath(QPoint start, QPoint finish)
|
QVector<QPointF> Map::createPath(QPoint start, QPoint finish)
|
||||||
{
|
{
|
||||||
QPointF tp;
|
QPointF tp;
|
||||||
QVector<QPoint> srcPath;
|
QVector<QPoint> srcPath;
|
||||||
QVector<QPointF> tmpPath;
|
QVector<QPointF> tmpPath;
|
||||||
QVector<QPointF> path;
|
QVector<QPointF> path;
|
||||||
//PathIndex = 1;
|
|
||||||
if (Cells[start.x()][start.y()] < 0)
|
if (Cells[start.x()][start.y()] < 0)
|
||||||
{
|
{
|
||||||
qDebug("ERROR invalid start");
|
qDebug("ERROR invalid start");
|
||||||
@@ -216,7 +146,6 @@ QVector<QPointF> Map::createPath(QPoint start, QPoint finish)
|
|||||||
tmpPath.push_back(QPointF(srcPath.at(i)));
|
tmpPath.push_back(QPointF(srcPath.at(i)));
|
||||||
}
|
}
|
||||||
srcPath.clear();
|
srcPath.clear();
|
||||||
//qDebug() << tmpPath.size();
|
|
||||||
if (!tmpPath.isEmpty())
|
if (!tmpPath.isEmpty())
|
||||||
{
|
{
|
||||||
for (int j=0; j<4; j++)
|
for (int j=0; j<4; j++)
|
||||||
@@ -226,7 +155,6 @@ QVector<QPointF> Map::createPath(QPoint start, QPoint finish)
|
|||||||
path.push_back(tp);
|
path.push_back(tp);
|
||||||
for (int i = 0; i < tmpPath.size() - 1; i++)
|
for (int i = 0; i < tmpPath.size() - 1; i++)
|
||||||
{
|
{
|
||||||
//if (j > 1) path.push_back(tmpPath[i]);
|
|
||||||
tp.setX((tmpPath.at(i).x() + tmpPath.at(i + 1).x()) / 2.0);
|
tp.setX((tmpPath.at(i).x() + tmpPath.at(i + 1).x()) / 2.0);
|
||||||
tp.setY((tmpPath.at(i).y() + tmpPath.at(i + 1).y()) / 2.0);
|
tp.setY((tmpPath.at(i).y() + tmpPath.at(i + 1).y()) / 2.0);
|
||||||
path.push_back(tp);
|
path.push_back(tp);
|
||||||
@@ -319,7 +247,6 @@ int Map::waveTrace(QPoint start, QPoint finish)
|
|||||||
step++;
|
step++;
|
||||||
}
|
}
|
||||||
qDebug() << "trace false";
|
qDebug() << "trace false";
|
||||||
//qDebug() << TmpCells;
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
17
map.h
17
map.h
@@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
// Maximum map is 65530 x 65530 because qHash may be repeat and towers has same Id
|
// Maximum map is 65530 x 65530 because qHash may be repeat and towers has same Id
|
||||||
|
|
||||||
|
/// TODO: fix cell type - must be a union of int and bit flags
|
||||||
|
|
||||||
class Map : public QObject
|
class Map : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -43,10 +45,10 @@ public:
|
|||||||
void removeAliensPath();
|
void removeAliensPath();
|
||||||
QVector <QPointF> createPath(QPoint start, QPoint finish);
|
QVector <QPointF> createPath(QPoint start, QPoint finish);
|
||||||
QRect rect() const {return QRect(QPoint(),mapSize);}
|
QRect rect() const {return QRect(QPoint(),mapSize);}
|
||||||
// QString name() const {return mapName;}
|
const QString &name() const {return mapName;}
|
||||||
QList <QPoint> starts() const {return Starts;}
|
const QList <QPoint> &starts() const {return Starts;}
|
||||||
QList <QPoint> finishs() const {return Finishs;}
|
const QList <QPoint> &finishs() const {return Finishs;}
|
||||||
QVector < QVector <int> > cells() const {return Cells;}
|
const QVector < QVector <int> > &cells() const {return Cells;}
|
||||||
int image() const {return imageType;}
|
int image() const {return imageType;}
|
||||||
int maxPlayers() const {return players;}
|
int maxPlayers() const {return players;}
|
||||||
signals:
|
signals:
|
||||||
@@ -60,16 +62,13 @@ private:
|
|||||||
int players;
|
int players;
|
||||||
int imageType;
|
int imageType;
|
||||||
QVector < QVector <int> > Cells;
|
QVector < QVector <int> > Cells;
|
||||||
QList <QPoint> Starts;
|
QVector < QVector <int> > TmpCells;
|
||||||
|
QList <QPoint> Starts;
|
||||||
QList <QPoint> Finishs;
|
QList <QPoint> Finishs;
|
||||||
|
|
||||||
QVector < QVector <int> > TmpCells;
|
|
||||||
|
|
||||||
QVector<QPoint> invWaveTrace(QPoint finish, int cnt);
|
QVector<QPoint> invWaveTrace(QPoint finish, int cnt);
|
||||||
int waveTrace(QPoint start, QPoint finish);
|
int waveTrace(QPoint start, QPoint finish);
|
||||||
bool isReachable(int playerId, QPoint pos);
|
bool isReachable(int playerId, QPoint pos);
|
||||||
//void CreateMapExample();
|
|
||||||
//void ReadSettings();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAP_H
|
#endif // MAP_H
|
||||||
|
|||||||
@@ -4,6 +4,6 @@ Player::Player(int Id, QObject *parent) :
|
|||||||
QObject(parent)
|
QObject(parent)
|
||||||
{
|
{
|
||||||
playerId = Id;
|
playerId = Id;
|
||||||
money = 100;
|
money = 50;
|
||||||
selectAlienId = -1;
|
selectAlienId = -1;
|
||||||
}
|
}
|
||||||
|
|||||||
2
player.h
2
player.h
@@ -8,7 +8,7 @@ class Player : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit Player(int Id, QObject *parent = 0);
|
explicit Player(int Id, QObject *parent = 0);
|
||||||
unsigned long int money;
|
long long int money;
|
||||||
unsigned long int score;
|
unsigned long int score;
|
||||||
int selectAlienId;
|
int selectAlienId;
|
||||||
QList <srcTowerType> srcTowers;
|
QList <srcTowerType> srcTowers;
|
||||||
|
|||||||
275
splashes.cpp
275
splashes.cpp
@@ -2,163 +2,206 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
Splashes::Splashes(Game_Data *gd, QObject *parent) :
|
Splashes::Splashes(Game_Data *gd, QObject *parent) :
|
||||||
QObject(parent)
|
QObject(parent)
|
||||||
{
|
{
|
||||||
gameData = gd;
|
gameData = gd;
|
||||||
nextId = 1;
|
nextId = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Splashes::addSplash(int player, int srcTower, int srcId, QPointF pos, QPointF dest, int aim, QPoint curTower)
|
void Splashes::addSplash(int player, srcSplashType *src, QPointF pos, QPointF dest, int aim)
|
||||||
{
|
{
|
||||||
srcSplashType src = gameData->players.at(player)->srcTowers.at(srcTower).splashes.at(srcId);
|
|
||||||
SplashType spl;
|
SplashType spl;
|
||||||
spl.id = nextId;
|
spl.id = nextId;
|
||||||
spl.TowerId = curTower;
|
spl.towerId = QPoint(-1,-1);
|
||||||
spl.srcTower = srcTower;
|
spl.srcTow = 0;
|
||||||
spl.PlayerId = player;
|
spl.PlayerId = player;
|
||||||
|
spl.AlienId = 0;
|
||||||
|
spl.pos = pos;
|
||||||
|
spl.destination = dest;
|
||||||
|
spl.AlienId = aim;
|
||||||
|
spl.angle = 180.0f*(- std::atan2(spl.pos.x() - spl.destination.x(),spl.pos.y() - spl.destination.y()))/M_PI;
|
||||||
|
spl.life = 0;
|
||||||
|
spl.src = src;
|
||||||
|
addSplash(&spl);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Splashes::addSplash(const TowerType &tower)
|
||||||
|
{
|
||||||
|
SplashType spl;
|
||||||
|
spl.src = &(tower.src->splashes[0]);
|
||||||
|
spl.id = nextId;
|
||||||
|
spl.towerId = tower.pos;
|
||||||
|
spl.PlayerId = tower.PlayerId;
|
||||||
|
spl.AlienId = tower.aim;
|
||||||
|
spl.srcTow = tower.src;
|
||||||
|
spl.pos = QPointF(tower.pos);
|
||||||
|
if (gameData->aliens->curAliens.contains(spl.AlienId))
|
||||||
|
spl.destination = gameData->aliens->curAliens.value(spl.AlienId).pos+QPointF(0.5,0.5);
|
||||||
|
else {qCritical("aim alien not exists(!)");return;}
|
||||||
|
spl.angle = 180.0f*(- std::atan2(spl.pos.x() - spl.destination.x(),spl.pos.y() - spl.destination.y()))/M_PI;
|
||||||
|
spl.life = 0;
|
||||||
|
addSplash(&spl);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Splashes::addSplash(srcTowerType *srctower, int id, QPointF pos, QPointF dest, int aim, QPoint towerId)
|
||||||
|
{
|
||||||
|
SplashType spl;
|
||||||
|
if (srctower != 0)
|
||||||
|
spl.src = &(srctower->splashes[id]);
|
||||||
|
else spl.src = &(gameData->srcSplashes[id]);
|
||||||
|
spl.id = nextId;
|
||||||
|
spl.towerId = towerId;
|
||||||
|
spl.PlayerId = srctower->PlayerId;
|
||||||
spl.AlienId = aim;
|
spl.AlienId = aim;
|
||||||
spl.pos = pos;
|
spl.pos = pos;
|
||||||
spl.destination = dest;
|
spl.destination = dest;
|
||||||
if (src.autoControl)
|
|
||||||
{
|
|
||||||
if (gameData->curAliens.contains(aim))
|
|
||||||
spl.destination = gameData->curAliens.value(aim).pos+QPointF(0.5,0.5);
|
|
||||||
}
|
|
||||||
spl.angle = 180.0f*(- std::atan2(spl.pos.x() - spl.destination.x(),spl.pos.y() - spl.destination.y()))/M_PI;
|
spl.angle = 180.0f*(- std::atan2(spl.pos.x() - spl.destination.x(),spl.pos.y() - spl.destination.y()))/M_PI;
|
||||||
spl.imgType = src.imgType;
|
|
||||||
spl.animIndex = 0;
|
|
||||||
spl.life = 0;
|
spl.life = 0;
|
||||||
spl.src = srcId;
|
spl.srcTow = srctower;
|
||||||
srcTriggerType trig;
|
addSplash(&spl);
|
||||||
for(int i=0; i<src.triggerIndexes.size(); i++)
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Splashes::addSplash(SplashType * spl)
|
||||||
|
{
|
||||||
|
srcTriggerType * trig;
|
||||||
|
for(int i=0; i<spl->src->triggerIndexes.size(); i++)
|
||||||
{
|
{
|
||||||
TriggerOnDest tod;
|
TriggerOnDest tod;
|
||||||
TriggerOnAlien toa;
|
TriggerOnAlien toa;
|
||||||
TriggerOnTimer tot;
|
TriggerOnTimer tot;
|
||||||
trig = gameData->players.at(player)->srcTowers.at(srcTower).triggers.at(src.triggerIndexes.at(i));
|
if (spl->srcTow != 0)
|
||||||
switch (trig.type)
|
trig = &(spl->srcTow->triggers[spl->src->triggerIndexes.at(i)]);
|
||||||
|
else {qDebug("no parent tower"); trig = &(gameData->srcTriggers[spl->src->triggerIndexes.at(i)]);}
|
||||||
|
switch (trig->type)
|
||||||
{
|
{
|
||||||
case srcTriggerType::onDestination :
|
case srcTriggerType::onDestination :
|
||||||
tod.src = src.triggerIndexes.at(i);
|
tod.src = trig;
|
||||||
spl.trigsOnDest.append(tod);
|
spl->trigsOnDest.append(tod);
|
||||||
break;
|
break;
|
||||||
case srcTriggerType::onAlienInRadius :
|
case srcTriggerType::onAlienInRadius :
|
||||||
toa.src = src.triggerIndexes.at(i);
|
toa.src = trig;
|
||||||
spl.trigsOnAlien.append(toa);
|
spl->trigsOnAlien.append(toa);
|
||||||
break;
|
break;
|
||||||
case srcTriggerType::onTimer :
|
case srcTriggerType::onTimer :
|
||||||
tot.src = src.triggerIndexes.at(i);
|
tot.src = trig;
|
||||||
tot.timer = 0;
|
tot.timer = 0;
|
||||||
spl.trigsOnTimer.append(tot);
|
spl->trigsOnTimer.append(tot);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
gameData->curSplashes.insert(spl.id,spl);
|
spl->item = new ADItem(spl->id, ADItem::Splash, spl->src->images);
|
||||||
|
spl->item->setPos(spl->pos*cellSize);
|
||||||
|
spl->item->setRotation(spl->angle);
|
||||||
|
scene->addItem(spl->item);
|
||||||
|
gameData->curSplashes.insert(spl->id,*spl);
|
||||||
nextId++;
|
nextId++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Splashes::addSplash(QPoint curTowerId)
|
|
||||||
{
|
|
||||||
if (gameData->curTowers.contains(curTowerId))
|
|
||||||
{
|
|
||||||
TowerType tw = gameData->curTowers.value(curTowerId);
|
|
||||||
addSplash(tw.PlayerId,tw.src,0,QPointF(tw.pos+QPoint(1,1)),gameData->curAliens.value(tw.aim).pos+QPointF(0.5,0.5),tw.aim,tw.pos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Splashes::update()
|
void Splashes::update()
|
||||||
{
|
{
|
||||||
QList <int> deadIndexes;
|
QList <int> deadIndexes;
|
||||||
// FIXME : rewrite loop with iterators, and correct onTrigTimer()
|
for (QHash<int, SplashType>::iterator
|
||||||
for (int i=0; i<gameData->curSplashes.size(); i++)
|
spl = gameData->curSplashes.begin();
|
||||||
|
spl != gameData->curSplashes.end(); ++spl)
|
||||||
{
|
{
|
||||||
float arctg,angl;
|
spl->life++;
|
||||||
SplashType spl = gameData->curSplashes.values().at(i);
|
if (spl->life > spl->src->lifetime)
|
||||||
srcSplashType src;
|
deadIndexes.append(spl->id);
|
||||||
// FIXME : if splash is not tower's splash, will be some trouble
|
if (!spl->trigsOnTimer.isEmpty())
|
||||||
src = gameData->players.at(spl.PlayerId)->srcTowers.at(spl.srcTower).splashes.at(spl.src);
|
doTriggerOnTimer(spl,&deadIndexes);
|
||||||
spl.life++;
|
float arctg;
|
||||||
if (spl.life > src.lifetime)
|
float speed = spl->src->speed;
|
||||||
deadIndexes.append(spl.id);
|
float speed2 = speed*speed;
|
||||||
if (!spl.trigsOnTimer.isEmpty())
|
if (spl->src->autoControl && spl->AlienId != -1)
|
||||||
{
|
|
||||||
doTriggerOnTimer(&spl,&deadIndexes);
|
|
||||||
}
|
|
||||||
if (src.autoControl)
|
|
||||||
{
|
{
|
||||||
bool badAl = false;
|
bool badAl = false;
|
||||||
if (gameData->curAliens.contains(spl.AlienId))
|
if (gameData->aliens->curAliens.contains(spl->AlienId))
|
||||||
spl.destination = gameData->curAliens.value(spl.AlienId).pos+QPointF(0.5,0.5);
|
spl->destination = gameData->aliens->curAliens.value(spl->AlienId).pos+QPointF(0.5,0.5);
|
||||||
else
|
else {
|
||||||
badAl = true;
|
badAl = true;
|
||||||
if (distance2(spl.pos, spl.destination) < src.speed*src.speed)
|
spl->AlienId = -1;
|
||||||
|
}
|
||||||
|
if (distance2(spl->pos, spl->destination) < speed2)
|
||||||
{
|
{
|
||||||
if (badAl)
|
if (badAl)
|
||||||
deadIndexes.push_back(spl.id);
|
deadIndexes.push_back(spl->id);
|
||||||
spl.pos = spl.destination;
|
spl->pos = spl->destination;
|
||||||
doTriggerOnDest(spl,&deadIndexes,badAl);
|
doTriggerOnDest(spl,&deadIndexes,badAl);
|
||||||
}
|
}
|
||||||
arctg = std::atan2(spl.pos.x() - spl.destination.x(),spl.pos.y() - spl.destination.y());
|
arctg = std::atan2(spl->pos.x() - spl->destination.x(),spl->pos.y() - spl->destination.y());
|
||||||
angl = 180.0f*(-arctg)/M_PI;
|
spl->angle = 180.0f*(-arctg)/M_PI;
|
||||||
spl.angle = angl;
|
|
||||||
spl.pos.setX(spl.pos.x()
|
|
||||||
-src.speed*std::sin(arctg));
|
|
||||||
spl.pos.setY(spl.pos.y()
|
|
||||||
-src.speed*std::cos(arctg));
|
|
||||||
} else {
|
} else {
|
||||||
if (!gameData->map->rect().contains(spl.pos.toPoint()))
|
if (!gameData->map->rect().contains(spl->pos.toPoint()))
|
||||||
deadIndexes.push_back(spl.id);
|
deadIndexes.push_back(spl->id);
|
||||||
if (!spl.trigsOnDest.isEmpty())
|
if (!spl->trigsOnDest.isEmpty())
|
||||||
{
|
{
|
||||||
if (distance2(spl.pos, spl.destination) < src.speed*src.speed)
|
if (distance2(spl->pos, spl->destination) < speed2)
|
||||||
{
|
{
|
||||||
spl.pos = spl.destination;
|
spl->pos = spl->destination;
|
||||||
doTriggerOnDest(spl,&deadIndexes,true);
|
doTriggerOnDest(spl,&deadIndexes,true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
spl.pos.setX(spl.pos.x()
|
arctg = -spl->angle*M_PI/180.f;
|
||||||
-src.speed*std::sin(-spl.angle*M_PI/180.f));
|
|
||||||
spl.pos.setY(spl.pos.y()
|
|
||||||
-src.speed*std::cos(-spl.angle*M_PI/180.f));
|
|
||||||
}
|
}
|
||||||
// TODO: smooth splash rotate
|
spl->pos.rx() -= speed*std::sin(arctg);
|
||||||
gameData->curSplashes.insert(spl.id,spl);
|
spl->pos.ry() -= speed*std::cos(arctg);
|
||||||
|
/// TODO: smooth splash rotate
|
||||||
|
spl->item->setPos(spl->pos*cellSize);
|
||||||
|
spl->item->setRotation(spl->angle);
|
||||||
|
if (speed == 0) spl->item->next(1.f);
|
||||||
|
else spl->item->next(speed*cellSize);
|
||||||
}
|
}
|
||||||
for (int j=0; j<deadIndexes.size(); j++)
|
for (int j=0; j<deadIndexes.size(); j++)
|
||||||
delSplash(deadIndexes.at(j));
|
delSplash(deadIndexes.at(j));
|
||||||
|
for (QHash<int,DeadAlienIndex>::iterator j = dead.begin();
|
||||||
|
j != dead.end(); ++j)
|
||||||
|
emit killAlien(j->player,j->id);
|
||||||
|
dead.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Splashes::delSplash(int Id)
|
void Splashes::delSplash(int Id)
|
||||||
{
|
{
|
||||||
|
scene->removeItem(gameData->curSplashes[Id].item);
|
||||||
|
delete gameData->curSplashes[Id].item;
|
||||||
gameData->curSplashes.remove(Id);
|
gameData->curSplashes.remove(Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Splashes::doTriggerOnTimer(SplashType *spl, QList<int> *deadIndexes)
|
/// FIXME : correct onTrigTimer()
|
||||||
|
void Splashes::doTriggerOnTimer(QHash<int, SplashType>::iterator
|
||||||
|
spl, QList<int> *deadIndexes)
|
||||||
{
|
{
|
||||||
for (int k=0; k<spl->trigsOnTimer.size(); k++)
|
for(QList<TriggerOnTimer>::iterator i = spl->trigsOnTimer.begin();
|
||||||
|
i != spl->trigsOnTimer.end(); ++i)
|
||||||
{
|
{
|
||||||
srcTriggerType strig = gameData->players.
|
srcTriggerType * strig = i->src;
|
||||||
at(spl->PlayerId)->srcTowers.
|
i->timer++;
|
||||||
at(spl->srcTower).triggers.
|
if (i->timer >= strig->timer)
|
||||||
at(spl->trigsOnTimer.at(k).src);
|
|
||||||
spl->trigsOnTimer[k].timer++;
|
|
||||||
if (spl->trigsOnTimer.at(k).timer >= strig.timer)
|
|
||||||
{
|
{
|
||||||
spl->trigsOnTimer[k].timer = 0;
|
/// TODO : add damage and other effects
|
||||||
if (strig.delParent) deadIndexes->append(spl->id);
|
i->timer = 0;
|
||||||
if (strig.count > 0 && strig.childId > 0)
|
if (strig->delParent) deadIndexes->append(spl->id);
|
||||||
|
if (strig->count > 0 && strig->childId > 0)
|
||||||
{
|
{
|
||||||
for (int j=0; j<strig.count; ++j)
|
int aim;
|
||||||
|
switch(strig->childAim)
|
||||||
|
{
|
||||||
|
/// TODO : othet aim types
|
||||||
|
case srcTriggerType::parentAim : aim = spl->AlienId; break;
|
||||||
|
case srcTriggerType::noAim : aim = -1; break;
|
||||||
|
default : aim = -1;
|
||||||
|
}
|
||||||
|
for (int j=0; j<strig->count; ++j)
|
||||||
{
|
{
|
||||||
// TODO: randomRadiusPos
|
/// TODO: randomRadiusPos
|
||||||
addSplash(spl->PlayerId,spl->srcTower,strig.childId,
|
addSplash(spl->srcTow, strig->childId, spl->pos, spl->destination, aim, spl->towerId);
|
||||||
spl->pos,spl->destination,-1,spl->TowerId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -166,50 +209,54 @@ void Splashes::doTriggerOnTimer(SplashType *spl, QList<int> *deadIndexes)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Splashes::doTriggerOnDest(const SplashType &spl, QList<int> *deadIndexes,
|
void Splashes::doTriggerOnDest(QHash<int, SplashType>::iterator
|
||||||
|
spl, QList<int> *deadIndexes,
|
||||||
bool badAl)
|
bool badAl)
|
||||||
{
|
{
|
||||||
for (int k=0; k<spl.trigsOnDest.size(); k++)
|
foreach(TriggerOnDest t, spl->trigsOnDest)
|
||||||
{
|
{
|
||||||
// TODO: aims for childs
|
/// TODO: different aims for childs
|
||||||
srcTriggerType strig = gameData->players.
|
if (t.src->delParent) deadIndexes->append(spl->id);
|
||||||
at(spl.PlayerId)->srcTowers.
|
int aim;
|
||||||
at(spl.srcTower).triggers.
|
switch(t.src->childAim)
|
||||||
at(spl.trigsOnDest.at(k).src);
|
|
||||||
if (strig.delParent) deadIndexes->append(spl.id);
|
|
||||||
if (strig.count > 0 && strig.childId > 0)
|
|
||||||
{
|
{
|
||||||
for (int j=0; j<strig.count; ++j)
|
case srcTriggerType::parentAim : aim = spl->AlienId; break;
|
||||||
|
/// TODO : other aim types
|
||||||
|
case srcTriggerType::noAim : aim = -1; break;
|
||||||
|
default : aim = -1;
|
||||||
|
}
|
||||||
|
if (t.src->count > 0 && t.src->childId > 0)
|
||||||
|
{
|
||||||
|
for (int j=0; j<t.src->count; ++j)
|
||||||
{
|
{
|
||||||
// TODO: randomRadiusPos
|
/// TODO: randomRadiusPos
|
||||||
addSplash(spl.PlayerId,spl.srcTower,strig.childId,
|
addSplash(spl->srcTow,t.src->childId,
|
||||||
spl.pos,spl.destination,-1,spl.TowerId);
|
spl->pos,spl->destination,aim,spl->towerId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (strig.damage > 0)
|
float dmg = t.src->damage;
|
||||||
|
float rad = t.src->radius;
|
||||||
|
if (dmg > 0)
|
||||||
{
|
{
|
||||||
if (!(strig.radius > 0))
|
float hh;
|
||||||
|
if (!(rad > 0))
|
||||||
{
|
{
|
||||||
if (!badAl)
|
if (!badAl)
|
||||||
{
|
{
|
||||||
float hh = gameData->curAliens[spl.AlienId].health -= strig.damage;
|
hh = gameData->aliens->curAliens[spl->AlienId].health -= dmg;
|
||||||
if (hh < 0)
|
if (hh <= 0) dead.insert(spl->AlienId, DeadAlienIndex(spl->AlienId, spl->PlayerId));
|
||||||
gameData->curAliens.remove(spl.AlienId);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
QList <int> dead;
|
|
||||||
for (QHash<int, AlienType>::iterator
|
for (QHash<int, AlienType>::iterator
|
||||||
i = gameData->curAliens.begin();
|
i = gameData->aliens->curAliens.begin();
|
||||||
i != gameData->curAliens.end(); ++i)
|
i != gameData->aliens->curAliens.end(); ++i)
|
||||||
{
|
{
|
||||||
if (distance2(spl.pos, (*i).pos) < strig.radius*strig.radius)
|
if (distance2(spl->pos, i->pos) < rad*rad)
|
||||||
{
|
{
|
||||||
(*i).health -= strig.damage;
|
hh = i->health -= dmg;
|
||||||
if ((*i).health < 0) dead.append((*i).id);
|
if (hh <= 0) dead.insert(i->id, DeadAlienIndex(i->id, spl->PlayerId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i=0; i<dead.size(); ++i)
|
|
||||||
gameData->curAliens.remove(dead.at(i));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
27
splashes.h
27
splashes.h
@@ -5,24 +5,41 @@
|
|||||||
|
|
||||||
class Splashes : public QObject
|
class Splashes : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit Splashes(Game_Data * gd, QObject *parent = 0);
|
explicit Splashes(Game_Data * gd, QObject *parent = 0);
|
||||||
void addSplash( int player, int srcTower, int srcId, QPointF pos, QPointF dest, int aim, QPoint curTower);
|
|
||||||
void delSplash(int Id);
|
void delSplash(int Id);
|
||||||
void update();
|
void update();
|
||||||
|
void setScene(QGraphicsScene * scene_) {scene = scene_;}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
/// TODO : fix killalien - new function for adding alien in kill list and del aliens in finish update
|
||||||
|
void killAlien(int playerId, int alienId);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void addSplash(QPoint towerId);
|
void addSplash(int player, srcSplashType * src, QPointF pos, QPointF dest, int aim = -1);
|
||||||
|
void addSplash(const TowerType &tower);
|
||||||
|
void addSplash(srcTowerType * srctower, int id, QPointF pos, QPointF dest, int aim = -1, QPoint towerId = QPoint(-1,-1));
|
||||||
|
void addSplash(SplashType *spl);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
QGraphicsScene * scene;
|
||||||
Game_Data *gameData;
|
Game_Data *gameData;
|
||||||
int nextId;
|
int nextId;
|
||||||
|
struct DeadAlienIndex
|
||||||
|
{
|
||||||
|
DeadAlienIndex(int i, int p) {id = i; player = p;}
|
||||||
|
int player;
|
||||||
|
int id;
|
||||||
|
};
|
||||||
|
QHash <int, DeadAlienIndex> dead;
|
||||||
|
|
||||||
void doTriggerOnDest(const SplashType &spl, QList <int> * deadIndexes,
|
void doTriggerOnDest(QHash<int, SplashType>::iterator
|
||||||
|
spl, QList <int> * deadIndexes,
|
||||||
bool badAl);
|
bool badAl);
|
||||||
void doTriggerOnTimer(SplashType * spl, QList <int> * deadIndexes);
|
void doTriggerOnTimer(QHash<int, SplashType>::iterator
|
||||||
|
spl, QList <int> * deadIndexes);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SPLASHES_H
|
#endif // SPLASHES_H
|
||||||
|
|||||||
108
touch_butt.cpp
Normal file
108
touch_butt.cpp
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
#include "touch_butt.h"
|
||||||
|
|
||||||
|
touch_butt::touch_butt(int butt_index, QString caption, QColor colr, QColor colg, QColor colw, QColor colp, QPushButton * parent) : QPushButton(parent)
|
||||||
|
{
|
||||||
|
cr = colr; cg = colg; cw = colw; cp = colp;
|
||||||
|
aim_col = this->palette().button().color();
|
||||||
|
next_col = aim_col;
|
||||||
|
index = butt_index;
|
||||||
|
this->setText(caption);
|
||||||
|
connect(this,SIGNAL(pressed()),SLOT(butt_push()));
|
||||||
|
connect(this,SIGNAL(clicked()),SLOT(butt_click()));
|
||||||
|
connect(this,SIGNAL(toggled(bool)),SLOT(butt_toggle(bool)));
|
||||||
|
connect(this,SIGNAL(released()),SLOT(butt_release()));
|
||||||
|
timer = new QTimer(this);
|
||||||
|
connect(timer,SIGNAL(timeout()),this,SLOT(timerDone()));
|
||||||
|
timer->start(10);
|
||||||
|
setWhite();
|
||||||
|
is_push = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void touch_butt::setColor(QColor colr, QColor colg, QColor colw, QColor colp)
|
||||||
|
{
|
||||||
|
cr = colr; cg = colg; cw = colw; cp = colp;
|
||||||
|
setWhite();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void touch_butt::timerDone()
|
||||||
|
{
|
||||||
|
float r = this->palette().button().color().redF();
|
||||||
|
float g = this->palette().button().color().greenF();
|
||||||
|
float b = this->palette().button().color().blueF();
|
||||||
|
r += (aim_col.redF()-r)/9.0f;
|
||||||
|
g += (aim_col.greenF()-g)/9.0f;
|
||||||
|
b += (aim_col.blueF()-b)/9.0f;
|
||||||
|
QPalette pal;
|
||||||
|
pal.setColor(QPalette::Button,QColor(qRound(r*255.0f),qRound(g*255.0f),qRound(b*255.0f)));
|
||||||
|
this->setPalette(pal);
|
||||||
|
if (qAbs(aim_col.redF() - r) < 0.02 && qAbs(aim_col.greenF() - g) < 0.02 && qAbs(aim_col.blueF() - b) < 0.02)
|
||||||
|
{
|
||||||
|
pal.setColor(QPalette::Button,aim_col);
|
||||||
|
this->setPalette(pal);
|
||||||
|
aim_col = next_col;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void touch_butt::butt_click()
|
||||||
|
{
|
||||||
|
is_push = false;
|
||||||
|
//setWhite();
|
||||||
|
//timerDone();
|
||||||
|
emit touch_click(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void touch_butt::butt_push()
|
||||||
|
{
|
||||||
|
is_push = true;
|
||||||
|
setPush();
|
||||||
|
emit touch_push(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void touch_butt::butt_release()
|
||||||
|
{
|
||||||
|
is_push = false;
|
||||||
|
setWhite();
|
||||||
|
timerDone();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void touch_butt::butt_toggle(bool checked)
|
||||||
|
{
|
||||||
|
if (!checked) {
|
||||||
|
setWhite();
|
||||||
|
}
|
||||||
|
emit touch_toggle(index,checked);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void touch_butt::setRed()
|
||||||
|
{
|
||||||
|
next_col = cr;
|
||||||
|
timerDone();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void touch_butt::setGreen()
|
||||||
|
{
|
||||||
|
//if (!is_push)
|
||||||
|
next_col = cg;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void touch_butt::setWhite()
|
||||||
|
{
|
||||||
|
//if (!is_push)
|
||||||
|
next_col = cw;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void touch_butt::setPush()
|
||||||
|
{
|
||||||
|
next_col = cp;
|
||||||
|
timerDone();
|
||||||
|
}
|
||||||
40
touch_butt.h
Normal file
40
touch_butt.h
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#ifndef TOUCH_BUTT_H
|
||||||
|
#define TOUCH_BUTT_H
|
||||||
|
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QPalette>
|
||||||
|
#include <QEvent>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
class touch_butt : public QPushButton
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
touch_butt(int butt_index, QString caption, QColor colr, QColor colg, QColor colw, QColor colp, QPushButton * parent = 0);
|
||||||
|
int index;
|
||||||
|
void setRed();
|
||||||
|
void setGreen();
|
||||||
|
void setWhite();
|
||||||
|
void setColor(QColor colr, QColor colg, QColor colw, QColor colp);
|
||||||
|
QColor color() const {return next_col;}
|
||||||
|
public slots:
|
||||||
|
void butt_click();
|
||||||
|
void butt_toggle(bool checked);
|
||||||
|
private:
|
||||||
|
QTimer * timer;
|
||||||
|
QColor aim_col, next_col;
|
||||||
|
QColor cr,cg,cw,cp;
|
||||||
|
bool is_push;
|
||||||
|
void setPush();
|
||||||
|
private slots:
|
||||||
|
void butt_push();
|
||||||
|
void butt_release();
|
||||||
|
void timerDone();
|
||||||
|
signals:
|
||||||
|
void touch_push(int index);
|
||||||
|
void touch_click(int index);
|
||||||
|
void touch_toggle(int index, bool checked);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TOUCH_BUTT_H
|
||||||
67
touchbuttframe.cpp
Normal file
67
touchbuttframe.cpp
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
#include "touchbuttframe.h"
|
||||||
|
|
||||||
|
TouchButtFrame::TouchButtFrame(QWidget *parent, QColor cr, QColor cg, QColor cw, QColor cp, Orientation orientation) :
|
||||||
|
QFrame(parent)
|
||||||
|
{
|
||||||
|
colr = cr; colg = cg; colw = cw; colp = cp;
|
||||||
|
setFrameShape(QFrame::StyledPanel);;
|
||||||
|
if (orientation == Horizontal) lay = new QHBoxLayout();
|
||||||
|
else lay = new QVBoxLayout();
|
||||||
|
count = 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void TouchButtFrame::addButton(QString caption)
|
||||||
|
{
|
||||||
|
touch_butt * butt = new touch_butt(count,caption,colr,colg,colw,colp);
|
||||||
|
butt->setMinimumHeight(50);
|
||||||
|
butt->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
|
||||||
|
butt->setCheckable(true);
|
||||||
|
butt->setAutoExclusive(true);
|
||||||
|
butt->setAutoFillBackground(true);
|
||||||
|
if (lay->isEmpty()) butt->setChecked(true);
|
||||||
|
connect(butt,SIGNAL(touch_click(int)),SLOT(butt_click(int)));
|
||||||
|
connect(butt,SIGNAL(touch_toggle(int,bool)),SLOT(butt_toggle(int,bool)));
|
||||||
|
lay->addWidget(butt);
|
||||||
|
this->setLayout(lay);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TouchButtFrame::butt_click(int index)
|
||||||
|
{
|
||||||
|
//qDebug() << "button" << index << "clicked!";
|
||||||
|
//if (((touch_butt*)lay->itemAt(index)->widget())->isChecked())
|
||||||
|
//((touch_butt*)lay->itemAt(index)->widget())->setGreen();
|
||||||
|
emit click(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TouchButtFrame::butt_toggle(int index,bool checked)
|
||||||
|
{
|
||||||
|
//if (((touch_butt*)lay->itemAt(index)->widget())->isChecked())
|
||||||
|
//qDebug() << "button" << index << "toggled" << checked;
|
||||||
|
emit toggle(index,checked);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void TouchButtFrame::resetColors()
|
||||||
|
{
|
||||||
|
for (int i=0; i<buttCount(); ++i)
|
||||||
|
{
|
||||||
|
Button(i)->setColor(colr,colg,colw,colp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int TouchButtFrame::buttCount()
|
||||||
|
{
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
touch_butt * TouchButtFrame::Button(int index)
|
||||||
|
{
|
||||||
|
return ((touch_butt*)lay->itemAt(index)->widget());
|
||||||
|
}
|
||||||
51
touchbuttframe.h
Normal file
51
touchbuttframe.h
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
#ifndef TOUCHBUTTFRAME_H
|
||||||
|
#define TOUCHBUTTFRAME_H
|
||||||
|
|
||||||
|
#include <QtGui/QFrame>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QDebug>
|
||||||
|
#include "touch_butt.h"
|
||||||
|
|
||||||
|
|
||||||
|
class TouchButtFrame : public QFrame
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QColor ColorYes READ colorYes WRITE setColorYes)
|
||||||
|
Q_PROPERTY(QColor ColorNo READ colorNo WRITE setColorNo)
|
||||||
|
Q_PROPERTY(QColor ColorDefault READ colorDefault WRITE setColorDefault)
|
||||||
|
Q_PROPERTY(QColor ColorPush READ colorPush WRITE setColorPush)
|
||||||
|
public:
|
||||||
|
enum Orientation {
|
||||||
|
Horizontal = 0,
|
||||||
|
Vertical = 1
|
||||||
|
};
|
||||||
|
TouchButtFrame(QWidget * parent = 0,
|
||||||
|
QColor red = Qt::red, QColor green = Qt::green, QColor white = Qt::white, QColor push = Qt::darkYellow,
|
||||||
|
Orientation orientation = Vertical);
|
||||||
|
void addButton(QString caption);
|
||||||
|
int buttCount();
|
||||||
|
QColor colorYes() const {return colg;}
|
||||||
|
QColor colorNo() const {return colr;}
|
||||||
|
QColor colorDefault() const {return colw;}
|
||||||
|
QColor colorPush() const {return colp;}
|
||||||
|
void setColorYes(QColor ColorYes) {colg = ColorYes; resetColors();}
|
||||||
|
void setColorNo(QColor ColorNo) {colr = ColorNo; resetColors();}
|
||||||
|
void setColorDefault(QColor ColorDefault) {colw = ColorDefault; resetColors();}
|
||||||
|
void setColorPush(QColor ColorPush) {colp = ColorPush; resetColors();}
|
||||||
|
touch_butt * Button(int index);
|
||||||
|
public slots:
|
||||||
|
void set_green(int index) {Button(index)->setGreen();}
|
||||||
|
private slots:
|
||||||
|
void butt_click(int index);
|
||||||
|
void butt_toggle(int index, bool checked);
|
||||||
|
private:
|
||||||
|
QColor colr,colg,colw,colp;
|
||||||
|
QLayout * lay;
|
||||||
|
int count;
|
||||||
|
void resetColors();
|
||||||
|
signals:
|
||||||
|
void click(int index);
|
||||||
|
void toggle(int index, bool checked);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TOUCHBUTTFRAME_H
|
||||||
109
towers.cpp
109
towers.cpp
@@ -3,45 +3,51 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
Towers::Towers(Game_Data *gd, QObject *parent) :
|
Towers::Towers(Game_Data *gd, QObject *parent) :
|
||||||
QObject(parent)
|
QObject(parent)
|
||||||
{
|
{
|
||||||
gameData = gd;
|
gameData = gd;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Towers::addTower(int playerId, int srcId, QPoint pos)
|
bool Towers::addTower(int playerId, int srcId, QPoint pos)
|
||||||
{
|
{
|
||||||
//QByteArray ar;
|
|
||||||
//ar << pos;
|
|
||||||
if (playerId < 0 || playerId >= gameData->players.size())
|
if (playerId < 0 || playerId >= gameData->players.size())
|
||||||
{
|
{
|
||||||
qCritical("ERROR out of players range");
|
qCritical("ERROR out of players range");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (srcId < 0 || srcId >= gameData->players.at(playerId)->srcTowers.size())
|
Player * p = gameData->players.at(playerId);
|
||||||
|
if (srcId < 0 || srcId >= p->srcTowers.size())
|
||||||
{
|
{
|
||||||
qCritical("ERROR out of towers range");
|
qCritical("ERROR out of towers range");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (p->money < p->srcTowers.at(srcId).cost)
|
||||||
|
{
|
||||||
|
qDebug() << "not enought money!";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
QRect alrec(pos,QSize(2,2));
|
QRect alrec(pos,QSize(2,2));
|
||||||
for (QHash<int, AlienType>::iterator i = gameData->curAliens.begin(); i != gameData->curAliens.end(); ++i)
|
for (QHash<int, AlienType>::iterator i = gameData->aliens->curAliens.begin(); i != gameData->aliens->curAliens.end(); ++i)
|
||||||
if (alrec.contains((*i).pos.toPoint())) return false;
|
if (alrec.contains(i->pos.toPoint())) return false;
|
||||||
TowerType tw;
|
TowerType tw;
|
||||||
tw.src = srcId;
|
tw.src = &(p->srcTowers[srcId]);
|
||||||
tw.imgType = gameData->players.at(playerId)->srcTowers.at(srcId).imgType;
|
|
||||||
tw.animIndex = 0;
|
|
||||||
tw.PlayerId = playerId;
|
tw.PlayerId = playerId;
|
||||||
tw.angle = 0;
|
tw.angle = 0;
|
||||||
tw.build = 0;
|
tw.build = 0;
|
||||||
tw.reload = 0;
|
tw.reload = 0;
|
||||||
tw.aim = -1;
|
tw.aim = -1;
|
||||||
tw.experience = 0;
|
tw.experience = 0;
|
||||||
//tw .oldAim = -1;
|
tw.isBilding = true;
|
||||||
if (gameData->map->addTowerOnMap(playerId,pos))
|
if (gameData->map->addTowerOnMap(playerId,pos))
|
||||||
{
|
{
|
||||||
tw.pos = pos;
|
tw.pos = pos;
|
||||||
//qDebug() << "tw" << pos;
|
tw.item = new ADItem(tw.pos,tw.src->image,QRectF(-cellSize,-cellSize,cellSize*2,cellSize*2));
|
||||||
//gameData->map->printMap();
|
tw.item->setPos(tw.pos * cellSize);
|
||||||
|
tw.item->rotate(tw.angle);
|
||||||
|
tw.item->setOpacity(0.5);
|
||||||
|
scene->addItem(tw.item);
|
||||||
gameData->curTowers.insert(tw.pos,tw);
|
gameData->curTowers.insert(tw.pos,tw);
|
||||||
|
p->money -= tw.src->cost;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -50,10 +56,18 @@ bool Towers::addTower(int playerId, int srcId, QPoint pos)
|
|||||||
|
|
||||||
void Towers::delTower(QPoint pos)
|
void Towers::delTower(QPoint pos)
|
||||||
{
|
{
|
||||||
if (gameData->curTowers.contains(pos))
|
QPoint p;
|
||||||
|
if (gameData->curTowers.contains(pos)) p = pos;
|
||||||
|
if (gameData->curTowers.contains(pos+QPoint(1,0))) p = pos+QPoint(1,0);
|
||||||
|
if (gameData->curTowers.contains(pos+QPoint(1,1))) p = pos+QPoint(1,1);
|
||||||
|
if (gameData->curTowers.contains(pos+QPoint(0,1))) p = pos+QPoint(0,1);
|
||||||
|
if (gameData->curTowers.contains(p))
|
||||||
{
|
{
|
||||||
gameData->map->delTowerOnMap(gameData->curTowers.value(pos).PlayerId,pos);
|
TowerType * t = &(gameData->curTowers[p]);
|
||||||
gameData->curTowers.remove(pos);
|
gameData->map->delTowerOnMap(t->PlayerId,p);
|
||||||
|
scene->removeItem(t->item);
|
||||||
|
delete t->item;
|
||||||
|
gameData->curTowers.remove(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,55 +76,58 @@ void Towers::update()
|
|||||||
{
|
{
|
||||||
for (QHash<QPoint, TowerType>::iterator i = gameData->curTowers.begin(); i != gameData->curTowers.end(); ++i)
|
for (QHash<QPoint, TowerType>::iterator i = gameData->curTowers.begin(); i != gameData->curTowers.end(); ++i)
|
||||||
{
|
{
|
||||||
srcTowerType stw = gameData->players.at((*i).PlayerId)->srcTowers.at((*i).src);
|
if (i->isBilding)
|
||||||
if ((*i).build < stw.buildTime)
|
|
||||||
{
|
{
|
||||||
(*i).build++;
|
if (i->build < i->src->buildTime)
|
||||||
//qDebug() << "building tower ..." << (*i).build;
|
{
|
||||||
|
i->build++;
|
||||||
|
i->item->setBarValue((float)(i->build)/i->src->buildTime);
|
||||||
|
} else {
|
||||||
|
i->isBilding = false;
|
||||||
|
i->item->hideBar();
|
||||||
|
i->item->setOpacity(1.0);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!(gameData->curAliens.contains((*i).aim)))
|
float rad = i->src->radius;
|
||||||
(*i).aim = -1;
|
float rad2 = rad*rad;
|
||||||
|
if (!(gameData->aliens->curAliens.contains(i->aim)))
|
||||||
|
i->aim = -1;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (distance2((*i).pos,gameData->curAliens.value((*i).aim).pos) > stw.radius*stw.radius)
|
if (distance2(i->pos,gameData->aliens->curAliens.value(i->aim).pos) > rad2)
|
||||||
(*i).aim = -1;
|
i->aim = -1;
|
||||||
}
|
}
|
||||||
if (gameData->players.at((*i).PlayerId)->selectAlienId > 0)
|
if (gameData->players.at(i->PlayerId)->selectAlienId > 0)
|
||||||
{
|
{
|
||||||
AlienType al = gameData->curAliens.value(gameData->players.at((*i).PlayerId)->selectAlienId);
|
AlienType al = gameData->aliens->curAliens.value(gameData->players.at(i->PlayerId)->selectAlienId);
|
||||||
if (distance2(al.pos, (*i).pos) < stw.radius*stw.radius) (*i).aim = al.id;
|
if (distance2(al.pos, i->pos) < rad2) i->aim = al.id;
|
||||||
}
|
}
|
||||||
if ((*i).aim < 0)
|
if (i->aim < 0)
|
||||||
{
|
{
|
||||||
for (QHash<int, AlienType>::iterator j = gameData->curAliens.begin(); j != gameData->curAliens.end(); ++j)
|
for (QHash<int, AlienType>::iterator j = gameData->aliens->curAliens.begin(); j != gameData->aliens->curAliens.end(); ++j)
|
||||||
{
|
{
|
||||||
float dist = distance2((*i).pos, (*j).pos);
|
float dist = distance2(i->pos, (*j).pos);
|
||||||
//qDebug() << "dist=" << dist << "radius=" << stw.radius*stw.radius;
|
if (dist < rad2) i->aim = (*j).id;
|
||||||
if (dist < stw.radius*stw.radius) (*i).aim = (*j).id;
|
|
||||||
//else (*i).aim = -1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: calculate tower angl
|
if (i->aim > 0)
|
||||||
if ((*i).aim > 0)
|
|
||||||
{
|
{
|
||||||
float arctg = std::atan2((*i).pos.x() - gameData->curAliens.value((*i).aim).pos.x(),(*i).pos.y() - gameData->curAliens.value((*i).aim).pos.y());
|
float arctg = std::atan2(i->pos.x() - gameData->aliens->curAliens.value(i->aim).pos.x(),i->pos.y() - gameData->aliens->curAliens.value(i->aim).pos.y());
|
||||||
//if (tmpdy < 0) arctg=arctg+M_PI;
|
i->angle = 180.0f*(-arctg)/M_PI;
|
||||||
(*i).angle = 180.0f*(-arctg)/M_PI;
|
i->item->setRotation(i->angle);
|
||||||
}
|
}
|
||||||
// TODO: smooth rotate tower to aim
|
/// TODO: smooth rotate tower to aim
|
||||||
if ((*i).reload < stw.reload)
|
if (i->reload < i->src->reload)
|
||||||
(*i).reload++;
|
i->reload++;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((*i).aim > 0)
|
if (i->aim > 0)
|
||||||
{
|
{
|
||||||
(*i).reload = 0;
|
i->reload = 0;
|
||||||
(*i).experience += stw.expByShot;
|
i->experience += i->src->expByShot;
|
||||||
emit shot((*i).pos);
|
emit shot((*i));
|
||||||
//qDebug("shot!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//qDebug() << "aim=" << (*i).aim;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
6
towers.h
6
towers.h
@@ -11,12 +11,16 @@ public:
|
|||||||
bool addTower(int playerId, int srcId, QPoint pos);
|
bool addTower(int playerId, int srcId, QPoint pos);
|
||||||
void delTower(QPoint pos);
|
void delTower(QPoint pos);
|
||||||
void update();
|
void update();
|
||||||
|
void setScene(QGraphicsScene * scene_) {scene = scene_;}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void shot(QPoint towerId);
|
void shot(const TowerType &tow);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Game_Data * gameData;
|
Game_Data * gameData;
|
||||||
|
QGraphicsScene * scene;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TOWERS_H
|
#endif // TOWERS_H
|
||||||
|
|||||||
Reference in New Issue
Block a user