Index: code/branches/presentation2011/data/levels/Spacerace2.oxw
===================================================================
--- code/branches/presentation2011/data/levels/Spacerace2.oxw	(revision 8998)
+++ code/branches/presentation2011/data/levels/Spacerace2.oxw	(revision 8998)
@@ -0,0 +1,206 @@
+<LevelInfo
+ name = "Spacerace2"
+ description = "Just a few tests"
+ tags = "test"
+/>
+
+<?lua
+  include("stats.oxo")
+  include("HUDTemplates3.oxo")
+  include("templates/lodInformation.oxt")
+
+  include("templates/spaceshipAssff.oxt")
+ 
+?>
+
+<?lua
+  include("templates/spaceshipAssff2.oxt")
+  include("templates/spaceshipPirate.oxt")
+?>
+
+<Level
+ name         = "Spacerace2"
+ description  = "Just a few tests"
+gametype = SpaceRace
+>
+  <templates>
+    <Template link=lodtemplate_default />
+  </templates>
+  <?lua include("includes/notifications.oxi") ?>
+
+  <Scene
+    ambientlight = "0.8, 0.8, 0.8"
+    skybox       = "Orxonox/Starbox"
+  >
+
+    <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
+
+	
+	<SpaceRaceManager>
+<checkpoints>	
+	<RaceCheckPoint name="checkpoint1" position="0,-2000,1000" direction="0,-1,1" collisionType="static" scale="1" distance="40" checkpointindex="0" islast="false" nextcheckpoints="1,2,-1">
+        <attached>
+            <Model mass="50" scale="50" mesh="raceCheckPoint.mesh" />
+        </attached>
+        <collisionShapes>
+            <BoxCollisionShape position="0,0,55"      halfExtents="55, 10, 10" />
+            <BoxCollisionShape position="0,0,-55"     halfExtents="55, 10, 10" />
+            <BoxCollisionShape position="55,0,0"      halfExtents="10, 10, 55" />
+            <BoxCollisionShape position="-55,0,0"     halfExtents="10, 10, 55" />
+        </collisionShapes>
+    </RaceCheckPoint>
+
+<RaceCheckPoint name="checkpoint2" position="0,2100,2300" direction="0,-1,1" collisionType="static" scale="1" distance="40" checkpointindex="1" islast="false" nextcheckpoints="3,-1,-1">
+        <attached>
+            <Model mass="50" scale="50" mesh="raceCheckPoint.mesh" />
+        </attached>
+        <collisionShapes>
+            <BoxCollisionShape position="0,0,55"      halfExtents="55, 10, 10" />
+            <BoxCollisionShape position="0,0,-55"     halfExtents="55, 10, 10" />
+            <BoxCollisionShape position="55,0,0"      halfExtents="10, 10, 55" />
+            <BoxCollisionShape position="-55,0,0"     halfExtents="10, 10, 55" />
+        </collisionShapes>
+    </RaceCheckPoint>
+
+<RaceCheckPoint name="checkpoint3" position="0,700,2700" direction="0,-1,1" collisionType="static" scale="1" distance="40" checkpointindex="2" islast="false" nextcheckpoints="3,-1,-1">
+        <attached>
+            <Model mass="50" scale="50" mesh="raceCheckPoint.mesh" />
+        </attached>
+        <collisionShapes>
+            <BoxCollisionShape position="0,0,55"      halfExtents="55, 10, 10" />
+            <BoxCollisionShape position="0,0,-55"     halfExtents="55, 10, 10" />
+            <BoxCollisionShape position="55,0,0"      halfExtents="10, 10, 55" />
+            <BoxCollisionShape position="-55,0,0"     halfExtents="10, 10, 55" />
+        </collisionShapes>
+    </RaceCheckPoint>
+
+<RaceCheckPoint name="checkpoint4" position="0,-400,300" direction="0,-1,1" collisionType="static" scale="1" distance="40" checkpointindex="3" islast="true">
+        <attached>
+            <Model mass="50" scale="50" mesh="raceCheckPoint.mesh" />
+        </attached>
+        <collisionShapes>
+            <BoxCollisionShape position="0,0,55"      halfExtents="55, 10, 10" />
+            <BoxCollisionShape position="0,0,-55"     halfExtents="55, 10, 10" />
+            <BoxCollisionShape position="55,0,0"      halfExtents="10, 10, 55" />
+            <BoxCollisionShape position="-55,0,0"     halfExtents="10, 10, 55" />
+        </collisionShapes>
+    </RaceCheckPoint>
+</checkpoints>
+</SpaceRaceManager>
+
+ 
+<SpaceShip position="0,0,200" lookat="0,0,0">
+      <templates>
+        <Template link=spaceshipassff />
+      </templates>
+      <controller>
+        <WaypointPatrolController alertnessradius=0 team=10>
+          <waypoints>
+            <Model mesh="cube.mesh" scale=0 position="0,-2000,1000" />
+            <Model mesh="cube.mesh" scale=0 position="0,2100,2300" />
+            <Model mesh="cube.mesh" scale=0 position="0,-400,300" />
+          </waypoints>
+        </WaypointPatrolController>
+      </controller>
+    </SpaceShip>
+
+    <SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
+
+
+    <!-- ------------------Planet----------------- -->
+    <Planet position="0,0,0" scale=300 pitch=-90 mesh="iceplanet.mesh" atmosphere="atmosphere1" rotationaxis="8,1,0" rotationrate="1" atmospheresize=224.0f imagesize=1024.0f />
+    <StaticEntity position="0,0,0" collisionType=static>
+        <collisionShapes>
+            <SphereCollisionShape radius="399" />
+        </collisionShapes>
+    </StaticEntity>
+
+    <!-- ---------------asteroid ellipse----------------- -->
+    <?lua
+    max = 20
+    for i = 0, max, 1
+    do
+    y = math.sin(i/max*6)*2000
+    z = math.cos(i/max*6)*2500
+    x = 0
+    ?>
+    <?lua
+    for k = 1, 15, 1
+    do
+    j = math.random()
+    ?>
+
+    <MovableEntity
+      position = "<?lua print(x + math.random() * 500) ?>,<?lua print(y + math.random() * 500) ?>,<?lua print(z + math.random() * 1000) ?>"
+      collisionType = "dynamic"
+      linearDamping = "0.5"
+      angularDamping = "0.01"
+      collisiondamage = "0.01"
+      enablecollisiondamage = "true"
+      scale="<?lua print(j * 5) ?>" >
+      <attached>
+        <Model position="0,0,0" scale="<?lua print(j * 10) ?>" mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh">
+      <?lua if k == 5 then ?><attached><!-- ---------asteroid fog----- -->
+            <ParticleEmitter position="0,0,0" source="Orxonox/Steam" />
+          </attached> <?lua end ?>
+        </Model>
+      </attached>
+      <collisionShapes>
+        <SphereCollisionShape radius="<?lua print(j * 80) ?>" />
+      </collisionShapes>
+    </MovableEntity>
+    <?lua
+    end
+    ?>
+    <?lua end ?>
+
+    <!-- ---------------ForceFields----------------- -->
+    <ForceField position="0,-700,2700" direction="0,1,0" diameter=500 velocity=2000 length=600 />
+        <MovableEntity position="0,-400,2700">
+            <attached>
+                <Billboard position="0,0,0" material="Flares/ringflare2" colour="0.5,0,0" scale=2/>
+                <?lua for i=0,15,1 do ?>
+                    <Billboard position="-200,<?lua print(i*40) ?>,0" material="Examples/Flare" colour="0.5,0,0" scale=1/>
+                    <Billboard position="200,<?lua print(i*40) ?>,0" material="Examples/Flare" colour="0.5,0,0" scale=1/>
+                <?lua end ?>
+                </attached>
+        </MovableEntity>
+
+     <ForceField position="0,2500,2000" direction="0,0,-1" diameter=250 velocity=2000 length=600 />
+        <MovableEntity position="0,2500,2000">
+            <attached>
+                <Billboard position="0,0,0" material="Flares/ringflare2" colour="0.5,0,0" scale=2/>
+                <?lua for i=0,15,1 do ?>
+                    <Billboard position="-100,0,-<?lua print(i*40) ?>" material="Examples/Flare" colour="0.5,0,0" scale=1/>
+                    <Billboard position="100,0,-<?lua print(i*40) ?>" material="Examples/Flare" colour="0.5,0,0" scale=1/>
+                <?lua end ?>
+                </attached>
+        </MovableEntity>
+
+    <ForceField position="0,1300,-800" direction="0,-1,-1" diameter=250 velocity=2000 length=800 />
+        <MovableEntity position="0,1300,-800">
+            <attached>
+                <Billboard position="0,0,0" material="Flares/ringflare2" colour="0.5,0,0" scale=2/>
+                <?lua for i=0,20,1 do ?>
+                    <Billboard position="-100,<?lua print(-i*40*0.7071) ?>,<?lua print(-i*40*0.7071) ?>" material="Examples/Flare" colour="0.5,0,0" scale=1/>
+                    <Billboard position="100,<?lua print(-i*40*0.7071) ?>,<?lua print(-i*40*0.7071) ?>" material="Examples/Flare" colour="0.5,0,0" scale=1/>
+                <?lua end ?>
+                </attached>
+        </MovableEntity>
+
+    <ForceField position="0,-1400,-700" direction="0,-1,1" diameter=250 velocity=2000 length=600 />
+        <MovableEntity position="0,-1400,-700">
+            <attached>
+                <Billboard position="0,0,0" material="Flares/ringflare2" colour="0.5,0,0" scale=2/>
+                <?lua for i=0,15,1 do ?>
+                    <Billboard position="-100,<?lua print(-i*40*0.7071) ?>,<?lua print(i*40*0.7071) ?>" material="Examples/Flare" colour="0.5,0,0" scale=1/>
+                    <Billboard position="100,<?lua print(-i*40*0.7071) ?>,<?lua print(i*40*0.7071) ?>" material="Examples/Flare" colour="0.5,0,0" scale=1/>
+                <?lua end ?>
+                </attached>
+        </MovableEntity>
+
+
+    
+  </Scene>
+</Level>
+
Index: code/branches/presentation2011/src/modules/gametypes/CMakeLists.txt
===================================================================
--- code/branches/presentation2011/src/modules/gametypes/CMakeLists.txt	(revision 8997)
+++ code/branches/presentation2011/src/modules/gametypes/CMakeLists.txt	(revision 8998)
@@ -2,4 +2,5 @@
   SpaceRace.cc
   RaceCheckPoint.cc
