Changeset 2952 for code/branches
- Timestamp:
- May 4, 2009, 4:34:48 PM (16 years ago)
- Location:
- code/branches/gametypes/src/orxonox/objects
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/gametypes/src/orxonox/objects/gametypes/Gametype.cc
r2826 r2952 93 93 if (!this->gtinfo_.bStarted_) 94 94 this->checkStart(); 95 else 95 else if (!this->gtinfo_.bEnded_) 96 96 this->spawnDeadPlayersIfRequested(); 97 97 … … 111 111 { 112 112 this->gtinfo_.bEnded_ = true; 113 114 for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) 115 { 116 if (it->first->getControllableEntity()) 117 { 118 ControllableEntity* oldentity = it->first->getControllableEntity(); 119 120 ControllableEntity* entity = this->defaultControllableEntity_.fabricate(oldentity->getCreator()); 121 if (oldentity->getCamera()) 122 { 123 entity->setPosition(oldentity->getCamera()->getWorldPosition()); 124 entity->setOrientation(oldentity->getCamera()->getWorldOrientation()); 125 } 126 else 127 { 128 entity->setPosition(oldentity->getWorldPosition()); 129 entity->setOrientation(oldentity->getWorldOrientation()); 130 } 131 132 it->first->stopControl(oldentity, true); 133 it->first->startControl(entity); 134 } 135 else 136 this->spawnPlayerAsDefaultPawn(it->first); 137 } 113 138 } 114 139 … … 254 279 if (!it->first->isReadyToSpawn() || !this->gtinfo_.bStarted_) 255 280 { 256 SpawnPoint* spawn = this->getBestSpawnPoint(it->first); 257 if (spawn) 258 { 259 // force spawn at spawnpoint with default pawn 260 ControllableEntity* entity = this->defaultControllableEntity_.fabricate(spawn); 261 spawn->spawn(entity); 262 it->first->startControl(entity); 263 it->second.state_ = PlayerState::Dead; 264 } 265 else 266 { 267 COUT(1) << "Error: No SpawnPoints in current Gametype" << std::endl; 268 abort(); 269 } 281 this->spawnPlayerAsDefaultPawn(it->first); 282 it->second.state_ = PlayerState::Dead; 270 283 } 271 284 } … … 345 358 } 346 359 360 void Gametype::spawnPlayerAsDefaultPawn(PlayerInfo* player) 361 { 362 SpawnPoint* spawn = this->getBestSpawnPoint(player); 363 if (spawn) 364 { 365 // force spawn at spawnpoint with default pawn 366 ControllableEntity* entity = this->defaultControllableEntity_.fabricate(spawn); 367 spawn->spawn(entity); 368 player->startControl(entity); 369 } 370 else 371 { 372 COUT(1) << "Error: No SpawnPoints in current Gametype" << std::endl; 373 abort(); 374 } 375 } 376 347 377 void Gametype::addBots(unsigned int amount) 348 378 { -
code/branches/gametypes/src/orxonox/objects/gametypes/Gametype.h
r2826 r2952 132 132 virtual void checkStart(); 133 133 virtual void spawnPlayer(PlayerInfo* player); 134 virtual void spawnPlayerAsDefaultPawn(PlayerInfo* player); 134 135 virtual void spawnPlayersIfRequested(); 135 136 virtual void spawnDeadPlayersIfRequested(); -
code/branches/gametypes/src/orxonox/objects/gametypes/UnderAttack.cc
r2935 r2952 35 35 #include "objects/worldentities/TeamSpawnPoint.h" 36 36 37 #include "network/Host.h" 37 38 namespace orxonox 38 39 { … … 50 51 } 51 52 53 void UnderAttack::setConfigValues() 54 { 55 SetConfigValue(gameTime_, 30); 56 } 57 52 58 void UnderAttack::addDestroyer(Destroyer* destroyer) 53 59 { … … 60 66 if (pawn == this->destroyer_) 61 67 { 62 63 COUT(0) << "Ship destroyed! Team 0 has won!" << std::endl; 64 // Todo: end game 68 this->end(); //end gametype 69 std::string message = "Ship destroyed! Team 0 has won!"; 70 COUT(0) << message << std::endl; 71 Host::Broadcast(message); 65 72 } 66 73 } … … 129 136 { 130 137 gameEnded_ = true; 131 COUT(0) << "Time is up! Team 1 has won!" << std::endl; 138 this->end(); 139 std::string message = "Time is up! Team 1 has won!"; 140 COUT(0) << message << std::endl; 141 Host::Broadcast(message); 132 142 } 133 143 } -
code/branches/gametypes/src/orxonox/objects/gametypes/UnderAttack.h
r2933 r2952 44 44 UnderAttack(BaseObject* creator); 45 45 virtual ~UnderAttack() {} 46 47 void setConfigValues(); 48 46 49 void tick (float dt); 47 50 void addDestroyer(Destroyer* destroyer); -
code/branches/gametypes/src/orxonox/objects/worldentities/SpawnPoint.cc
r2662 r2952 95 95 void SpawnPoint::spawn(ControllableEntity* entity) 96 96 { 97 entity->setPosition(this->get Position());98 entity->setOrientation(this->get Orientation());97 entity->setPosition(this->getWorldPosition()); 98 entity->setOrientation(this->getWorldOrientation()); 99 99 } 100 100 }
Note: See TracChangeset
for help on using the changeset viewer.