Changeset 10908
- Timestamp:
- Nov 30, 2015, 10:55:38 PM (9 years ago)
- Location:
- code/branches/particleEffectsHS15
- Files:
-
- 2 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/particleEffectsHS15/data/levels/includes/weaponSettingsEscort.oxi
r10889 r10908 14 14 </links> 15 15 <Weapon> 16 <MineGun mode=0 munitionpershot=0 delay=0.125 damage= 9.3 muzzleoffset=" 0.1, 1.4,-3" maxtimeuntilexplosion=5 timeuntilactivation=1.5/>16 <MineGun mode=0 munitionpershot=0 delay=0.125 damage=50 shielddamage=15 healthdamage=10 muzzleoffset=" 0.1, 1.4,-3" maxtimeuntilexplosion=25 timeuntilactivation=2.5/> 17 17 </Weapon> 18 18 <Weapon> 19 < SplitGun mode=0 munitionpershot=0 delay=0.125 damage=9.3 muzzleoffset=" 0.1, 1.4,-3"/>19 <IceGun mode=0 munitionpershot=0 delay=0.125 damage=9.3 muzzleoffset=" 0.1, 1.4,-3" freezefactor=0.5 freezetime=2.0 /> 20 20 </Weapon> 21 21 </WeaponPack> -
code/branches/particleEffectsHS15/src/modules/weapons/projectiles/MineProjectile.cc
r10897 r10908 21 21 * 22 22 * Author: 23 * Jannis Holzer 23 24 * Fabien Vultier 24 25 * Co-authors: … … 35 36 36 37 #include "core/CoreIncludes.h" 38 #include "graphics/Model.h" 37 39 #include "core/command/Executor.h" 40 #include "graphics/ParticleSpawner.h" 41 #include "worldentities/pawns/Pawn.h" 38 42 #include "core/EventIncludes.h" 39 #include " graphics/Model.h"43 #include "sound/WorldSound.h" 40 44 41 45 namespace orxonox … … 43 47 RegisterClass(MineProjectile); 44 48 49 const float MineProjectile::collisionShapeRadius_ = 15.0f; 50 const float MineProjectile::damageRadius_ = 200.0f; 51 const float MineProjectile::triggerRadius_ = 100.0f; 52 45 53 MineProjectile::MineProjectile(Context* context) : MovableEntity(context), BasicProjectile() 46 54 { 47 55 RegisterObject(MineProjectile); 48 56 49 this->bA ctive_ = false;57 this->bAllowExplosion_ = false; 50 58 this->maxTimeUntilExplosion_ = 10.0f; 51 59 this->timeUntilActivation_ = 1.0f; 52 60 53 rings_ = new MovableEntity(this->getContext()); 54 this->attach(rings_); 55 rings_->setPosition(Vector3(0.0,0.0,0.0)); 56 rings_->setAngularVelocity(Vector3(0.0,5.0,0.0)); 57 61 //Create movable entities 62 rings1_ = new MovableEntity(this->getContext()); 63 this->attach(rings1_); 64 rings1_->setPosition(Vector3(0.0,0.0,0.0)); 65 rings1_->setAngularVelocity(Vector3(0.0,5.0,0.0)); 66 67 rings2_ = new MovableEntity(this->getContext()); 68 this->attach(rings2_); 69 rings2_->setPosition(Vector3(0.0,0.0,0.0)); 70 rings2_->setAngularVelocity(Vector3(0.0,0.0,5.0)); 71 72 core_ = new MovableEntity(this->getContext()); 73 this->attach(core_); 74 core_->setPosition(Vector3(0.0,0.0,0.0)); 75 core_->setAngularVelocity(Vector3(2.5,2.5,0.0)); 76 77 //Create Models 78 //Core 58 79 modelCore_ = new Model(this->getContext()); 59 80 modelCore_->setMeshSource("Mine_Core.mesh"); 60 81 modelCore_->setScale(15.0); 61 this->attach(modelCore_);82 core_->attach(modelCore_); 62 83 modelCore_->setPosition(Vector3(0,0,0)); 63 84 85 //Ring 1 64 86 modelRing1_ = new Model(this->getContext()); 65 87 modelRing1_->setMeshSource("Mine_Ring.mesh"); 66 88 modelRing1_->setScale(15.0); 67 rings _->attach(modelRing1_);89 rings1_->attach(modelRing1_); 68 90 modelRing1_->setPosition(Vector3(0,0,0)); 69 91 modelRing1_->yaw(Degree(0)); 70 92 //Ring 2 71 93 modelRing2_ = new Model(this->getContext()); 72 94 modelRing2_->setMeshSource("Mine_Ring.mesh"); 73 95 modelRing2_->setScale(15.0); 74 rings _->attach(modelRing2_);96 rings1_->attach(modelRing2_); 75 97 modelRing2_->setPosition(Vector3(0,0,0)); 76 98 modelRing2_->yaw(Degree(180)); 99 //Ring 3 100 modelRing3_ = new Model(this->getContext()); 101 modelRing3_->setMeshSource("Mine_Ring.mesh"); 102 modelRing3_->setScale(15.0); 103 rings2_->attach(modelRing3_); 104 modelRing3_->setPosition(Vector3(0,0,0)); 105 modelRing3_->yaw(Degree(90)); 106 //Ring 4 107 modelRing4_ = new Model(this->getContext()); 108 modelRing4_->setMeshSource("Mine_Ring.mesh"); 109 modelRing4_->setScale(15.0); 110 rings2_->attach(modelRing4_); 111 modelRing4_->setPosition(Vector3(0,0,0)); 112 modelRing4_->yaw(Degree(270)); 113 114 emitter_ = NULL; 77 115 78 116 if (GameMode::isMaster()) … … 86 124 // Create a sphere collision shape and attach it to the projectile. 87 125 collisionShape_ = new SphereCollisionShape(this->getContext()); 88 collisionShape_->setRadius( 10.0f);126 collisionShape_->setRadius(collisionShapeRadius_); 89 127 this->attachCollisionShape(collisionShape_); 128 collisionShape_->setPosition(Vector3(0,0,0)); 90 129 91 130 // Create a distance trigger and attach it to the projectile. … … 93 132 this->attach(distanceTrigger_); 94 133 distanceTrigger_->setPosition(Vector3(0,0,0)); 95 distanceTrigger_->setDistance( 40.0f);134 distanceTrigger_->setDistance(triggerRadius_); 96 135 distanceTrigger_->addTarget("Pawn"); 97 distanceTrigger_->setStayActive( true);136 distanceTrigger_->setStayActive(false); 98 137 99 138 this->addEventSource(distanceTrigger_, "explode"); … … 105 144 if (this->isInitialized()) 106 145 { 107 /*if (modelCore_ != NULL) 146 modelCore_->destroy(); 147 modelRing1_->destroy(); 148 modelRing2_->destroy(); 149 modelRing3_->destroy(); 150 modelRing4_->destroy(); 151 152 distanceTrigger_->destroy(); 153 154 if (emitter_) 108 155 { 109 modelCore_->destroy(); 110 }*/ 111 if (distanceTrigger_) 112 distanceTrigger_->destroy(); 113 } 114 } 115 156 emitter_->destroy(); 157 } 158 } 159 } 160 161 /** 162 @brief 163 TODO 164 */ 116 165 void MineProjectile::XMLEventPort(Element& xmlelement, XMLPort::Mode mode) 117 166 { 118 167 SUPER(MineProjectile, XMLEventPort, xmlelement, mode); 119 XMLPortEventState(MineProjectile, BaseObject, "explode", Explode, xmlelement, mode);168 XMLPortEventState(MineProjectile, BaseObject, "explode", explode, xmlelement, mode); 120 169 } 121 170 … … 131 180 if (GameMode::isMaster()) 132 181 { 133 this->explodeTimer_.setTimer(this->maxTimeUntilExplosion_, false, createExecutor(createFunctor(&MineProjectile:: Explode, this)));182 this->explodeTimer_.setTimer(this->maxTimeUntilExplosion_, false, createExecutor(createFunctor(&MineProjectile::explode, this))); 134 183 } 135 184 } … … 150 199 if (GameMode::isMaster()) 151 200 { 152 this->activationTimer_.setTimer(this->timeUntilActivation_, false, createExecutor(createFunctor(&MineProjectile::Activate, this))); 153 } 154 } 155 156 /** 157 @brief 158 TODO 159 */ 160 void MineProjectile::Explode() 161 { 162 orxout() << "MineProjectile::Explode" << endl; 163 164 this->destroyLater(); 165 166 167 } 168 169 /** 170 @brief 171 TODO 172 */ 173 void MineProjectile::Activate() 174 { 175 orxout() << "MineProjectile::Activate" << endl; 176 177 bActive_ = true; 201 this->activationTimer_.setTimer(this->timeUntilActivation_, false, createExecutor(createFunctor(&MineProjectile::allowExplosion, this))); 202 } 203 } 204 205 /** 206 @brief 207 TODO 208 */ 209 void MineProjectile::explode() 210 { 211 if (bAllowExplosion_) 212 { 213 if (GameMode::isMaster()) 214 { 215 // Damage all pawns within the damage radius 216 for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it) 217 { 218 Vector3 distanceVector = it->getWorldPosition()-this->getWorldPosition(); 219 if(distanceVector.length()< damageRadius_) 220 { 221 it->hit(this->getShooter(), it->getWorldPosition(), NULL, this->getDamage(), this->getHealthDamage(), this->getShieldDamage()); 222 } 223 } 224 } 225 226 this->destructionEffect(); 227 this->destroyLater(); 228 } 229 } 230 231 /** 232 @brief 233 TODO 234 */ 235 void MineProjectile::allowExplosion() 236 { 237 // Allow explosion 238 bAllowExplosion_ = true; 239 // Add particle effect 240 emitter_ = new ParticleEmitter(this->getContext()); 241 this->attach(emitter_); 242 emitter_->setOrientation(this->getOrientation()); 243 emitter_->setSource("Orxonox/mineparticle"); 244 } 245 246 /** 247 @brief 248 TODO 249 */ 250 void MineProjectile::destructionEffect() 251 { 252 ParticleSpawner *effect1, *effect2, *effect3; 253 254 effect1 = new ParticleSpawner(this->getContext()); 255 effect2 = new ParticleSpawner(this->getContext()); 256 effect3 = new ParticleSpawner(this->getContext()); 257 258 effect1->setPosition(this->getPosition()); 259 effect1->setOrientation(this->getOrientation()); 260 effect1->setDestroyAfterLife(true); 261 effect1->setSource("Orxonox/MineExpl"); 262 effect1->setLifetime(2.5f); 263 264 effect2->setPosition(this->getPosition()); 265 effect2->setOrientation(this->getOrientation()); 266 effect2->setDestroyAfterLife(true); 267 effect2->setSource("Orxonox/MineExpl1"); 268 effect2->setLifetime(2.5f); 269 270 effect3->setPosition(this->getPosition()); 271 effect3->setOrientation(this->getOrientation()); 272 effect3->setDestroyAfterLife(true); 273 effect3->setSource("Orxonox/MineExpl2"); 274 effect3->setLifetime(2.5f); 275 276 // Explosion sound effect. 277 WeakPtr<WorldSound> explosionSound_ = new WorldSound(getContext()); 278 explosionSound_->setSource("sounds/GravityFieldExplosion.ogg"); 279 explosionSound_->setVolume(1.0); 280 explosionSound_->play(); 178 281 } 179 282 } -
code/branches/particleEffectsHS15/src/modules/weapons/projectiles/MineProjectile.h
r10897 r10908 21 21 * 22 22 * Author: 23 * Jannis Holzer 23 24 * Fabien Vultier 24 25 * Co-authors: … … 60 61 virtual void setMaxTimeUntilExplosion(float maxTimeUntilExplosion); 61 62 virtual void setTimeUntilActivation(float timeUntilActivation); 62 63 protected: 64 static const float triggerRadius_; 65 static const float damageRadius_; 66 static const float collisionShapeRadius_; 63 67 private: 64 bool bA ctive_; // The mine can only explode if it is active68 bool bAllowExplosion_; // The mine can only explode if it is active 65 69 float maxTimeUntilExplosion_; 66 70 float timeUntilActivation_; … … 70 74 Model* modelRing1_; 71 75 Model* modelRing2_; 72 MovableEntity* rings_; 76 Model* modelRing3_; 77 Model* modelRing4_; 78 MovableEntity* rings1_; 79 MovableEntity* rings2_; 80 MovableEntity* core_; 81 ParticleEmitter* emitter_; 73 82 74 83 WeakPtr<SphereCollisionShape> collisionShape_; // The collision shape of the projectile. 75 84 WeakPtr<DistanceTrigger> distanceTrigger_; 76 85 77 virtual void Activate(); 78 virtual void Explode(); 86 virtual void destructionEffect(); 87 virtual void allowExplosion(); 88 virtual void explode(); 79 89 }; 80 90 } -
code/branches/particleEffectsHS15/src/modules/weapons/weaponmodes/MineGun.h
r10889 r10908 43 43 /** 44 44 @brief 45 A Mine that explodes when a ship is too close45 A Weapon that drops mines to space. 46 46 @ingroup WeaponsWeaponModes 47 47 */
Note: See TracChangeset
for help on using the changeset viewer.