+  SpaceRaceManager.cc
 )
 
Index: code/branches/presentation2011/src/modules/gametypes/RaceCheckPoint.cc
===================================================================
--- code/branches/presentation2011/src/modules/gametypes/RaceCheckPoint.cc	(revision 8997)
+++ code/branches/presentation2011/src/modules/gametypes/RaceCheckPoint.cc	(revision 8998)
@@ -34,4 +34,7 @@
 #include "chat/ChatManager.h"
 
+#include <infos/PlayerInfo.h>
+#include <worldentities/ControllableEntity.h>
+
 #include "SpaceRace.h"
 
@@ -39,11 +42,14 @@
 {
     CreateFactory(RaceCheckPoint);
+    
+     
 
-    RaceCheckPoint::RaceCheckPoint(BaseObject* creator): DistanceTrigger(creator), RadarViewable(creator, static_cast<WorldEntity*>(this))
+    RaceCheckPoint::RaceCheckPoint(BaseObject* creator): DistanceMultiTrigger(creator), RadarViewable(creator, static_cast<WorldEntity*>(this))
     {
         RegisterObject(RaceCheckPoint);
-
-        this->bCheckpointIndex_ = 0;
-        this->bIsLast_ = false;
+        this->setDistance(100);
+        this->setBeaconMode("off");
+        this->setBroadcast(false);
+        this->setSimultaneousTriggerers(100);
         this->bTimeLimit_ = 0;
 
@@ -51,9 +57,14 @@
         this->setRadarObjectShape(RadarViewable::Triangle);
         this->setRadarVisibility(false);
+        this->settingsChanged();
+        this->reached_=NULL;
+      
     }
+    
 
-    RaceCheckPoint::~RaceCheckPoint()
-    {
-    }
+   RaceCheckPoint::~RaceCheckPoint()
+   {
+    
+   }
 
     void RaceCheckPoint::tick(float dt)
@@ -63,8 +74,4 @@
         SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
         assert(gametype);
-        if (this->getCheckpointIndex() == gametype->getCheckpointsReached())
-            this->setRadarVisibility(true);
-        else
-            this->setRadarVisibility(false);
     }
 
