some work...
read all, but missing morphs and upgrades new in-game types (src and cur)
This commit is contained in:
63
base_types.h
63
base_types.h
@@ -5,11 +5,10 @@
|
|||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
|
||||||
struct Alien
|
struct AlienType
|
||||||
{
|
{
|
||||||
int Id; // uses for QHash
|
int Id; // uses for QHash
|
||||||
QString name;
|
int src;
|
||||||
int type;
|
|
||||||
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.)
|
||||||
@@ -17,24 +16,38 @@ struct Alien
|
|||||||
QPoint finish;
|
QPoint finish;
|
||||||
QVector <QPointF> path;
|
QVector <QPointF> path;
|
||||||
int pathIndex;
|
int pathIndex;
|
||||||
|
int imgType;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct srcAlienType
|
||||||
|
{
|
||||||
|
QString name;
|
||||||
|
float speed;
|
||||||
|
float health;
|
||||||
|
float armor;
|
||||||
|
float regeneration;
|
||||||
|
bool isFlying;
|
||||||
|
unsigned int score;
|
||||||
|
int imgType;
|
||||||
unsigned int prise;
|
unsigned int prise;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct Tower
|
struct TowerType
|
||||||
{
|
{
|
||||||
QString name;
|
int src;
|
||||||
int type;
|
|
||||||
int AlienId; // aim alien
|
int AlienId; // aim alien
|
||||||
int PlayerId; // tower's owner
|
int PlayerId; // tower's owner
|
||||||
|
int imgType;
|
||||||
QPoint pos; // not QPointF because tower fixed on grid
|
QPoint pos; // not QPointF because tower fixed on grid
|
||||||
float angle; // -180 .. 180
|
float angle; // -180 .. 180
|
||||||
float range; // in cells
|
unsigned int reload; // time for reload in ticks
|
||||||
float reload; // time for reload in ticks
|
unsigned int build;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct srcTrigger
|
struct srcTriggerType
|
||||||
{
|
{
|
||||||
enum triggerType
|
enum triggerType
|
||||||
{
|
{
|
||||||
@@ -53,36 +66,44 @@ struct srcTrigger
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct srcSplash
|
struct srcSplashType
|
||||||
{
|
{
|
||||||
QString name;
|
QString name;
|
||||||
int imgType;
|
int imgType;
|
||||||
float speed; // in cells
|
float speed; // in cells
|
||||||
|
int lifetime;
|
||||||
bool autoControl;
|
bool autoControl;
|
||||||
QList <int> triggerIndexes;
|
QList <int> triggerIndexes;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct srcTower
|
|
||||||
|
struct srcTowerType
|
||||||
{
|
{
|
||||||
QString name;
|
QString name;
|
||||||
int type;
|
int imgType;
|
||||||
int PlayerId; // tower's owner
|
int PlayerId; // tower's owner
|
||||||
float range; // in cells
|
unsigned int cost;
|
||||||
float reload; // time for reload in ticks
|
unsigned int reload;
|
||||||
QList <srcTrigger> triggers;
|
unsigned int buildTime;
|
||||||
QList <srcSplash> splashes;
|
float radius; // in cells
|
||||||
|
float expByShot;
|
||||||
|
float expByKill;
|
||||||
|
float expByDamage;
|
||||||
|
QList <srcTriggerType> triggers;
|
||||||
|
QList <srcSplashType> splashes;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct Splash
|
struct SplashType
|
||||||
{
|
{
|
||||||
int Id;
|
int Id;
|
||||||
QString name;
|
int imgType;
|
||||||
int type;
|
int src;
|
||||||
QPoint TowerId; // parent tower (-1;-1) for null parent
|
QPoint TowerId; // parent tower (-1;-1) for null parent
|
||||||
|
int PlayerId;
|
||||||
int AlienId; // aim alien (different from tower.AlienId)
|
int AlienId; // aim alien (different from tower.AlienId)
|
||||||
int lifetime; // in ticks
|
QPointF destination;
|
||||||
float radius; // in cells
|
int life; // in ticks
|
||||||
float angle; // -180 .. 180
|
float angle; // -180 .. 180
|
||||||
QPointF pos;
|
QPointF pos;
|
||||||
};
|
};
|
||||||
|
|||||||
13
data.xml
13
data.xml
@@ -34,6 +34,7 @@
|
|||||||
</splashes>
|
</splashes>
|
||||||
<towers>
|
<towers>
|
||||||
<tower id="1" imageType="1" name="rocket launcher" cost="30" buildTime="50" reload="20" splash="1" radius="3" expByDamage="0.04" expByKill="0.1" expByShot="0.15"/>
|
<tower id="1" imageType="1" name="rocket launcher" cost="30" buildTime="50" reload="20" splash="1" radius="3" expByDamage="0.04" expByKill="0.1" expByShot="0.15"/>
|
||||||
|
<tower id="3" imageType="1" name="rocket launcher 2" cost="30" buildTime="50" reload="20" splash="1" radius="3" expByDamage="0.04" expByKill="0.1" expByShot="0.15"/>
|
||||||
<tower id="2" imageType="2" name="gun" cost="10" buildTime="25" reload="5" splash="3" radius="1.5" expByDamage="0.1" expByShot="0.1" expByKill="0.2"/>
|
<tower id="2" imageType="2" name="gun" cost="10" buildTime="25" reload="5" splash="3" radius="1.5" expByDamage="0.1" expByShot="0.1" expByKill="0.2"/>
|
||||||
</towers>
|
</towers>
|
||||||
<triggers>
|
<triggers>
|
||||||
@@ -41,4 +42,16 @@
|
|||||||
<trigger id="3" name="explosion" type="onDestination" count="1" delParent="true" damage="5" radius="1.5"/>
|
<trigger id="3" name="explosion" type="onDestination" count="1" delParent="true" damage="5" radius="1.5"/>
|
||||||
<trigger id="4" name="smoke" type="onTimer" timer="2" count="1"/>
|
<trigger id="4" name="smoke" type="onTimer" timer="2" count="1"/>
|
||||||
</triggers>
|
</triggers>
|
||||||
|
<chains>
|
||||||
|
<chain tower="1" parent="1" trigger="3" child="4"/>
|
||||||
|
<chain tower="1" parent="1" trigger="4" child="5"/>
|
||||||
|
<chain tower="3" parent="2" trigger="3" child="4"/>
|
||||||
|
<chain tower="3" parent="2" trigger="4" child="5"/>
|
||||||
|
<chain tower="2" parent="3" trigger="2"/>
|
||||||
|
</chains>
|
||||||
|
<towersOnLevels>
|
||||||
|
<towerOnLevel level="1" tower="1"/>
|
||||||
|
<towerOnLevel level="1" tower="2"/>
|
||||||
|
<towerOnLevel level="1" tower="3"/>
|
||||||
|
</towersOnLevels>
|
||||||
</ADdata>
|
</ADdata>
|
||||||
|
|||||||
89
loader.cpp
89
loader.cpp
@@ -27,8 +27,9 @@ void Loader::load()
|
|||||||
readSplashes();
|
readSplashes();
|
||||||
readTowers();
|
readTowers();
|
||||||
readTriggers();
|
readTriggers();
|
||||||
//readChains();
|
readChains();
|
||||||
//readLevTowers();
|
//readUpgrades();
|
||||||
|
readLevTowers();
|
||||||
readWaves();
|
readWaves();
|
||||||
readWaveParts();
|
readWaveParts();
|
||||||
readLevWaves();
|
readLevWaves();
|
||||||
@@ -43,10 +44,6 @@ void Loader::create()
|
|||||||
if (!cfile.open(QIODevice::WriteOnly))
|
if (!cfile.open(QIODevice::WriteOnly))
|
||||||
return;
|
return;
|
||||||
cfile.resize(0);
|
cfile.resize(0);
|
||||||
// if (!doc.setContent(&file)) {
|
|
||||||
// file.close();
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
QDomElement elem;
|
QDomElement elem;
|
||||||
QDomElement root = doc->createElement("ADdata");
|
QDomElement root = doc->createElement("ADdata");
|
||||||
doc->appendChild(root);
|
doc->appendChild(root);
|
||||||
@@ -110,7 +107,6 @@ void Loader::create()
|
|||||||
elem.setAttribute("autoControl","true");
|
elem.setAttribute("autoControl","true");
|
||||||
elem.setAttribute("radius",1.2);
|
elem.setAttribute("radius",1.2);
|
||||||
elem.setAttribute("id",0);
|
elem.setAttribute("id",0);
|
||||||
|
|
||||||
cfile.write(doc->toByteArray());
|
cfile.write(doc->toByteArray());
|
||||||
cfile.close();
|
cfile.close();
|
||||||
}
|
}
|
||||||
@@ -235,6 +231,53 @@ void Loader::readWaveParts()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Loader::readChains()
|
||||||
|
{
|
||||||
|
QDomNodeList celems = doc->elementsByTagName("chain");
|
||||||
|
for (int i=0; i<celems.size(); i++)
|
||||||
|
{
|
||||||
|
bool OK = true;
|
||||||
|
tbChain chain;
|
||||||
|
QDomNamedNodeMap nm = celems.at(i).attributes();
|
||||||
|
chain.towerId = nm.namedItem("tower").nodeValue().toInt();
|
||||||
|
if (!towers.contains(chain.towerId))
|
||||||
|
{
|
||||||
|
qCritical("invalid tower Id");
|
||||||
|
OK = false;
|
||||||
|
}
|
||||||
|
chain.childSplashId = nm.namedItem("child").nodeValue().toInt();
|
||||||
|
if (chain.childSplashId > 0)
|
||||||
|
{
|
||||||
|
if (!splashes.contains(chain.childSplashId))
|
||||||
|
{
|
||||||
|
qCritical("invalid child splash Id");
|
||||||
|
OK = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
chain.parentSplashId = nm.namedItem("parent").nodeValue().toInt();
|
||||||
|
if (!splashes.contains(chain.parentSplashId))
|
||||||
|
{
|
||||||
|
qCritical("invalid parent splash Id");
|
||||||
|
OK = false;
|
||||||
|
}
|
||||||
|
chain.triggerId = nm.namedItem("trigger").nodeValue().toInt();
|
||||||
|
if (!triggers.contains(chain.triggerId))
|
||||||
|
{
|
||||||
|
qCritical("invalid parent splash Id");
|
||||||
|
OK = false;
|
||||||
|
}
|
||||||
|
if (OK)
|
||||||
|
{
|
||||||
|
chains.insert(chain.towerId,chain);
|
||||||
|
qDebug() << tr("Tower=%1 parent=%2 child=%3 trigger=%4").arg(chain.towerId).arg(chain.parentSplashId).arg(chain.childSplashId).arg(chain.triggerId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
qDebug("================");
|
||||||
|
qDebug() << tr("Found %1 chains").arg(chains.size());
|
||||||
|
qDebug("================");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Loader::readLevWaves()
|
void Loader::readLevWaves()
|
||||||
{
|
{
|
||||||
QDomNodeList lwelems = doc->elementsByTagName("waveOnLevel");
|
QDomNodeList lwelems = doc->elementsByTagName("waveOnLevel");
|
||||||
@@ -267,6 +310,38 @@ void Loader::readLevWaves()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Loader::readLevTowers()
|
||||||
|
{
|
||||||
|
QDomNodeList ltelems = doc->elementsByTagName("towerOnLevel");
|
||||||
|
for (int i=0; i<ltelems.size(); i++)
|
||||||
|
{
|
||||||
|
bool OK = true;
|
||||||
|
tbTowerOnLevel lt;
|
||||||
|
QDomNamedNodeMap nm = ltelems.at(i).attributes();
|
||||||
|
lt.levelId= nm.namedItem("level").nodeValue().toInt();
|
||||||
|
if (!levels.contains(lt.levelId))
|
||||||
|
{
|
||||||
|
qCritical("invalid level Id");
|
||||||
|
OK = false;
|
||||||
|
}
|
||||||
|
lt.towerId = nm.namedItem("tower").nodeValue().toInt();
|
||||||
|
if (!towers.contains(lt.towerId))
|
||||||
|
{
|
||||||
|
qCritical("invalid tower Id");
|
||||||
|
OK = false;
|
||||||
|
}
|
||||||
|
if (OK)
|
||||||
|
{
|
||||||
|
levTowers.insert(lt.levelId,lt);
|
||||||
|
qDebug() << tr("level=%1 tower=%2").arg(lt.levelId).arg(lt.towerId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
qDebug("================");
|
||||||
|
qDebug() << tr("Found %1 Towers On Level").arg(levTowers.size());
|
||||||
|
qDebug("================");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Loader::readLevels()
|
void Loader::readLevels()
|
||||||
{
|
{
|
||||||
QDomNodeList lelems = doc->elementsByTagName("level");
|
QDomNodeList lelems = doc->elementsByTagName("level");
|
||||||
|
|||||||
2
loader.h
2
loader.h
@@ -179,6 +179,7 @@ private:
|
|||||||
QMultiHash <int,tbChain> chains;
|
QMultiHash <int,tbChain> chains;
|
||||||
QMultiHash <int,tbMorph> morphs;
|
QMultiHash <int,tbMorph> morphs;
|
||||||
QMultiHash <int,tbTowerOnLevel> levTowers;
|
QMultiHash <int,tbTowerOnLevel> levTowers;
|
||||||
|
QMultiHash <int,tbUpgrade> upgrades;
|
||||||
|
|
||||||
void readAliens();
|
void readAliens();
|
||||||
void readMaps();
|
void readMaps();
|
||||||
@@ -192,6 +193,7 @@ private:
|
|||||||
void readWaves();
|
void readWaves();
|
||||||
void readLevWaves();
|
void readLevWaves();
|
||||||
void readWaveParts();
|
void readWaveParts();
|
||||||
|
void readUpgrades();
|
||||||
|
|
||||||
void validate();
|
void validate();
|
||||||
void load();
|
void load();
|
||||||
|
|||||||
37
schema.xml
37
schema.xml
@@ -67,6 +67,20 @@
|
|||||||
</xsd:sequence>
|
</xsd:sequence>
|
||||||
</xsd:complexType>
|
</xsd:complexType>
|
||||||
</xsd:element>
|
</xsd:element>
|
||||||
|
<xsd:element name="chains">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="chain" type="chainType" maxOccurs="unbounded"/>
|
||||||
|
</xsd:sequence>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="towersOnLevels">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="towerOnLevel" type="towerOnLevelType" maxOccurs="unbounded"/>
|
||||||
|
</xsd:sequence>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
</xsd:sequence>
|
</xsd:sequence>
|
||||||
</xsd:complexType>
|
</xsd:complexType>
|
||||||
</xsd:element>
|
</xsd:element>
|
||||||
@@ -146,18 +160,25 @@
|
|||||||
</xsd:complexType>
|
</xsd:complexType>
|
||||||
|
|
||||||
<xsd:complexType name="morphType">
|
<xsd:complexType name="morphType">
|
||||||
<xsd:attribute name="from" type="xsd:nonNegativeInteger" use="required"/>
|
<xsd:attribute name="from" type="xsd:positiveInteger" use="required"/>
|
||||||
<xsd:attribute name="to" type="xsd:nonNegativeInteger" use="required"/>
|
<xsd:attribute name="to" type="xsd:positiveInteger" use="required"/>
|
||||||
<xsd:attribute name="cost" type="xsd:positiveInteger" use="required"/>
|
<xsd:attribute name="cost" type="xsd:positiveInteger" use="required"/>
|
||||||
<xsd:attribute name="expRequired" type="xsd:float" use="required"/>
|
<xsd:attribute name="expRequired" type="xsd:float" use="required"/>
|
||||||
</xsd:complexType>
|
</xsd:complexType>
|
||||||
|
|
||||||
<xsd:complexType name="wavePartType">
|
<xsd:complexType name="wavePartType">
|
||||||
<xsd:attribute name="alien" type="xsd:nonNegativeInteger" use="required"/>
|
<xsd:attribute name="alien" type="xsd:positiveInteger" use="required"/>
|
||||||
<xsd:attribute name="wave" type="xsd:nonNegativeInteger" use="required"/>
|
<xsd:attribute name="wave" type="xsd:positiveInteger" use="required"/>
|
||||||
<xsd:attribute name="count" type="xsd:positiveInteger" use="required"/>
|
<xsd:attribute name="count" type="xsd:positiveInteger" use="required"/>
|
||||||
</xsd:complexType>
|
</xsd:complexType>
|
||||||
|
|
||||||
|
<xsd:complexType name="chainType">
|
||||||
|
<xsd:attribute name="tower" type="xsd:positiveInteger" use="required"/>
|
||||||
|
<xsd:attribute name="parent" type="xsd:positiveInteger" use="required"/>
|
||||||
|
<xsd:attribute name="trigger" type="xsd:positiveInteger" use="required"/>
|
||||||
|
<xsd:attribute name="child" type="xsd:positiveInteger" use="optional"/>
|
||||||
|
</xsd:complexType>
|
||||||
|
|
||||||
<xsd:complexType name="waveType">
|
<xsd:complexType name="waveType">
|
||||||
<xsd:attribute name="id" type="xsd:positiveInteger" use="required"/>
|
<xsd:attribute name="id" type="xsd:positiveInteger" use="required"/>
|
||||||
<xsd:attribute name="timeout" type="xsd:nonNegativeInteger" use="required"/>
|
<xsd:attribute name="timeout" type="xsd:nonNegativeInteger" use="required"/>
|
||||||
@@ -166,13 +187,13 @@
|
|||||||
</xsd:complexType>
|
</xsd:complexType>
|
||||||
|
|
||||||
<xsd:complexType name="waveOnLevelType">
|
<xsd:complexType name="waveOnLevelType">
|
||||||
<xsd:attribute name="level" type="xsd:nonNegativeInteger" use="required"/>
|
<xsd:attribute name="level" type="xsd:positiveInteger" use="required"/>
|
||||||
<xsd:attribute name="wave" type="xsd:nonNegativeInteger" use="required"/>
|
<xsd:attribute name="wave" type="xsd:positiveInteger" use="required"/>
|
||||||
</xsd:complexType>
|
</xsd:complexType>
|
||||||
|
|
||||||
<xsd:complexType name="towerOnLevelType">
|
<xsd:complexType name="towerOnLevelType">
|
||||||
<xsd:attribute name="level" type="xsd:nonNegativeInteger" use="required"/>
|
<xsd:attribute name="level" type="xsd:positiveInteger" use="required"/>
|
||||||
<xsd:attribute name="tower" type="xsd:nonNegativeInteger" use="required"/>
|
<xsd:attribute name="tower" type="xsd:positiveInteger" use="required"/>
|
||||||
<!--xsd:attribute name="enableWave" type="xsd:nonNegativeInteger" use="optional"-->
|
<!--xsd:attribute name="enableWave" type="xsd:nonNegativeInteger" use="optional"-->
|
||||||
</xsd:complexType>
|
</xsd:complexType>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user