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