[Orxonox-commit 4269] r8940 - code/branches/spaceraceTwo/src/modules/gametypes

eceline at orxonox.net eceline at orxonox.net
Wed Nov 16 16:20:26 CET 2011


Author: eceline
Date: 2011-11-16 16:20:26 +0100 (Wed, 16 Nov 2011)
New Revision: 8940

Modified:
   code/branches/spaceraceTwo/src/modules/gametypes/RaceCheckPoint.cc
   code/branches/spaceraceTwo/src/modules/gametypes/RaceCheckPoint.h
   code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.cc
   code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.h
   code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.cc
   code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.h
Log:
level Spacerace2

Modified: code/branches/spaceraceTwo/src/modules/gametypes/RaceCheckPoint.cc
===================================================================
--- code/branches/spaceraceTwo/src/modules/gametypes/RaceCheckPoint.cc	2011-11-16 15:08:23 UTC (rev 8939)
+++ code/branches/spaceraceTwo/src/modules/gametypes/RaceCheckPoint.cc	2011-11-16 15:20:26 UTC (rev 8940)
@@ -44,7 +44,7 @@
         RegisterObject(RaceCheckPoint);
 
         this->bCheckpointIndex_ = 0;
-        this->bIsLast_ = false;
+        //this->bIsLast_ = false;
         this->bTimeLimit_ = 0;
         this->isVisible_=false;
 
@@ -89,11 +89,11 @@
     void RaceCheckPoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     {
         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&);
+    XMLPortParamTemplate(RaceCheckPoint, "nextcheckpoints", setNextcheckpoint, getNextcheckpoint, xmlelement, mode,const Vector3&).defaultValues(v);
     }
 
 	void RaceCheckPoint::triggered(bool bIsTriggered, PlayerInfo* player)
@@ -101,6 +101,7 @@
         DistanceTrigger::triggered(bIsTriggered);
 
         SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
+        assert(gametype);
         if (gametype && this->getCheckpointIndex() == gametype->getCheckpointReached(player) && bIsTriggered)
         {
             gametype->clock_.capture();
@@ -114,7 +115,7 @@
                 gametype->end();
             else
             {
-                gametype->newCheckpointReached(this);
+                gametype->newCheckpointReached(this,player);
                 this->setRadarObjectColour(ColourValue::Green); //sets the radar colour of the checkpoint to green if it is reached, else it is red.
             }
         }
@@ -126,6 +127,7 @@
         if (this->bTimeLimit_ != 0)
         {
             SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
+            assert(gametype);
             if (gametype)
             {
                 const std::string& message =  "You have " + multi_cast<std::string>(this->bTimeLimit_)

Modified: code/branches/spaceraceTwo/src/modules/gametypes/RaceCheckPoint.h
===================================================================
--- code/branches/spaceraceTwo/src/modules/gametypes/RaceCheckPoint.h	2011-11-16 15:08:23 UTC (rev 8939)
+++ code/branches/spaceraceTwo/src/modules/gametypes/RaceCheckPoint.h	2011-11-16 15:20:26 UTC (rev 8940)
@@ -61,7 +61,7 @@
            inline const Vector3& getNextcheckpoint() const
 		{return this->nextcheckpoints_;}
 
-	inline void setVisibility(bool b)
+	inline void setV(bool b)
 		{this->isVisible_ = b;}
         protected:
             virtual void triggered(bool bIsTriggered, PlayerInfo* player);

Modified: code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.cc
===================================================================
--- code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.cc	2011-11-16 15:08:23 UTC (rev 8939)
+++ code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.cc	2011-11-16 15:20:26 UTC (rev 8940)
@@ -44,12 +44,13 @@
     SpaceRace::SpaceRace(BaseObject* creator) : Gametype(creator)
     {
         RegisterObject(SpaceRace);
-        this->checkpointReached_ = 0;
+        
         this->bTimeIsUp_ = false;
         this->numberOfBots_ = 0;
         this->cantMove_=false;
         
-       
+       for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
+        {this->checkpointReached_[it->first]=0;}
     }
     
   // void SpaceRace::SetConfigValues(){
@@ -135,12 +136,24 @@
     
     }
 
-	
-	
+	void SpaceRace::setV(SpaceRaceManager* m){
+		Vector3 v =Vector3(0,0,0);
+        int j=0;
+        for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
+        {
+        	j=this->getCheckpointReached(it->first);
+        	RaceCheckPoint* r=m->getCheckpoint(j);
+        	v=r->getNextcheckpoint();
+        	for(int i=1;i<4;i++){
+        	 RaceCheckPoint* n=m->getCheckpoint(i);
+           	 n->setV(true);
+           	 }
+	}
+	}
 
-    void SpaceRace::newCheckpointReached(SpaceRaceManager* p, int index)
+    void SpaceRace::newCheckpointReached(SpaceRaceManager* p, int index,PlayerInfo* pl)
     {
-        this->checkpointReached_=index;
+        this->checkpointReached_[pl]=index;
         this->clock_.capture();
         int s = this->clock_.getSeconds();
         int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s);
@@ -153,9 +166,9 @@
        
     }
     
