Changeset 2462 for code/branches/objecthierarchy2/src/orxonox/objects
- Timestamp:
- Dec 15, 2008, 1:38:02 AM (16 years ago)
- Location:
- code/branches/objecthierarchy2/src/orxonox/objects
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy2/src/orxonox/objects/controllers/HumanController.cc
r2254 r2462 33 33 #include "core/ConsoleCommand.h" 34 34 #include "objects/worldentities/ControllableEntity.h" 35 #include "objects/worldentities/pawns/Pawn.h" 36 #include "objects/gametypes/Gametype.h" 35 37 36 38 namespace orxonox … … 48 50 SetConsoleCommand(HumanController, use, true); 49 51 SetConsoleCommand(HumanController, switchCamera, true); 52 SetConsoleCommand(HumanController, suicide, true); 53 SetConsoleCommand(HumanController, addBots, true).defaultValues(1); 54 SetConsoleCommand(HumanController, killBots, true).defaultValues(0); 50 55 51 56 CreateUnloadableFactory(HumanController); … … 136 141 HumanController::localController_s->controllableEntity_->switchCamera(); 137 142 } 143 144 void HumanController::suicide() 145 { 146 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 147 { 148 Pawn* pawn = dynamic_cast<Pawn*>(HumanController::localController_s->controllableEntity_); 149 if (pawn) 150 pawn->kill(); 151 } 152 } 153 154 void HumanController::addBots(unsigned int amount) 155 { 156 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && HumanController::localController_s->controllableEntity_->getGametype()) 157 HumanController::localController_s->controllableEntity_->getGametype()->addBots(amount); 158 } 159 160 void HumanController::killBots(unsigned int amount) 161 { 162 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && HumanController::localController_s->controllableEntity_->getGametype()) 163 HumanController::localController_s->controllableEntity_->getGametype()->killBots(amount); 164 } 138 165 } -
code/branches/objecthierarchy2/src/orxonox/objects/controllers/HumanController.h
r2254 r2462 59 59 static void switchCamera(); 60 60 61 static void suicide(); 62 63 static void addBots(unsigned int amount); 64 static void killBots(unsigned int amount = 0); 65 61 66 private: 62 67 static HumanController* localController_s; -
code/branches/objecthierarchy2/src/orxonox/objects/gametypes/Gametype.cc
r2447 r2462 36 36 #include "core/ConfigValueIncludes.h" 37 37 #include "objects/infos/PlayerInfo.h" 38 #include "objects/infos/Bot.h" 38 39 #include "objects/worldentities/pawns/Spectator.h" 39 40 #include "objects/worldentities/SpawnPoint.h" … … 50 51 RegisterObject(Gametype); 51 52 53 this->setGametype(this); 54 52 55 this->defaultControllableEntity_ = Class(Spectator); 53 56 54 57 this->bAutoStart_ = false; 55 58 this->bForceSpawn_ = false; 59 this->numberOfBots_ = 0; 56 60 57 61 this->initialStartCountdown_ = 3; 58 62 59 63 this->setConfigValues(); 64 65 this->addBots(this->numberOfBots_); 60 66 } 61 67 … … 65 71 SetConfigValue(bAutoStart_, false); 66 72 SetConfigValue(bForceSpawn_, false); 73 SetConfigValue(numberOfBots_, 0); 67 74 } 68 75 … … 293 300 } 294 301 } 302 303 void Gametype::addBots(unsigned int amount) 304 { 305 for (unsigned int i = 0; i < amount; ++i) 306 new Bot(this); 307 } 308 309 void Gametype::killBots(unsigned int amount) 310 { 311 unsigned int i = 0; 312 for (ObjectList<Bot>::iterator it = ObjectList<Bot>::begin(); (it != ObjectList<Bot>::end()) && ((amount == 0) || (i < amount)); ) 313 { 314 if (it->getGametype() == this) 315 { 316 delete (*(it++)); 317 ++i; 318 } 319 } 320 } 295 321 } -
code/branches/objecthierarchy2/src/orxonox/objects/gametypes/Gametype.h
r2428 r2462 98 98 { return this->gtinfo_.startCountdown_; } 99 99 100 void addBots(unsigned int amount); 101 void killBots(unsigned int amount = 0); 102 100 103 private: 101 104 virtual SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const; … … 116 119 117 120 float initialStartCountdown_; 121 unsigned int numberOfBots_; 118 122 119 123 std::map<PlayerInfo*, PlayerState::Enum> players_; -
code/branches/objecthierarchy2/src/orxonox/objects/infos/PlayerInfo.cc
r2438 r2462 65 65 this->controller_ = 0; 66 66 } 67 68 if (this->getGametype()) 69 this->getGametype()->playerLeft(this); 67 70 } 68 71 }
Note: See TracChangeset
for help on using the changeset viewer.