Changeset 2971
- Timestamp:
- May 11, 2009, 5:31:21 PM (16 years ago)
- Location:
- code/branches/gametypes/src/orxonox/objects/gametypes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/gametypes/src/orxonox/objects/gametypes/UnderAttack.cc
r2952 r2971 34 34 #include "objects/Teamcolourable.h" 35 35 #include "objects/worldentities/TeamSpawnPoint.h" 36 #include "util/Convert.h" 36 37 37 38 #include "network/Host.h" … … 43 44 { 44 45 RegisterObject(UnderAttack); 45 this->gameTime_ = 30;46 this->gameTime_ = 90; 46 47 this->teams_ = 2; 47 48 this->destroyer_ = 0; … … 49 50 50 51 this->setConfigValues(); 52 this->timesequence_ = (int) this->gameTime_; 51 53 } 52 54 … … 70 72 COUT(0) << message << std::endl; 71 73 Host::Broadcast(message); 74 this->gameEnded_ = true; 72 75 } 73 76 } … … 126 129 return TeamDeathmatch::allowPawnDeath(victim, originator); 127 130 } 131 132 128 133 void UnderAttack::tick(float dt) 129 134 { 130 135 SUPER(UnderAttack, tick, dt); 131 136 132 if (this->hasStarted() )137 if (this->hasStarted() && !gameEnded_) 133 138 { 134 139 gameTime_ = gameTime_ - dt; 135 if (gameTime_<= 0 && !gameEnded_)140 if (gameTime_<= 0) 136 141 { 137 gameEnded_ = true;142 this->gameEnded_ = true; 138 143 this->end(); 139 144 std::string message = "Time is up! Team 1 has won!"; … … 141 146 Host::Broadcast(message); 142 147 } 148 149 //prints gametime 150 if ( gameTime_ <= timesequence_) 151 { 152 std::string message = convertToString(timesequence_) + " sec left!"; 153 COUT(0) << message << std::endl; 154 Host::Broadcast(message); 155 if (timesequence_ >= 30 && timesequence_ <= 60) 156 { 157 timesequence_ = timesequence_ - 10; 158 } 159 else if (timesequence_ <= 30) 160 { 161 timesequence_ = timesequence_ - 5; 162 } 163 else 164 { 165 timesequence_ = timesequence_ - 30; 166 } 167 } 143 168 } 144 169 } -
code/branches/gametypes/src/orxonox/objects/gametypes/UnderAttack.h
r2952 r2971 46 46 47 47 void setConfigValues(); 48 49 48 void tick (float dt); 50 49 void addDestroyer(Destroyer* destroyer); … … 62 61 unsigned int teams_; 63 62 float gameTime_; 63 int timesequence_; 64 64 bool gameEnded_; 65 65 };
Note: See TracChangeset
for help on using the changeset viewer.