- Timestamp:
- Apr 23, 2015, 4:19:02 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.cc
r10369 r10391 19 19 RegisterObject(GravityBomb); 20 20 21 this->setMass(15.0); 21 this->setMass(10.0); 22 this->isDetonated_ = false; 22 23 if (GameMode::isMaster()) 23 24 { 24 25 //Define CollisionType of the bomb 25 this-> velocityAtLastTick_= 1000;26 this->timeToLife_= 5; 26 27 this->setCollisionResponse(false); 27 this->setCollisionType(WorldEntity:: Kinematic);28 this->setCollisionType(WorldEntity::Dynamic); 28 29 this->enableCollisionCallback(); 29 30 … … 46 47 void GravityBomb::tick(float dt) 47 48 { 48 velocityAtLastTick_=getVelocity().length();49 49 SUPER(GravityBomb,tick,dt); 50 if(velocityAtLastTick_ < this->getVelocity().length()) 50 timeToLife_ -= dt; 51 if(timeToLife_ < 0) 51 52 { 52 53 orxout(debug_output) << "bomb has stoped moving" <<endl; 53 54 setVelocity(Vector3::ZERO); 54 55 setAcceleration(Vector3::ZERO); 55 velocityAtLastTick_=0;56 56 detonate(); 57 orxout(debug_output) << "denoting" <<endl;58 57 } 59 58 else 60 59 { 61 velocityAtLastTick_=getVelocity().length(); 62 orxout(debug_output)<< velocityAtLastTick_ <<endl; 63 orxout(debug_output) << "acceleration" << getAcceleration().length() <<endl; 60 orxout(debug_output)<< "Time to live:" << timeToLife_ <<endl; 64 61 destroyCheck(); 65 62 } 63 if(isDetonated_) detonate(); 66 64 } 67 65 68 66 bool GravityBomb::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint) 69 67 { 70 orxout(debug_output) << "collides" << endl; 71 processCollision(otherObject, contactPoint,cs); 72 //detonate(); 73 return true; 68 if(otherObject != getShooter()) 69 { 70 orxout(debug_output) << "collides" << endl; 71 processCollision(otherObject, contactPoint,cs); 72 isDetonated_ = true; 73 return true; 74 } 75 else{ 76 orxout(debug_output) << "collided with shooter. Has no effect..." << endl; 77 return false; 78 } 74 79 } 75 80 … … 77 82 { 78 83 GravityBombField* field = new GravityBombField(this->getContext()); 79 orxout(debug_output) << "denoting" <<endl; 84 field->setPosition(getPosition()); 85 orxout(debug_output) << "detonating. Creating GravityBombField." <<endl; 86 orxout(debug_output) << "Field is at Position: " << getPosition() << endl; 80 87 this->destroy(); 81 88 }
Note: See TracChangeset
for help on using the changeset viewer.