added Towers loading in level
This commit is contained in:
@@ -1,12 +1,13 @@
|
|||||||
#include "adcore.h"
|
#include "adcore.h"
|
||||||
|
|
||||||
adCore::adCore(QObject *parent) :
|
adCore::adCore(QObject *parent) :
|
||||||
QThread(parent)
|
QThread(parent)
|
||||||
{
|
{
|
||||||
step = 0;
|
step = 0;
|
||||||
//admap = new Map(1);
|
//admap = new Map(1);
|
||||||
//addata = new Game_Data(admap);
|
//addata = new Game_Data(admap);
|
||||||
adloader = new Loader();
|
adloader = new Loader();
|
||||||
|
adloader->load("data2.xml");
|
||||||
addata = adloader->loadlevel(1);
|
addata = adloader->loadlevel(1);
|
||||||
if (addata != 0) qDebug("Sucsess");
|
if (addata != 0) qDebug("Sucsess");
|
||||||
else qDebug("Error");
|
else qDebug("Error");
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||||
<value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration" type="int">2</value>
|
<value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration" type="int">2</value>
|
||||||
<value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory" type="QString">C:/Users/Andrey/Desktop/aliendefender-build-desktop</value>
|
<value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory" type="QString">C:/Users/Andrey/Desktop/aliendefender-build-desktop</value>
|
||||||
<value key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId" type="int">5</value>
|
<value key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId" type="int">9</value>
|
||||||
<value key="Qt4ProjectManager.Qt4BuildConfiguration.ToolChain" type="int">2</value>
|
<value key="Qt4ProjectManager.Qt4BuildConfiguration.ToolChain" type="int">2</value>
|
||||||
<value key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild" type="bool">true</value>
|
<value key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild" type="bool">true</value>
|
||||||
</valuemap>
|
</valuemap>
|
||||||
@@ -81,7 +81,7 @@
|
|||||||
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||||
<value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration" type="int">0</value>
|
<value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration" type="int">0</value>
|
||||||
<value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory" type="QString">C:/Users/Andrey/Desktop/aliendefender-build-desktop</value>
|
<value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory" type="QString">C:/Users/Andrey/Desktop/aliendefender-build-desktop</value>
|
||||||
<value key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId" type="int">5</value>
|
<value key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId" type="int">9</value>
|
||||||
<value key="Qt4ProjectManager.Qt4BuildConfiguration.ToolChain" type="int">2</value>
|
<value key="Qt4ProjectManager.Qt4BuildConfiguration.ToolChain" type="int">2</value>
|
||||||
<value key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild" type="bool">true</value>
|
<value key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild" type="bool">true</value>
|
||||||
</valuemap>
|
</valuemap>
|
||||||
@@ -96,8 +96,8 @@
|
|||||||
<value key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal" type="bool">false</value>
|
<value key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal" type="bool">false</value>
|
||||||
<valuelist key="Qt4ProjectManager.Qt4RunConfiguration.UserEnvironmentChanges" type="QVariantList"/>
|
<valuelist key="Qt4ProjectManager.Qt4RunConfiguration.UserEnvironmentChanges" type="QVariantList"/>
|
||||||
<value key="Qt4ProjectManager.Qt4RunConfiguration.UserSetName" type="bool">false</value>
|
<value key="Qt4ProjectManager.Qt4RunConfiguration.UserSetName" type="bool">false</value>
|
||||||
<value key="Qt4ProjectManager.Qt4RunConfiguration.UserSetWorkingDirectory" type="bool">false</value>
|
<value key="Qt4ProjectManager.Qt4RunConfiguration.UserSetWorkingDirectory" type="bool">true</value>
|
||||||
<value key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory" type="QString"></value>
|
<value key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory" type="QString">C:\Users\Andrey\Desktop\aliendefender</value>
|
||||||
</valuemap>
|
</valuemap>
|
||||||
<value key="ProjectExplorer.Target.RunConfigurationCount" type="int">1</value>
|
<value key="ProjectExplorer.Target.RunConfigurationCount" type="int">1</value>
|
||||||
</valuemap>
|
</valuemap>
|
||||||
|
|||||||
@@ -72,6 +72,14 @@ struct srcTriggerType
|
|||||||
onTimer,
|
onTimer,
|
||||||
onAlienInRadius
|
onAlienInRadius
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum aimType
|
||||||
|
{
|
||||||
|
noAim,
|
||||||
|
parentAim,
|
||||||
|
allSide,
|
||||||
|
nearlestAlien
|
||||||
|
};
|
||||||
int childId; // =-1 for non birth splash (e.q. only damage)
|
int childId; // =-1 for non birth splash (e.q. only damage)
|
||||||
bool delParent;
|
bool delParent;
|
||||||
float damage;
|
float damage;
|
||||||
|
|||||||
64
data2.xml
Normal file
64
data2.xml
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
<!DOCTYPE data>
|
||||||
|
<ADdata>
|
||||||
|
<aliens>
|
||||||
|
<alien flying="true" speed="0.03" imageType="31" prise="15" id="2" score="12" name="Monstr" health="150"/>
|
||||||
|
<alien flying="true" speed="0.01" imageType="-1078580008" prise="1" id="4" score="10" name="test" health="60"/>
|
||||||
|
<alien speed="0.06" imageType="1" prise="4" id="10" score="99" name="first" health="100"/>
|
||||||
|
<alien regeneration="3" speed="0.0099" imageType="1" prise="10" armor="1.5" id="12" score="99" name="MONSTR" health="99.99"/>
|
||||||
|
</aliens>
|
||||||
|
<maps>
|
||||||
|
<map width="16" imageType="1" height="16" id="1" data="AAAERHicY2BgEGAA4v///0hQgmFmAGlGcjCxZuCTHzUDuxkMDOr85JrBwKC0A8kMJlwYagYOeYgZ+NXgNwMtPEbNINIMIsynOO8DAG0r1Q0=" name="My Map" maxPlayers="2"/>
|
||||||
|
</maps>
|
||||||
|
<waves>
|
||||||
|
<wave prise="100" timeout="20000" id="1"/>
|
||||||
|
<wave prise="200" timeout="20000" id="2"/>
|
||||||
|
<wave prise="220" timeout="20000" id="3"/>
|
||||||
|
</waves>
|
||||||
|
<levels>
|
||||||
|
<level map="1" id="1" score="138978384" name="First Level"/>
|
||||||
|
</levels>
|
||||||
|
<waveParts>
|
||||||
|
<wavePart alien="10" count="10" wave="1"/>
|
||||||
|
<wavePart alien="12" count="5" wave="1"/>
|
||||||
|
<wavePart alien="10" count="4" wave="1"/>
|
||||||
|
<wavePart alien="10" count="9" wave="2"/>
|
||||||
|
<wavePart alien="12" count="4" wave="3"/>
|
||||||
|
<wavePart alien="12" count="3" wave="3"/>
|
||||||
|
<wavePart alien="10" count="2" wave="3"/>
|
||||||
|
<wavePart alien="10" count="1" wave="3"/>
|
||||||
|
</waveParts>
|
||||||
|
<wavesOnLevels>
|
||||||
|
<waveOnLevel wave="3" level="1"/>
|
||||||
|
<waveOnLevel wave="2" level="1"/>
|
||||||
|
<waveOnLevel wave="1" level="1"/>
|
||||||
|
</wavesOnLevels>
|
||||||
|
<splashes>
|
||||||
|
<splash speed="0.2" imageType="1" lifetime="9999" id="1" name="rocket"/>
|
||||||
|
<splash speed="0.2" imageType="1" lifetime="9999" autoControl="true" id="2" name="smart rocket"/>
|
||||||
|
<splash speed="100" imageType="2" lifetime="100" autoControl="true" id="3" name="bullet"/>
|
||||||
|
<splash speed="1" imageType="3" lifetime="10" id="4" name="bum"/>
|
||||||
|
<splash speed="0" imageType="4" lifetime="10" id="5" name="smoke"/>
|
||||||
|
</splashes>
|
||||||
|
<towers>
|
||||||
|
<tower imageType="1" radius="3" expByKill="0.1" expByShot="0.15" buildTime="50" splash="1" reload="20" id="1" name="rocket launcher" cost="30" expByDamage="0.04"/>
|
||||||
|
<tower imageType="2" radius="1.5" expByKill="0.2" expByShot="0.1" buildTime="25" splash="3" reload="5" id="2" name="gun" cost="10" expByDamage="0.1"/>
|
||||||
|
<tower imageType="1" radius="3" expByKill="0.1" expByShot="0.15" buildTime="50" splash="2" reload="20" id="3" name="rocket launcher 2" cost="30" expByDamage="0.04"/>
|
||||||
|
</towers>
|
||||||
|
<triggers>
|
||||||
|
<trigger damage="5" childAim="noAim" delParent="true" type="onDestination" id="2" name="shot"/>
|
||||||
|
<trigger damage="5" childAim="noAim" radius="1.5" delParent="true" count="1" type="onDestination" id="3" name="explosion"/>
|
||||||
|
<trigger childAim="noAim" count="1" type="onTimer" id="4" name="smoke"/>
|
||||||
|
</triggers>
|
||||||
|
<chains>
|
||||||
|
<chain tower="1" trigger="4" child="5" parent="1"/>
|
||||||
|
<chain tower="1" trigger="3" child="4" parent="1"/>
|
||||||
|
<chain tower="2" trigger="2" parent="3"/>
|
||||||
|
<chain tower="3" trigger="4" child="5" parent="2"/>
|
||||||
|
<chain tower="3" trigger="3" child="4" parent="2"/>
|
||||||
|
</chains>
|
||||||
|
<towersOnLevels>
|
||||||
|
<towerOnLevel tower="3" level="1"/>
|
||||||
|
<towerOnLevel tower="2" level="1"/>
|
||||||
|
<towerOnLevel tower="1" level="1"/>
|
||||||
|
</towersOnLevels>
|
||||||
|
</ADdata>
|
||||||
259
loader.cpp
259
loader.cpp
@@ -188,13 +188,13 @@ void Loader::save(QString filename)
|
|||||||
elem.setAttribute("randomPosRadius",trig.randomPosRadius);
|
elem.setAttribute("randomPosRadius",trig.randomPosRadius);
|
||||||
switch (trig.childAim)
|
switch (trig.childAim)
|
||||||
{
|
{
|
||||||
case tbTrigger::allSide :
|
case srcTriggerType::allSide :
|
||||||
elem.setAttribute("childAim","allSide");
|
elem.setAttribute("childAim","allSide");
|
||||||
break;
|
break;
|
||||||
case tbTrigger::nearlestAlien :
|
case srcTriggerType::nearlestAlien :
|
||||||
elem.setAttribute("childAim","nearlestAlien");
|
elem.setAttribute("childAim","nearlestAlien");
|
||||||
break;
|
break;
|
||||||
case tbTrigger::parentAim :
|
case srcTriggerType::parentAim :
|
||||||
elem.setAttribute("childAim","parentAim");
|
elem.setAttribute("childAim","parentAim");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -203,15 +203,15 @@ void Loader::save(QString filename)
|
|||||||
}
|
}
|
||||||
switch (trig.type)
|
switch (trig.type)
|
||||||
{
|
{
|
||||||
case tbTrigger::onTimer :
|
case srcTriggerType::onTimer :
|
||||||
elem.setAttribute("type","onTimer");
|
elem.setAttribute("type","onTimer");
|
||||||
break;
|
break;
|
||||||
case tbTrigger::onDestination :
|
case srcTriggerType::onDestination :
|
||||||
elem.setAttribute("type","onDestination");
|
elem.setAttribute("type","onDestination");
|
||||||
break;
|
break;
|
||||||
case tbTrigger::onAlienInRadius :
|
case srcTriggerType::onAlienInRadius :
|
||||||
elem.setAttribute("type","onAlienInRadius");
|
elem.setAttribute("type","onAlienInRadius");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
child = data.createElement("chains");
|
child = data.createElement("chains");
|
||||||
@@ -243,84 +243,151 @@ void Loader::save(QString filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Game_Data * Loader::loadlevel(int id)
|
Game_Data * Loader::loadlevel(int id)
|
||||||
//{
|
{
|
||||||
// if (!levels.contains(id))
|
if (!levels.contains(id))
|
||||||
// {
|
{
|
||||||
// qCritical() << tr("Error Level %1 not found!").arg(id);
|
qCritical() << tr("Error Level %1 not found!").arg(id);
|
||||||
// return 0;
|
return 0;
|
||||||
// }
|
}
|
||||||
// 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);
|
||||||
// Game_Data * gd = new Game_Data(map);
|
Game_Data * gd = new Game_Data(map);
|
||||||
// QList <tbWaveOnLevel> wollist = levWaves.values(id);
|
QList <tbWaveOnLevel> wollist = levWaves.values(id);
|
||||||
// if (wollist.isEmpty())
|
if (wollist.isEmpty())
|
||||||
// {
|
{
|
||||||
// qCritical() << tr("Error no waves on level!");
|
qCritical() << tr("Error no waves on level!");
|
||||||
// return 0;
|
return 0;
|
||||||
// }
|
}
|
||||||
// tbWave tbw;
|
tbWave tbw;
|
||||||
// tbWavePart tbwpt;
|
tbWavePart tbwpt;
|
||||||
// QList <tbWavePart> wplist;
|
QList <tbWavePart> wplist;
|
||||||
// QList <int> alienIds;
|
QList <int> alienIds;
|
||||||
// for (int i=0; i<wollist.size(); i++)
|
for (int i=0; i<wollist.size(); i++)
|
||||||
// {
|
{
|
||||||
// WaveType wt;
|
WaveType wt;
|
||||||
// tbw = waves.value(wollist.at(i).waveId);
|
tbw = waves.value(wollist.at(i).waveId);
|
||||||
// wt.prise = tbw.prise;
|
wt.prise = tbw.prise;
|
||||||
// wt.timeout = tbw.timeout;
|
wt.timeout = tbw.timeout;
|
||||||
// wplist = waveParts.values(tbw.id);
|
wplist = waveParts.values(tbw.id);
|
||||||
// if (wplist.isEmpty())
|
if (wplist.isEmpty())
|
||||||
// {
|
{
|
||||||
// qCritical() << tr("Error wave %1 is empty!").arg(tbw.id);
|
qCritical() << tr("Error wave %1 is empty!").arg(tbw.id);
|
||||||
// return 0;
|
return 0;
|
||||||
// }
|
}
|
||||||
// for (int j=0; j<wplist.size(); j++)
|
for (int j=0; j<wplist.size(); j++)
|
||||||
// {
|
{
|
||||||
// tbwpt = wplist.at(j);
|
tbwpt = wplist.at(j);
|
||||||
// if (alienIds.contains(tbwpt.alienId))
|
if (alienIds.contains(tbwpt.alienId))
|
||||||
// {
|
{
|
||||||
// wt.types.prepend(alienIds.indexOf(tbwpt.alienId));
|
wt.types.prepend(alienIds.indexOf(tbwpt.alienId));
|
||||||
// } else {
|
} else {
|
||||||
// alienIds.append(tbwpt.alienId);
|
alienIds.append(tbwpt.alienId);
|
||||||
// wt.types.prepend(alienIds.size()-1);
|
wt.types.prepend(alienIds.size()-1);
|
||||||
// }
|
}
|
||||||
// wt.counts.prepend(tbwpt.count);
|
wt.counts.prepend(tbwpt.count);
|
||||||
// }
|
}
|
||||||
// gd->waves.prepend(wt);
|
gd->waves.prepend(wt);
|
||||||
// wplist.clear();
|
wplist.clear();
|
||||||
// }
|
}
|
||||||
// for (int i=0; i<gd->waves.size(); i++)
|
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;
|
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++)
|
||||||
// {
|
{
|
||||||
// srcAlienType salt;
|
srcAlienType salt;
|
||||||
// tbAlien tbal = aliens.value(alienIds.at(i));
|
tbAlien tbal = aliens.value(alienIds.at(i));
|
||||||
// salt.armor = tbal.armor;
|
salt.armor = tbal.armor;
|
||||||
// salt.health = tbal.health;
|
salt.health = tbal.health;
|
||||||
// salt.imgType = tbal.imgType;
|
salt.imgType = tbal.imgType;
|
||||||
// salt.isFlying = tbal.isFlying;
|
salt.isFlying = tbal.isFlying;
|
||||||
// salt.name = tbal.name;
|
salt.name = tbal.name;
|
||||||
// salt.prise = tbal.prise;
|
salt.prise = tbal.prise;
|
||||||
// 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->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);
|
||||||
// tbTower tbt;
|
tbTower tbt;
|
||||||
// for (int i=0; i<tollist.size(); i++)
|
for (int i=0; i<tollist.size(); i++)
|
||||||
// {
|
{
|
||||||
// srcTowerType stt;
|
srcTowerType stt;
|
||||||
// tbt = towers.value(tollist.at(i).towerId);
|
tbt = towers.value(tollist.at(i).towerId);
|
||||||
// }
|
stt.buildTime = tbt.buildTime;
|
||||||
// return gd;
|
stt.cost = tbt.cost;
|
||||||
//}
|
stt.expByDamage = tbt.expByDamage;
|
||||||
|
stt.expByKill = tbt.expByKill;
|
||||||
|
stt.expByShot = tbt.expByShot;
|
||||||
|
stt.imgType = tbt.imgType;
|
||||||
|
stt.name = tbt.name;
|
||||||
|
stt.radius = tbt.radius;
|
||||||
|
stt.reload = tbt.reload;
|
||||||
|
QList <tbChain> chlist = chains.values(tbt.id);
|
||||||
|
QList <int> trigIds;
|
||||||
|
tbSplash tbs = splashes.value(tbt.splashId);
|
||||||
|
srcSplashType sst;
|
||||||
|
sst.autoControl = tbs.autoControl;
|
||||||
|
sst.imgType = tbs.imgType;
|
||||||
|
sst.lifetime = tbs.lifetime;
|
||||||
|
sst.name = tbs.name;
|
||||||
|
sst.speed = tbs.speed;
|
||||||
|
stt.splashes.append(sst);
|
||||||
|
int recursiveCheck = 1;
|
||||||
|
fillTowerChains(&chlist,&trigIds,&stt,tbt.splashId,0,&recursiveCheck);
|
||||||
|
qDebug() << tr("Tower %1 trig=%2 splash=%3").arg(stt.name).arg(stt.triggers.size()).arg(stt.splashes.size()) << tr("chain lenght %1").arg(recursiveCheck);
|
||||||
|
}
|
||||||
|
return gd;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Loader::fillTowerChains(QList <tbChain> * chlist, QList <int> * trigIds, srcTowerType * stt, int parId, int parIndex, int * recursiveCheck)
|
||||||
|
{
|
||||||
|
if (*recursiveCheck > 100)
|
||||||
|
{
|
||||||
|
qCritical("circle dependencies detected!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (int i=0; i<chlist->size(); i++)
|
||||||
|
{
|
||||||
|
if (chlist->at(i).parentSplashId == parId)
|
||||||
|
{
|
||||||
|
int trigid = chlist->at(i).triggerId;
|
||||||
|
if (!(trigIds->contains(trigid)))
|
||||||
|
{
|
||||||
|
srcTriggerType strigt;
|
||||||
|
tbTrigger tbtrig = triggers.value(trigid);
|
||||||
|
strigt.count = tbtrig.count;
|
||||||
|
strigt.damage = tbtrig.damage;
|
||||||
|
strigt.delParent = tbtrig.delParent;
|
||||||
|
strigt.radius = tbtrig.radius;
|
||||||
|
strigt.randomPosRadius = tbtrig.randomPosRadius;
|
||||||
|
strigt.timer = tbtrig.timer;
|
||||||
|
strigt.type = tbtrig.type;
|
||||||
|
stt->triggers.append(strigt);
|
||||||
|
trigIds->append(trigid);
|
||||||
|
}
|
||||||
|
stt->splashes[parIndex].triggerIndexes.append(trigIds->indexOf(trigid));
|
||||||
|
if (chlist->at(i).childSplashId > 0 && stt->triggers.at(trigIds->indexOf(trigid)).count > 0)
|
||||||
|
{
|
||||||
|
tbSplash tbs = splashes.value(chlist->at(i).childSplashId);
|
||||||
|
srcSplashType sst;
|
||||||
|
sst.autoControl = tbs.autoControl;
|
||||||
|
sst.imgType = tbs.imgType;
|
||||||
|
sst.lifetime = tbs.lifetime;
|
||||||
|
sst.name = tbs.name;
|
||||||
|
sst.speed = tbs.speed;
|
||||||
|
stt->splashes.append(sst);
|
||||||
|
stt->triggers[stt->splashes.at(parIndex).triggerIndexes.size()-1].childId = stt->splashes.size() - 1;
|
||||||
|
*recursiveCheck += 1;
|
||||||
|
fillTowerChains(chlist,trigIds,stt,chlist->at(i).childSplashId, stt->splashes.size()-1,recursiveCheck);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QString Loader::CreateMapExample()
|
QString Loader::CreateMapExample()
|
||||||
{
|
{
|
||||||
QVector < QVector < int > > Cells;
|
QVector < QVector < int > > Cells;
|
||||||
@@ -611,19 +678,19 @@ void Loader::readTriggers()
|
|||||||
trig.delParent = (str == "true");
|
trig.delParent = (str == "true");
|
||||||
str = nm.namedItem("type").nodeValue();
|
str = nm.namedItem("type").nodeValue();
|
||||||
if (str == "onDestination")
|
if (str == "onDestination")
|
||||||
trig.type = tbTrigger::onDestination;
|
trig.type = srcTriggerType::onDestination;
|
||||||
if (str == "onTimer")
|
if (str == "onTimer")
|
||||||
trig.type = tbTrigger::onTimer;
|
trig.type = srcTriggerType::onTimer;
|
||||||
if (str == "onAlienInRadius")
|
if (str == "onAlienInRadius")
|
||||||
trig.type = tbTrigger::onAlienInRadius;
|
trig.type = srcTriggerType::onAlienInRadius;
|
||||||
str = nm.namedItem("childAim").nodeValue();
|
str = nm.namedItem("childAim").nodeValue();
|
||||||
trig.childAim = tbTrigger::noAim;
|
trig.childAim = srcTriggerType::noAim;
|
||||||
if (str == "allSide")
|
if (str == "allSide")
|
||||||
trig.childAim = tbTrigger::allSide;
|
trig.childAim = srcTriggerType::allSide;
|
||||||
if (str == "parentAim")
|
if (str == "parentAim")
|
||||||
trig.childAim = tbTrigger::parentAim;
|
trig.childAim = srcTriggerType::parentAim;
|
||||||
if (str == "nearlestAlien")
|
if (str == "nearlestAlien")
|
||||||
trig.childAim = tbTrigger::nearlestAlien;
|
trig.childAim = srcTriggerType::nearlestAlien;
|
||||||
triggers.insert(trig.id,trig);
|
triggers.insert(trig.id,trig);
|
||||||
qDebug() << tr("Trigger %1 id=%2 damage=%3 radius=%4 delParent=%5 timer=%6").arg(trig.name).arg(trig.id).arg(trig.damage).arg(trig.radius).arg(trig.delParent).arg(trig.timer)
|
qDebug() << tr("Trigger %1 id=%2 damage=%3 radius=%4 delParent=%5 timer=%6").arg(trig.name).arg(trig.id).arg(trig.damage).arg(trig.radius).arg(trig.delParent).arg(trig.timer)
|
||||||
<< tr("count=%1 chance=%2 randomPosRadius=%3 type=%4 childAim=%5").arg(trig.count).arg(trig.chance).arg(trig.randomPosRadius).arg(trig.type).arg(trig.childAim);
|
<< tr("count=%1 chance=%2 randomPosRadius=%3 type=%4 childAim=%5").arg(trig.count).arg(trig.chance).arg(trig.randomPosRadius).arg(trig.type).arg(trig.childAim);
|
||||||
@@ -726,7 +793,7 @@ void Loader::readMaps()
|
|||||||
|
|
||||||
void Loader::validate(QString filename)
|
void Loader::validate(QString filename)
|
||||||
{
|
{
|
||||||
QFile sfile("schema.xml");
|
QFile sfile("schema.xml");
|
||||||
if (!sfile.open(QIODevice::ReadOnly))
|
if (!sfile.open(QIODevice::ReadOnly))
|
||||||
qFatal("No file schema.xml found!");
|
qFatal("No file schema.xml found!");
|
||||||
QXmlSchema schema;
|
QXmlSchema schema;
|
||||||
|
|||||||
23
loader.h
23
loader.h
@@ -10,8 +10,8 @@
|
|||||||
|
|
||||||
struct tbHeader
|
struct tbHeader
|
||||||
{
|
{
|
||||||
int id;
|
int id;
|
||||||
QString name;
|
QString name;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct tbAlien : tbHeader
|
struct tbAlien : tbHeader
|
||||||
@@ -36,26 +36,12 @@ struct tbSplash : tbHeader
|
|||||||
|
|
||||||
struct tbTrigger : tbHeader
|
struct tbTrigger : tbHeader
|
||||||
{
|
{
|
||||||
enum triggerType
|
|
||||||
{
|
|
||||||
onDestination,
|
|
||||||
onTimer,
|
|
||||||
onAlienInRadius
|
|
||||||
};
|
|
||||||
|
|
||||||
enum aimType
|
|
||||||
{
|
|
||||||
noAim,
|
|
||||||
parentAim,
|
|
||||||
allSide,
|
|
||||||
nearlestAlien
|
|
||||||
};
|
|
||||||
float damage;
|
float damage;
|
||||||
float radius;
|
float radius;
|
||||||
int chance;
|
int chance;
|
||||||
bool delParent;
|
bool delParent;
|
||||||
aimType childAim;
|
srcTriggerType::aimType childAim;
|
||||||
triggerType type;
|
srcTriggerType::triggerType type;
|
||||||
unsigned int timer;
|
unsigned int timer;
|
||||||
int count;
|
int count;
|
||||||
float randomPosRadius;
|
float randomPosRadius;
|
||||||
@@ -191,6 +177,7 @@ private:
|
|||||||
void readWaveParts();
|
void readWaveParts();
|
||||||
void readUpgrades();
|
void readUpgrades();
|
||||||
|
|
||||||
|
void fillTowerChains(QList <tbChain> * chlist, QList <int> * trigIds, srcTowerType * stt, int parId, int parIndex, int * recursiveCheck);
|
||||||
void validate(QString filename);
|
void validate(QString filename);
|
||||||
QString CreateMapExample();
|
QString CreateMapExample();
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user