-     void SpaceRace::newCheckpointReached(RaceCheckPoint* p)
+     void SpaceRace::newCheckpointReached(RaceCheckPoint* p, PlayerInfo* pl)
     {	int index = p->getCheckpointIndex();
-        this->checkpointReached_=index;
+        this->checkpointReached_[pl]=index;
         this->clock_.capture();
         int s = this->clock_.getSeconds();
         int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s);
@@ -168,12 +181,10 @@
        
     }
     
-     int SpaceRace::getCheckpointReached(PlayerInfo* player){
-    	return this->currentCheckpoint_[player];
-}
+    
 
 void SpaceRace::playerEntered(PlayerInfo* player){
-    	this->currentCheckpoint_[player]=1;
+    	this->checkpointReached_[player]=0;
     	this->playersAlive_++;
     }
     

Modified: code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.h
===================================================================
--- code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.h	2011-11-16 15:08:23 UTC (rev 8939)
+++ code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.h	2011-11-16 15:20:26 UTC (rev 8940)
@@ -52,7 +52,7 @@
     class _GametypesExport SpaceRace : public Gametype
     {
         friend class RaceCheckPoint;
-	friend class SpaceRaceManager;
+	//friend class SpaceRaceManager;
 
         public:
             SpaceRace(BaseObject* creator);
@@ -61,33 +61,32 @@
             virtual void start();
             virtual void end();
 		
-            virtual void newCheckpointReached(SpaceRaceManager* p, int index);
-		virtual void newCheckpointReached(RaceCheckPoint* p);
+            virtual void newCheckpointReached(SpaceRaceManager* p, int index,PlayerInfo* pl);
+		virtual void newCheckpointReached(RaceCheckPoint* p, PlayerInfo* pl);
 
-            inline void setCheckpointReached(int n)
-                { this->checkpointReached_ = n;}
-            inline int getCheckpointReached()
-                { return this->checkpointReached_; }
+            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);
 
-	int getCheckpointReached(PlayerInfo* player);
 
-	 
+	 void setV(SpaceRaceManager* m);
         protected:
 		virtual void playerEntered(PlayerInfo* player); //!< Initializes values.
 		 virtual bool playerLeft(PlayerInfo* player); //!< Manages all local variables.
         private:
 	float maxSpeedBack_; float maxSpeedFront_; float maxSpeedLeftRight_; float maxSpeedUpDown_; 
 	bool cantMove_;
-            int checkpointReached_; //The number of the last check point reached by each player.
+            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.
 
-		std::map<PlayerInfo*, int> currentCheckpoint_;
+		
 		int playersAlive_;
 
 	

Modified: code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.cc
===================================================================
--- code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.cc	2011-11-16 15:08:23 UTC (rev 8939)
+++ code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.cc	2011-11-16 15:20:26 UTC (rev 8940)
@@ -28,6 +28,7 @@
 
 #include "SpaceRaceManager.h"
 #include "SpaceRace.h"
+#include "infos/PlayerInfo.h"
 
 #include "core/XMLPort.h"
 
@@ -38,7 +39,7 @@
 
 namespace orxonox
 {
-    CreateUnloadableFactory(SpaceRaceManager);
+    CreateFactory(SpaceRaceManager);
 
     SpaceRaceManager::SpaceRaceManager(BaseObject* creator) : BaseObject(creator)
     {
@@ -73,25 +74,16 @@
         SUPER(SpaceRaceManager, XMLPort, xmlelement, mode);
 
         //XMLPortParam(WaypointController, "accuracy", setAccuracy, getAccuracy, xmlelement, mode).defaultValues(100.0f);
-        //XMLPortObject(WaypointController, WorldEntity, "waypoints", addWaypoint, getWaypoint,  xmlelement, mode);
+        XMLPortObject(SpaceRaceManager, RaceCheckPoint, "checkpoints", addCheckpoint, getCheckpoint,  xmlelement, mode);
     }
     
     void SpaceRaceManager::tick(float dt)
     {
     SUPER(SpaceRaceManager,tick,dt);
      SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
-           Vector3 v =Vector3(0,0,0);
-        int j=0;
-        for (std::map<PlayerInfo*, Player>::iterator it = gametype->players_.begin(); it != gametype->players_.end(); ++it)
-        {
-        	j=gametype->getCheckpointReached(it->first);
-        	RaceCheckPoint* r=this->getCheckpoint(j);
-        	v=r->getNextcheckpoint();
-        	for(int i=1;i<4;i++){
-        	 RaceCheckPoint* n=this->getCheckpoint(i);
-           	 n->setVisibility(true);
-           	 }
-    	}
+     gametype->setV(this);
+         
+    	
      
     }
 }

Modified: code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.h
===================================================================
--- code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.h	2011-11-16 15:08:23 UTC (rev 8939)
+++ code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.h	2011-11-16 15:20:26 UTC (rev 8940)
@@ -33,7 +33,7 @@
 
 #include <set>
 #include <string>
-# include <vector>
+#include <vector>
 
 #include <util/Clock.h>
 




More information about the Orxonox-commit mailing list