File indexing completed on 2024-05-05 04:02:09

0001 /*
0002     SPDX-FileCopyrightText: 2009 Mathias Kraus <k.hias@gmx.de>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef BONUSITEM_H
0008 #define BONUSITEM_H
0009 
0010 #include "elementitem.h"
0011 
0012 class Bonus;
0013 class QTimer;
0014 class KGameRenderer;
0015 
0016 /**
0017  * @brief This class is the graphical representation of a Bonus.
0018  */
0019 class BonusItem : public ElementItem
0020 {
0021 
0022     Q_OBJECT
0023 
0024 private:
0025 
0026     /** The explosion ID that destroyed the block that contained this bonus and therefore cannot destroy this bonus */
0027     int m_undestroyableExplosionID;
0028 
0029     /** Timer used to animate explosion */
0030     QTimer* m_destructionTimer;
0031 
0032     /** Number of frames for the destruction */
0033     int m_destructionCounter;
0034 
0035 public:
0036 
0037     /**
0038      * Creates a new BonusItem instance.
0039      * @param p_model the Bonus model
0040      * @param renderer the KGameRenderer
0041      */
0042     BonusItem(Bonus* p_model, KGameRenderer* renderer);
0043 
0044     /**
0045      * Deletes the BonusItem instance.
0046      */
0047     ~BonusItem() override;
0048 
0049     /**
0050      * Sets the undestroyable explosion IDs
0051      * @param nExplosionID the explosion that destroyed the block that contained this bonus and therefore can't destroy this bonus
0052      */
0053     void setUndestroyable(int nExplosionID);
0054 
0055     /**
0056      * Inits the destruction
0057      * @param nExplosionID the explosion ID from the blast that hit the bonus
0058      */
0059     void initDestruction(int nExplosionID);
0060 
0061 private Q_SLOTS:
0062     /**
0063      * destruction animation
0064      */
0065     void destructionAnimation();
0066 
0067 Q_SIGNALS:
0068     /**
0069      * signals the end of the destruction animation
0070      * @param bonusItem this bonus item
0071      */
0072     void bonusItemDestroyed(BonusItem* bonusItem);
0073 };
0074 
0075 #endif