- Timestamp:
- Mar 21, 2019, 2:19:16 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc
r12210 r12212 28 28 29 29 /** 30 @file Pong.cc31 @brief Implementation of the Pongclass.30 @file OrxoBlox.cc 31 @brief Implementation of the OrxoBlox class. 32 32 */ 33 33 34 #include " Pong.h"34 #include "OrxoBlox.h" 35 35 36 36 #include "core/CoreIncludes.h" … … 42 42 #include "chat/ChatManager.h" 43 43 44 #include "PongCenterpoint.h" 45 #include "PongBall.h" 46 #include "PongBat.h" 47 #include "PongBot.h" 48 #include "PongAI.h" 49 44 #include "OrxoBloxCenterpoint.h" 45 #include "OrxoBloxBall.h" 46 #include "OrxoBloxBat.h" 47 #include "OrxoBloxBot.h" 48 #include "OrxoBloxAI.h" 50 49 namespace orxonox 51 50 { 52 51 // Events to allow to react to scoring of a player, in the level-file. 53 CreateEventName( PongCenterpoint, right);54 CreateEventName( PongCenterpoint, left);55 56 RegisterUnloadableClass( Pong);52 CreateEventName(OrxoBloxCenterpoint, right); 53 CreateEventName(OrxoBloxCenterpoint, left); 54 55 RegisterUnloadableClass(OrxoBlox); 57 56 58 57 /** … … 60 59 Constructor. Registers and initializes the object. 61 60 */ 62 Pong::Pong(Context* context) : Deathmatch(context)63 { 64 RegisterObject( Pong);61 OrxoBlox::OrxoBlox(Context* context) : Deathmatch(context) 62 { 63 RegisterObject(OrxoBlox); 65 64 66 65 this->center_ = nullptr; … … 69 68 this->bat_[1] = nullptr; 70 69 71 this->setHUDTemplate(" PongHUD");70 this->setHUDTemplate("OrxoBloxHUD"); 72 71 73 72 // Pre-set the timer, but don't start it yet. 74 this->starttimer_.setTimer(1.0, false, createExecutor(createFunctor(& Pong::startBall, this)));73 this->starttimer_.setTimer(1.0, false, createExecutor(createFunctor(&OrxoBlox::startBall, this))); 75 74 this->starttimer_.stopTimer(); 76 75 77 76 // Set the type of Bots for this particular Gametype. 78 this->botclass_ = Class( PongBot);77 this->botclass_ = Class(OrxoBloxBot); 79 78 80 79 this->scoreLimit_ = 10; … … 86 85 Destructor. Cleans up, if initialized. 87 86 */ 88 Pong::~Pong()87 OrxoBlox::~OrxoBlox() 89 88 { 90 89 if (this->isInitialized()) … … 92 91 } 93 92 94 void Pong::setConfigValues()93 void OrxoBlox::setConfigValues() 95 94 { 96 95 SetConfigValue(scoreLimit_, 10).description("The player first reaching those points wins."); … … 101 100 Cleans up the Gametype by destroying the ball and the bats. 102 101 */ 103 void Pong::cleanup()102 void OrxoBlox::cleanup() 104 103 { 105 104 if (this->ball_ != nullptr) // Destroy the ball, if present. … … 123 122 /** 124 123 @brief 125 Starts the Pongminigame.126 */ 127 void Pong::start()128 { 129 if (this->center_ != nullptr) // There needs to be a PongCenterpoint, i.e. the area the game takes place.124 Starts the OrxoBlox minigame. 125 */ 126 void OrxoBlox::start() 127 { 128 if (this->center_ != nullptr) // There needs to be a OrxoBloxCenterpoint, i.e. the area the game takes place. 130 129 { 131 130 if (this->ball_ == nullptr) // If there is no ball, create a new ball. 132 131 { 133 this->ball_ = new PongBall(this->center_->getContext());132 this->ball_ = new OrxoBloxBall(this->center_->getContext()); 134 133 // Apply the template for the ball specified by the centerpoint. 135 134 this->ball_->addTemplate(this->center_->getBalltemplate()); … … 145 144 146 145 // If one of the bats is missing, create it. Apply the template for the bats as specified in the centerpoint. 147 for (WeakPtr<orxonox:: PongBat>& bat : this->bat_)146 for (WeakPtr<orxonox::OrxoBloxBat>& bat : this->bat_) 148 147 { 149 148 if (bat == nullptr) 150 149 { 151 bat = new PongBat(this->center_->getContext());150 bat = new OrxoBloxBat(this->center_->getContext()); 152 151 bat->addTemplate(this->center_->getBattemplate()); 153 152 } … … 173 172 else // If no centerpoint was specified, an error is thrown and the level is exited. 174 173 { 175 orxout(internal_error) << " Pong: No Centerpoint specified." << endl;174 orxout(internal_error) << "OrxoBlox: No Centerpoint specified." << endl; 176 175 GSLevel::startMainMenu(); 177 176 return; … … 194 193 /** 195 194 @brief 196 Ends the Pongminigame.197 */ 198 void Pong::end()195 Ends the OrxoBlox minigame. 196 */ 197 void OrxoBlox::end() 199 198 { 200 199 this->cleanup(); … … 208 207 Spawns players, and fills the rest up with bots. 209 208 */ 210 void Pong::spawnPlayersIfRequested()209 void OrxoBlox::spawnPlayersIfRequested() 211 210 { 212 211 // first spawn human players to assign always the left bat to the player in singleplayer … … 226 225 The player to be spawned. 227 226 */ 228 void Pong::spawnPlayer(PlayerInfo* player)227 void OrxoBlox::spawnPlayer(PlayerInfo* player) 229 228 { 230 229 assert(player); … … 247 246 248 247 // If the player is an AI, it receives a pointer to the ball. 249 if (player->getController() != nullptr && player->getController()->isA(Class( PongAI)))250 { 251 PongAI* ai = orxonox_cast<PongAI*>(player->getController());252 ai->set PongBall(this->ball_);248 if (player->getController() != nullptr && player->getController()->isA(Class(OrxoBloxAI))) 249 { 250 OrxoBloxAI* ai = orxonox_cast<OrxoBloxAI*>(player->getController()); 251 ai->setOrxoBloxBall(this->ball_); 253 252 } 254 253 } … … 258 257 Is called when the player scored. 259 258 */ 260 void Pong::playerScored(PlayerInfo* player, int score)259 void OrxoBlox::playerScored(PlayerInfo* player, int score) 261 260 { 262 261 Deathmatch::playerScored(player, score); … … 266 265 // Fire an event for the player that has scored, to be able to react to it in the level, e.g. by displaying fireworks. 267 266 if (player == this->getRightPlayer()) 268 this->center_->fireEvent(FireEventName( PongCenterpoint, right));267 this->center_->fireEvent(FireEventName(OrxoBloxCenterpoint, right)); 269 268 else if (player == this->getLeftPlayer()) 270 this->center_->fireEvent(FireEventName( PongCenterpoint, left));269 this->center_->fireEvent(FireEventName(OrxoBloxCenterpoint, left)); 271 270 272 271 // Also announce, that the player has scored. … … 312 311 Starts the ball with some default speed. 313 312 */ 314 void Pong::startBall()313 void OrxoBlox::startBall() 315 314 { 316 315 if (this->ball_ != nullptr && this->center_ != nullptr) … … 324 323 Returns a pointer to the player playing on the left. If there is no left player, nullptr is returned. 325 324 */ 326 PlayerInfo* Pong::getLeftPlayer() const325 PlayerInfo* OrxoBlox::getLeftPlayer() const 327 326 { 328 327 if (this->bat_[0] != nullptr) … … 338 337 Returns a pointer to the player playing on the right. If there is no right player, nullptr is returned. 339 338 */ 340 PlayerInfo* Pong::getRightPlayer() const339 PlayerInfo* OrxoBlox::getRightPlayer() const 341 340 { 342 341 if (this->bat_[1] != nullptr)
Note: See TracChangeset
for help on using the changeset viewer.