Changeset 10889 for code/branches/particleEffectsHS15/src/modules/weapons/projectiles/MineProjectile.cc
- Timestamp:
- Nov 29, 2015, 9:05:26 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/particleEffectsHS15/src/modules/weapons/projectiles/MineProjectile.cc
r10836 r10889 35 35 36 36 #include "core/CoreIncludes.h" 37 #include "graphics/Model.h" 37 38 #include "core/command/Executor.h" 38 #include "util/Convert.h"39 #include "util/Math.h"40 41 #include "core/CoreIncludes.h"42 #include "graphics/Model.h"43 #include "graphics/ParticleSpawner.h"44 #include "Scene.h"45 #include "core/command/Executor.h"46 #include "tools/ParticleInterface.h"47 39 48 40 namespace orxonox … … 50 42 RegisterClass(MineProjectile); 51 43 52 MineProjectile::MineProjectile(Context* context) : Projectile(context)44 MineProjectile::MineProjectile(Context* context) : MovableEntity(context), BasicProjectile() 53 45 { 54 46 RegisterObject(MineProjectile); 55 47 56 this->lifeTime_ = 1.0f; 48 this->bActive_ = false; 49 this->maxTimeUntilExplosion_ = 10.0f; 50 this->timeUntilActivation_ = 1.0f; 57 51 58 Model* model = new Model(this->getContext()); 59 model->setMeshSource("sphere.mesh"); 60 model->setScale(15.0); 61 this->attach(model); 62 model->setPosition(Vector3(0,0,0)); 52 rings_ = new MovableEntity(this->getContext()); 53 this->attach(rings_); 54 rings_->setPosition(Vector3(0.0,0.0,0.0)); 55 rings_->setAngularVelocity(Vector3(0.0,5.0,0.0)); 56 57 modelCore_ = new Model(this->getContext()); 58 modelCore_->setMeshSource("Mine_Core.mesh"); 59 modelCore_->setScale(15.0); 60 this->attach(modelCore_); 61 modelCore_->setPosition(Vector3(0,0,0)); 62 63 modelRing1_ = new Model(this->getContext()); 64 modelRing1_->setMeshSource("Mine_Ring.mesh"); 65 modelRing1_->setScale(15.0); 66 rings_->attach(modelRing1_); 67 modelRing1_->setPosition(Vector3(0,0,0)); 68 modelRing1_->yaw(Degree(0)); 69 70 modelRing2_ = new Model(this->getContext()); 71 modelRing2_->setMeshSource("Mine_Ring.mesh"); 72 modelRing2_->setScale(15.0); 73 rings_->attach(modelRing2_); 74 modelRing2_->setPosition(Vector3(0,0,0)); 75 modelRing2_->yaw(Degree(180)); 76 77 if (GameMode::isMaster()) 78 { 79 this->setMass(10.0f); 80 this->setFriction(100.0f); 81 this->enableCollisionCallback(); 82 this->setCollisionResponse(false); 83 this->setCollisionType(Dynamic); 84 85 // Create a sphere collision shape and attach it to the projectile. 86 collisionShape_ = new SphereCollisionShape(this->getContext()); 87 collisionShape_->setRadius(10.0f); 88 this->attachCollisionShape(collisionShape_); 89 90 // Create a distance trigger and attach it to the projectile. 91 distanceTrigger_ = new DistanceTrigger(this->getContext()); 92 this->attach(distanceTrigger_); 93 distanceTrigger_->setPosition(Vector3(0,0,0)); 94 distanceTrigger_->setDistance(40.0f); 95 distanceTrigger_->addTarget("Pawn"); 96 distanceTrigger_->setStayActive(true); 97 } 63 98 } 64 99 65 100 MineProjectile::~MineProjectile() 101 { 102 /*if (modelCore_ != NULL) 103 { 104 modelCore_->destroy(); 105 }*/ 106 /*if (distanceTrigger_ != NULL) 107 { 108 distanceTrigger_->destroy(); 109 }*/ 110 } 111 66 112 /** 67 113 @brief 68 T his function starts a timer that will cause the projectile to Mine after a time defined by the argument @param LifeTime.114 TODO 69 115 */ 70 void MineProjectile::set LifeTime(float lifeTime)116 void MineProjectile::setMaxTimeUntilExplosion(float maxTimeUntilExplosion) 71 117 { 72 orxout() << lifeTime << endl; 73 74 if (lifeTime >= 0) 118 if (maxTimeUntilExplosion >= 0) 75 119 { 76 this->lifeTime_ = lifeTime; 77 this->explodeTimer.setTimer(this->lifeTime_, false, createExecutor(createFunctor(&MineProjectile::Explode, this))); 120 this->maxTimeUntilExplosion_ = maxTimeUntilExplosion; 121 if (GameMode::isMaster()) 122 { 123 this->explodeTimer_.setTimer(this->maxTimeUntilExplosion_, false, createExecutor(createFunctor(&MineProjectile::Explode, this))); 124 } 78 125 } 79 126 else 80 127 { 81 this-> lifeTime_ = 0;128 this->maxTimeUntilExplosion_ = 0; 82 129 } 83 130 } 84 131 132 /** 133 @brief 134 TODO 135 */ 136 void MineProjectile::setTimeUntilActivation(float timeUntilActivation) 137 { 138 timeUntilActivation_ = timeUntilActivation; 139 140 if (GameMode::isMaster()) 141 { 142 this->activationTimer_.setTimer(this->timeUntilActivation_, false, createExecutor(createFunctor(&MineProjectile::Activate, this))); 143 } 144 } 85 145 86 146 /** 87 147 @brief 88 This is the setter function for the damageReduction_ variable. The value of the variable is bounded between 0 and 1. 89 */ 90 91 92 /** 93 @brief 94 If this function is called the projectile Mines up into many child projectiles. The original projectiles does not get destroyed but it will never Mine up again. 148 TODO 95 149 */ 96 150 void MineProjectile::Explode() 97 151 { 98 orxout() << " Explode" << endl;152 orxout() << "MineProjectile::Explode" << endl; 99 153 100 154 this->destroyLater(); … … 102 156 103 157 } 158 159 /** 160 @brief 161 TODO 162 */ 163 void MineProjectile::Activate() 164 { 165 orxout() << "MineProjectile::Activate" << endl; 166 167 bActive_ = true; 168 } 104 169 }
Note: See TracChangeset
for help on using the changeset viewer.