Changeset 10341 for code/branches
- Timestamp:
- Apr 2, 2015, 4:08:52 PM (10 years ago)
- Location:
- code/branches/weaponFS15/src/modules
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/weaponFS15/src/modules/objects/ForceField.h
r9939 r10341 160 160 const std::string& getMode(void); //!< Get the mode of the ForceField. 161 161 162 static const std::string modeTube_s; 163 static const std::string modeSphere_s; 164 static const std::string modeInvertedSphere_s; 165 static const std::string modeNewtonianGravity_s; 166 167 static const std::string modeHomogen_s; 168 162 169 private: 163 170 //! Strings to represent the modes. 164 static const std::string modeTube_s;165 static const std::string modeSphere_s;166 static const std::string modeInvertedSphere_s;167 static const std::string modeNewtonianGravity_s;168 171 169 static const std::string modeHomogen_s;170 172 171 173 float velocity_; //!< The velocity of the ForceField. -
code/branches/weaponFS15/src/modules/weapons/projectiles/CMakeLists.txt
r10336 r10341 8 8 SimpleRocket.cc 9 9 GravityBomb.cc 10 GravityBombField.cc 10 11 ) -
code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.cc
r10336 r10341 11 11 RegisterClass(GravityBomb); 12 12 13 const float GravityBomb::FUEL_START = 10; 14 const float GravityBomb::FORCE_SPHERE_START_RADIUS = 30; 15 const float GravityBomb::FORCE_SPHERE_START_STRENGTH = 100; 13 const float GravityBomb::INITIAL_VELOCITY = 20; 14 const float GravityBomb::SLOW_DOWN_RATIO = 2; 16 15 17 16 GravityBomb::GravityBomb(Context* context): 18 BasicProjectile(),19 MovableEntity(context),20 RadarViewable(this,static_cast<WorldEntity*>(this))17 BasicProjectile(), 18 MovableEntity(context), 19 RadarViewable(this,static_cast<WorldEntity*>(this)) 21 20 { 22 21 RegisterObject(GravityBomb); 23 this->lifetime_=FUEL_START;24 this->forceSphereRadius_= FORCE_SPHERE_START_RADIUS;25 this->forceStrength_ = FORCE_SPHERE_START_STRENGTH;26 22 27 ForceField* field = new ForceField(context); 28 field->setMode("sphere"); 29 field->setDiameter(this->forceSphereRadius_); 30 field->setVelocity(this->forceStrength_); 31 this->attach(field); 23 this->setMass(15.0); 24 if (GameMode::isMaster()) 25 { 26 //Define movement of the bomb 27 this->setVelocity(this->getOrientation()*WorldEntity::FRONT*INITIAL_VELOCITY); 28 this->velocityAtLastTick_=INITIAL_VELOCITY; 29 this->setAcceleration(this->getOrientation()*WorldEntity::BACK*SLOW_DOWN_RATIO); 30 this->setCollisionType(WorldEntity::Dynamic); 31 this->enableCollisionCallback(); 32 32 33 //Add Collision Shape 34 SphereCollisionShape* collisionShape = new SphereCollisionShape(context); 35 collisionShape->setRadius(5.0); 36 this->attachCollisionShape(collisionShape); 37 38 //Create Bomb Model 39 40 41 } 33 42 } 34 43 … … 37 46 void GravityBomb::tick(float dt) 38 47 { 39 48 if(velocityAtLastTick_ < this->getVelocity().length()) 49 { 50 setVelocity(Vector3::ZERO); 51 setAcceleration(Vector3::ZERO); 52 velocityAtLastTick_=0; 53 detonate(); 54 } 55 velocityAtLastTick_=getVelocity().length(); 40 56 } 41 57 42 58 bool GravityBomb::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint) 43 59 { 60 detonate(); 61 processCollision(otherObject, contactPoint,cs); 44 62 return true; 63 } 64 65 void GravityBomb::detonate() 66 { 67 GravityBombField* field = new GravityBombField(this->getContext()); 45 68 } 46 69 } -
code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.h
r10336 r10341 48 48 #include "worldentities/MovableEntity.h" 49 49 #include "core/CoreIncludes.h" 50 #include "objects/collisionshapes/SphereCollisionShape.h" 51 #include "../../../orxonox/worldentities/WorldEntity.h" 52 #include "GravityBombField.h" 50 53 51 54 namespace orxonox 52 55 { 53 54 class ConeCollisionShape;55 56 56 57 class _WeaponsExport GravityBomb : public BasicProjectile , public MovableEntity, public RadarViewable … … 62 63 63 64 virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint); 65 void detonate(); 64 66 65 67 private: 66 static const float FUEL_START; 67 static const float FORCE_SPHERE_START_RADIUS; 68 static const float FORCE_SPHERE_START_STRENGTH; 68 static const float INITIAL_VELOCITY; 69 static const float SLOW_DOWN_RATIO; 69 70 70 float fuel_; 71 float lifetime_; 72 float forceSphereRadius_; 73 float forceStrength_; 74 71 float velocityAtLastTick_; //Used to check wether the Object is already accelarating in the oposite direction to detect the time to detonate it. 75 72 76 73 };
Note: See TracChangeset
for help on using the changeset viewer.