@@ -72,32 +79,23 @@
     {
         SUPER(RaceCheckPoint, XMLPort, xmlelement, mode);
-
+        Vector3 v= Vector3(0,0,0);
         XMLPortParam(RaceCheckPoint, "checkpointindex", setCheckpointIndex, getCheckpointIndex, xmlelement, mode).defaultValues(0);
         XMLPortParam(RaceCheckPoint, "islast", setLast, getLast, xmlelement, mode).defaultValues(false);
         XMLPortParam(RaceCheckPoint, "timelimit", setTimelimit, getTimeLimit, xmlelement, mode).defaultValues(0);
+    XMLPortParamTemplate(RaceCheckPoint, "nextcheckpoints", setNextcheckpoint, getNextcheckpoint, xmlelement, mode,const Vector3&).defaultValues(v);
     }
 
-    void RaceCheckPoint::triggered(bool bIsTriggered)
+    void RaceCheckPoint::fire(bool bIsTriggered,BaseObject* player)
     {
-        DistanceTrigger::triggered(bIsTriggered);
-
+        DistanceMultiTrigger::fire((bool)bIsTriggered,player);
+        
         SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
-        if (gametype && this->getCheckpointIndex() == gametype->getCheckpointsReached() && bIsTriggered)
-        {
-            gametype->clock_.capture();
-            float time = gametype->clock_.getSecondsPrecise();
-            if (this->bTimeLimit_!=0 && time > this->bTimeLimit_)
-            {
-                gametype->timeIsUp();
-                gametype->end();
-            }
-            else if (this->getLast())
-                gametype->end();
-            else
-            {
-                gametype->newCheckpointReached();
-                this->setRadarObjectColour(ColourValue::Green); //sets the radar colour of the checkpoint to green if it is reached, else it is red.
-            }
-        }
+        assert(gametype);
+        ControllableEntity* entity = (ControllableEntity*) player;
+     
+        PlayerInfo* player2 = entity->getPlayer();
+     
+        if(bIsTriggered)
+            this->reached_=player2;
     }
 
