Changeset 1552 for code/trunk/src/orxonox/objects/Projectile.cc
- Timestamp:
- Jun 6, 2008, 5:31:58 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/objects/Projectile.cc
r1505 r1552 35 35 #include "core/Executor.h" 36 36 #include "core/ConfigValueIncludes.h" 37 #include "particle/ParticleInterface.h" 37 38 38 #include "SpaceShip .h"39 #include " Explosion.h"39 #include "SpaceShipAI.h" 40 #include "ParticleSpawner.h" 40 41 #include "Model.h" 41 42 42 43 namespace orxonox 43 44 { 44 CreateFactory(Projectile);45 float Projectile::speed_ = 2000; 45 46 46 float Projectile::speed_ = 0; 47 48 Projectile::Projectile(SpaceShip* owner) : 49 owner_(owner) 47 Projectile::Projectile(SpaceShip* owner) : owner_(owner) 50 48 { 51 49 RegisterObject(Projectile); 52 50 53 51 this->setConfigValues(); 54 55 this->billboard_.setBillboardSet("Examples/Flare", ColourValue(1.0, 1.0, 0.5), 1); 56 this->attachObject(this->billboard_.getBillboardSet()); 57 this->scale(0.5); 52 this->explosionTemplateName_ = "Orxonox/explosion1"; 53 this->smokeTemplateName_ = "Orxonox/smoke3"; 58 54 59 55 if (this->owner_) … … 63 59 this->setPosition(this->owner_->getPosition()); 64 60 this->translate(Vector3(55, 0, 0), Ogre::Node::TS_LOCAL); 65 this->setVelocity( Vector3(1, 0, 0) * this->speed_);61 this->setVelocity(this->owner_->getInitialDir() * this->speed_); 66 62 } 67 63 68 64 this->destroyTimer_.setTimer(this->lifetime_, false, this, createExecutor(createFunctor(&Projectile::destroyObject))); 69 // COUT(3) << this->classID << std::endl;70 65 } 71 66 … … 76 71 void Projectile::setConfigValues() 77 72 { 78 SetConfigValue(lifetime_, 10.0).description("The time in seconds a projectile stays alive"); 73 SetConfigValue(damage_, 15.0).description("The damage caused by the projectile"); 74 SetConfigValue(lifetime_, 5.0).description("The time in seconds a projectile stays alive"); 79 75 SetConfigValue(speed_, 2000.0).description("The speed of a projectile in units per second"); 80 76 81 this->setVelocity( Vector3(1, 0, 0) * this->speed_);77 this->setVelocity(this->owner_->getInitialDir() * this->speed_); 82 78 } 83 79 … … 95 91 if (this->getPosition().squaredDistance(it->getPosition()) <= (radius*radius)) 96 92 { 97 Explosion *exp = new Explosion(this); 98 exp->create(); 93 // hit 94 if (it->isA(Class(SpaceShipAI))) 95 ((SpaceShipAI*)(*it))->damage(this->damage_); 96 ParticleSpawner* explosion = new ParticleSpawner(this->explosionTemplateName_, 2.0); 97 explosion->setPosition(this->getPosition()); 98 explosion->create(); 99 ParticleSpawner* smoke = new ParticleSpawner(this->smokeTemplateName_, 6.0, 0.0); 100 smoke->setPosition(this->getPosition()); 101 smoke->getParticleInterface()->setSpeedFactor(3.0); 102 smoke->create(); 99 103 delete this; 100 104 return; … … 108 112 delete this; 109 113 } 110 111 void Projectile::setColour(const ColourValue& colour)112 {113 this->billboard_.getBillboardSet()->getBillboard(0)->setColour(colour);114 }115 114 }
Note: See TracChangeset
for help on using the changeset viewer.