Files
aliendefender/loader.h
buull 191e5ed1a1 I think finished structures
and some changes in loading
and changes in map class
we have 2 TODO now
2010-08-22 21:55:29 +03:00

206 lines
2.9 KiB
C++

#ifndef LOADER_H
#define LOADER_H
#include <QObject>
#include <QDomDocument>
#include <QFile>
#include <QTextStream>
#include <QDebug>
#include <QXmlSchema>
#include <QXmlSchemaValidator>
#include "game_data.h"
struct tbAlien
{
int id;
QString name;
float speed;
float health;
float armor;
float regeneration;
bool isFlying;
unsigned int score;
int imgType;
unsigned int prise;
};
struct tbSplash
{
int id;
QString name;
float speed;
unsigned int lifetime;
bool autoControl;
int imgType;
};
struct tbTrigger
{
enum triggerType
{
onDestination,
onTimer,
onAlienInRadius
};
enum aimType
{
noAim,
parentAim,
allSide,
nearlestAlien
};
int id;
QString name;
float damage;
float radius;
int chance;
bool delParent;
aimType childAim;
triggerType type;
unsigned int timer;
int count;
float randomPosRadius;
};
struct tbTower
{
int id;
QString name;
float radius;
unsigned int cost;
unsigned int reload;
unsigned int buildTime;
float expByShot;
float expByKill;
float expByDamage;
int splashId;
int imgType;
};
struct tbChain
{
int towerId;
int parentSplashId;
int childSplashId;
int triggerId;
};
struct tbUpgrade
{
int towerId;
int triggerId;
unsigned int cost;
float towRadius;
unsigned int towReload;
float trigDamage;
float trigDamageRadius;
};
struct tbMorph
{
int fromId;
int toId;
int cost;
float expRequired;
};
struct tbWavePart
{
int waveId;
int alienId;
unsigned int count;
};
struct tbWave
{
int id;
unsigned int timeout;
unsigned int prise;
//int type;
};
struct tbWaveOnLevel
{
int levelId;
int waveId;
};
struct tbMap
{
int id;
QString name;
unsigned int maxPlayers;
//QVector < QVector <int> > cells;
QByteArray data;
QSize size;
int imgType;
};
struct tbTowerOnLevel
{
int levelId;
int towerId;
//int enableWaveId;
};
struct tbLevel
{
int id;
QString name;
int mapId;
unsigned int score;
};
class Loader : public QObject
{
Q_OBJECT
public:
explicit Loader(QObject *parent = 0);
void create();
void reload();
Game_Data * loadlevel();
signals:
public slots:
private:
QDomDocument * doc;
QFile * file;
QHash <int,tbAlien> aliens;
QHash <int,tbMap> maps;
QHash <int,tbLevel> levels;
QHash <int,tbSplash> splashes;
QHash <int,tbTower> towers;
QHash <int,tbTrigger> triggers;
QHash <int,tbWave> waves;
QMultiHash <int,tbWaveOnLevel> levWaves;
QMultiHash <int,tbWavePart> waveParts;
QMultiHash <int,tbChain> chains;
QMultiHash <int,tbMorph> morphs;
QMultiHash <int,tbTowerOnLevel> levTowers;
QMultiHash <int,tbUpgrade> upgrades;
void readAliens();
void readMaps();
void readLevels();
void readMorphs();
void readSplashes();
void readTowers();
void readLevTowers();
void readTriggers();
void readChains();
void readWaves();
void readLevWaves();
void readWaveParts();
void readUpgrades();
void validate();
void load();
QString CreateMapExample();
};
#endif // LOADER_H