[4779] | 1 | /*! |
---|
[5556] | 2 | * @file aim.h |
---|
| 3 | * Definition of |
---|
| 4 | */ |
---|
[3329] | 5 | |
---|
[5556] | 6 | #ifndef _AIM_H |
---|
| 7 | #define _AIM_H |
---|
[1853] | 8 | |
---|
[4849] | 9 | #include "p_node.h" |
---|
| 10 | #include "element_2d.h" |
---|
[5557] | 11 | |
---|
[5405] | 12 | // FORWARD DECLARATION |
---|
[4830] | 13 | class Model; |
---|
[5750] | 14 | class Text; |
---|
[4830] | 15 | class Material; |
---|
[4832] | 16 | class TiXmlElement; |
---|
[5750] | 17 | template<class T> class tAnimation; |
---|
[3543] | 18 | |
---|
[5556] | 19 | //! An Aim for zooming in on Targets. |
---|
[5750] | 20 | /** |
---|
| 21 | * An Aim is a PNode, that is connected, to the Target, it has aquired |
---|
| 22 | * The target becomes, if selected its Parent. |
---|
| 23 | * |
---|
| 24 | * Also the Aim is a Element2D, as it draws a cross onto the Target. |
---|
| 25 | */ |
---|
[5556] | 26 | class Aim : public PNode, public Element2D { |
---|
[2036] | 27 | |
---|
[1904] | 28 | public: |
---|
[5750] | 29 | Aim(PNode* source, const TiXmlElement* root = NULL); |
---|
[5556] | 30 | virtual ~Aim(); |
---|
[1853] | 31 | |
---|
[4832] | 32 | void init(); |
---|
[6512] | 33 | virtual void loadParams(const TiXmlElement* root); |
---|
[3245] | 34 | |
---|
[5750] | 35 | inline void setSource(PNode* source) { this->source = source; }; |
---|
| 36 | |
---|
[5557] | 37 | inline void selectTarget(PNode* target) { this->setParent(target); }; |
---|
| 38 | inline PNode* getTarget(PNode* target) { return this->getParent(); }; |
---|
| 39 | |
---|
[6637] | 40 | void searchTarget(); |
---|
[5557] | 41 | |
---|
[6637] | 42 | void setRange(float range){this->range = range;}; |
---|
| 43 | void setAngle(float angle){this->angle = angle;}; |
---|
| 44 | |
---|
[4832] | 45 | void setSize(float size); |
---|
| 46 | void setTexture(const char* textureFile); |
---|
| 47 | /** @param rotationSpeed the speed at what the crosshair should rotate */ |
---|
[5557] | 48 | inline void setRotationSpeed(float rotationSpeed) { this->rotationSpeed = rotationSpeed; }; |
---|
[4832] | 49 | |
---|
[4849] | 50 | virtual void tick(float dt); |
---|
| 51 | virtual void draw() const; |
---|
[4779] | 52 | |
---|
[3245] | 53 | private: |
---|
[4830] | 54 | Material* material; //!< a material for the Aim. |
---|
[4832] | 55 | float rotationSpeed; //!< Speed of the Rotation. |
---|
[5750] | 56 | tAnimation<Aim>* anim; |
---|
| 57 | |
---|
[6637] | 58 | float range; //!< |
---|
| 59 | float angle; //!< |
---|
| 60 | |
---|
[5750] | 61 | PNode* source; //!< Where this Shot has come from. |
---|
| 62 | |
---|
| 63 | Text* text; //!< A Text to display onto this Node. (distance to Target) |
---|
[1853] | 64 | }; |
---|
| 65 | |
---|
[5556] | 66 | #endif /* _AIM_H */ |
---|