[Orxonox-commit 4263] r8934 - code/branches/spaceraceTwo/src/modules/gametypes

eceline at orxonox.net eceline at orxonox.net
Wed Nov 16 14:07:18 CET 2011


Author: eceline
Date: 2011-11-16 14:07:17 +0100 (Wed, 16 Nov 2011)
New Revision: 8934

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
Log:
spaceracemanager

Modified: code/branches/spaceraceTwo/src/modules/gametypes/RaceCheckPoint.cc
===================================================================
--- code/branches/spaceraceTwo/src/modules/gametypes/RaceCheckPoint.cc	2011-11-16 13:02:06 UTC (rev 8933)
+++ code/branches/spaceraceTwo/src/modules/gametypes/RaceCheckPoint.cc	2011-11-16 13:07:17 UTC (rev 8934)
@@ -35,7 +35,6 @@
 
 #include "SpaceRace.h"
 
-
 namespace orxonox
 {
     CreateFactory(RaceCheckPoint);
@@ -47,6 +46,7 @@
         this->bCheckpointIndex_ = 0;
         this->bIsLast_ = false;
         this->bTimeLimit_ = 0;
+        this->isVisible_=false;
 
         this->setRadarObjectColour(ColourValue::Blue);
         this->setRadarObjectShape(RadarViewable::Triangle);
@@ -69,7 +69,9 @@
 
         SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
         assert(gametype);
-        this->setRadarVisibility(false);
+        if(this->isVisible_){this->setRadarVisibility(true);}
+        else{this->setRadarVisibility(false);}
+        /*this->setRadarVisibility(false);
         Vector3 v =Vector3(0,0,0);
         int j=0;
         for (std::map<PlayerInfo*, Player>::iterator it = gametype->players_.begin(); it != gametype->players_.end(); ++it)
@@ -80,8 +82,8 @@
         	for(int i=1;i<4;i++){
         	if (this->getCheckpointIndex() == v[i])
            	 this->setRadarVisibility(true);
-           	 }
-        }     
+           	 }*/
+        //}     
     }
 
     void RaceCheckPoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
@@ -94,9 +96,7 @@
     XMLPortParamTemplate(RaceCheckPoint, "nextcheckpoints", setNextcheckpoint, getNextcheckpoint, xmlelement, mode,const Vector3&);
     }
 
-
-
-    void RaceCheckPoint::triggered(bool bIsTriggered, PlayerInfo* player)
+	void RaceCheckPoint::triggered(bool bIsTriggered, PlayerInfo* player)
     {
         DistanceTrigger::triggered(bIsTriggered);
 

Modified: code/branches/spaceraceTwo/src/modules/gametypes/RaceCheckPoint.h
===================================================================
--- code/branches/spaceraceTwo/src/modules/gametypes/RaceCheckPoint.h	2011-11-16 13:02:06 UTC (rev 8933)
+++ code/branches/spaceraceTwo/src/modules/gametypes/RaceCheckPoint.h	2011-11-16 13:07:17 UTC (rev 8934)
@@ -60,6 +60,9 @@
                 { this->setNextcheckpoint(Vector3(x, y, z)); }
            inline const Vector3& getNextcheckpoint() const
 		{return this->nextcheckpoints_;}
+
+	inline void setVisibility(bool b)
+		{this->isVisible_ = b;}
         protected:
             virtual void triggered(bool bIsTriggered, PlayerInfo* player);
             inline void setLast(bool isLast)
@@ -83,6 +86,8 @@
 
 	
 	Vector3 nextcheckpoints_; //the indexes of the next check points
+
+	bool isVisible_;
       
     };
 }

Modified: code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.cc
===================================================================
--- code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.cc	2011-11-16 13:02:06 UTC (rev 8933)
+++ code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.cc	2011-11-16 13:07:17 UTC (rev 8934)
@@ -44,7 +44,7 @@
     SpaceRace::SpaceRace(BaseObject* creator) : Gametype(creator)
     {
         RegisterObject(SpaceRace);
-        //this->checkpointsReached_ = 0;
+        this->checkpointReached_ = 0;
         this->bTimeIsUp_ = false;
         this->numberOfBots_ = 0;
         this->cantMove_=false;
@@ -138,13 +138,13 @@
 	
 	
 
-    void SpaceRace::newCheckpointReached(RaceCheckPoint* p)
+    void SpaceRace::newCheckpointReached(SpaceRaceManager* p, int index)
     {
-        this->checkpointReached_=p->getCheckpointIndex();
+        this->checkpointReached_=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>(p)
+        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);
@@ -153,6 +153,21 @@
        
     }
     
+     void SpaceRace::newCheckpointReached(RaceCheckPoint* p)
+    {	int index = p->getCheckpointIndex();
+        this->checkpointReached_=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.";
+        const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
+        ChatManager::message(message);
+        
+       
+    }
+    
      int SpaceRace::getCheckpointReached(PlayerInfo* player){
     	return this->currentCheckpoint_[player];
 }

Modified: code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.h
===================================================================
--- code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.h	2011-11-16 13:02:06 UTC (rev 8933)
+++ code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.h	2011-11-16 13:07:17 UTC (rev 8934)
@@ -39,8 +39,10 @@
 
 #include "gametypes/Gametype.h"
 
-#include "RaceCheckPoint.h"
 
+
+#include "SpaceRaceManager.h"
+
 namespace orxonox
 {
   /**
@@ -50,6 +52,7 @@
     class _GametypesExport SpaceRace : public Gametype
     {
         friend class RaceCheckPoint;
+	friend class SpaceRaceManager;
 
         public:
             SpaceRace(BaseObject* creator);
@@ -58,7 +61,8 @@
             virtual void start();
             virtual void end();
 		
-            virtual void newCheckpointReached(RaceCheckPoint* p);
+            virtual void newCheckpointReached(SpaceRaceManager* p, int index);
+		virtual void newCheckpointReached(RaceCheckPoint* p);
 
             inline void setCheckpointReached(int n)
                 { this->checkpointReached_ = n;}

Modified: code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.cc
===================================================================
--- code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.cc	2011-11-16 13:02:06 UTC (rev 8933)
+++ code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.cc	2011-11-16 13:07:17 UTC (rev 8934)
@@ -27,8 +27,8 @@
  */
 
 #include "SpaceRaceManager.h"
+#include "SpaceRace.h"
 
-
 #include "core/XMLPort.h"
 
 #include "core/CoreIncludes.h"
@@ -79,14 +79,21 @@
     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);
+           	 }
+    	}
      
-    
-    
-    
-   
-    
     }
+}
 
 




More information about the Orxonox-commit mailing list