Changeset 1629 for code/branches/input/src/orxonox/objects/Projectile.cc
- Timestamp:
- Jun 27, 2008, 8:07:29 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/input/src/orxonox/objects/Projectile.cc
r1505 r1629 35 35 #include "core/Executor.h" 36 36 #include "core/ConfigValueIncludes.h" 37 #include "tools/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_ = 5000; 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/explosion3"; 53 this->smokeTemplateName_ = "Orxonox/smoke4"; 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"); 79 SetConfigValue(speed_, 2000.0).description("The speed of a projectile in units per second"); 73 SetConfigValue(damage_, 15.0).description("The damage caused by the projectile"); 74 SetConfigValue(lifetime_, 4.0).description("The time in seconds a projectile stays alive"); 75 SetConfigValue(speed_, 5000.0).description("The speed of a projectile in units per second"); 80 76 81 this->setVelocity(Vector3(1, 0, 0) * this->speed_); 77 if(this->owner_) 78 this->setVelocity(this->owner_->getInitialDir() * this->speed_); 82 79 } 83 80 … … 85 82 { 86 83 WorldEntity::tick(dt); 84 85 if (!this->isActive()) 86 return; 87 87 88 88 float radius; … … 95 95 if (this->getPosition().squaredDistance(it->getPosition()) <= (radius*radius)) 96 96 { 97 Explosion *exp = new Explosion(this); 98 exp->create(); 97 // hit 98 if (it->isA(Class(SpaceShipAI))) 99 ((SpaceShipAI*)(*it))->damage(this->damage_); 100 ParticleSpawner* explosion = new ParticleSpawner(this->explosionTemplateName_, LODParticle::low, 2.0); 101 explosion->setPosition(this->getPosition()); 102 explosion->create(); 103 ParticleSpawner* smoke = new ParticleSpawner(this->smokeTemplateName_, LODParticle::normal, 2.0, 0.0); 104 smoke->setPosition(this->getPosition()); 105 // smoke->getParticleInterface()->setSpeedFactor(3.0); 106 smoke->create(); 99 107 delete this; 100 108 return; … … 108 116 delete this; 109 117 } 110 111 void Projectile::setColour(const ColourValue& colour)112 {113 this->billboard_.getBillboardSet()->getBillboard(0)->setColour(colour);114 }115 118 }
Note: See TracChangeset
for help on using the changeset viewer.