changes in arhitecture, some improvments, much optimising and simplify,
many bagfixes and new graphics engine
This commit is contained in:
39
loader.cpp
39
loader.cpp
@@ -1,12 +1,10 @@
|
||||
#include "loader.h"
|
||||
|
||||
Loader::Loader(QObject *parent) :
|
||||
QObject(parent)
|
||||
QObject(parent)
|
||||
{
|
||||
doc = new QDomDocument("data");
|
||||
//create();
|
||||
qDebug() << createMapExample();
|
||||
//load();
|
||||
}
|
||||
|
||||
|
||||
@@ -266,11 +264,10 @@ Game_Data * Loader::loadlevel(int id)
|
||||
qDebug() << tr("Loading level %1 ...").arg(levels.value(id).name);
|
||||
tbMap tbm = maps.value(levels.value(id).mapId);
|
||||
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);
|
||||
for (int i=0; i<map->maxPlayers(); i++)
|
||||
{
|
||||
Player * pl = new Player(0);
|
||||
Player * pl = new Player(i);
|
||||
gd->players.append(pl);
|
||||
}
|
||||
qDebug() << gd->players.size();
|
||||
@@ -312,10 +309,9 @@ Game_Data * Loader::loadlevel(int id)
|
||||
wt.counts.prepend(tbwpt.count);
|
||||
}
|
||||
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();
|
||||
}
|
||||
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();
|
||||
for (int i=0; i<alienIds.size(); ++i)
|
||||
{
|
||||
@@ -332,7 +328,7 @@ Game_Data * Loader::loadlevel(int id)
|
||||
salt.regeneration = tbal.regeneration;
|
||||
salt.score = tbal.score;
|
||||
salt.speed = tbal.speed;
|
||||
gd->srcAliens.append(salt);
|
||||
gd->aliens->srcAliens.append(salt);
|
||||
qDebug() << tr("Alien %1 #%2 ").arg(salt.name).arg(i);
|
||||
}
|
||||
QList <tbTowerOnLevel> tollist = levTowers.values(id);
|
||||
@@ -374,11 +370,21 @@ Game_Data * Loader::loadlevel(int id)
|
||||
for (int i=0; i<animIds.size(); i++)
|
||||
{
|
||||
AnimationType anim;
|
||||
anim.images = new QList<QImage *>;
|
||||
for (int k=0; k<animations.value(animIds.at(i)).pathes.size(); k++)
|
||||
anim.images.append(new QImage(animations.value(animIds.at(i))
|
||||
.pathes.at(k)));
|
||||
anim.images->append(new QImage(animations.value(animIds.at(i))
|
||||
.pathes.at(k)));
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -436,13 +442,14 @@ void Loader::fillTowerChains(QList <int> * animIds, QList <tbChain> * chlist,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QString Loader::createMapExample()
|
||||
{
|
||||
QVector < QVector < int > > Cells;
|
||||
Cells.resize(30);
|
||||
Cells.resize(25);
|
||||
for (int i=0; i<Cells.size(); i++)
|
||||
{
|
||||
Cells[i].resize(20);
|
||||
Cells[i].resize(11);
|
||||
Cells[i][0]=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 j=1; j<Cells[i].size()-1; j++)
|
||||
Cells[i][j]=Map::Player;
|
||||
for (int i=2; i<Cells.size()-2; i++)
|
||||
Cells[i][Cells[i].size()/2] = Map::Wall;
|
||||
//for (int i=2; i<Cells.size()-2; i++)
|
||||
//Cells[i][Cells[i].size()/2] = Map::Wall;
|
||||
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()/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;
|
||||
QDataStream tmps(&ba,QIODevice::ReadWrite);
|
||||
tmps << Cells;
|
||||
|
||||
Reference in New Issue
Block a user