Index: code/branches/particleEffectsHS15/src/modules/weapons/projectiles/MineProjectile.cc
===================================================================
--- code/branches/particleEffectsHS15/src/modules/weapons/projectiles/MineProjectile.cc	(revision 10897)
+++ code/branches/particleEffectsHS15/src/modules/weapons/projectiles/MineProjectile.cc	(revision 10908)
@@ -21,4 +21,5 @@
  *
  *   Author:
+ *      Jannis Holzer
  *      Fabien Vultier
  *   Co-authors:
@@ -35,7 +36,10 @@
 
 #include "core/CoreIncludes.h"
+#include "graphics/Model.h"
 #include "core/command/Executor.h"
+#include "graphics/ParticleSpawner.h"
+#include "worldentities/pawns/Pawn.h"
 #include "core/EventIncludes.h"
-#include "graphics/Model.h"
+#include "sound/WorldSound.h"
 
 namespace orxonox
@@ -43,36 +47,70 @@
     RegisterClass(MineProjectile);
 
+    const float MineProjectile::collisionShapeRadius_ = 15.0f;
+    const float MineProjectile::damageRadius_ = 200.0f;
+    const float MineProjectile::triggerRadius_ = 100.0f;
+
     MineProjectile::MineProjectile(Context* context) : MovableEntity(context), BasicProjectile()
     {
         RegisterObject(MineProjectile);
 
-        this->bActive_ = false;
+        this->bAllowExplosion_ = false;
         this->maxTimeUntilExplosion_ = 10.0f;
         this->timeUntilActivation_ = 1.0f;
 
-        rings_ = new MovableEntity(this->getContext());
-        this->attach(rings_);
-        rings_->setPosition(Vector3(0.0,0.0,0.0));
-        rings_->setAngularVelocity(Vector3(0.0,5.0,0.0));
-
+        //Create movable entities
+        rings1_ = new MovableEntity(this->getContext());
+        this->attach(rings1_);
+        rings1_->setPosition(Vector3(0.0,0.0,0.0));
+        rings1_->setAngularVelocity(Vector3(0.0,5.0,0.0));
+
+        rings2_ = new MovableEntity(this->getContext());
+        this->attach(rings2_);
+        rings2_->setPosition(Vector3(0.0,0.0,0.0));
+        rings2_->setAngularVelocity(Vector3(0.0,0.0,5.0));
+
+        core_ = new MovableEntity(this->getContext());
+        this->attach(core_);
+        core_->setPosition(Vector3(0.0,0.0,0.0));
+        core_->setAngularVelocity(Vector3(2.5,2.5,0.0));
+
+        //Create Models
+        //Core
         modelCore_ = new Model(this->getContext());
         modelCore_->setMeshSource("Mine_Core.mesh");
         modelCore_->setScale(15.0);
-        this->attach(modelCore_);
+        core_->attach(modelCore_);
         modelCore_->setPosition(Vector3(0,0,0));
 
+        //Ring 1
         modelRing1_ = new Model(this->getContext());
         modelRing1_->setMeshSource("Mine_Ring.mesh");
         modelRing1_->setScale(15.0);
-        rings_->attach(modelRing1_);
+        rings1_->attach(modelRing1_);
         modelRing1_->setPosition(Vector3(0,0,0));
         modelRing1_->yaw(Degree(0));
-
+        //Ring 2
         modelRing2_ = new Model(this->getContext());
         modelRing2_->setMeshSource("Mine_Ring.mesh");
         modelRing2_->setScale(15.0);
-        rings_->attach(modelRing2_);
+        rings1_->attach(modelRing2_);
         modelRing2_->setPosition(Vector3(0,0,0));
         modelRing2_->yaw(Degree(180));
+        //Ring 3
+        modelRing3_ = new Model(this->getContext());
+        modelRing3_->setMeshSource("Mine_Ring.mesh");
+        modelRing3_->setScale(15.0);
+        rings2_->attach(modelRing3_);
+        modelRing3_->setPosition(Vector3(0,0,0));
+        modelRing3_->yaw(Degree(90));
+        //Ring 4
+        modelRing4_ = new Model(this->getContext());
+        modelRing4_->setMeshSource("Mine_Ring.mesh");
+        modelRing4_->setScale(15.0);
+        rings2_->attach(modelRing4_);
+        modelRing4_->setPosition(Vector3(0,0,0));
+        modelRing4_->yaw(Degree(270));
+
+        emitter_ = NULL;
 
         if (GameMode::isMaster())
@@ -86,6 +124,7 @@
             // Create a sphere collision shape and attach it to the projectile.
             collisionShape_ = new SphereCollisionShape(this->getContext());
-            collisionShape_->setRadius(10.0f);
+            collisionShape_->setRadius(collisionShapeRadius_);
             this->attachCollisionShape(collisionShape_);
+            collisionShape_->setPosition(Vector3(0,0,0));
 
             // Create a distance trigger and attach it to the projectile.
@@ -93,7 +132,7 @@
             this->attach(distanceTrigger_);
             distanceTrigger_->setPosition(Vector3(0,0,0));
-            distanceTrigger_->setDistance(40.0f);
+            distanceTrigger_->setDistance(triggerRadius_);
             distanceTrigger_->addTarget("Pawn");
-            distanceTrigger_->setStayActive(true);
+            distanceTrigger_->setStayActive(false);
 
             this->addEventSource(distanceTrigger_, "explode");
@@ -105,17 +144,27 @@
         if (this->isInitialized())
         {
-            /*if (modelCore_ != NULL)
+            modelCore_->destroy();
+            modelRing1_->destroy();
+            modelRing2_->destroy();
+            modelRing3_->destroy();
+            modelRing4_->destroy();
+
+            distanceTrigger_->destroy();
+
+            if (emitter_)
             {
-                modelCore_->destroy();
-            }*/
-            if (distanceTrigger_)
-                distanceTrigger_->destroy();
-        }
-    }
-
+                emitter_->destroy();
+            }
+        }
+    }
+
+    /**
+    @brief
+        TODO
+    */
     void MineProjectile::XMLEventPort(Element& xmlelement, XMLPort::Mode mode)
     {
         SUPER(MineProjectile, XMLEventPort, xmlelement, mode);
-        XMLPortEventState(MineProjectile, BaseObject, "explode", Explode, xmlelement, mode);
+        XMLPortEventState(MineProjectile, BaseObject, "explode", explode, xmlelement, mode);
     }
 
