[10341] | 1 | /* |
---|
| 2 | * GravityBombField.h |
---|
| 3 | * |
---|
| 4 | * Created on: Apr 2, 2015 |
---|
| 5 | * Author: meggiman |
---|
| 6 | */ |
---|
| 7 | |
---|
| 8 | #ifndef GRAVITYBOMBFIELD_H_ |
---|
| 9 | #define GRAVITYBOMBFIELD_H_ |
---|
| 10 | |
---|
| 11 | #include "graphics/ParticleSpawner.h" |
---|
| 12 | #include "interfaces/RadarViewable.h" |
---|
| 13 | #include "objects/ForceField.h" |
---|
| 14 | #include "BasicProjectile.h" |
---|
| 15 | #include "worldentities/MovableEntity.h" |
---|
| 16 | #include "core/CoreIncludes.h" |
---|
| 17 | #include "GravityBomb.h" |
---|
[10409] | 18 | #include "graphics/ParticleSpawner.h" |
---|
[10435] | 19 | #include "tools/ParticleInterface.h" |
---|
| 20 | #include <stdlib.h> |
---|
| 21 | #include <time.h> |
---|
[10455] | 22 | #include <math.h> |
---|
[10435] | 23 | #include "graphics/Backlight.h" |
---|
[10487] | 24 | #include "sound/WorldSound.h" |
---|
[10341] | 25 | |
---|
| 26 | namespace orxonox { |
---|
[10455] | 27 | |
---|
| 28 | /** |
---|
| 29 | * @class GravityBombField |
---|
| 30 | * |
---|
| 31 | * @brief This class is used by GravityBomb to place the ForceField and Visual effect to the environment. |
---|
| 32 | * The field has a maximum lifetime and gets smaller and stronger the more time passes. In the end, the field explodes and damages all pawns nearby. |
---|
| 33 | * |
---|
| 34 | * @author Manuel Eggimann |
---|
| 35 | * @date 23.05.2015 |
---|
| 36 | */ |
---|
[10409] | 37 | class GravityBombField: public ForceField, public RadarViewable { |
---|
[10341] | 38 | public: |
---|
| 39 | GravityBombField(Context* context); |
---|
| 40 | virtual ~GravityBombField(); |
---|
| 41 | virtual void tick(float dt); |
---|
| 42 | virtual void destroy(); |
---|
[10435] | 43 | |
---|
[10455] | 44 | /** |
---|
| 45 | * @fn void GravityBombField::setShooter(Pawn* shooter) |
---|
| 46 | * |
---|
| 47 | * @brief This function is used to determine save the pawn who created the field and is used inside the GravityBomb class. |
---|
| 48 | * |
---|
| 49 | * @author Manuel Eggimann |
---|
| 50 | * @date 23.05.2015 |
---|
| 51 | * |
---|
| 52 | * @param [in,out] the Pawn that created the field. |
---|
| 53 | */ |
---|
[10435] | 54 | void setShooter(Pawn* shooter) |
---|
| 55 | { this->shooter_ = shooter; } |
---|
| 56 | |
---|
| 57 | Pawn* getShooter() |
---|
| 58 | { return this->shooter_; } |
---|
| 59 | |
---|
[10341] | 60 | private: |
---|
[10455] | 61 | //Set these constants inside GravityBombField.cc to alter the behaviour of the field. |
---|
| 62 | |
---|
| 63 | static const float FORCE_FIELD_LIFETIME; ///< The lifetime of the ForceField in seconds. After lifetime seconds, has already exploded and the particle effects will start to vanish. |
---|
| 64 | static const float FORCE_SPHERE_START_RADIUS; ///< The initial sphere radius of the Force Field. The forcefield gets smaller by time. |
---|
| 65 | static const float FORCE_SPHERE_START_STRENGTH; ///< The initial Force the Field exerts on every object with non-zero mass. |
---|
| 66 | static const float FORCE_FIELD_EXPLOSION_DAMMAGE; ///< The maximum dammage a pawn gets nearby an exploding field. The farer away from explosion center the smaller the dammage. |
---|
| 67 | static const float EXPLOSION_DURATION; ///< Determines how fast the shockwave of the Explosion expands. It takes GravityBombField::EXPLOSION_DURATION seconds for the field to expand from 0 radius to GravityBombField::EXPLOSION_RADIUS. |
---|
| 68 | static const float EXPLOSION_RADIUS; ///< How far does the shockwave reach. All pawns which outside of a sphere witch this radius rest unharmed by the explosion. |
---|
| 69 | static const float PEAK_ANGULAR_VELOCITY; ///< The model of the bomb in the center of the Field does rotate faster and faster as time passes until it reaches PEAK_ANGULAR_VELOCITY at the fields end of life. |
---|
| 70 | static const float PEAK_EXPLOSION_FORCE; ///< The peak force the explosion exerts on the pawns nearby. |
---|
| 71 | static const float CENTRE_MODEL_END_SIZE; ///< Size of the 3d-model of the bomb in the fields centre. |
---|
[10341] | 72 | |
---|
| 73 | float forceSphereRadius_; |
---|
| 74 | float forceStrength_; |
---|
| 75 | float lifetime_; |
---|
[10455] | 76 | float modelScaling_; |
---|
[10435] | 77 | Vector3 rotationVector_; |
---|
[10409] | 78 | bool fieldExploded_; |
---|
| 79 | ParticleEmitter * particleSphere_; |
---|
[10435] | 80 | ParticleEmitter * explosionCross_; |
---|
| 81 | std::vector<Pawn*> victimsAlreadyDamaged_; |
---|
| 82 | MovableEntity * bombModel_; |
---|
| 83 | Pawn* shooter_; |
---|
[10455] | 84 | Backlight* centreLight_; |
---|
| 85 | WorldSound* explosionSound_; |
---|
[10341] | 86 | }; |
---|
| 87 | |
---|
| 88 | } |
---|
| 89 | #endif /* GRAVITYBOMBFIELD_H_ */ |
---|
| 90 | |
---|