#ifndef BASE_TYPES_H #define BASE_TYPES_H #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "aditem.h" const float cellSize = 20.f; struct srcAlienType { QString name; float speed; float health; float armor; float regeneration; bool isFlying; unsigned int score; int imgType; QList * images; unsigned int prise; }; struct AlienType { int id; // uses for QHash srcAlienType * src; QPointF pos; float angle; // -180 .. 180 float speed; // cells per tick (speed=1 is 60cells by 1 sec for 60fps e.g.) float health; QPoint finish; QVector path; int pathIndex; ADItem * item; }; struct srcTriggerType { enum triggerType { onDestination, onTimer, onAlienInRadius }; enum aimType { noAim, parentAim, allSide, nearlestAlien }; int childId; // =-1 for none birth splash (e.q. only damage) aimType childAim; bool delParent; float damage; float radius; triggerType type; unsigned int timer; int count; float randomPosRadius; }; struct TriggerOnDest { srcTriggerType * src; }; struct TriggerOnTimer { srcTriggerType * src; unsigned int timer; }; struct TriggerOnAlien { srcTriggerType * src; QList triggerAliens; }; struct srcSplashType; struct srcTowerType { QString name; QImage * image; int imgType; int PlayerId; // tower's owner unsigned int cost; unsigned int reload; unsigned int buildTime; float radius; // in cells float expByShot; float expByKill; float expByDamage; QList triggers; QList splashes; }; struct TowerType { srcTowerType * src; int aim; // aim alien Id int PlayerId; // tower's owner QPoint pos; // same as Id; not QPointF because tower fixed on grid float angle; // -180 .. 180 unsigned int reload; // time for reload in ticks unsigned int build; float experience; ADItem * item; bool isBilding; }; struct srcSplashType { QString name; int imgType; float speed; // in cells int lifetime; bool autoControl; QList triggerIndexes; QList * 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 trigsOnAlien; QList trigsOnDest; QList trigsOnTimer; ADItem * item; }; /// DEPRECATED !!! struct AnimationType { QList * images; }; /// DEPRECATED !!! struct WaveType { QList types; // some types of aliens (e.g. 2 fly and 3 grount in one wave) QList counts; // count aliens of each type unsigned int timeout; // time in ticks unsigned int prise; }; inline uint qHash(const QPoint &pos) { return qHash(pos.x() + (pos.y() << 16)); } inline float distance2(const QPointF &p1, const QPointF &p2) { return (p1.x()-p2.x())*(p1.x()-p2.x())+(p1.y()-p2.y())*(p1.y()-p2.y()); } #endif // BASE_TYPES_H