Changeset 9720 for code/branches/sfxThilo/src/modules/pong/PongBall.cc
- Timestamp:
- Oct 28, 2013, 3:58:45 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/sfxThilo/src/modules/pong/PongBall.cc
r9667 r9720 40 40 41 41 #include "PongBat.h" 42 43 #include "sound/WorldSound.h" //Thilo 44 #include "core/XMLPort.h" 42 45 43 46 namespace orxonox … … 66 69 67 70 this->registerVariables(); 71 72 //Thilo 73 if (GameMode::isMaster()) 74 { 75 this->defScoreSound_ = new WorldSound(this->getContext()); 76 this->defScoreSound_->setLooping(false); 77 this->defBatSound_ = new WorldSound(this->getContext()); 78 this->defBatSound_->setLooping(false); 79 this->defBoundarySound_ = new WorldSound(this->getContext()); 80 this->defBoundarySound_->setLooping(false); 81 } 82 else 83 { 84 this->defScoreSound_ = 0; 85 } 68 86 } 69 87 … … 81 99 delete[] this->batID_; 82 100 } 101 } 102 103 //Thilo 104 void PongBall::XMLPort(Element& xmlelement, XMLPort::Mode mode) 105 { 106 SUPER(PongBall, XMLPort, xmlelement, mode); 107 XMLPortParam(PongBall, "defScoreSound", setDefScoreSound, getDefScoreSound, xmlelement, mode); 108 XMLPortParam(PongBall, "defBatSound", setDefBatSound, getDefBatSound, xmlelement, mode); 109 XMLPortParam(PongBall, "defBoundarySound", setDefBoundarySound, getDefBoundarySound, xmlelement, mode); 83 110 } 84 111 … … 155 182 else if (GameMode::isMaster() && position.x > this->fieldWidth_ / 2 * (1 + this->relMercyOffset_)) 156 183 { 184 defScoreSound_->play();//Thilo 157 185 if (this->getGametype() && this->bat_[0]) 158 186 { … … 182 210 else if (GameMode::isMaster() && position.x < -this->fieldWidth_ / 2 * (1 + this->relMercyOffset_)) 183 211 { 212 defScoreSound_->play();//Thilo 184 213 if (this->getGametype() && this->bat_[1]) 185 214 { … … 262 291 this->bat_[1] = orxonox_cast<PongBat*>(Synchronisable::getSynchronisable(this->batID_[1])); 263 292 } 293 294 void PongBall::setDefScoreSound(const std::string &pongSound) 295 { 296 if( defScoreSound_ ) 297 defScoreSound_->setSource(pongSound); 298 else 299 assert(0); // This should never happen, because soundpointer is only available on master 300 } 301 302 const std::string& PongBall::getDefScoreSound() 303 { 304 if( defScoreSound_ ) 305 return defScoreSound_->getSource(); 306 else 307 assert(0); 308 return BLANKSTRING; 309 } 310 311 void PongBall::setDefBatSound(const std::string &pongSound) 312 { 313 if( defBatSound_ ) 314 defBatSound_->setSource(pongSound); 315 else 316 assert(0); // This should never happen, because soundpointer is only available on master 317 } 318 319 const std::string& PongBall::getDefBatSound() 320 { 321 if( defBatSound_ ) 322 return defBatSound_->getSource(); 323 else 324 assert(0); 325 return BLANKSTRING; 326 } 327 328 void PongBall::setDefBoundarySound(const std::string &pongSound) 329 { 330 if( defBoundarySound_ ) 331 defBoundarySound_->setSource(pongSound); 332 else 333 assert(0); // This should never happen, because soundpointer is only available on master 334 } 335 336 const std::string& PongBall::getDefBoundarySound() 337 { 338 if( defBoundarySound_ ) 339 return defBoundarySound_->getSource(); 340 else 341 assert(0); 342 return BLANKSTRING; 343 } 264 344 }
Note: See TracChangeset
for help on using the changeset viewer.