@@ -108,4 +106,5 @@
         {
             SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
+            assert(gametype);
             if (gametype)
             {
Index: code/branches/presentation2011/src/modules/gametypes/RaceCheckPoint.h
===================================================================
--- code/branches/presentation2011/src/modules/gametypes/RaceCheckPoint.h	(revision 8997)
+++ code/branches/presentation2011/src/modules/gametypes/RaceCheckPoint.h	(revision 8998)
@@ -32,5 +32,7 @@
 #include "gametypes/GametypesPrereqs.h"
 
-#include "objects/triggers/DistanceTrigger.h"
+
+
+#include "objects/triggers/DistanceMultiTrigger.h"
 #include "interfaces/RadarViewable.h"
 
@@ -40,7 +42,7 @@
     @brief
         The RaceCheckPoint class enables the creation of a check point to use in a SpaceRace level.
-        !!! Don't forget to control the indexes of your check points and to set one last check point!!!
+         Don't forget to control the indexes of your check points and to set one last check point
     */
-    class _GametypesExport RaceCheckPoint : public DistanceTrigger, public RadarViewable
+    class _GametypesExport RaceCheckPoint : public DistanceMultiTrigger, public RadarViewable
     {
         public:
@@ -50,26 +52,38 @@
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
             virtual void tick(float dt);
+            inline void setCheckpointIndex(int checkpointIndex)
+                { this->bCheckpointIndex_ = checkpointIndex; }
+            inline int getCheckpointIndex()
+                { return this->bCheckpointIndex_; }
 
-            protected:
-            virtual void triggered(bool bIsTriggered);
+            inline void setNextcheckpoint(const Vector3& checkpoints)
+                { this->nextcheckpoints_=checkpoints; }
+            inline void setNextcheckpoint(float x, float y, float z)
+                { this->setNextcheckpoint(Vector3(x, y, z)); }
+            inline const Vector3& getNextcheckpoint() const
+                { return this->nextcheckpoints_; }
             inline void setLast(bool isLast)
                 { this->bIsLast_ = isLast; }
             inline bool getLast()
                 { return this->bIsLast_; }
-            inline void setCheckpointIndex(int checkpointIndex)
-                { this->bCheckpointIndex_ = checkpointIndex; }
-            inline int getCheckpointIndex()
-                { return this->bCheckpointIndex_; }
+
+            bool bIsLast_; //True if this check point is the last of the level. There can be only one last check point for each level and there must be a last check point in the level.
+            float bTimeLimit_; //The time limit (from the start of the level) to reach this check point. If the check point is reached after this time, the game ends and the player looses.
+            PlayerInfo* reached_;
+                
+            inline float getTimeLimit()
+                { return this->bTimeLimit_; }
+    
+        protected:
+            virtual void fire(bool bIsTriggered,BaseObject* player);
             virtual void setTimelimit(float timeLimit);
-            inline float getTimeLimit()
-                { return this->bTimeLimit_;}
+            
             inline const WorldEntity* getWorldEntity() const
                 { return this; }
 
         private:
-            int bCheckpointIndex_; //The index of this check point. This value will be compared with the number of check points reached in the level. The check points must be indexed in ascending order beginning from zero and without any jumps between the indexes.
-            bool bIsLast_; //True if this check point is the last of the level. There can be only one last check point for each level and there must be a last check point in the level.
-            float bTimeLimit_; //The time limit (from the start of the level) to reach this check point. If the check point is reached after this time, the game ends and the player looses.
-      
+            int bCheckpointIndex_; //The index of this check point. The race starts with the check point with the index 0
+            Vector3 nextcheckpoints_; //the indexes of the next check points
+            
     };
 }
Index: code/branches/presentation2011/src/modules/gametypes/SpaceRace.cc
===================================================================
--- code/branches/presentation2011/src/modules/gametypes/SpaceRace.cc	(revision 8997)
+++ code/branches/presentation2011/src/modules/gametypes/SpaceRace.cc	(revision 8998)
@@ -29,8 +29,13 @@
 #include "SpaceRace.h"
 
+
+#include "items/Engine.h"
+
 #include "core/CoreIncludes.h"
 #include "chat/ChatManager.h"
 #include "util/Convert.h"
 #include "util/Math.h"
+
+#include "items/Engine.h"
 
 namespace orxonox
@@ -41,8 +46,15 @@
     {
         RegisterObject(SpaceRace);
-        this->checkpointsReached_ = 0;
+        
         this->bTimeIsUp_ = false;
         this->numberOfBots_ = 0;
+        this->cantMove_=false;
+        
     }
+       
+    
+  // void SpaceRace::SetConfigValues(){
+    //SUPER(Gametype,setConfigValues);
+    //this->Gametype::SetConfigValue(initialStartCountdown_, 3.0f);}
 
     void SpaceRace::end()
@@ -56,6 +68,5 @@
             int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s);
             const std::string& message = multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) + " seconds !!\n"