@@ -131,5 +180,5 @@
             if (GameMode::isMaster())
             {
-                this->explodeTimer_.setTimer(this->maxTimeUntilExplosion_, false, createExecutor(createFunctor(&MineProjectile::Explode, this)));
+                this->explodeTimer_.setTimer(this->maxTimeUntilExplosion_, false, createExecutor(createFunctor(&MineProjectile::explode, this)));
             }
         }
@@ -150,30 +199,84 @@
         if (GameMode::isMaster())
         {
-            this->activationTimer_.setTimer(this->timeUntilActivation_, false, createExecutor(createFunctor(&MineProjectile::Activate, this)));
-        }
-    }
-
-    /**
-    @brief
-        TODO
-    */
-    void MineProjectile::Explode()
-    {
-        orxout() << "MineProjectile::Explode" << endl;
-
-        this->destroyLater();
-
-
-    }
-
-    /**
-    @brief
-        TODO
-    */
-    void MineProjectile::Activate()
-    {
-        orxout() << "MineProjectile::Activate" << endl;
-
-        bActive_ = true;
+            this->activationTimer_.setTimer(this->timeUntilActivation_, false, createExecutor(createFunctor(&MineProjectile::allowExplosion, this)));
+        }
+    }
+
+    /**
+    @brief
+        TODO
+    */
+    void MineProjectile::explode()
+    {
+        if (bAllowExplosion_)
+        {
+            if (GameMode::isMaster())
+            {
+                // Damage all pawns within the damage radius
+                for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)
+                {
+                    Vector3 distanceVector = it->getWorldPosition()-this->getWorldPosition();
+                    if(distanceVector.length()< damageRadius_)
+                    {
+                        it->hit(this->getShooter(), it->getWorldPosition(), NULL, this->getDamage(), this->getHealthDamage(), this->getShieldDamage());
+                    }
+                }
+            }
+
+            this->destructionEffect();
+            this->destroyLater();
+        }
+    }
+
+    /**
+    @brief
+        TODO
+    */
+    void MineProjectile::allowExplosion()
+    {
+        // Allow explosion
+        bAllowExplosion_ = true;
+        // Add particle effect
+        emitter_ = new ParticleEmitter(this->getContext());
+        this->attach(emitter_);
+        emitter_->setOrientation(this->getOrientation());
+        emitter_->setSource("Orxonox/mineparticle");  
+    }
+
+    /**
+    @brief
+        TODO
+    */
+    void MineProjectile::destructionEffect()
+    {
+        ParticleSpawner *effect1, *effect2, *effect3;
+       
+        effect1 = new ParticleSpawner(this->getContext());
+        effect2 = new ParticleSpawner(this->getContext());
+        effect3 = new ParticleSpawner(this->getContext());
+
+        effect1->setPosition(this->getPosition());
+        effect1->setOrientation(this->getOrientation());
+        effect1->setDestroyAfterLife(true);
+        effect1->setSource("Orxonox/MineExpl");
+        effect1->setLifetime(2.5f);
+
+        effect2->setPosition(this->getPosition());
+        effect2->setOrientation(this->getOrientation());
+        effect2->setDestroyAfterLife(true);
+        effect2->setSource("Orxonox/MineExpl1");
+        effect2->setLifetime(2.5f);
+
+        effect3->setPosition(this->getPosition());
+        effect3->setOrientation(this->getOrientation());
+        effect3->setDestroyAfterLife(true);
+        effect3->setSource("Orxonox/MineExpl2");
+        effect3->setLifetime(2.5f);
+
+        // Explosion sound effect.
+        WeakPtr<WorldSound> explosionSound_ = new WorldSound(getContext());
+        explosionSound_->setSource("sounds/GravityFieldExplosion.ogg");
+        explosionSound_->setVolume(1.0);
+        explosionSound_->play();
     }
 }
