Changeset 12260 for code/branches/OrxoBlox_FS19
- Timestamp:
- Mar 28, 2019, 3:49:58 PM (6 years ago)
- Location:
- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc
r12212 r12260 47 47 #include "OrxoBloxBot.h" 48 48 #include "OrxoBloxAI.h" 49 49 50 namespace orxonox 50 51 { … … 66 67 this->ball_ = nullptr; 67 68 this->bat_[0] = nullptr; 68 this->bat_[1] = nullptr;69 69 70 70 this->setHUDTemplate("OrxoBloxHUD"); … … 157 157 this->center_->attach(this->bat_[1]); 158 158 this->bat_[0]->setPosition(-this->center_->getFieldDimension().x / 2, 0, 0); 159 this->bat_[1]->setPosition( this->center_->getFieldDimension().x / 2, 0, 0);160 159 this->bat_[0]->yaw(Degree(-90)); 161 this->bat_[1]->yaw(Degree(90));162 160 this->bat_[0]->setSpeed(this->center_->getBatSpeed()); 163 this->bat_[1]->setSpeed(this->center_->getBatSpeed());164 161 this->bat_[0]->setFieldHeight(this->center_->getFieldDimension().y); 165 this->bat_[1]->setFieldHeight(this->center_->getFieldDimension().y);166 162 this->bat_[0]->setLength(this->center_->getBatLength()); 167 this->bat_[1]->setLength(this->center_->getBatLength());168 163 169 164 // Set the bats for the ball. … … 235 230 this->players_[player].state_ = PlayerState::Alive; 236 231 } 237 // If the second (right) bat has no player.238 else if (this->bat_[1]->getPlayer() == nullptr)239 {240 player->startControl(this->bat_[1]);241 this->players_[player].state_ = PlayerState::Alive;242 }243 // If both bats are taken.244 232 else 245 233 return; … … 264 252 { 265 253 // Fire an event for the player that has scored, to be able to react to it in the level, e.g. by displaying fireworks. 266 if (player == this->getRightPlayer()) 267 this->center_->fireEvent(FireEventName(OrxoBloxCenterpoint, right)); 268 else if (player == this->getLeftPlayer()) 254 255 if (player == this->getLeftPlayer()) 269 256 this->center_->fireEvent(FireEventName(OrxoBloxCenterpoint, left)); 270 257 … … 287 274 { 288 275 this->bat_[0]->setPosition(-this->center_->getFieldDimension().x / 2, 0, 0); 289 this->bat_[1]->setPosition( this->center_->getFieldDimension().x / 2, 0, 0);276 290 277 } 291 278 … … 294 281 if (this->getLeftPlayer() && this->getScore(this->getLeftPlayer()) >= scoreLimit_) 295 282 winningPlayer = this->getLeftPlayer(); 296 else if (this->getRightPlayer() && this->getScore(this->getRightPlayer()) >= scoreLimit_)297 winningPlayer = this->getRightPlayer();298 283 299 284 if (winningPlayer) … … 337 322 Returns a pointer to the player playing on the right. If there is no right player, nullptr is returned. 338 323 */ 339 PlayerInfo* OrxoBlox::getRightPlayer() const 340 { 341 if (this->bat_[1] != nullptr) 342 return this->bat_[1]->getPlayer(); 343 else 344 return nullptr; 345 } 324 346 325 } -
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.h
r12212 r12260 94 94 WeakPtr<OrxoBloxCenterpoint> center_; //!< The playing field. 95 95 WeakPtr<OrxoBloxBall> ball_; //!< The OrxoBlox ball. 96 WeakPtr<OrxoBloxBat> bat_[ 2]; //!< The two bats.96 WeakPtr<OrxoBloxBat> bat_[1]; //!< The two bats. 97 97 Timer starttimer_; //!< A timer to delay the start of the game. 98 98 int scoreLimit_; //!< If a player scored that much points, the game is ended.
Note: See TracChangeset
for help on using the changeset viewer.