[10078] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | * > www.orxonox.net < |
---|
| 4 | * |
---|
| 5 | * |
---|
| 6 | * License notice: |
---|
| 7 | * |
---|
| 8 | * This program is free software; you can redistribute it and/or |
---|
| 9 | * modify it under the terms of the GNU General Public License |
---|
| 10 | * as published by the Free Software Foundation; either version 2 |
---|
| 11 | * of the License, or (at your option) any later version. |
---|
| 12 | * |
---|
| 13 | * This program is distributed in the hope that it will be useful, |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | * GNU General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with this program; if not, write to the Free Software |
---|
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 21 | * |
---|
| 22 | * Author: |
---|
| 23 | * Fabien Vultier |
---|
| 24 | * Co-authors: |
---|
| 25 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | /** |
---|
| 30 | @file Jump.cc |
---|
| 31 | @brief This is the gametype for the awesome minigame. Here the level is randomly created, the camera is shifted, ... |
---|
| 32 | */ |
---|
| 33 | |
---|
| 34 | #include "Jump.h" |
---|
| 35 | #include "core/CoreIncludes.h" |
---|
[11502] | 36 | #include "Highscore.h" |
---|
[11071] | 37 | |
---|
[10078] | 38 | #include "JumpCenterpoint.h" |
---|
| 39 | #include "JumpPlatform.h" |
---|
| 40 | #include "JumpPlatformStatic.h" |
---|
| 41 | #include "JumpPlatformHMove.h" |
---|
| 42 | #include "JumpPlatformVMove.h" |
---|
| 43 | #include "JumpPlatformDisappear.h" |
---|
| 44 | #include "JumpPlatformTimer.h" |
---|
| 45 | #include "JumpPlatformFake.h" |
---|
| 46 | #include "JumpProjectile.h" |
---|
| 47 | #include "JumpEnemy.h" |
---|
| 48 | #include "JumpFigure.h" |
---|
| 49 | #include "JumpItem.h" |
---|
| 50 | #include "JumpSpring.h" |
---|
| 51 | #include "JumpRocket.h" |
---|
| 52 | #include "JumpPropeller.h" |
---|
| 53 | #include "JumpBoots.h" |
---|
| 54 | #include "JumpShield.h" |
---|
[11071] | 55 | |
---|
| 56 | #include "gamestates/GSLevel.h" |
---|
[10078] | 57 | #include "infos/PlayerInfo.h" |
---|
[11071] | 58 | #include "graphics/Camera.h" |
---|
[10078] | 59 | |
---|
| 60 | namespace orxonox |
---|
| 61 | { |
---|
| 62 | RegisterUnloadableClass(Jump); |
---|
| 63 | |
---|
| 64 | Jump::Jump(Context* context) : Deathmatch(context) |
---|
| 65 | { |
---|
| 66 | RegisterObject(Jump); |
---|
| 67 | |
---|
[11071] | 68 | center_ = nullptr; |
---|
| 69 | figure_ = nullptr; |
---|
| 70 | camera = nullptr; |
---|
[10078] | 71 | setHUDTemplate("JumpHUD"); |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | Jump::~Jump() |
---|
| 75 | { |
---|
| 76 | if (isInitialized()) |
---|
| 77 | { |
---|
| 78 | cleanup(); |
---|
| 79 | } |
---|
| 80 | } |
---|
| 81 | |
---|
| 82 | void Jump::tick(float dt) |
---|
| 83 | { |
---|
[10215] | 84 | SUPER(Jump, tick, dt); |
---|
[10078] | 85 | |
---|
[11071] | 86 | if (figure_ != nullptr) |
---|
[10215] | 87 | { |
---|
| 88 | Vector3 figurePosition = figure_->getPosition(); |
---|
| 89 | Vector3 figureVelocity = figure_->getVelocity(); |
---|
[10078] | 90 | |
---|
[10215] | 91 | float boundary = totalScreenShift_+center_->getCameraOffset(); |
---|
[10078] | 92 | |
---|
[10215] | 93 | if (figurePosition.z > boundary) |
---|
| 94 | { |
---|
| 95 | screenShiftSinceLastUpdate_ += figurePosition.z - boundary; |
---|
| 96 | totalScreenShift_ = figurePosition.z - center_->getCameraOffset(); |
---|
[10078] | 97 | |
---|
| 98 | // Create new platforms if needed |
---|
| 99 | if (screenShiftSinceLastUpdate_ > center_->getSectionLength()) |
---|
| 100 | { |
---|
[11071] | 101 | if (sectionNumber_ > 2 && sectionNumber_%4 == 0 && rand()%2 == 0 && figure_->propellerActive_ == nullptr && figure_->rocketActive_ == nullptr && addAdventure(adventureNumber_) == true) |
---|
[10215] | 102 | { |
---|
| 103 | screenShiftSinceLastUpdate_ -= 2*center_->getSectionLength(); |
---|
| 104 | ++ adventureNumber_; |
---|
| 105 | } |
---|
| 106 | else |
---|
| 107 | { |
---|
| 108 | screenShiftSinceLastUpdate_ -= center_->getSectionLength(); |
---|
| 109 | addSection(); |
---|
| 110 | } |
---|
[10078] | 111 | } |
---|
[10215] | 112 | } |
---|
[10078] | 113 | |
---|
[10215] | 114 | if (figurePosition.z < totalScreenShift_ - center_->getFieldDimension().y + platformHeight_ && figureVelocity.z < 0) |
---|
| 115 | { |
---|
| 116 | figure_->dead_ = true; |
---|
| 117 | } |
---|
[10078] | 118 | |
---|
[10215] | 119 | if (figure_->fireSignal_ == true) |
---|
| 120 | { |
---|
| 121 | if (figure_->dead_ == true) |
---|
| 122 | { |
---|
| 123 | end(); |
---|
| 124 | } |
---|
| 125 | else |
---|
| 126 | { |
---|
| 127 | figure_->fireSignal_ = false; |
---|
| 128 | addProjectile(figurePosition.x, figurePosition.z + figure_->getPropellerPos()); |
---|
| 129 | } |
---|
| 130 | } |
---|
[10078] | 131 | |
---|
| 132 | |
---|
[11071] | 133 | if (camera != nullptr) |
---|
[10215] | 134 | { |
---|
| 135 | Vector3 cameraPosition = Vector3(0, totalScreenShift_, 0); |
---|
| 136 | camera->setPosition(cameraPosition); |
---|
| 137 | } |
---|
| 138 | else |
---|
| 139 | { |
---|
| 140 | orxout() << "No camera found." << endl; |
---|
| 141 | } |
---|
| 142 | } |
---|
[10078] | 143 | |
---|
[11071] | 144 | ObjectList<JumpPlatform> listPlatform; |
---|
| 145 | ObjectList<JumpPlatform>::iterator itPlatform = listPlatform.begin(); |
---|
[10215] | 146 | Vector3 platformPosition; |
---|
[10078] | 147 | |
---|
[11071] | 148 | while (itPlatform != listPlatform.end()) |
---|
[10215] | 149 | { |
---|
| 150 | platformPosition = itPlatform->getPosition(); |
---|
| 151 | if (platformPosition.z < totalScreenShift_ - center_->getFieldDimension().y) |
---|
| 152 | { |
---|
| 153 | ObjectList<JumpPlatform>::iterator temp = itPlatform; |
---|
| 154 | ++ itPlatform; |
---|
| 155 | center_->detach(*temp); |
---|
| 156 | temp->destroy(); |
---|
| 157 | } |
---|
| 158 | else |
---|
| 159 | { |
---|
| 160 | ++ itPlatform; |
---|
| 161 | } |
---|
| 162 | } |
---|
[10078] | 163 | |
---|
[10215] | 164 | // Deleted deactivated platforms |
---|
[11071] | 165 | ObjectList<JumpPlatformDisappear> listDisappear; |
---|
| 166 | ObjectList<JumpPlatformDisappear>::iterator itDisappear = listDisappear.begin(); |
---|
[10078] | 167 | |
---|
[11071] | 168 | while (itDisappear != listDisappear.end()) |
---|
[10215] | 169 | { |
---|
| 170 | if (!itDisappear->isActive()) |
---|
| 171 | { |
---|
| 172 | ObjectList<JumpPlatformDisappear>::iterator temp = itDisappear; |
---|
| 173 | ++ itDisappear; |
---|
| 174 | center_->detach(*temp); |
---|
| 175 | temp->destroy(); |
---|
| 176 | } |
---|
| 177 | else |
---|
| 178 | { |
---|
| 179 | ++ itDisappear; |
---|
| 180 | } |
---|
| 181 | } |
---|
[10078] | 182 | |
---|
[11071] | 183 | ObjectList<JumpPlatformTimer> listTimer; |
---|
| 184 | ObjectList<JumpPlatformTimer>::iterator itTimer = listTimer.begin(); |
---|
[10078] | 185 | |
---|
[11071] | 186 | while (itTimer != listTimer.end()) |
---|
[10215] | 187 | { |
---|
| 188 | if (!itTimer->isActive()) |
---|
| 189 | { |
---|
| 190 | ObjectList<JumpPlatformTimer>::iterator temp = itTimer; |
---|
| 191 | ++ itTimer; |
---|
| 192 | center_->detach(*temp); |
---|
| 193 | temp->destroy(); |
---|
| 194 | } |
---|
| 195 | else |
---|
| 196 | { |
---|
| 197 | ++ itTimer; |
---|
| 198 | } |
---|
| 199 | } |
---|
[10078] | 200 | |
---|
[11071] | 201 | ObjectList<JumpProjectile> listProjectile; |
---|
| 202 | ObjectList<JumpProjectile>::iterator itProjectile = listProjectile.begin(); |
---|
[10215] | 203 | Vector3 projectilePosition; |
---|
[10078] | 204 | |
---|
[11071] | 205 | while (itProjectile != listProjectile.end()) |
---|
[10215] | 206 | { |
---|
| 207 | projectilePosition = itProjectile->getPosition(); |
---|
| 208 | if (projectilePosition.z > totalScreenShift_ + 5*center_->getFieldDimension().y) |
---|
| 209 | { |
---|
| 210 | ObjectList<JumpProjectile>::iterator temp = itProjectile; |
---|
| 211 | ++ itProjectile; |
---|
| 212 | center_->detach(*temp); |
---|
| 213 | temp->destroy(); |
---|
| 214 | } |
---|
| 215 | else |
---|
| 216 | { |
---|
| 217 | ++ itProjectile; |
---|
| 218 | } |
---|
| 219 | } |
---|
[10078] | 220 | |
---|
[11071] | 221 | ObjectList<JumpEnemy> listEnemy; |
---|
| 222 | ObjectList<JumpEnemy>::iterator itEnemy = listEnemy.begin(); |
---|
[10215] | 223 | Vector3 enemyPosition; |
---|
[10078] | 224 | |
---|
[11071] | 225 | while (itEnemy != listEnemy.end()) |
---|
[10215] | 226 | { |
---|
| 227 | enemyPosition = itEnemy->getPosition(); |
---|
| 228 | if (enemyPosition.z < totalScreenShift_ - center_->getFieldDimension().y || itEnemy->dead_ == true) |
---|
| 229 | { |
---|
| 230 | ObjectList<JumpEnemy>::iterator temp = itEnemy; |
---|
| 231 | ++ itEnemy; |
---|
| 232 | center_->detach(*temp); |
---|
| 233 | temp->destroy(); |
---|
| 234 | } |
---|
| 235 | else |
---|
| 236 | { |
---|
| 237 | ++ itEnemy; |
---|
| 238 | } |
---|
| 239 | } |
---|
[10078] | 240 | |
---|
[11071] | 241 | ObjectList<JumpItem> listItem; |
---|
| 242 | ObjectList<JumpItem>::iterator itItem = listItem.begin(); |
---|
[10215] | 243 | Vector3 itemPosition; |
---|
[10078] | 244 | |
---|
[11071] | 245 | while (itItem != listItem.end()) |
---|
[10215] | 246 | { |
---|
| 247 | itemPosition = itItem->getPosition(); |
---|
[10078] | 248 | |
---|
[10215] | 249 | WorldEntity* parent = itItem->getParent(); |
---|
[10078] | 250 | |
---|
[10215] | 251 | if (itItem->attachedToFigure_ == false && itemPosition.z < totalScreenShift_ - center_->getFieldDimension().y && parent == center_) |
---|
| 252 | { |
---|
| 253 | ObjectList<JumpItem>::iterator temp = itItem; |
---|
| 254 | ++ itItem; |
---|
| 255 | center_->detach(*temp); |
---|
| 256 | temp->destroy(); |
---|
| 257 | } |
---|
| 258 | else |
---|
| 259 | { |
---|
| 260 | ++ itItem; |
---|
| 261 | } |
---|
| 262 | } |
---|
[10078] | 263 | } |
---|
| 264 | |
---|
| 265 | void Jump::cleanup() |
---|
| 266 | { |
---|
[11071] | 267 | camera = nullptr; |
---|
[10078] | 268 | } |
---|
| 269 | |
---|
| 270 | void Jump::start() |
---|
| 271 | { |
---|
[11071] | 272 | if (center_ != nullptr) // There needs to be a JumpCenterpoint, i.e. the area the game takes place. |
---|
[10078] | 273 | { |
---|
[11071] | 274 | if (figure_ == nullptr) |
---|
[10215] | 275 | { |
---|
| 276 | figure_ = new JumpFigure(center_->getContext()); |
---|
| 277 | figure_->addTemplate(center_->getFigureTemplate()); |
---|
| 278 | figure_->InitializeAnimation(center_->getContext()); |
---|
| 279 | } |
---|
[10078] | 280 | |
---|
| 281 | center_->attach(figure_); |
---|
| 282 | figure_->setPosition(0, 0, 0); |
---|
| 283 | figure_->setFieldDimension(center_->getFieldDimension()); |
---|
| 284 | } |
---|
| 285 | else // If no centerpoint was specified, an error is thrown and the level is exited. |
---|
| 286 | { |
---|
| 287 | orxout(internal_error) << "Jump: No Centerpoint specified." << endl; |
---|
| 288 | GSLevel::startMainMenu(); |
---|
| 289 | return; |
---|
| 290 | } |
---|
| 291 | |
---|
| 292 | // Call start for the parent class. |
---|
| 293 | Deathmatch::start(); |
---|
| 294 | |
---|
[11071] | 295 | if (figure_ != nullptr) |
---|
[10078] | 296 | { |
---|
[10215] | 297 | camera = figure_->getCamera(); |
---|
[10078] | 298 | } |
---|
| 299 | |
---|
| 300 | totalScreenShift_ = 0.0; |
---|
| 301 | screenShiftSinceLastUpdate_ = 0.0; |
---|
| 302 | sectionNumber_ = 0; |
---|
| 303 | adventureNumber_ = 0; |
---|
| 304 | |
---|
| 305 | addStartSection(); |
---|
| 306 | addSection(); |
---|
| 307 | addSection(); |
---|
| 308 | } |
---|
| 309 | |
---|
| 310 | void Jump::end() |
---|
| 311 | { |
---|
[10215] | 312 | cleanup(); |
---|
| 313 | GSLevel::startMainMenu(); |
---|
[11502] | 314 | if (Highscore::exists()){ |
---|
| 315 | int score = this->getScore(this->getPlayer()); |
---|
| 316 | if(score > Highscore::getInstance().getHighestScoreOfGame("Jump")) |
---|
| 317 | Highscore::getInstance().storeHighscore("Jump",score); |
---|
[10078] | 318 | |
---|
[11502] | 319 | } |
---|
[10078] | 320 | Deathmatch::end(); |
---|
| 321 | } |
---|
| 322 | |
---|
| 323 | void Jump::spawnPlayer(PlayerInfo* player) |
---|
| 324 | { |
---|
| 325 | assert(player); |
---|
| 326 | |
---|
[11071] | 327 | if (figure_->getPlayer() == nullptr) |
---|
[10078] | 328 | { |
---|
| 329 | player->startControl(figure_); |
---|
| 330 | players_[player].state_ = PlayerState::Alive; |
---|
| 331 | } |
---|
| 332 | } |
---|
| 333 | |
---|
| 334 | PlayerInfo* Jump::getPlayer() const |
---|
| 335 | { |
---|
[11071] | 336 | if (this->figure_ != nullptr) |
---|
[10078] | 337 | { |
---|
| 338 | return this->figure_->getPlayer(); |
---|
| 339 | } |
---|
| 340 | else |
---|
| 341 | { |
---|
[11071] | 342 | return nullptr; |
---|
[10078] | 343 | } |
---|
| 344 | } |
---|
| 345 | |
---|
| 346 | void Jump::addPlatform(JumpPlatform* newPlatform, std::string platformTemplate, float xPosition, float zPosition) |
---|
| 347 | { |
---|
[11071] | 348 | if (newPlatform != nullptr && center_ != nullptr) |
---|
[10215] | 349 | { |
---|
| 350 | newPlatform->addTemplate(platformTemplate); |
---|
| 351 | newPlatform->setPosition(Vector3(xPosition, 0.0, zPosition)); |
---|
| 352 | newPlatform->setFigure(this->figure_); |
---|
| 353 | center_->attach(newPlatform); |
---|
| 354 | } |
---|
[10078] | 355 | } |
---|
| 356 | |
---|
| 357 | JumpPlatformStatic* Jump::addPlatformStatic(float xPosition, float zPosition) |
---|
| 358 | { |
---|
[10215] | 359 | JumpPlatformStatic* newPlatform = new JumpPlatformStatic(center_->getContext()); |
---|
| 360 | addPlatform(newPlatform, center_->getPlatformStaticTemplate(), xPosition, zPosition); |
---|
[10078] | 361 | |
---|
[10215] | 362 | return newPlatform; |
---|
[10078] | 363 | } |
---|
| 364 | |
---|
| 365 | JumpPlatformHMove* Jump::addPlatformHMove(float xPosition, float zPosition, float leftBoundary, float rightBoundary, float speed) |
---|
| 366 | { |
---|
[10215] | 367 | JumpPlatformHMove* newPlatform = new JumpPlatformHMove(center_->getContext()); |
---|
| 368 | newPlatform->setProperties(leftBoundary, rightBoundary, speed); |
---|
| 369 | addPlatform(newPlatform, center_->getPlatformHMoveTemplate(), xPosition, zPosition); |
---|
[10078] | 370 | |
---|
[10215] | 371 | return newPlatform; |
---|
[10078] | 372 | } |
---|
| 373 | |
---|
| 374 | JumpPlatformVMove* Jump::addPlatformVMove(float xPosition, float zPosition, float lowerBoundary, float upperBoundary, float speed) |
---|
| 375 | { |
---|
[10215] | 376 | JumpPlatformVMove* newPlatform = new JumpPlatformVMove(center_->getContext()); |
---|
| 377 | newPlatform->setProperties(lowerBoundary, upperBoundary, speed); |
---|
| 378 | addPlatform(newPlatform, center_->getPlatformVMoveTemplate(), xPosition, zPosition); |
---|
[10078] | 379 | |
---|
[10215] | 380 | return newPlatform; |
---|
[10078] | 381 | } |
---|
| 382 | |
---|
| 383 | JumpPlatformDisappear* Jump::addPlatformDisappear(float xPosition, float zPosition) |
---|
| 384 | { |
---|
[10215] | 385 | JumpPlatformDisappear* newPlatform = new JumpPlatformDisappear(center_->getContext()); |
---|
| 386 | newPlatform->setProperties(true); |
---|
| 387 | addPlatform(newPlatform, center_->getPlatformDisappearTemplate(), xPosition, zPosition); |
---|
[10078] | 388 | |
---|
[10215] | 389 | return newPlatform; |
---|
[10078] | 390 | } |
---|
| 391 | |
---|
| 392 | JumpPlatformTimer* Jump::addPlatformTimer(float xPosition, float zPosition, float time, float variance) |
---|
| 393 | { |
---|
[10261] | 394 | float additionalTime = (float)(rand()%100)/100.0f*variance - variance/2.0f; |
---|
[10078] | 395 | |
---|
[10215] | 396 | JumpPlatformTimer* newPlatform = new JumpPlatformTimer(center_->getContext()); |
---|
| 397 | newPlatform->setProperties(time + additionalTime); |
---|
| 398 | addPlatform(newPlatform, center_->getPlatformTimerTemplate(), xPosition, zPosition); |
---|
[10078] | 399 | |
---|
[10215] | 400 | return newPlatform; |
---|
[10078] | 401 | } |
---|
| 402 | |
---|
| 403 | JumpPlatformFake* Jump::addPlatformFake(float xPosition, float zPosition) |
---|
| 404 | { |
---|
[10215] | 405 | JumpPlatformFake* newPlatform = new JumpPlatformFake(center_->getContext()); |
---|
| 406 | addPlatform(newPlatform, center_->getPlatformFakeTemplate(), xPosition, zPosition); |
---|
| 407 | newPlatform->setAngularVelocity(Vector3(0, 0, 2.0)); |
---|
[10078] | 408 | |
---|
[10215] | 409 | return newPlatform; |
---|
[10078] | 410 | } |
---|
| 411 | |
---|
| 412 | |
---|
| 413 | void Jump::addProjectile(float xPosition, float zPosition) |
---|
| 414 | { |
---|
[10215] | 415 | JumpProjectile* newProjectile = new JumpProjectile(center_->getContext()); |
---|
[11071] | 416 | if (newProjectile != nullptr && center_ != nullptr) |
---|
[10215] | 417 | { |
---|
| 418 | newProjectile->addTemplate(center_->getProjectileTemplate()); |
---|
| 419 | newProjectile->setPosition(Vector3(xPosition, 0.0, zPosition)); |
---|
| 420 | newProjectile->setFieldDimension(center_->getFieldDimension()); |
---|
| 421 | newProjectile->setFigure(this->figure_); |
---|
| 422 | center_->attach(newProjectile); |
---|
| 423 | } |
---|
[10078] | 424 | } |
---|
| 425 | |
---|
| 426 | void Jump::addSpring(float xPosition, float zPosition, float leftBoundary, float rightBoundary, float lowerBoundary, float upperBoundary, float xVelocity, float zVelocity) |
---|
| 427 | { |
---|
[10215] | 428 | JumpSpring* newSpring = new JumpSpring(center_->getContext()); |
---|
[11071] | 429 | if (newSpring != nullptr && center_ != nullptr) |
---|
[10215] | 430 | { |
---|
| 431 | newSpring->addTemplate(center_->getSpringTemplate()); |
---|
| 432 | newSpring->setPosition(Vector3(xPosition, 0.0, zPosition)); |
---|
| 433 | newSpring->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity); |
---|
| 434 | newSpring->setFigure(figure_); |
---|
| 435 | center_->attach(newSpring); |
---|
| 436 | } |
---|
[10078] | 437 | } |
---|
| 438 | |
---|
| 439 | void Jump::addSpring(JumpPlatform* platform) |
---|
| 440 | { |
---|
[10215] | 441 | JumpSpring* newSpring = new JumpSpring(center_->getContext()); |
---|
[11071] | 442 | if (newSpring != nullptr && center_ != nullptr) |
---|
[10215] | 443 | { |
---|
| 444 | newSpring->addTemplate(center_->getSpringTemplate()); |
---|
| 445 | newSpring->setPosition(Vector3(0.0, 0.0, 0.0)); |
---|
| 446 | newSpring->setProperties(-10.0, 10.0, -10.0, 10.0, 0.0, 0.0); |
---|
| 447 | newSpring->setFigure(figure_); |
---|
| 448 | platform->attach(newSpring); |
---|
| 449 | } |
---|
[10078] | 450 | } |
---|
| 451 | |
---|
| 452 | void Jump::addRocket(float xPosition, float zPosition, float leftBoundary, float rightBoundary, float lowerBoundary, float upperBoundary, float xVelocity, float zVelocity) |
---|
| 453 | { |
---|
[10215] | 454 | JumpRocket* newRocket = new JumpRocket(center_->getContext()); |
---|
[11071] | 455 | if (newRocket != nullptr && center_ != nullptr) |
---|
[10215] | 456 | { |
---|
| 457 | newRocket->addTemplate(center_->getRocketTemplate()); |
---|
| 458 | newRocket->setPosition(Vector3(xPosition, 0.0, zPosition)); |
---|
| 459 | newRocket->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity); |
---|
| 460 | newRocket->setFigure(figure_); |
---|
| 461 | center_->attach(newRocket); |
---|
| 462 | } |
---|
[10078] | 463 | } |
---|
| 464 | |
---|
| 465 | void Jump::addRocket(JumpPlatform* platform) |
---|
| 466 | { |
---|
[10215] | 467 | JumpRocket* newRocket = new JumpRocket(center_->getContext()); |
---|
[11071] | 468 | if (newRocket != nullptr && center_ != nullptr) |
---|
[10215] | 469 | { |
---|
| 470 | newRocket->addTemplate(center_->getRocketTemplate()); |
---|
| 471 | newRocket->setPosition(Vector3(0.0, 0.0, 0.0)); |
---|
| 472 | newRocket->setProperties(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); |
---|
| 473 | newRocket->setFigure(figure_); |
---|
| 474 | platform->attach(newRocket); |
---|
| 475 | } |
---|
[10078] | 476 | } |
---|
| 477 | |
---|
| 478 | void Jump::addPropeller(float xPosition, float zPosition, float leftBoundary, float rightBoundary, float lowerBoundary, float upperBoundary, float xVelocity, float zVelocity) |
---|
| 479 | { |
---|
[10215] | 480 | JumpPropeller* newPropeller = new JumpPropeller(center_->getContext()); |
---|
[11071] | 481 | if (newPropeller != nullptr && center_ != nullptr) |
---|
[10215] | 482 | { |
---|
| 483 | newPropeller->addTemplate(center_->getPropellerTemplate()); |
---|
| 484 | newPropeller->setPosition(Vector3(xPosition, 0.0, zPosition)); |
---|
| 485 | newPropeller->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity); |
---|
| 486 | newPropeller->setFigure(figure_); |
---|
| 487 | center_->attach(newPropeller); |
---|
| 488 | } |
---|
[10078] | 489 | } |
---|
| 490 | |
---|
| 491 | void Jump::addPropeller(JumpPlatform* platform) |
---|
| 492 | { |
---|
[10215] | 493 | JumpPropeller* newPropeller = new JumpPropeller(center_->getContext()); |
---|
[11071] | 494 | if (newPropeller != nullptr && center_ != nullptr) |
---|
[10215] | 495 | { |
---|
| 496 | newPropeller->addTemplate(center_->getPropellerTemplate()); |
---|
| 497 | newPropeller->setPosition(Vector3(0.0, 0.0, 0.0)); |
---|
| 498 | newPropeller->setProperties(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); |
---|
| 499 | newPropeller->setFigure(figure_); |
---|
| 500 | platform->attach(newPropeller); |
---|
| 501 | } |
---|
[10078] | 502 | } |
---|
| 503 | |
---|
| 504 | void Jump::addBoots(float xPosition, float zPosition, float leftBoundary, float rightBoundary, float lowerBoundary, float upperBoundary, float xVelocity, float zVelocity) |
---|
| 505 | { |
---|
[10215] | 506 | JumpBoots* newBoots = new JumpBoots(center_->getContext()); |
---|
[11071] | 507 | if (newBoots != nullptr && center_ != nullptr) |
---|
[10215] | 508 | { |
---|
| 509 | newBoots->addTemplate(center_->getBootsTemplate()); |
---|
| 510 | newBoots->setPosition(Vector3(xPosition, 0.0, zPosition)); |
---|
| 511 | newBoots->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity); |
---|
| 512 | newBoots->setFigure(figure_); |
---|
| 513 | center_->attach(newBoots); |
---|
| 514 | } |
---|
[10078] | 515 | } |
---|
| 516 | |
---|
| 517 | void Jump::addBoots(JumpPlatform* platform) |
---|
| 518 | { |
---|
[10215] | 519 | JumpBoots* newBoots = new JumpBoots(center_->getContext()); |
---|
[11071] | 520 | if (newBoots != nullptr && center_ != nullptr) |
---|
[10215] | 521 | { |
---|
| 522 | newBoots->addTemplate(center_->getBootsTemplate()); |
---|
| 523 | newBoots->setPosition(Vector3(0.0, 0.0, 0.0)); |
---|
| 524 | newBoots->setProperties(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); |
---|
| 525 | newBoots->setFigure(figure_); |
---|
| 526 | platform->attach(newBoots); |
---|
| 527 | } |
---|
[10078] | 528 | } |
---|
| 529 | |
---|
| 530 | void Jump::addShield(float xPosition, float zPosition, float leftBoundary, float rightBoundary, float lowerBoundary, float upperBoundary, float xVelocity, float zVelocity) |
---|
| 531 | { |
---|
[10215] | 532 | JumpShield* newShield = new JumpShield(center_->getContext()); |
---|
[11071] | 533 | if (newShield != nullptr && center_ != nullptr) |
---|
[10215] | 534 | { |
---|
| 535 | newShield->addTemplate(center_->getShieldTemplate()); |
---|
| 536 | newShield->setPosition(Vector3(xPosition, 0.0, zPosition)); |
---|
| 537 | newShield->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity); |
---|
| 538 | newShield->setFigure(figure_); |
---|
| 539 | center_->attach(newShield); |
---|
| 540 | } |
---|
[10078] | 541 | } |
---|
| 542 | |
---|
| 543 | void Jump::addShield(JumpPlatform* platform) |
---|
| 544 | { |
---|
[10215] | 545 | JumpShield* newShield = new JumpShield(center_->getContext()); |
---|
[11071] | 546 | if (newShield != nullptr && center_ != nullptr) |
---|
[10215] | 547 | { |
---|
| 548 | newShield->addTemplate(center_->getShieldTemplate()); |
---|
| 549 | newShield->setPosition(Vector3(0.0, 0.0, 0.0)); |
---|
| 550 | newShield->setProperties(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); |
---|
| 551 | newShield->setFigure(figure_); |
---|
| 552 | platform->attach(newShield); |
---|
| 553 | } |
---|
[10078] | 554 | } |
---|
| 555 | |
---|
| 556 | void Jump::addEnemy(int type, float xPosition, float zPosition, float leftBoundary, float rightBoundary, float lowerBoundary, float upperBoundary, float xVelocity, float zVelocity) |
---|
| 557 | { |
---|
[10215] | 558 | JumpEnemy* newEnemy = new JumpEnemy(center_->getContext()); |
---|
[11071] | 559 | if (newEnemy != nullptr && center_ != nullptr) |
---|
[10215] | 560 | { |
---|
| 561 | switch (type) |
---|
| 562 | { |
---|
| 563 | case 1: |
---|
| 564 | newEnemy->addTemplate(center_->getEnemy1Template()); |
---|
| 565 | break; |
---|
| 566 | case 2: |
---|
| 567 | newEnemy->addTemplate(center_->getEnemy2Template()); |
---|
| 568 | break; |
---|
| 569 | case 3: |
---|
| 570 | newEnemy->addTemplate(center_->getEnemy3Template()); |
---|
| 571 | break; |
---|
| 572 | case 4: |
---|
| 573 | newEnemy->addTemplate(center_->getEnemy4Template()); |
---|
| 574 | break; |
---|
| 575 | default: |
---|
| 576 | return; |
---|
| 577 | } |
---|
[10078] | 578 | |
---|
[10215] | 579 | newEnemy->setPosition(Vector3(xPosition, 0.0, zPosition)); |
---|
| 580 | newEnemy->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity); |
---|
| 581 | newEnemy->setFieldDimension(center_->getFieldDimension()); |
---|
| 582 | newEnemy->setFigure(this->figure_); |
---|
| 583 | center_->attach(newEnemy); |
---|
| 584 | } |
---|
[10078] | 585 | } |
---|
| 586 | |
---|
| 587 | void Jump::addStartSection() |
---|
| 588 | { |
---|
[10215] | 589 | JumpPlatform* newPlatform; |
---|
[10078] | 590 | |
---|
[10215] | 591 | float sectionLength = center_->getSectionLength(); |
---|
[10078] | 592 | |
---|
[10215] | 593 | newPlatform = new JumpPlatformStatic(center_->getContext()); |
---|
[10218] | 594 | addPlatform(newPlatform, center_->getPlatformStaticTemplate(), 0.0, -0.05f*sectionLength); |
---|
[10078] | 595 | |
---|
[10215] | 596 | platformWidth_ = newPlatform->getWidth(); |
---|
| 597 | platformHeight_ = newPlatform->getHeight(); |
---|
[10078] | 598 | |
---|
[10215] | 599 | for (float xPosition = platformWidth_; xPosition <= center_->getFieldDimension().x; xPosition += platformWidth_) |
---|
| 600 | { |
---|
| 601 | newPlatform = new JumpPlatformStatic(center_->getContext()); |
---|
[10218] | 602 | addPlatform(newPlatform, center_->getPlatformStaticTemplate(), xPosition, -0.05f*sectionLength); |
---|
[10215] | 603 | newPlatform = new JumpPlatformStatic(center_->getContext()); |
---|
[10218] | 604 | addPlatform(newPlatform, center_->getPlatformStaticTemplate(), -xPosition, -0.05f*sectionLength); |
---|
[10215] | 605 | } |
---|
[10078] | 606 | } |
---|
| 607 | |
---|
| 608 | void Jump::addSection() |
---|
| 609 | { |
---|
| 610 | float fieldWidth = center_->getFieldDimension().x; |
---|
| 611 | float sectionLength = center_->getSectionLength(); |
---|
| 612 | float sectionBegin = sectionNumber_ * sectionLength; |
---|
| 613 | float sectionEnd = (1 + sectionNumber_) * sectionLength; |
---|
| 614 | |
---|
[10218] | 615 | const int numI = 6; |
---|
| 616 | const int numJ = 4; |
---|
[10078] | 617 | |
---|
[11071] | 618 | enum class PlatformType |
---|
[10215] | 619 | { |
---|
[11071] | 620 | EMPTY, STATIC, HMOVE, VMOVE, DISAPPEAR, TIMER, FAKE |
---|
[10215] | 621 | }; |
---|
[10078] | 622 | |
---|
[11071] | 623 | enum class ItemType |
---|
[10215] | 624 | { |
---|
[11071] | 625 | NOTHING, SPRING, PROPELLER, ROCKET, BOOTS, SHIELD |
---|
[10215] | 626 | }; |
---|
[10078] | 627 | |
---|
| 628 | struct PlatformMatrix |
---|
| 629 | { |
---|
[10215] | 630 | PlatformType type; |
---|
[10078] | 631 | bool done; |
---|
| 632 | } matrix[numI][numJ]; |
---|
| 633 | |
---|
| 634 | |
---|
[10215] | 635 | for (int i = 0; i < numI; ++i) |
---|
| 636 | { |
---|
| 637 | for (int j = 0; j < numJ; ++j) |
---|
| 638 | { |
---|
[11071] | 639 | matrix[i][j].type = PlatformType::EMPTY; |
---|
[10215] | 640 | matrix[i][j].done = false; |
---|
| 641 | } |
---|
| 642 | } |
---|
| 643 | PlatformType platformtype1; |
---|
| 644 | PlatformType platformtype2; |
---|
[11071] | 645 | ItemType itemType = ItemType::NOTHING; |
---|
[10078] | 646 | |
---|
[10215] | 647 | if (rand()%2 == 0) |
---|
| 648 | { |
---|
[11071] | 649 | itemType = ItemType::SPRING; |
---|
[10215] | 650 | } |
---|
| 651 | else if (rand()%2 == 0 && sectionNumber_ > 3) |
---|
| 652 | { |
---|
| 653 | switch(rand()%4) |
---|
| 654 | { |
---|
| 655 | case 0: |
---|
[11071] | 656 | itemType = ItemType::PROPELLER; |
---|
[10215] | 657 | break; |
---|
| 658 | case 1: |
---|
[11071] | 659 | itemType = ItemType::ROCKET; |
---|
[10215] | 660 | break; |
---|
| 661 | case 2: |
---|
[11071] | 662 | itemType = ItemType::BOOTS; |
---|
[10215] | 663 | break; |
---|
| 664 | case 3: |
---|
[11071] | 665 | itemType = ItemType::SHIELD; |
---|
[10215] | 666 | break; |
---|
| 667 | default: |
---|
| 668 | break; |
---|
| 669 | } |
---|
| 670 | } |
---|
[10078] | 671 | |
---|
[10215] | 672 | switch((sectionNumber_ > 28) ? rand()%29 : rand()%(sectionNumber_+1)) |
---|
| 673 | { |
---|
| 674 | case 0: |
---|
[11071] | 675 | platformtype1 = PlatformType::STATIC; |
---|
| 676 | platformtype2 = PlatformType::STATIC; |
---|
[10215] | 677 | break; |
---|
| 678 | case 1: |
---|
[11071] | 679 | platformtype1 = PlatformType::STATIC; |
---|
| 680 | platformtype2 = PlatformType::STATIC; |
---|
[10215] | 681 | break; |
---|
| 682 | case 2: |
---|
[11071] | 683 | platformtype1 = PlatformType::STATIC; |
---|
| 684 | platformtype2 = PlatformType::HMOVE; |
---|
[10215] | 685 | break; |
---|
| 686 | case 3: |
---|
[11071] | 687 | platformtype1 = PlatformType::STATIC; |
---|
| 688 | platformtype2 = PlatformType::DISAPPEAR; |
---|
[10215] | 689 | break; |
---|
| 690 | case 4: |
---|
[11071] | 691 | platformtype1 = PlatformType::STATIC; |
---|
| 692 | platformtype2 = PlatformType::VMOVE; |
---|
[10215] | 693 | break; |
---|
| 694 | case 5: |
---|
[11071] | 695 | platformtype1 = PlatformType::STATIC; |
---|
| 696 | platformtype2 = PlatformType::TIMER; |
---|
[10215] | 697 | break; |
---|
| 698 | case 6: |
---|
[11071] | 699 | platformtype1 = PlatformType::HMOVE; |
---|
| 700 | platformtype2 = PlatformType::STATIC; |
---|
[10215] | 701 | break; |
---|
| 702 | case 7: |
---|
[11071] | 703 | platformtype1 = PlatformType::HMOVE; |
---|
| 704 | platformtype2 = PlatformType::HMOVE; |
---|
[10215] | 705 | break; |
---|
| 706 | case 8: |
---|
[11071] | 707 | platformtype1 = PlatformType::HMOVE; |
---|
| 708 | platformtype2 = PlatformType::HMOVE; |
---|
[10215] | 709 | break; |
---|
| 710 | case 9: |
---|
[11071] | 711 | platformtype1 = PlatformType::HMOVE; |
---|
| 712 | platformtype2 = PlatformType::DISAPPEAR; |
---|
[10215] | 713 | break; |
---|
| 714 | case 10: |
---|
[11071] | 715 | platformtype1 = PlatformType::HMOVE; |
---|
| 716 | platformtype2 = PlatformType::VMOVE; |
---|
[10215] | 717 | break; |
---|
| 718 | case 11: |
---|
[11071] | 719 | platformtype1 = PlatformType::HMOVE; |
---|
| 720 | platformtype2 = PlatformType::TIMER; |
---|
[10215] | 721 | break; |
---|
| 722 | case 12: |
---|
[11071] | 723 | platformtype1 = PlatformType::DISAPPEAR; |
---|
| 724 | platformtype2 = PlatformType::STATIC; |
---|
[10215] | 725 | break; |
---|
| 726 | case 13: |
---|
[11071] | 727 | platformtype1 = PlatformType::DISAPPEAR; |
---|
| 728 | platformtype2 = PlatformType::HMOVE; |
---|
[10215] | 729 | break; |
---|
| 730 | case 14: |
---|
[11071] | 731 | platformtype1 = PlatformType::DISAPPEAR; |
---|
| 732 | platformtype2 = PlatformType::DISAPPEAR; |
---|
[10215] | 733 | break; |
---|
| 734 | case 15: |
---|
[11071] | 735 | platformtype1 = PlatformType::DISAPPEAR; |
---|
| 736 | platformtype2 = PlatformType::DISAPPEAR; |
---|
[10215] | 737 | break; |
---|
| 738 | case 16: |
---|
[11071] | 739 | platformtype1 = PlatformType::DISAPPEAR; |
---|
| 740 | platformtype2 = PlatformType::VMOVE; |
---|
[10215] | 741 | break; |
---|
| 742 | case 17: |
---|
[11071] | 743 | platformtype1 = PlatformType::DISAPPEAR; |
---|
| 744 | platformtype2 = PlatformType::TIMER; |
---|
[10215] | 745 | break; |
---|
| 746 | case 18: |
---|
[11071] | 747 | platformtype1 = PlatformType::VMOVE; |
---|
| 748 | platformtype2 = PlatformType::STATIC; |
---|
[10215] | 749 | break; |
---|
| 750 | case 19: |
---|
[11071] | 751 | platformtype1 = PlatformType::VMOVE; |
---|
| 752 | platformtype2 = PlatformType::HMOVE; |
---|
[10215] | 753 | break; |
---|
| 754 | case 20: |
---|
[11071] | 755 | platformtype1 = PlatformType::VMOVE; |
---|
| 756 | platformtype2 = PlatformType::DISAPPEAR; |
---|
[10215] | 757 | break; |
---|
| 758 | case 21: |
---|
[11071] | 759 | platformtype1 = PlatformType::VMOVE; |
---|
| 760 | platformtype2 = PlatformType::VMOVE; |
---|
[10215] | 761 | break; |
---|
| 762 | case 22: |
---|
[11071] | 763 | platformtype1 = PlatformType::VMOVE; |
---|
| 764 | platformtype2 = PlatformType::VMOVE; |
---|
[10215] | 765 | break; |
---|
| 766 | case 23: |
---|
[11071] | 767 | platformtype1 = PlatformType::VMOVE; |
---|
| 768 | platformtype2 = PlatformType::TIMER; |
---|
[10215] | 769 | break; |
---|
| 770 | case 24: |
---|
[11071] | 771 | platformtype1 = PlatformType::TIMER; |
---|
| 772 | platformtype2 = PlatformType::STATIC; |
---|
[10215] | 773 | break; |
---|
| 774 | case 25: |
---|
[11071] | 775 | platformtype1 = PlatformType::TIMER; |
---|
| 776 | platformtype2 = PlatformType::HMOVE; |
---|
[10215] | 777 | break; |
---|
| 778 | case 26: |
---|
[11071] | 779 | platformtype1 = PlatformType::TIMER; |
---|
| 780 | platformtype2 = PlatformType::DISAPPEAR; |
---|
[10215] | 781 | break; |
---|
| 782 | case 27: |
---|
[11071] | 783 | platformtype1 = PlatformType::TIMER; |
---|
| 784 | platformtype2 = PlatformType::VMOVE; |
---|
[10215] | 785 | break; |
---|
| 786 | case 28: |
---|
[11071] | 787 | platformtype1 = PlatformType::TIMER; |
---|
| 788 | platformtype2 = PlatformType::TIMER; |
---|
[10215] | 789 | break; |
---|
| 790 | default: |
---|
[11071] | 791 | platformtype1 = PlatformType::TIMER; |
---|
| 792 | platformtype2 = PlatformType::TIMER; |
---|
[10215] | 793 | break; |
---|
| 794 | } |
---|
[10078] | 795 | |
---|
[10215] | 796 | // Fill matrix with selected platform types |
---|
| 797 | for (int i = 0; i < numI; ++ i) |
---|
| 798 | { |
---|
| 799 | for (int j = 0; j < numJ; ++ j) |
---|
| 800 | { |
---|
| 801 | if (rand()%3 == 0) |
---|
| 802 | { |
---|
| 803 | matrix[i][j].type = platformtype1; |
---|
| 804 | } |
---|
| 805 | else |
---|
| 806 | { |
---|
| 807 | matrix[i][j].type = platformtype2; |
---|
| 808 | } |
---|
| 809 | matrix[i][j].done = false; |
---|
| 810 | } |
---|
| 811 | } |
---|
[10078] | 812 | |
---|
[10215] | 813 | if (platformtype1 == platformtype2 && sectionNumber_ > 10 && rand()%2 == 0) |
---|
| 814 | { |
---|
[11071] | 815 | matrix[rand()%numI][rand()%numJ].type = PlatformType::EMPTY; |
---|
| 816 | matrix[rand()%numI][rand()%numJ].type = PlatformType::EMPTY; |
---|
[10215] | 817 | } |
---|
[10078] | 818 | |
---|
[10215] | 819 | // Delete some planned platforms or replace them with fake platforms |
---|
| 820 | if (sectionNumber_ > 5) |
---|
| 821 | { |
---|
| 822 | if (rand()%2 == 0) |
---|
| 823 | { |
---|
[11071] | 824 | matrix[rand()%numI][rand()%numJ].type = PlatformType::EMPTY; |
---|
[10215] | 825 | } |
---|
| 826 | else |
---|
| 827 | { |
---|
[11071] | 828 | matrix[rand()%numI][rand()%numJ].type = PlatformType::FAKE; |
---|
[10215] | 829 | } |
---|
| 830 | } |
---|
| 831 | else if (sectionNumber_ > 10) |
---|
| 832 | { |
---|
| 833 | if (rand()%2 == 0) |
---|
| 834 | { |
---|
[11071] | 835 | matrix[rand()%numI][rand()%numJ].type = PlatformType::EMPTY; |
---|
[10215] | 836 | } |
---|
| 837 | else |
---|
| 838 | { |
---|
[11071] | 839 | matrix[rand()%numI][rand()%numJ].type = PlatformType::FAKE; |
---|
[10215] | 840 | } |
---|
| 841 | if (rand()%2 == 0) |
---|
| 842 | { |
---|
[11071] | 843 | matrix[rand()%numI][rand()%numJ].type = PlatformType::EMPTY; |
---|
[10215] | 844 | } |
---|
| 845 | else |
---|
| 846 | { |
---|
[11071] | 847 | matrix[rand()%numI][rand()%numJ].type = PlatformType::FAKE; |
---|
[10215] | 848 | } |
---|
| 849 | } |
---|
| 850 | else if (sectionNumber_ > 15) |
---|
| 851 | { |
---|
| 852 | if (rand()%2 == 0) |
---|
| 853 | { |
---|
[11071] | 854 | matrix[rand()%numI][rand()%numJ].type = PlatformType::EMPTY; |
---|
[10215] | 855 | } |
---|
| 856 | else |
---|
| 857 | { |
---|
[11071] | 858 | matrix[rand()%numI][rand()%numJ].type = PlatformType::FAKE; |
---|
[10215] | 859 | } |
---|
| 860 | if (rand()%2 == 0) |
---|
| 861 | { |
---|
[11071] | 862 | matrix[rand()%numI][rand()%numJ].type = PlatformType::EMPTY; |
---|
[10215] | 863 | } |
---|
| 864 | else |
---|
| 865 | { |
---|
[11071] | 866 | matrix[rand()%numI][rand()%numJ].type = PlatformType::FAKE; |
---|
[10215] | 867 | } |
---|
| 868 | if (rand()%2 == 0) |
---|
| 869 | { |
---|
[11071] | 870 | matrix[rand()%numI][rand()%numJ].type = PlatformType::EMPTY; |
---|
[10215] | 871 | } |
---|
| 872 | else |
---|
| 873 | { |
---|
[11071] | 874 | matrix[rand()%numI][rand()%numJ].type = PlatformType::FAKE; |
---|
[10215] | 875 | } |
---|
| 876 | } |
---|
[10078] | 877 | |
---|
[10215] | 878 | std::vector<JumpPlatform*> platformList; |
---|
[10078] | 879 | |
---|
[10215] | 880 | for (int i = 0; i < numI; ++ i) |
---|
| 881 | { |
---|
| 882 | for (int j = 0; j < numJ; ++ j) |
---|
| 883 | { |
---|
| 884 | if (matrix[i][j].done == false) |
---|
| 885 | { |
---|
| 886 | float xPosition = 0.0; |
---|
| 887 | float zPosition = 0.0; |
---|
| 888 | float leftBoundary = 0.0; |
---|
| 889 | float rightBoundary = 0.0; |
---|
| 890 | float lowerBoundary = 0.0; |
---|
| 891 | float upperBoundary = 0.0; |
---|
| 892 | float xVelocity = 0.0; |
---|
| 893 | float zVelocity = 0.0; |
---|
[10078] | 894 | |
---|
[10215] | 895 | switch(matrix[i][j].type) |
---|
| 896 | { |
---|
[11071] | 897 | case PlatformType::EMPTY: |
---|
[10215] | 898 | matrix[i][j].done = true; |
---|
| 899 | break; |
---|
[11071] | 900 | case PlatformType::STATIC: |
---|
[10215] | 901 | xPosition = randomXPosition(numJ, j); |
---|
| 902 | zPosition = sectionBegin + i*sectionLength/numI; |
---|
| 903 | platformList.push_back(addPlatformStatic(xPosition, zPosition)); |
---|
| 904 | matrix[i][j].done = true; |
---|
| 905 | break; |
---|
[11071] | 906 | case PlatformType::FAKE: |
---|
[10215] | 907 | xPosition = randomXPosition(numJ, j); |
---|
| 908 | zPosition = sectionBegin + i*sectionLength/numI; |
---|
| 909 | platformList.push_back(addPlatformFake(xPosition, zPosition)); |
---|
| 910 | matrix[i][j].done = true; |
---|
| 911 | break; |
---|
[11071] | 912 | case PlatformType::TIMER: |
---|
[10215] | 913 | xPosition = randomXPosition(numJ, j); |
---|
| 914 | zPosition = sectionBegin + i*sectionLength/numI; |
---|
| 915 | platformList.push_back(addPlatformTimer(xPosition, zPosition, 12.0, 1.5)); |
---|
| 916 | matrix[i][j].done = true; |
---|
| 917 | break; |
---|
[11071] | 918 | case PlatformType::DISAPPEAR: |
---|
[10215] | 919 | xPosition = randomXPosition(numJ, j); |
---|
| 920 | zPosition = sectionBegin + i*sectionLength/numI; |
---|
| 921 | platformList.push_back(addPlatformDisappear(xPosition, zPosition)); |
---|
| 922 | matrix[i][j].done = true; |
---|
| 923 | break; |
---|
[11071] | 924 | case PlatformType::HMOVE: |
---|
[10215] | 925 | xVelocity = randomSpeed(); |
---|
[11071] | 926 | if (j <= numJ-3 && matrix[i][j+1].type == PlatformType::HMOVE && matrix[i][j+2].type == PlatformType::HMOVE && rand()%2 == 0) |
---|
[10215] | 927 | { |
---|
| 928 | leftBoundary = randomXPositionLeft(numJ, j); |
---|
| 929 | rightBoundary = randomXPositionRight(numJ, j+2); |
---|
| 930 | xPosition = randomPosition(leftBoundary, rightBoundary); |
---|
| 931 | zPosition = sectionBegin + i*sectionLength/numI; |
---|
| 932 | platformList.push_back(addPlatformHMove(xPosition, zPosition, leftBoundary, rightBoundary, xVelocity)); |
---|
| 933 | matrix[i][j].done = true; |
---|
| 934 | matrix[i][j+1].done = true; |
---|
| 935 | matrix[i][j+2].done = true; |
---|
| 936 | } |
---|
[11071] | 937 | else if (j <= numJ-2 && matrix[i][j+1].type == PlatformType::HMOVE && rand()%2 == 0) |
---|
[10215] | 938 | { |
---|
| 939 | leftBoundary = randomXPositionLeft(numJ, j); |
---|
| 940 | rightBoundary = randomXPositionRight(numJ, j+1); |
---|
| 941 | xPosition = randomPosition(leftBoundary, rightBoundary); |
---|
| 942 | zPosition = sectionBegin + i*sectionLength/numI; |
---|
| 943 | platformList.push_back(addPlatformHMove(xPosition, zPosition, leftBoundary, rightBoundary, xVelocity)); |
---|
| 944 | matrix[i][j].done = true; |
---|
| 945 | matrix[i][j+1].done = true; |
---|
| 946 | } |
---|
| 947 | else |
---|
| 948 | { |
---|
| 949 | leftBoundary = randomXPositionLeft(numJ, j); |
---|
| 950 | rightBoundary = randomXPositionRight(numJ, j); |
---|
| 951 | xPosition = randomPosition(leftBoundary, rightBoundary); |
---|
| 952 | zPosition = sectionBegin + i*sectionLength/numI; |
---|
| 953 | platformList.push_back(addPlatformHMove(xPosition, zPosition, leftBoundary, rightBoundary, xVelocity)); |
---|
| 954 | matrix[i][j].done = true; |
---|
| 955 | } |
---|
| 956 | break; |
---|
[11071] | 957 | case PlatformType::VMOVE: |
---|
[10215] | 958 | zVelocity = randomSpeed(); |
---|
[11071] | 959 | if (i <= numI-3 && matrix[i+1][j].type == PlatformType::VMOVE && matrix[i+2][j].type == PlatformType::VMOVE && rand()%2 == 0) |
---|
[10215] | 960 | { |
---|
| 961 | lowerBoundary = randomZPositionLower(numI, i, sectionBegin, sectionEnd); |
---|
| 962 | upperBoundary = randomZPositionUpper(numI, i+2, sectionBegin, sectionEnd); |
---|
| 963 | zPosition = randomPosition(lowerBoundary, upperBoundary); |
---|
| 964 | xPosition = randomXPosition(numJ, j); |
---|
| 965 | platformList.push_back(addPlatformVMove(xPosition, zPosition, lowerBoundary, upperBoundary, zVelocity)); |
---|
| 966 | matrix[i][j].done = true; |
---|
| 967 | matrix[i+1][j].done = true; |
---|
| 968 | matrix[i+2][j].done = true; |
---|
| 969 | } |
---|
[11071] | 970 | else if (i <= numI-2 && matrix[i+1][j].type == PlatformType::VMOVE && rand()%2 == 0) |
---|
[10215] | 971 | { |
---|
| 972 | lowerBoundary = randomZPositionLower(numI, i, sectionBegin, sectionEnd); |
---|
| 973 | upperBoundary = randomZPositionUpper(numI, i+1, sectionBegin, sectionEnd); |
---|
| 974 | zPosition = randomPosition(lowerBoundary, upperBoundary); |
---|
| 975 | xPosition = randomXPosition(numJ, j); |
---|
| 976 | platformList.push_back(addPlatformVMove(xPosition, zPosition, lowerBoundary, upperBoundary, zVelocity)); |
---|
| 977 | matrix[i][j].done = true; |
---|
| 978 | matrix[i+1][j].done = true; |
---|
| 979 | } |
---|
| 980 | else |
---|
| 981 | { |
---|
| 982 | lowerBoundary = randomZPositionLower(numI, i, sectionBegin, sectionEnd); |
---|
| 983 | upperBoundary = randomZPositionUpper(numI, i, sectionBegin, sectionEnd); |
---|
| 984 | zPosition = randomPosition(lowerBoundary, upperBoundary); |
---|
| 985 | xPosition = randomXPosition(numJ, j); |
---|
| 986 | platformList.push_back(addPlatformVMove(xPosition, zPosition, lowerBoundary, upperBoundary, zVelocity)); |
---|
| 987 | matrix[i][j].done = true; |
---|
| 988 | } |
---|
| 989 | break; |
---|
| 990 | default: |
---|
| 991 | //ERROR |
---|
| 992 | break; |
---|
[10078] | 993 | |
---|
[10215] | 994 | } |
---|
| 995 | } |
---|
| 996 | } |
---|
| 997 | } |
---|
[10078] | 998 | |
---|
[10215] | 999 | //Add items |
---|
| 1000 | int numNewPlatforms = platformList.size(); |
---|
[10078] | 1001 | |
---|
[10215] | 1002 | if (rand()%4 == 0) |
---|
| 1003 | { |
---|
| 1004 | if (rand()%2 == 0) |
---|
| 1005 | { |
---|
| 1006 | switch (itemType) |
---|
| 1007 | { |
---|
[11071] | 1008 | case ItemType::ROCKET: |
---|
[10215] | 1009 | addRocket(0.0, randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/2, fieldWidth/2, 0.0, 0.0, randomSpeed(), 0.0); |
---|
| 1010 | break; |
---|
[11071] | 1011 | case ItemType::PROPELLER: |
---|
[10215] | 1012 | addPropeller(0.0, randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/2, fieldWidth/2, 0.0, 0.0, randomSpeed(), 0.0); |
---|
| 1013 | break; |
---|
[11071] | 1014 | case ItemType::BOOTS: |
---|
[10215] | 1015 | addBoots(0.0, randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/2, fieldWidth/2, 0.0, 0.0, randomSpeed(), 0.0); |
---|
| 1016 | break; |
---|
[11071] | 1017 | case ItemType::SHIELD: |
---|
[10215] | 1018 | addShield(0.0, randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/2, fieldWidth/2, 0.0, 0.0, randomSpeed(), 0.0); |
---|
| 1019 | break; |
---|
| 1020 | default: |
---|
| 1021 | break; |
---|
| 1022 | } |
---|
| 1023 | } |
---|
| 1024 | else |
---|
| 1025 | { |
---|
| 1026 | switch (itemType) |
---|
| 1027 | { |
---|
[11071] | 1028 | case ItemType::ROCKET: |
---|
[10215] | 1029 | addRocket(randomPosition(-fieldWidth/2, fieldWidth/2), sectionBegin + sectionLength/2, 0.0, 0.0, sectionBegin, sectionEnd, 0.0, randomSpeed()); |
---|
| 1030 | break; |
---|
[11071] | 1031 | case ItemType::PROPELLER: |
---|
[10215] | 1032 | addPropeller(randomPosition(-fieldWidth/2, fieldWidth/2), sectionBegin + sectionLength/2, 0.0, 0.0, sectionBegin, sectionEnd, 0.0, randomSpeed()); |
---|
| 1033 | break; |
---|
[11071] | 1034 | case ItemType::BOOTS: |
---|
[10215] | 1035 | addBoots(randomPosition(-fieldWidth/2, fieldWidth/2), sectionBegin + sectionLength/2, 0.0, 0.0, sectionBegin, sectionEnd, 0.0, randomSpeed()); |
---|
| 1036 | break; |
---|
[11071] | 1037 | case ItemType::SHIELD: |
---|
[10215] | 1038 | addShield(randomPosition(-fieldWidth/2, fieldWidth/2), sectionBegin + sectionLength/2, 0.0, 0.0, sectionBegin, sectionEnd, 0.0, randomSpeed()); |
---|
| 1039 | break; |
---|
| 1040 | default: |
---|
| 1041 | break; |
---|
| 1042 | } |
---|
| 1043 | } |
---|
| 1044 | } |
---|
| 1045 | else |
---|
| 1046 | { |
---|
| 1047 | if (numNewPlatforms > 0) |
---|
| 1048 | { |
---|
| 1049 | JumpPlatform* itemPlatform = platformList[rand()%numNewPlatforms]; |
---|
[10078] | 1050 | |
---|
[10215] | 1051 | switch (itemType) |
---|
| 1052 | { |
---|
[11071] | 1053 | case ItemType::SPRING: |
---|
[10215] | 1054 | addSpring(itemPlatform); |
---|
| 1055 | break; |
---|
[11071] | 1056 | case ItemType::ROCKET: |
---|
[10215] | 1057 | addRocket(itemPlatform); |
---|
| 1058 | break; |
---|
[11071] | 1059 | case ItemType::PROPELLER: |
---|
[10215] | 1060 | addPropeller(itemPlatform); |
---|
| 1061 | break; |
---|
[11071] | 1062 | case ItemType::BOOTS: |
---|
[10215] | 1063 | addBoots(itemPlatform); |
---|
| 1064 | break; |
---|
[11071] | 1065 | case ItemType::SHIELD: |
---|
[10215] | 1066 | addShield(itemPlatform); |
---|
| 1067 | break; |
---|
| 1068 | default: |
---|
| 1069 | break; |
---|
| 1070 | } |
---|
| 1071 | } |
---|
| 1072 | } |
---|
[10078] | 1073 | |
---|
| 1074 | if (sectionNumber_ >= 5 && rand()%3 == 0) |
---|
| 1075 | { |
---|
[10215] | 1076 | switch(rand()%4) |
---|
| 1077 | { |
---|
[10078] | 1078 | case 0: |
---|
[10215] | 1079 | addEnemy(1, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/3*2, fieldWidth/3*2, sectionBegin, sectionBegin + sectionLength, randomSpeed(), 0.0); |
---|
| 1080 | break; |
---|
[10078] | 1081 | case 1: |
---|
[10215] | 1082 | addEnemy(2, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/3*2, fieldWidth/3*2, sectionBegin, sectionBegin + sectionLength, randomSpeed(), 0.0); |
---|
| 1083 | break; |
---|
[10078] | 1084 | case 2: |
---|
[10215] | 1085 | addEnemy(3, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/3*2, fieldWidth/3*2, sectionBegin, sectionBegin + sectionLength, randomSpeed(), 0.0); |
---|
| 1086 | break; |
---|
[10078] | 1087 | case 3: |
---|
[10215] | 1088 | addEnemy(4, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/3*2, fieldWidth/3*2, sectionBegin, sectionBegin + sectionLength, randomSpeed(), 0.0); |
---|
| 1089 | break; |
---|
| 1090 | } |
---|
[10078] | 1091 | } |
---|
[10215] | 1092 | ++ sectionNumber_; |
---|
[10078] | 1093 | } |
---|
| 1094 | |
---|
| 1095 | bool Jump::addAdventure(int number) |
---|
| 1096 | { |
---|
| 1097 | float fieldWidth = center_->getFieldDimension().x; |
---|
| 1098 | float sectionLength = center_->getSectionLength(); |
---|
| 1099 | float sectionBegin = sectionNumber_ * sectionLength; |
---|
| 1100 | sectionLength *= 2; |
---|
| 1101 | |
---|
| 1102 | switch(number) |
---|
| 1103 | { |
---|
| 1104 | case 0: |
---|
[10215] | 1105 | { |
---|
| 1106 | int numI = 10; |
---|
| 1107 | if (rand()%2 == 0) |
---|
| 1108 | { |
---|
| 1109 | for (int i = 0; i < numI; ++ i) |
---|
| 1110 | { |
---|
| 1111 | addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth+platformWidth_/2, sectionBegin+i*sectionLength/numI); |
---|
| 1112 | } |
---|
| 1113 | } |
---|
| 1114 | else |
---|
| 1115 | { |
---|
| 1116 | for (int i = 0; i < numI; ++ i) |
---|
| 1117 | { |
---|
| 1118 | addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth+platformWidth_/2, sectionBegin+(numI-i)*sectionLength/numI); |
---|
| 1119 | } |
---|
| 1120 | } |
---|
| 1121 | break; |
---|
| 1122 | } |
---|
[10078] | 1123 | case 1: |
---|
[10215] | 1124 | { |
---|
| 1125 | int numI = 7; |
---|
[10078] | 1126 | |
---|
[10215] | 1127 | addPlatformStatic(0.0, sectionBegin); |
---|
| 1128 | if (rand()%2 == 0) |
---|
| 1129 | { |
---|
| 1130 | for (int i = 1; i < numI; ++ i) |
---|
| 1131 | { |
---|
| 1132 | addPlatformStatic((fieldWidth-platformWidth_/2)*i/numI, sectionBegin+i*sectionLength/numI); |
---|
| 1133 | addPlatformStatic(-(fieldWidth-platformWidth_/2)*i/numI, sectionBegin+i*sectionLength/numI); |
---|
| 1134 | } |
---|
| 1135 | } |
---|
| 1136 | else |
---|
| 1137 | { |
---|
| 1138 | for (int i = 1; i < numI; ++ i) |
---|
| 1139 | { |
---|
| 1140 | addPlatformStatic((fieldWidth-platformWidth_/2)*i/numI, sectionBegin+(numI-i)*sectionLength/numI); |
---|
| 1141 | addPlatformStatic(-(fieldWidth-platformWidth_/2)*i/numI, sectionBegin+(numI-i)*sectionLength/numI); |
---|
| 1142 | } |
---|
| 1143 | } |
---|
| 1144 | break; |
---|
| 1145 | } |
---|
[10078] | 1146 | case 2: |
---|
[10215] | 1147 | { |
---|
| 1148 | int numI = 5; |
---|
| 1149 | for (int i = 0; i <= numI; ++ i) |
---|
| 1150 | { |
---|
| 1151 | addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth, sectionBegin); |
---|
| 1152 | addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth, sectionBegin+sectionLength/5); |
---|
| 1153 | addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth, sectionBegin+sectionLength*2/5); |
---|
| 1154 | addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth, sectionBegin+sectionLength*3/5); |
---|
| 1155 | addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth, sectionBegin+sectionLength*4/5); |
---|
| 1156 | addEnemy(4, (2*fieldWidth-platformWidth_)*i/numI-fieldWidth+platformWidth_/2, sectionBegin+sectionLength/2, -fieldWidth, fieldWidth, sectionBegin, sectionBegin + sectionLength, 0.0, 0.0); |
---|
| 1157 | } |
---|
| 1158 | break; |
---|
| 1159 | } |
---|
[10078] | 1160 | case 3: |
---|
[10215] | 1161 | { |
---|
| 1162 | addRocket(addPlatformStatic(0.0, sectionBegin)); |
---|
| 1163 | addEnemy(2, 0.0, sectionBegin+sectionLength/5, 0.0,0.0, 0.0, 0.0, 0.0, 0.0); |
---|
| 1164 | break; |
---|
| 1165 | } |
---|
[10078] | 1166 | case 4: |
---|
[10215] | 1167 | { |
---|
| 1168 | addPropeller(addPlatformStatic(0.0, sectionBegin)); |
---|
| 1169 | addPropeller(addPlatformStatic(-fieldWidth/2, sectionBegin)); |
---|
| 1170 | addPropeller(addPlatformStatic(fieldWidth/2, sectionBegin)); |
---|
| 1171 | break; |
---|
| 1172 | } |
---|
[10078] | 1173 | default: |
---|
[10215] | 1174 | return false; |
---|
[10078] | 1175 | } |
---|
| 1176 | sectionNumber_ +=2; |
---|
| 1177 | return true; |
---|
| 1178 | } |
---|
| 1179 | |
---|
| 1180 | float Jump::randomXPosition() |
---|
| 1181 | { |
---|
| 1182 | float fieldWidth = center_->getFieldDimension().x; |
---|
| 1183 | |
---|
[10215] | 1184 | return (float)(rand()%(2*(int)fieldWidth)) - fieldWidth; |
---|
[10078] | 1185 | } |
---|
| 1186 | |
---|
| 1187 | float Jump::randomXPosition(int totalColumns, int culomn) |
---|
| 1188 | { |
---|
[10215] | 1189 | float fieldWidth = center_->getFieldDimension().x; |
---|
[10078] | 1190 | |
---|
[10215] | 1191 | float halfWidth = fieldWidth/totalColumns; |
---|
| 1192 | float leftBound = culomn*halfWidth*2-fieldWidth; |
---|
| 1193 | float rightBound = leftBound + 2*halfWidth; |
---|
[10078] | 1194 | |
---|
[10215] | 1195 | return randomPosition(leftBound+platformWidth_/2, rightBound-platformWidth_/2); |
---|
[10078] | 1196 | } |
---|
| 1197 | |
---|
| 1198 | float Jump::randomXPositionLeft(int totalColumns, int culomn) |
---|
| 1199 | { |
---|
[10215] | 1200 | float fieldWidth = center_->getFieldDimension().x; |
---|
[10078] | 1201 | |
---|
[10215] | 1202 | float halfWidth = fieldWidth/totalColumns; |
---|
| 1203 | float leftBound = culomn*halfWidth*2-fieldWidth; |
---|
| 1204 | float rightBound = leftBound + 2*halfWidth/3; |
---|
[10078] | 1205 | |
---|
[10215] | 1206 | return randomPosition(leftBound+platformWidth_/2, rightBound-platformWidth_/2); |
---|
[10078] | 1207 | } |
---|
| 1208 | |
---|
| 1209 | float Jump::randomXPositionRight(int totalColumns, int culomn) |
---|
| 1210 | { |
---|
[10215] | 1211 | float fieldWidth = center_->getFieldDimension().x; |
---|
[10078] | 1212 | |
---|
[10215] | 1213 | float halfWidth = fieldWidth/totalColumns; |
---|
| 1214 | float rightBound = (culomn+1)*halfWidth*2-fieldWidth; |
---|
| 1215 | float leftBound = rightBound - 2*halfWidth/3; |
---|
| 1216 | return randomPosition(leftBound+platformWidth_/2, rightBound-platformWidth_/2); |
---|
[10078] | 1217 | } |
---|
| 1218 | |
---|
| 1219 | float Jump::randomZPosition(int totalRows, int row, float sectionBegin, float SectionEnd) |
---|
| 1220 | { |
---|
[10215] | 1221 | float fieldHeight = SectionEnd - sectionBegin; |
---|
| 1222 | float halfHeight = fieldHeight/totalRows; |
---|
| 1223 | float lowerBound = row*halfHeight*2+sectionBegin; |
---|
| 1224 | float upperBound = lowerBound + 2*halfHeight; |
---|
[10078] | 1225 | |
---|
[10215] | 1226 | return randomPosition(lowerBound+platformHeight_/2, upperBound-platformHeight_/2); |
---|
[10078] | 1227 | } |
---|
| 1228 | |
---|
| 1229 | float Jump::randomZPositionLower(int totalRows, int row, float sectionBegin, float SectionEnd) |
---|
| 1230 | { |
---|
[10215] | 1231 | float fieldHeight = SectionEnd - sectionBegin; |
---|
| 1232 | float rowHeight = fieldHeight/totalRows; |
---|
| 1233 | float lowerBound = row*rowHeight+sectionBegin; |
---|
| 1234 | float upperBound = lowerBound + rowHeight/3; |
---|
[10078] | 1235 | |
---|
[10215] | 1236 | return randomPosition(lowerBound+platformHeight_/2, upperBound-platformHeight_/2); |
---|
[10078] | 1237 | } |
---|
| 1238 | |
---|
| 1239 | float Jump::randomZPositionUpper(int totalRows, int row, float sectionBegin, float SectionEnd) |
---|
| 1240 | { |
---|
[10215] | 1241 | float fieldHeight = SectionEnd - sectionBegin; |
---|
| 1242 | float rowHeight = fieldHeight/totalRows; |
---|
| 1243 | float lowerBound = (row+1)*rowHeight+sectionBegin; |
---|
| 1244 | float upperBound = lowerBound - rowHeight/3; |
---|
[10078] | 1245 | |
---|
[10215] | 1246 | return randomPosition(lowerBound+platformHeight_/2, upperBound-platformHeight_/2); |
---|
[10078] | 1247 | } |
---|
| 1248 | |
---|
| 1249 | float Jump::randomPosition(float lowerBoundary, float upperBoundary) |
---|
| 1250 | { |
---|
[10215] | 1251 | if (lowerBoundary >= upperBoundary) |
---|
| 1252 | { |
---|
| 1253 | return (lowerBoundary + upperBoundary)/2; |
---|
| 1254 | } |
---|
[10078] | 1255 | |
---|
[10215] | 1256 | return (float)(rand()%(int)(100*(upperBoundary - lowerBoundary)))/100 + lowerBoundary; |
---|
[10078] | 1257 | } |
---|
| 1258 | |
---|
| 1259 | float Jump::randomSpeed() |
---|
| 1260 | { |
---|
[10215] | 1261 | float platformSpeed = center_->getPlatformSpeed(); |
---|
[10218] | 1262 | return randomPosition(0.5f*platformSpeed, 1.5f*platformSpeed); |
---|
[10078] | 1263 | } |
---|
| 1264 | |
---|
| 1265 | int Jump::getScore(PlayerInfo* player) const |
---|
| 1266 | { |
---|
| 1267 | return sectionNumber_ - 2; |
---|
| 1268 | } |
---|
| 1269 | |
---|
[10260] | 1270 | float Jump::getFuel() const |
---|
| 1271 | { |
---|
[11071] | 1272 | if (this->figure_ != nullptr) |
---|
[10260] | 1273 | { |
---|
[11071] | 1274 | if (this->figure_->rocketActive_ != nullptr) |
---|
[10260] | 1275 | { |
---|
| 1276 | return this->figure_->rocketActive_->getFuelState(); |
---|
| 1277 | } |
---|
[11071] | 1278 | else if (this->figure_->propellerActive_ != nullptr) |
---|
[10260] | 1279 | { |
---|
| 1280 | return this->figure_->propellerActive_->getFuelState(); |
---|
| 1281 | } |
---|
[11071] | 1282 | else if (this->figure_->shieldActive_ != nullptr) |
---|
[10260] | 1283 | { |
---|
| 1284 | return this->figure_->shieldActive_->getFuelState(); |
---|
| 1285 | } |
---|
[11071] | 1286 | else if (this->figure_->bootsActive_ != nullptr) |
---|
[10260] | 1287 | { |
---|
| 1288 | return this->figure_->bootsActive_->getFuelState(); |
---|
| 1289 | } |
---|
| 1290 | } |
---|
| 1291 | |
---|
| 1292 | return 0.0; |
---|
| 1293 | } |
---|
| 1294 | |
---|
[10078] | 1295 | bool Jump::getDead(PlayerInfo* player) const |
---|
| 1296 | { |
---|
| 1297 | return figure_->dead_; |
---|
| 1298 | } |
---|
[11071] | 1299 | |
---|
| 1300 | void Jump::setCenterpoint(JumpCenterpoint* center) |
---|
| 1301 | { |
---|
| 1302 | center_ = center; |
---|
| 1303 | } |
---|
| 1304 | |
---|
[10078] | 1305 | } |
---|