[Orxonox-commit 368] r2971 - branches/gametypes/src/orxonox/objects/gametypes

mockm at orxonox.net mockm at orxonox.net
Mon May 11 17:31:21 CEST 2009


Author: mockm
Date: 2009-05-11 17:31:21 +0200 (Mon, 11 May 2009)
New Revision: 2971

Modified:
   branches/gametypes/src/orxonox/objects/gametypes/UnderAttack.cc
   branches/gametypes/src/orxonox/objects/gametypes/UnderAttack.h
Log:
new revision of Gametype UnderAttack: Timerfunction and some color added

Modified: branches/gametypes/src/orxonox/objects/gametypes/UnderAttack.cc
===================================================================
--- branches/gametypes/src/orxonox/objects/gametypes/UnderAttack.cc	2009-05-11 15:00:55 UTC (rev 2970)
+++ branches/gametypes/src/orxonox/objects/gametypes/UnderAttack.cc	2009-05-11 15:31:21 UTC (rev 2971)
@@ -33,6 +33,7 @@
 #include "core/ConfigValueIncludes.h"
 #include "objects/Teamcolourable.h"
 #include "objects/worldentities/TeamSpawnPoint.h"
+#include "util/Convert.h"
 
 #include "network/Host.h"
 namespace orxonox
@@ -42,12 +43,13 @@
     UnderAttack::UnderAttack(BaseObject* creator) : TeamDeathmatch(creator)
     {
         RegisterObject(UnderAttack);
-        this->gameTime_ = 30;
+        this->gameTime_ = 90;
         this->teams_ = 2;
         this->destroyer_ = 0;
         this->gameEnded_ = false;
 
         this->setConfigValues();
+        this->timesequence_ = (int) this->gameTime_;
     }
 
     void UnderAttack::setConfigValues()
@@ -69,6 +71,7 @@
             std::string message = "Ship destroyed! Team 0 has won!";
             COUT(0) << message << std::endl;
             Host::Broadcast(message);
+            this->gameEnded_ = true;
         }
     }
 
@@ -125,21 +128,43 @@
 
         return TeamDeathmatch::allowPawnDeath(victim, originator);
     }
+
+
     void UnderAttack::tick(float dt)
     {
         SUPER(UnderAttack, tick, dt);
 
-        if (this->hasStarted())
+        if (this->hasStarted() && !gameEnded_)
         {
             gameTime_ = gameTime_ - dt;
-            if (gameTime_<= 0 && !gameEnded_)
+            if (gameTime_<= 0)
             {
-                gameEnded_ = true;
+                this->gameEnded_ = true;
                 this->end();
                 std::string message = "Time is up! Team 1 has won!";
                 COUT(0) << message << std::endl;
                 Host::Broadcast(message);
             }
+
+             //prints gametime
+            if ( gameTime_ <= timesequence_)
+            {
+                std::string message = convertToString(timesequence_) + " sec left!";
+                COUT(0) << message << std::endl;
+                Host::Broadcast(message);
+                if (timesequence_ >= 30 && timesequence_ <= 60)
+                {
+                    timesequence_ = timesequence_ - 10;
+                }
+                else if (timesequence_ <= 30)
+                {
+                    timesequence_ = timesequence_ - 5;
+                }
+                else
+                {
+                    timesequence_ = timesequence_ - 30;
+                }
+            }
         }
     }
 

Modified: branches/gametypes/src/orxonox/objects/gametypes/UnderAttack.h
===================================================================
--- branches/gametypes/src/orxonox/objects/gametypes/UnderAttack.h	2009-05-11 15:00:55 UTC (rev 2970)
+++ branches/gametypes/src/orxonox/objects/gametypes/UnderAttack.h	2009-05-11 15:31:21 UTC (rev 2971)
@@ -45,7 +45,6 @@
             virtual ~UnderAttack() {}
 
             void setConfigValues();
-
             void tick (float dt);
             void addDestroyer(Destroyer* destroyer);
             inline Destroyer* getDestroyer() const
@@ -61,6 +60,7 @@
             Destroyer* destroyer_;
             unsigned int teams_;
             float gameTime_;
+            int timesequence_;
             bool gameEnded_;
     };
 }




More information about the Orxonox-commit mailing list