-                        + "You didn't reach the check point " + multi_cast<std::string>(this->checkpointsReached_+1)
-                        + " before the time limit. You lose!";
+                        + "You didn't reach the check point  before the time limit. You lose!";
             const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
             ChatManager::message(message);
@@ -70,11 +81,10 @@
             const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
             ChatManager::message(message);
-/*
+
             float time = this->clock_.getSecondsPrecise();
             this->scores_.insert(time);
             std::set<float>::iterator it;
-            for (it=this->scores_.begin(); it!=this->scores_.end(); it++)
-                orxout(level::message) << multi_cast<std::string>(*it) << endl;
-*/
+            
+
         }
     }
@@ -82,23 +92,100 @@
     void SpaceRace::start()
     {
-        Gametype::start();
 
-        std::string message("The match has started! Reach the check points as quickly as possible!");
+        this->spawnPlayersIfRequested();
+        Gametype::checkStart(); 
+        this->cantMove_=true; 
+        
+        for(ObjectList<Engine>::iterator it = ObjectList<Engine>::begin(); it; ++it) 
+        {
+            it->setActive(false);
+            
+        } 
+        this->addBots(this->numberOfBots_); 
+    }
+    
+    void SpaceRace::tick(float dt)
+    {
+        SUPER(SpaceRace,tick,dt);
+    
+        if(!this->isStartCountdownRunning() && this->cantMove_)
+        {
+            for(ObjectList<Engine>::iterator it = ObjectList<Engine>::begin(); it; ++it) 
+            { 
+                it->setActive(true);
+                
+            }
+            this->cantMove_= false;
+            
+            std::string message("The match has started! Reach the check points as quickly as possible!");
+            const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
+            ChatManager::message(message);            
+        }
+   
+    }
+
+    
+    
+    void SpaceRace::newCheckpointReached(SpaceRaceManager* p, int index,PlayerInfo* pl)
+    {
+        this->checkpointReached_[pl]=index;
+        this->clock_.capture();
+        int s = this->clock_.getSeconds();
+        int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s);
+        const std::string& message = "Checkpoint " + multi_cast<std::string>(index)
+            + " reached after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms)
+            + " seconds.";// Message is too long for a normal screen.
         const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
         ChatManager::message(message);
     }
-
-    void SpaceRace::newCheckpointReached()
-    {
-        this->checkpointsReached_++;
+   
+    void SpaceRace::newCheckpointReached(RaceCheckPoint* p, PlayerInfo* pl)
+    {   
+        int index = p->getCheckpointIndex();
+        this->checkpointReached_[pl]=index;
         this->clock_.capture();
         int s = this->clock_.getSeconds();
         int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s);
-        const std::string& message = "Checkpoint " + multi_cast<std::string>(this->getCheckpointsReached())
-                        + " reached after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms)
-                        + " seconds.";
+        const std::string& message = "Checkpoint " + multi_cast<std::string>(index)
+            + " reached after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms)
+            + " seconds.";
         const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
         ChatManager::message(message);
     }
+        
+    
+    void SpaceRace::playerEntered(PlayerInfo* player)
+    {
+        Gametype::playerEntered(player);
+    
+        this->checkpointReached_[player]=-1;
+        //this->playersAlive_++;
+    }
+    
+    bool SpaceRace::playerLeft(PlayerInfo* player)
+    {
+        return Gametype::playerLeft(player);
+        // bool valid_player = true;
+        //if (valid_player)
+       // {
+        //    this->playersAlive_--;
+        //}
 
+       // return valid_player;
+    }
+    
+    bool SpaceRace::allowPawnHit(Pawn* victim, Pawn* originator)
+    {
+        return false;
+    }
+
+    bool SpaceRace::allowPawnDamage(Pawn* victim, Pawn* originator)
+    {
+        return false;
+    }
+
+    bool SpaceRace::allowPawnDeath(Pawn* victim, Pawn* originator)
+    {
+        return false;
+    }
 }
Index: code/branches/presentation2011/src/modules/gametypes/SpaceRace.h
===================================================================
--- code/branches/presentation2011/src/modules/gametypes/SpaceRace.h	(revision 8997)
+++ code/branches/presentation2011/src/modules/gametypes/SpaceRace.h	(revision 8998)
@@ -34,4 +34,5 @@
 #include <set>
 #include <string>
+# include <vector>
 
 #include <util/Clock.h>
@@ -39,5 +40,5 @@
 #include "gametypes/Gametype.h"
 
-#include "RaceCheckPoint.h"
+#include "SpaceRaceManager.h"
 
 namespace orxonox
