#ifndef ENEMY_H #define ENEMY_H #include #include class QTimer; class Board; class Engine; class Enemy : public QObject { Q_OBJECT Q_ENUMS(TravelStatus) Q_ENUMS(WalkingDirection) Q_PROPERTY(QString image READ image NOTIFY imageChanged) Q_PROPERTY(int imageBaseSize READ imageBaseSize NOTIFY imageChanged) Q_PROPERTY(WalkingDirection walkingDirection READ walkingDirection NOTIFY walkingDirectionChanged) Q_PROPERTY(int spriteCount READ spriteCount NOTIFY imageChanged) Q_PROPERTY(qreal frameRate READ frameRate NOTIFY imageChanged) Q_PROPERTY(int x READ x NOTIFY currentFieldChanged) Q_PROPERTY(int y READ y NOTIFY currentFieldChanged) Q_PROPERTY(int currentField READ currentField NOTIFY currentFieldChanged) Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged) Q_PROPERTY(int nextX READ nextX NOTIFY currentFieldChanged) Q_PROPERTY(int nextY READ nextY NOTIFY currentFieldChanged) Q_PROPERTY(int nextField READ nextField NOTIFY currentFieldChanged) Q_PROPERTY(int speed READ speed NOTIFY speedChanged) Q_PROPERTY(int energy READ energy NOTIFY energyChanged) Q_PROPERTY(int maxEnergy READ maxEnergy NOTIFY maxEnergyChanged) public: enum TravelStatus { TravelStatusEntry = -1, TravelStatusExit = -2, TravelStatusNoWayFound = -3, }; enum WalkingDirection { WalkingDirectionLeft, WalkingDirectionRight, WalkingDirectionUp, WalkingDirectionDown }; explicit Enemy(Engine *engine); QString image() const; int imageBaseSize() const; int spriteCount() const; qreal frameRate() const; void setImage(const QString &image, int baseSize, int spriteCount = 1, qreal frameRate = 1); int x() const; int y() const; int currentField() const; int nextX() const; int nextY() const; int nextField() const; qreal progress() const; int speed() const; void setSpeed(int speed); void setEnergy(int energy); int reward() const; void setReward(int reward); int energy() const; int maxEnergy() const; Q_INVOKABLE qreal travelledDistance() const; WalkingDirection walkingDirection() const; public slots: void advance(); void hit(int damage, int slowDown, int delay); signals: void imageChanged(); void currentFieldChanged(); void walkingDirectionChanged(); void progressChanged(); void speedChanged(); void energyChanged(int energy); void maxEnergyChanged(); void exited(); void died(); private slots: void tick(); void executeHit(); void undoSlowdown(); private: Engine *m_engine; Board *m_board; QString m_image; int m_imageBaseSize; WalkingDirection m_walkingDirection; int m_spriteCount; qreal m_frameRate; qreal m_progress; qreal m_travelledDistance; int m_currentField; int m_nextField; int m_speed; int m_energy; int m_maxEnergy; int m_reward; QList m_slowdowns; class Hit { public: int damage; int slowDown; }; QHash m_hitList; QList m_upcomingFields; QList m_travelledFields; }; #endif // ENEMY_H