[Orxonox-commit 4227] r8898 - in code/branches/spaceraceTwo/src: modules/gametypes orxonox/gametypes orxonox/infos

eceline at orxonox.net eceline at orxonox.net
Wed Oct 19 16:21:48 CEST 2011


Author: eceline
Date: 2011-10-19 16:21:48 +0200 (Wed, 19 Oct 2011)
New Revision: 8898

Modified:
   code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.cc
   code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.h
   code/branches/spaceraceTwo/src/orxonox/gametypes/Gametype.cc
   code/branches/spaceraceTwo/src/orxonox/gametypes/Gametype.h
   code/branches/spaceraceTwo/src/orxonox/infos/GametypeInfo.cc
Log:
Space Race mit countdown

Modified: code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.cc
===================================================================
--- code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.cc	2011-10-19 14:18:16 UTC (rev 8897)
+++ code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.cc	2011-10-19 14:21:48 UTC (rev 8898)
@@ -33,6 +33,8 @@
 #include "util/Convert.h"
 #include "util/Math.h"
 
+#include "items/Engine.h"
+
 namespace orxonox
 {
     CreateUnloadableFactory(SpaceRace);
@@ -43,7 +45,12 @@
         this->checkpointsReached_ = 0;
         this->bTimeIsUp_ = false;
         this->numberOfBots_ = 0;
+        
     }
+    
+  // void SpaceRace::SetConfigValues(){
+    //SUPER(Gametype,setConfigValues);
+    //this->Gametype::SetConfigValue(initialStartCountdown_, 3.0f);}
 
     void SpaceRace::end()
     {
@@ -80,14 +87,57 @@
     }
 
     void SpaceRace::start()
-    {
-        Gametype::start();
-
+    {	int i=0;
+        for(ObjectList<Engine>::iterator it = ObjectList<Engine>::begin(); it; ++it)
+        {this->maxSpeedBack_[i]=it->getMaxSpeedBack();
+        this->maxSpeedFront_[i]=it->getMaxSpeedFront();
+        this->maxSpeedLeftRight_[i]=it->getMaxSpeedLeftRight();
+        this->maxSpeedUpDown_[i]=(it->getMaxSpeedUpDown());
+        
+        it->setMaxSpeedBack(0);
+        it->setMaxSpeedFront(0);
+        it->setMaxSpeedLeftRight(0);
+        it->setMaxSpeedUpDown(0);
+        
+        i++;
+        }
+        //Gametype::start();
+        this->addBots(this->numberOfBots_);
+   this->spawnPlayersIfRequested();
+   
+   	
+       Gametype::checkStart();
+	
+	i=0;
+     for(ObjectList<Engine>::iterator it = ObjectList<Engine>::begin(); it; ++it)
+        {
+        it->setMaxSpeedBack(this->maxSpeedBack_[i]);
+         it->setMaxSpeedFront(this->maxSpeedFront_[i]);
+         it->setMaxSpeedLeftRight(this->maxSpeedLeftRight_[i]);
+         it->setMaxSpeedUpDown(this->maxSpeedUpDown_[i]);
+         i++;
+         
+      
+        }
+		delete &this->maxSpeedBack_;
+		delete &this->maxSpeedFront_;
+		delete &this->maxSpeedLeftRight_;
+		delete &this->maxSpeedUpDown_;
         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::tick(float dt)
+	{SUPER(SpaceRace,tick,dt);
+	
+	
+		//if(const_cast<GametypeInfo*>(this->getGametypeInfo())->isStartCountdownRunning()){
+		//const_cast<GametypeInfo*>(this->getGametypeInfo())->start();}
+	}
+	
+
     void SpaceRace::newCheckpointReached()
     {
         this->checkpointsReached_++;

Modified: code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.h
===================================================================
--- code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.h	2011-10-19 14:18:16 UTC (rev 8897)
+++ code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.h	2011-10-19 14:21:48 UTC (rev 8898)
@@ -33,6 +33,7 @@
 
 #include <set>
 #include <string>
+#include <vector>
 
 #include <util/Clock.h>
 
@@ -56,7 +57,7 @@
 
             virtual void start();
             virtual void end();
-
+		
             virtual void newCheckpointReached();
 
             inline void setCheckpointsReached(int n)
@@ -65,10 +66,11 @@
                 { return this->checkpointsReached_; }
             inline void timeIsUp()
                 { this->bTimeIsUp_ = true;}
-
+	void tick(float dt);
         protected:
 
         private:
+	std::vector<float> maxSpeedBack_; std::vector<float> maxSpeedFront_; std::vector<float> maxSpeedLeftRight_; std::vector<float> maxSpeedUpDown_;
             int checkpointsReached_; //The current number of check points reached by the 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.

Modified: code/branches/spaceraceTwo/src/orxonox/gametypes/Gametype.cc
===================================================================
--- code/branches/spaceraceTwo/src/orxonox/gametypes/Gametype.cc	2011-10-19 14:18:16 UTC (rev 8897)
+++ code/branches/spaceraceTwo/src/orxonox/gametypes/Gametype.cc	2011-10-19 14:21:48 UTC (rev 8898)
@@ -122,22 +122,24 @@
 
         if (this->gtinfo_->isStartCountdownRunning() && !this->gtinfo_->hasStarted())
             this->gtinfo_->countdownStartCountdown(dt);
-
+			
         if (!this->gtinfo_->hasStarted())
         {
             for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
             {
                 // Inform the GametypeInfo that the player is ready to spawn.
-                if(it->first->isHumanPlayer() && it->first->isReadyToSpawn())
+                if(it->first->isHumanPlayer() && it->first->isReadyToSpawn()){
                     this->gtinfo_->playerReadyToSpawn(it->first);
+                   
+                }
             }
-                    
-            this->checkStart();
+                 
+           	this->checkStart();
         }
         else if (!this->gtinfo_->hasEnded())
-            this->spawnDeadPlayersIfRequested();
+           { this->spawnDeadPlayersIfRequested();
 
-        this->assignDefaultPawnsIfNeeded();
+        this->assignDefaultPawnsIfNeeded();}
     }
 
     void Gametype::start()

Modified: code/branches/spaceraceTwo/src/orxonox/gametypes/Gametype.h
===================================================================
--- code/branches/spaceraceTwo/src/orxonox/gametypes/Gametype.h	2011-10-19 14:18:16 UTC (rev 8897)
+++ code/branches/spaceraceTwo/src/orxonox/gametypes/Gametype.h	2011-10-19 14:21:48 UTC (rev 8898)
@@ -155,6 +155,8 @@
             virtual void resetTimer();
             virtual void resetTimer(float t);
 
+	
+
         protected:
             virtual SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const;
 

Modified: code/branches/spaceraceTwo/src/orxonox/infos/GametypeInfo.cc
===================================================================
--- code/branches/spaceraceTwo/src/orxonox/infos/GametypeInfo.cc	2011-10-19 14:18:16 UTC (rev 8897)
+++ code/branches/spaceraceTwo/src/orxonox/infos/GametypeInfo.cc	2011-10-19 14:21:48 UTC (rev 8898)
@@ -70,9 +70,9 @@
         
         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;
 




More information about the Orxonox-commit mailing list