@@ -50,4 +51,5 @@
     {
         friend class RaceCheckPoint;
+       
 
         public:
@@ -58,20 +60,33 @@
             virtual void end();
 
-            virtual void newCheckpointReached();
+            virtual void newCheckpointReached(SpaceRaceManager* p, int index,PlayerInfo* pl);
+            virtual void newCheckpointReached(RaceCheckPoint* p, PlayerInfo* pl);
 
-            inline void setCheckpointsReached(int n)
-                { this->checkpointsReached_ = n;}
-            inline int getCheckpointsReached()
-                { return this->checkpointsReached_; }
+            inline void setCheckpointReached(int n, PlayerInfo* p)
+                { this->checkpointReached_[p] = n;}
+            inline int getCheckpointReached(PlayerInfo* p)
+                { return this->checkpointReached_[p]; }
+
             inline void timeIsUp()
                 { this->bTimeIsUp_ = true;}
+            void tick(float dt);
+            Clock clock_; //The clock starts running at the beginning of the game. It is used to give the time at each check point, the give the time at the end of the game, and to stop the game if a check point is reached too late.
 
+
+            bool allowPawnHit(Pawn* victim, Pawn* originator);
+
+            bool allowPawnDamage(Pawn* victim, Pawn* originator);
+
+            bool allowPawnDeath(Pawn* victim, Pawn* originator);
         protected:
-
+            virtual void playerEntered(PlayerInfo* player); //!< Initializes values.
+            virtual bool playerLeft(PlayerInfo* player); //!< Manages all local variables.
         private:
-            int checkpointsReached_; //The current number of check points reached by the player.
+            bool cantMove_;
+            std::map<PlayerInfo*, int>checkpointReached_; //The number of the last check point reached by each player.
             std::set<float> scores_; //The times of the players are saved in a set.
             bool bTimeIsUp_; //True if one of the check points is reached too late.
-            Clock clock_; //The clock starts running at the beginning of the game. It is used to give the time at each check point, the give the time at the end of the game, and to stop the game if a check point is reached too late.
+            
+            int playersAlive_;
     };
 }
