Changeset 12307 for code/branches/OrxoBlox_FS19/src/modules
- Timestamp:
- Apr 18, 2019, 3:00:44 PM (6 years ago)
- Location:
- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc
r12305 r12307 68 68 this->center_ = nullptr; 69 69 this->ball_ = nullptr; 70 this->bat_[0] = nullptr;71 70 this->futureWall_ = nullptr; 72 73 //this->setHUDTemplate("pongHUD"); 71 this->player_ = nullptr; 72 73 74 this->setHUDTemplate("OrxoBloxHUD"); 74 75 //Error when specified 75 76 … … 78 79 this->starttimer_.stopTimer(); 79 80 80 // Set the type of Bots for this particular Gametype. 81 this->botclass_ = Class(OrxoBloxBat); 82 83 this->scoreLimit_ = 10; 84 this->setConfigValues(); 81 82 85 83 } 86 84 … … 95 93 } 96 94 97 void OrxoBlox::setConfigValues()98 {99 SetConfigValue(scoreLimit_, 10).description("The player first reaching those points wins.");100 }101 102 95 /** 103 96 @brief … … 112 105 } 113 106 114 // Destroy both bats, if present. 115 for (size_t i = 0; i < 2; ++i) 116 { 117 if (this->bat_[0] != nullptr) 118 { 119 this->bat_[0]->destroy(); 120 this->bat_[0] = nullptr; 121 } 122 } 123 124 } 125 126 /** 127 @brief 107 if (this->futureWall_) 108 { 109 this->futureWall_->destroy(); 110 this->futureWall_ = nullptr; 111 } 112 113 // Destroy 6 bWalls, if present. 114 for (size_t i = 0; i < 6; ++i) 115 { 116 if (this->activeWalls_[0] != nullptr) 117 { 118 this->activeWalls_[0]->destroy(); 119 this->activeWalls_[0] = nullptr; 120 } 121 122 } 123 124 } 125 126 /** 127 @brieftt 128 128 Starts the OrxoBlox minigame. 129 129 */ … … 141 141 // Attach the ball to the centerpoint and set the parameters as specified in the centerpoint, the ball is attached to. 142 142 this->center_->attach(this->ball_); 143 this->ball_->setPosition(0, 0,50); //Startposition143 this->ball_->setPosition(0, 0, 50); 144 144 this->ball_->setFieldDimension(this->center_->getFieldDimension()); 145 145 this->ball_->setSpeed(0); 146 146 this->ball_->setAccelerationFactor(this->center_->getBallAccelerationFactor()); 147 147 this->ball_->setBatLength(this->center_->getBatLength()); 148 149 150 151 148 152 149 153 // If one of the bats is missing, create it. Apply the template for the bats as specified in the centerpoint. … … 157 161 } 158 162 159 // Attach the bats to the centerpoint and set the parameters as specified in the centerpoint, the bats are attached to. 160 this->center_->attach(this->bat_[0]); 161 this->center_->attach(this->bat_[1]); 162 this->bat_[0]->setPosition(-this->center_->getFieldDimension().x / 2, 0, 0); 163 this->bat_[0]->yaw(Degree(-90)); 164 this->bat_[0]->setSpeed(this->center_->getBatSpeed()); 165 this->bat_[0]->setFieldHeight(this->center_->getFieldDimension().y); 166 this->bat_[0]->setLength(this->center_->getBatLength()); 167 168 // Set the bats for the ball. 169 this->ball_->setBats(this->bat_); 163 164 // Create the first Wall. 165 this->createWall(); 166 orxout()<< "helloo"<< endl; 167 170 168 } 171 169 else // If no centerpoint was specified, an error is thrown and the level is exited. … … 188 186 // Reset the variable. 189 187 this->bForceSpawn_ = temp; 190 191 188 } 192 189 … … 220 217 } 221 218 219 222 220 /** 223 221 @brief … … 228 226 void OrxoBlox::spawnPlayer(PlayerInfo* player) 229 227 { 230 assert(player); 231 232 // If the first (left) bat has no player. 233 if (this->bat_[0]->getPlayer() == nullptr) 234 { 235 player->startControl(this->bat_[0]); 228 assert(player); 229 230 if(this->player_ == nullptr) 231 { 232 this->player_ = player; 236 233 this->players_[player].state_ = PlayerState::Alive; 237 234 } 238 else239 return;240 235 } 241 236 … … 244 239 Is called when the player scored. 245 240 */ 246 void OrxoBlox::playerScored(PlayerInfo* player, int score) 247 { 248 Deathmatch::playerScored(player, score); 249 250 if (this->center_ != nullptr) // If there is a centerpoint. 251 { 252 // Fire an event for the player that has scored, to be able to react to it in the level, e.g. by displaying fireworks. 253 254 if (player == this->getLeftPlayer()) 255 this->center_->fireEvent(FireEventName(OrxoBloxCenterpoint, left)); 256 257 // Also announce, that the player has scored. 258 if (player != nullptr) 259 this->gtinfo_->sendAnnounceMessage(player->getName() + " scored"); 260 } 261 262 // If there is a ball present, reset its position, velocity and acceleration. 263 if (this->ball_ != nullptr) 264 { 265 this->ball_->setPosition(Vector3::ZERO); 266 this->ball_->setVelocity(Vector3::ZERO); 267 this->ball_->setAcceleration(Vector3::ZERO); 268 this->ball_->setSpeed(0); 269 } 270 271 // If there are bats reset them to the middle position. 272 if (this->bat_[0] != nullptr && this->bat_[1] != nullptr) 273 { 274 this->bat_[0]->setPosition(-this->center_->getFieldDimension().x / 2, 0, 0); 275 276 } 277 278 279 // Restart the timer to start the ball. 280 this->starttimer_.startTimer(); 281 } 282 283 /*void OrxoBlox::createStonewall(void){ 284 this->futureWall_ = new OrxoBolxWall(this->center_->getContext()); 285 } 286 287 /*void Tetris::createBrick(void) //TODO: random rotation offset between 0 and 3 (times 90°) 288 { 289 // create new futureBrick_ 290 this->futureBrick_ = new TetrisBrick(this->center_->getContext()); 291 292 241 242 //void startWall(void); 243 244 245 246 void OrxoBlox::createWall(void){ 247 this->futureWall_ = new OrxoBloxWall(this->center_->getContext()); 293 248 // Apply the stone template to the stone. 294 this->future Brick_->addTemplate(this->center_->getBrickTemplate());249 this->futureWall_->addTemplate(this->center_->getWallTemplate()); 295 250 296 251 // Attach the brick to the Centerpoint and set the position of the brick to be at the left side. 297 this->center_->attach(this->futureBrick_); 298 float xPos = (this->center_->getWidth()*1.6f + ((this->center_->getWidth() % 2)*2-1)/2.0f)*this->center_->getStoneSize(); 299 float yPos = (this->center_->getHeight()-5.1f)*this->center_->getStoneSize(); 300 301 this->futureBrick_->setPosition(xPos, yPos, 0.0f); 302 this->futureBrick_->setGame(this); 303 } 304 305 }*/ 252 this->center_->attach(this->futureWall_); 253 254 255 this->futureWall_->setPosition(10, 10, 0.0f); 256 this->futureWall_->setGame(this); 257 } 258 259 // void OrxoBlox::createWall(void) //TODO: random rotation offset between 0 and 3 (times 90°) 260 // { 261 // // create new futureBrick_ 262 // this->futureWall_ = new TetrisBrick(this->center_->getContext()); 263 264 265 // // Apply the stone template to the stone. 266 // this->futureBrick_->addTemplate(this->center_->getBrickTemplate()); 267 268 // // Attach the brick to the Centerpoint and set the position of the brick to be at the left side. 269 // this->center_->attach(this->futureBrick_); 270 // float xPos = (this->center_->getWidth()*1.6f + ((this->center_->getWidth() % 2)*2-1)/2.0f)*this->center_->getStoneSize(); 271 // float yPos = (this->center_->getHeight()-5.1f)*this->center_->getStoneSize(); 272 273 // this->futureBrick_->setPosition(xPos, yPos, 0.0f); 274 // this->futureBrick_->setGame(this); 275 // } 306 276 307 277 /** … … 315 285 } 316 286 317 /** 318 @brief 319 Get the left player. 320 @return 321 Returns a pointer to the player playing on the left. If there is no left player, nullptr is returned. 322 */ 323 PlayerInfo* OrxoBlox::getLeftPlayer() const 324 { 325 if (this->bat_[0] != nullptr) 326 return this->bat_[0]->getPlayer(); 327 else 328 return nullptr; 329 } 330 287 331 288 332 289 } -
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.h
r12288 r12307 74 74 virtual void spawnPlayer(PlayerInfo* player) override; //!< Spawns the input player. 75 75 76 virtual void playerScored(PlayerInfo* player, int score = 1) override; //!< Is called when the player scored.76 77 77 78 78 /** … … 82 82 void setCenterpoint(OrxoBloxCenterpoint* center) 83 83 { this->center_ = center; } 84 void setConfigValues(); //!< Makes scoreLimit configurable.85 84 86 PlayerInfo* getLeftPlayer() const; //!< Get the left player. 85 OrxoBloxCenterpoint* getCenterpoint(void) 86 { return this->center_; } 87 87 88 88 protected: 89 89 virtual void spawnPlayersIfRequested() override; //!< Spawns players, and fills the rest up with bots. 90 90 private: 91 void startWall(void); 92 void createWall(void); 91 93 void startBall(); //!< Starts the ball with some default speed. 92 94 void cleanup(); //!< Cleans up the Gametype by destroying the ball and the bats. … … 94 96 WeakPtr<OrxoBloxCenterpoint> center_; //!< The playing field. 95 97 WeakPtr<OrxoBloxBall> ball_; //!< The OrxoBlox ball. 96 WeakPtr<OrxoBloxBat> bat_[1]; //!< The two bats. 98 WeakPtr<OrxoBloxBat> bat_[0]; //!< The two bats. 99 PlayerInfo* player_; 100 97 101 Timer starttimer_; //!< A timer to delay the start of the game. 98 int scoreLimit_; //!< If a player scored that much points, the game is ended.102 99 103 WeakPtr<OrxoBloxWall> futureWall_; 104 WeakPtr<OrxoBloxWall> activeWalls_[6]; //6 is the number of wallls in the game. 100 105 }; 101 106 } -
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxCenterpoint.cc
r12305 r12307 80 80 XMLPortParam(OrxoBloxCenterpoint, "ballaccfactor", setBallAccelerationFactor, getBallAccelerationFactor, xmlelement, mode); 81 81 XMLPortParam(OrxoBloxCenterpoint, "batspeed", setBatSpeed, getBatSpeed, xmlelement, mode); 82 XMLPortParam(OrxoBloxCenterpoint, "stoneTemplate", setStoneTemplate, getStoneTemplate, xmlelement, mode); 83 XMLPortParam(OrxoBloxCenterpoint, "WallTemplate", setWallTemplate, getWallTemplate, xmlelement, mode); 82 84 XMLPortParam(OrxoBloxCenterpoint, "batlength", setBatLength, getBatLength, xmlelement, mode); 83 85 } -
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxCenterpoint.h
r12266 r12307 217 217 { return this->batlength_; } 218 218 219 /** 220 @brief Set the template for the stones. 221 @param templateName The template name to be applied to each stone. 222 */ 223 void setStoneTemplate(const std::string& templateName) 224 { this->stoneTemplate_ = templateName; } 225 /** 226 @brief Get the template for the stones. 227 @return Returns the template name to be applied to each stone. 228 */ 229 const std::string& getStoneTemplate(void) const 230 { return this->stoneTemplate_; } 231 232 233 /** 234 @brief Set the template for the bricks. 235 @param templateName The template name to be applied to each brick. 236 */ 237 void setWallTemplate(const std::string& templateName) 238 { this->WallTemplate_ = templateName; } 239 240 /** 241 @brief Get the template for the bricks. 242 @return Returns the template name to be applied to each brick. 243 */ 244 const std::string& getWallTemplate(void) const 245 { return this->WallTemplate_; } 246 247 219 248 private: 220 249 void checkGametype(); //!< Checks whether the gametype is OrxoBlox and if it is, sets its centerpoint. … … 222 251 std::string balltemplate_; //!< The template for the ball. 223 252 std::string battemplate_; //!< The template for the bats. 253 std::string WallTemplate_; 254 std::string stoneTemplate_; 224 255 225 256 float ballspeed_; //!< The speed of then ball. … … 230 261 float width_; //!< The height of the playing field. 231 262 float height_; //!< The width of the playing field. 263 264 232 265 }; 233 266 } -
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxPrereqs.h
r12212 r12307 72 72 class OrxoBloxBall; 73 73 class OrxoBloxBat; 74 class OrxoBloxBot;75 74 class OrxoBloxCenterpoint; 76 class OrxoBloxScore; 75 class OrxoBloxWall; 76 class OrxobloxStones; 77 77 } 78 78 -
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxStones.cc
r12251 r12307 1 1 #include "OrxoBloxStones.h" 2 2 3 #include "core/CoreIncludes.h" 3 4 #include "core/XMLPort.h" -
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxStones.h
r12251 r12307 46 46 } 47 47 48 48 void setGame(OrxoBlox* orxoblox) 49 { assert(orxoblox); orxoblox_ = orxoblox; } 50 49 51 private: 50 52 float size_; //!< The dimensions a stone has in the game world. … … 52 54 bool delay_; 53 55 56 OrxoBlox* orxoblox_; 54 57 55 58 -
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxWall.cc
r12278 r12307 16 16 RegisterObject(OrxoBloxWall); 17 17 18 this->health_ = 1 0;18 this->health_ = 1 + static_cast<unsigned int>(rnd(6.0f)); //<! random number between 0 and 7; 19 19 this->delay_ = false; 20 this->orxoblox_ = this->getOrxoBlox(); 21 22 23 OrxoBloxStones* stone = new OrxoBloxStones(this->getContext()); 24 if(this->orxoblox_ != nullptr) 25 { 26 stone->setGame(this->orxoblox_); 27 if(this->orxoblox_->getCenterpoint() != nullptr) 28 stone->addTemplate(this->orxoblox_->getCenterpoint()->getStoneTemplate()); 29 else 30 orxout()<< "tetris_->getCenterpoint == nullptr in TetrisBrick.cc"<< endl; 31 } 32 else 33 orxout()<< "tetris_ == nullptr in TetrisBrick.cc"<< endl; 34 } 35 36 37 OrxoBlox* OrxoBloxWall::getOrxoBlox() 38 { 39 if (this->getGametype() != nullptr && this->getGametype()->isA(Class(OrxoBlox))) 40 { 41 OrxoBlox* orxobloxGametype = orxonox_cast<OrxoBlox*>(this->getGametype()); 42 return orxobloxGametype; 43 } 44 else orxout()<<"There is no Gametype! ask Anna"<< endl; 45 return nullptr; 20 46 } 21 47 } -
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxWall.h
r12278 r12307 45 45 // else ~OrxoBloxStones(); 46 46 } 47 48 47 void setGame(OrxoBlox* orxoblox) 48 { assert(orxoblox); orxoblox_ = orxoblox; } 49 49 private: 50 OrxoBlox* getOrxoBlox(); 50 51 unsigned int health_; 51 52 bool delay_; 52 53 OrxoBlox* orxoblox_; 53 54 54 55
Note: See TracChangeset
for help on using the changeset viewer.