Index: code/branches/presentation2011/src/modules/gametypes/SpaceRaceManager.cc
===================================================================
--- code/branches/presentation2011/src/modules/gametypes/SpaceRaceManager.cc	(revision 8998)
+++ code/branches/presentation2011/src/modules/gametypes/SpaceRaceManager.cc	(revision 8998)
@@ -0,0 +1,195 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *     Celine Eggenberger
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "SpaceRaceManager.h"
+#include "SpaceRace.h"
+#include "infos/PlayerInfo.h"
+
+#include "core/XMLPort.h"
+
+#include "core/CoreIncludes.h"
+
+#include "util/Convert.h"
+#include "util/Math.h"
+
+
+
+namespace orxonox
+{
+    CreateFactory(SpaceRaceManager);
+
+    SpaceRaceManager::SpaceRaceManager(BaseObject* creator) : BaseObject(creator)
+    {
+        RegisterObject(SpaceRaceManager);
+         
+        this->firstcheckpointvisible_=false;
+         
+    }
+
+    SpaceRaceManager::~SpaceRaceManager()
+    {
+        if (this->isInitialized())
+        {
+            for (size_t i = 0; i < this->checkpoints_.size(); ++i)
+                this->checkpoints_[i]->destroy();
+        }
+    }
+   
+    void SpaceRaceManager::addCheckpoint(RaceCheckPoint* checkpoint)
+    {
+        this->checkpoints_.push_back(checkpoint);
+    }
+
+    RaceCheckPoint* SpaceRaceManager::getCheckpoint(unsigned int index) const
+    {
+        if (index < this->checkpoints_.size())
+            return this->checkpoints_[index];
+        else
+            return 0;
+    }
+    
+    int SpaceRaceManager::getIndex(RaceCheckPoint* r) 
+    {
+        for (size_t i = 0; i < this->checkpoints_.size(); ++i)
+            if (this->checkpoints_[i]==r) {return i;}
+           
+        return -1;
+    }
+    
+    void SpaceRaceManager::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(SpaceRaceManager, XMLPort, xmlelement, mode);
+
+        
+        XMLPortObject(SpaceRaceManager, RaceCheckPoint, "checkpoints", addCheckpoint, getCheckpoint,  xmlelement, mode);
+    }
+    
+    void SpaceRaceManager::tick(float dt)
+    {
+        SUPER(SpaceRaceManager,tick,dt);
+     
+        if(this->checkpoints_[0] != NULL && !this->firstcheckpointvisible_)
+        {
+            this->checkpoints_[0]->setRadarVisibility(true);
+            this->firstcheckpointvisible_=true;
+        }
+         
+        for (size_t i = 0; i < this->checkpoints_.size(); ++i)
+        {
+            if(this->checkpoints_[i]->reached_!=NULL)
+                this->checkpointReached(this->checkpoints_[i],this->checkpoints_[i]->reached_);
+        }
+    }
+    
+    
+    void SpaceRaceManager::checkpointReached(RaceCheckPoint* check, PlayerInfo* player)
+    {
+        SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
+        assert(gametype);
+        
+        bool b =false;    
+            
+        int index=gametype->getCheckpointReached(player);
+        Vector3 v=Vector3 (-1,-1,-1);
+        if (index>-1)
+        {
+            RaceCheckPoint* tmp= this->getCheckpoint(index);
+            v= tmp->getNextcheckpoint();
+       
+            if (this->getCheckpoint(v.x) == check)
+            {
+                b = true;
+            }    
+       
+            if (this->getCheckpoint(v.y) == check)
+            {
+                b = true;
+            }    
+            if (this->getCheckpoint(v.z) == check)
+            {
+                b = true;
+            }    
+        }
+        else
+        {
+            b = (this->getIndex(check) == 0);
+        }
+            
+        if (gametype && b)
+        {
+            gametype->clock_.capture();
+            float time = gametype->clock_.getSecondsPrecise();
+            if (check->getTimeLimit()!=0 && time > check->getTimeLimit())
+            {
+                gametype->timeIsUp();
+                gametype->end();
+            }
+            else if (check->getLast())
+                gametype->end();
+            else
+				{
+                if (index > -1)this->setRadVis(player,false);
+                	else this->getCheckpoint(0)->setRadarVisibility(false);
+                gametype->newCheckpointReached(check,player);
+               
+                
+                this->setRadVis(player, true);
+            }
+        }
+        check->reached_=NULL;
+    }
+    
+    void SpaceRaceManager::setRadVis(PlayerInfo* player, bool b)
+    {
+        SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
+        assert(gametype);
+        int index = gametype->getCheckpointReached(player);
+        Vector3 v = Vector3(-1,-1,-1);
+        RaceCheckPoint* tmp = this->getCheckpoint(index);
+        v = tmp->getNextcheckpoint();
+    
+        if(v.x > -1)
+        {
+            this->getCheckpoint(v.x)->setRadarVisibility(b);
+            this->getCheckpoint(v.x)->settingsChanged();
+        }
+        if(v.y > -1)
+        {
+            this->getCheckpoint(v.y)->setRadarVisibility(b);
+            this->getCheckpoint(v.y)->settingsChanged();
+        }
+        if(v.z > -1)
+        {
+            this->getCheckpoint(v.z)->setRadarVisibility(b);
+           this->getCheckpoint(v.z)->settingsChanged();
+        }
+        
+        
+    }
+    
+}
Index: code/branches/presentation2011/src/modules/gametypes/SpaceRaceManager.h
===================================================================
--- code/branches/presentation2011/src/modules/gametypes/SpaceRaceManager.h	(revision 8998)
+++ code/branches/presentation2011/src/modules/gametypes/SpaceRaceManager.h	(revision 8998)
@@ -0,0 +1,79 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Mauro Salomon
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _SpaceRaceManager_H__
+#define _SpaceRaceManager_H__
+
+#include "gametypes/GametypesPrereqs.h"
+
+#include <set>
+#include <string>
+#include <vector>
+
+#include <util/Clock.h>
+
+#include "gametypes/Gametype.h"
+#include "tools/interfaces/Tickable.h"
+#include "RaceCheckPoint.h"
+
+
+
+namespace orxonox
+{
+  /**
+  @brief
+    The SpaceRaceManager class controls a space race level, where the player has to reach check points in a given order.
+  */
+    class _GametypesExport SpaceRaceManager : public BaseObject, public Tickable
+    {
+        friend class RaceCheckPoint;
+    
+        public:
+            SpaceRaceManager(BaseObject* creator);
+            virtual ~SpaceRaceManager() ;
+
+            void XMLPort(Element& xmlelement, XMLPort::Mode mode); 
+            int getIndex(RaceCheckPoint* r);
+            void addCheckpoint(RaceCheckPoint* checkpoint);
+            RaceCheckPoint* getCheckpoint(unsigned int index) const;
+        
+            void checkpointReached(RaceCheckPoint* check, PlayerInfo* player);
+        
+            void tick(float dt);
+    
+        protected:
+            void setRadVis(PlayerInfo* player, bool b);//sets RadarVisibility of the checkpoints the player can reach.
+    
+        private:
+            std::vector<RaceCheckPoint*> checkpoints_;
+            bool firstcheckpointvisible_;//true if the first check point is visible.
+        
+    };
+}
+
+#endif /* _SpaceRaceManager_H__ */
Index: code/branches/presentation2011/src/modules/objects/triggers/DistanceMultiTrigger.h
===================================================================
--- code/branches/presentation2011/src/modules/objects/triggers/DistanceMultiTrigger.h	(revision 8997)
+++ code/branches/presentation2011/src/modules/objects/triggers/DistanceMultiTrigger.h	(revision 8998)
@@ -91,5 +91,5 @@
     @ingroup MultiTrigger
     */
-    class _ObjectsExport DistanceMultiTrigger : public MultiTrigger
+    class _ObjectsExport DistanceMultiTrigger : public MultiTrigger 
     {
 
Index: code/branches/presentation2011/src/modules/objects/triggers/MultiTrigger.h
===================================================================
--- code/branches/presentation2011/src/modules/objects/triggers/MultiTrigger.h	(revision 8997)
+++ code/branches/presentation2011/src/modules/objects/triggers/MultiTrigger.h	(revision 8998)
@@ -157,5 +157,5 @@
             bool isTriggered(BaseObject* triggerer = NULL); //!< Get whether the MultiTrigger is triggered for a given object.
 
-            void fire(bool status, BaseObject* originator = NULL);  //!< Helper method. Creates an Event for the given status and originator and fires it.
+            virtual void fire(bool status, BaseObject* originator = NULL);  //!< Helper method. Creates an Event for the given status and originator and fires it.
             void broadcast(bool status); //!< Helper method. Broadcasts an Event for every object that is a target.
 
Index: code/branches/presentation2011/src/orxonox/gametypes/Gametype.cc
===================================================================
--- code/branches/presentation2011/src/orxonox/gametypes/Gametype.cc	(revision 8997)
+++ code/branches/presentation2011/src/orxonox/gametypes/Gametype.cc	(revision 8998)
@@ -85,5 +85,4 @@
         this->dedicatedKillBots_ = createConsoleCommand( "dedicatedKillBots", createExecutor( createFunctor(&Gametype::killBots, this) ) );
         /* HACK HACK HACK */
-        //this->numberOfPlayers_ = 0;
     }
 
@@ -124,5 +123,5 @@
         if (this->gtinfo_->isStartCountdownRunning() && !this->gtinfo_->hasStarted())
             this->gtinfo_->countdownStartCountdown(dt);
-
+			
         if (!this->gtinfo_->hasStarted())
         {
@@ -132,6 +131,7 @@
                 if(it->first->isHumanPlayer() && it->first->isReadyToSpawn())
                     this->gtinfo_->playerReadyToSpawn(it->first);
-            }
-
+                   
+                
+            }
             this->checkStart();
         }
@@ -144,4 +144,5 @@
     void Gametype::start()
     {
+         
         this->addBots(this->numberOfBots_);
 
@@ -149,4 +150,6 @@
 
         this->spawnPlayersIfRequested();
+        
+        
     }
 
@@ -377,5 +380,5 @@
                 {
                     this->gtinfo_->stopStartCountdown();
-                    this->gtinfo_->setStartCountdown(0.0f);;
+                    this->gtinfo_->setStartCountdown(0.0f);
                     this->start();
                 }
@@ -398,4 +401,5 @@
                             hashumanplayers = true;
                     }
+                         
                     if (allplayersready && hashumanplayers)
                     {
@@ -409,4 +413,5 @@
                 }
             }
+            
         }
     }
Index: code/branches/presentation2011/src/orxonox/gametypes/Gametype.h
===================================================================
--- code/branches/presentation2011/src/orxonox/gametypes/Gametype.h	(revision 8997)
+++ code/branches/presentation2011/src/orxonox/gametypes/Gametype.h	(revision 8998)
@@ -155,4 +155,6 @@
               { return this->gtinfo_->getNumberOfPlayers(); }
 
+	
+
         protected:
             virtual SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const;
Index: code/branches/presentation2011/src/orxonox/infos/GametypeInfo.cc
===================================================================
--- code/branches/presentation2011/src/orxonox/infos/GametypeInfo.cc	(revision 8997)
+++ code/branches/presentation2011/src/orxonox/infos/GametypeInfo.cc	(revision 8998)
@@ -71,7 +71,7 @@
         this->bStarted_ = false;
         this->bEnded_ = false;
-        this->startCountdown_ = 0.0f;
+        this->startCountdown_ = 10.0f;
         this->bStartCountdownRunning_ = false;
-        this->counter_ = 0;
+        this->counter_ = 10;
         this->spawned_ = false;
         this->readyToSpawn_ = false;
@@ -164,8 +164,10 @@
     {
         if(this->bStarted_)
-            return;
+           { return;}
         
         this->bStarted_ = true;
         this->changedStarted();
+        
+       
     }
 
Index: code/branches/presentation2011/src/orxonox/infos/PlayerInfo.cc
===================================================================
--- code/branches/presentation2011/src/orxonox/infos/PlayerInfo.cc	(revision 8997)
+++ code/branches/presentation2011/src/orxonox/infos/PlayerInfo.cc	(revision 8998)
@@ -58,4 +58,5 @@
 
         this->registerVariables();
+        
     }
 
