[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" |
---|
[11356] | 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(); |
---|
[11716] | 314 | if (Highscore::exists()) |
---|
| 315 | { |
---|
| 316 | int score = this->getScore(this->getPlayer()); |
---|
| 317 | Highscore::getInstance().storeScore("Jump", score, this->getPlayer()); |
---|
| 318 | } |
---|
[10078] | 319 | Deathmatch::end(); |
---|
| 320 | } |
---|
| 321 | |
---|
| 322 | void Jump::spawnPlayer(PlayerInfo* player) |
---|
| 323 | { |
---|
| 324 | assert(player); |
---|
| 325 | |
---|
[11071] | 326 | if (figure_->getPlayer() == nullptr) |
---|
[10078] | 327 | { |
---|
| 328 | player->startControl(figure_); |
---|
| 329 | players_[player].state_ = PlayerState::Alive; |
---|
| 330 | } |
---|
| 331 | } |
---|
| 332 | |
---|
| 333 | PlayerInfo* Jump::getPlayer() const |
---|
| 334 | { |
---|
[11071] | 335 | if (this->figure_ != nullptr) |
---|
[10078] | 336 | { |
---|
| 337 | return this->figure_->getPlayer(); |
---|
| 338 | } |
---|
| 339 | else |
---|
| 340 | { |
---|
[11071] | 341 | return nullptr; |
---|
[10078] | 342 | } |
---|
| 343 | } |
---|
| 344 | |
---|
| 345 | void Jump::addPlatform(JumpPlatform* newPlatform, std::string platformTemplate, float xPosition, float zPosition) |
---|
| 346 | { |
---|
[11071] | 347 | if (newPlatform != nullptr && center_ != nullptr) |
---|
[10215] | 348 | { |
---|
| 349 | newPlatform->addTemplate(platformTemplate); |
---|
| 350 | newPlatform->setPosition(Vector3(xPosition, 0.0, zPosition)); |
---|
| 351 | newPlatform->setFigure(this->figure_); |
---|
| 352 | center_->attach(newPlatform); |
---|
| 353 | } |
---|
[10078] | 354 | } |
---|
| 355 | |
---|
| 356 | JumpPlatformStatic* Jump::addPlatformStatic(float xPosition, float zPosition) |
---|
| 357 | { |
---|
[10215] | 358 | JumpPlatformStatic* newPlatform = new JumpPlatformStatic(center_->getContext()); |
---|
| 359 | addPlatform(newPlatform, center_->getPlatformStaticTemplate(), xPosition, zPosition); |
---|
[10078] | 360 | |
---|
[10215] | 361 | return newPlatform; |
---|
[10078] | 362 | } |
---|
| 363 | |
---|
| 364 | JumpPlatformHMove* Jump::addPlatformHMove(float xPosition, float zPosition, float leftBoundary, float rightBoundary, float speed) |
---|
| 365 | { |
---|
[10215] | 366 | JumpPlatformHMove* newPlatform = new JumpPlatformHMove(center_->getContext()); |
---|
| 367 | newPlatform->setProperties(leftBoundary, rightBoundary, speed); |
---|
| 368 | addPlatform(newPlatform, center_->getPlatformHMoveTemplate(), xPosition, zPosition); |
---|
[10078] | 369 | |
---|
[10215] | 370 | return newPlatform; |
---|
[10078] | 371 | } |
---|
| 372 | |
---|
| 373 | JumpPlatformVMove* Jump::addPlatformVMove(float xPosition, float zPosition, float lowerBoundary, float upperBoundary, float speed) |
---|
| 374 | { |
---|
[10215] | 375 | JumpPlatformVMove* newPlatform = new JumpPlatformVMove(center_->getContext()); |
---|
| 376 | newPlatform->setProperties(lowerBoundary, upperBoundary, speed); |
---|
| 377 | addPlatform(newPlatform, center_->getPlatformVMoveTemplate(), xPosition, zPosition); |
---|
[10078] | 378 | |
---|
[10215] | 379 | return newPlatform; |
---|
[10078] | 380 | } |
---|
| 381 | |
---|
| 382 | JumpPlatformDisappear* Jump::addPlatformDisappear(float xPosition, float zPosition) |
---|
| 383 | { |
---|
[10215] | 384 | JumpPlatformDisappear* newPlatform = new JumpPlatformDisappear(center_->getContext()); |
---|
| 385 | newPlatform->setProperties(true); |
---|
| 386 | addPlatform(newPlatform, center_->getPlatformDisappearTemplate(), xPosition, zPosition); |
---|
[10078] | 387 | |
---|
[10215] | 388 | return newPlatform; |
---|
[10078] | 389 | } |
---|
| 390 | |
---|
| 391 | JumpPlatformTimer* Jump::addPlatformTimer(float xPosition, float zPosition, float time, float variance) |
---|
| 392 | { |
---|
[10261] | 393 | float additionalTime = (float)(rand()%100)/100.0f*variance - variance/2.0f; |
---|
[10078] | 394 | |
---|
[10215] | 395 | JumpPlatformTimer* newPlatform = new JumpPlatformTimer(center_->getContext()); |
---|
| 396 | newPlatform->setProperties(time + additionalTime); |
---|
| 397 | addPlatform(newPlatform, center_->getPlatformTimerTemplate(), xPosition, zPosition); |
---|
[10078] | 398 | |
---|
[10215] | 399 | return newPlatform; |
---|
[10078] | 400 | } |
---|
| 401 | |
---|
| 402 | JumpPlatformFake* Jump::addPlatformFake(float xPosition, float zPosition) |
---|
| 403 | { |
---|
[10215] | 404 | JumpPlatformFake* newPlatform = new JumpPlatformFake(center_->getContext()); |
---|
| 405 | addPlatform(newPlatform, center_->getPlatformFakeTemplate(), xPosition, zPosition); |
---|
| 406 | newPlatform->setAngularVelocity(Vector3(0, 0, 2.0)); |
---|
[10078] | 407 | |
---|
[10215] | 408 | return newPlatform; |
---|
[10078] | 409 | } |
---|
| 410 | |
---|
| 411 | |
---|
| 412 | void Jump::addProjectile(float xPosition, float zPosition) |
---|
| 413 | { |
---|
[10215] | 414 | JumpProjectile* newProjectile = new JumpProjectile(center_->getContext()); |
---|
[11071] | 415 | if (newProjectile != nullptr && center_ != nullptr) |
---|
[10215] | 416 | { |
---|
| 417 | newProjectile->addTemplate(center_->getProjectileTemplate()); |
---|
| 418 | newProjectile->setPosition(Vector3(xPosition, 0.0, zPosition)); |
---|
| 419 | newProjectile->setFieldDimension(center_->getFieldDimension()); |
---|
| 420 | newProjectile->setFigure(this->figure_); |
---|
| 421 | center_->attach(newProjectile); |
---|
| 422 | } |
---|
[10078] | 423 | } |
---|
| 424 | |
---|
| 425 | void Jump::addSpring(float xPosition, float zPosition, float leftBoundary, float rightBoundary, float lowerBoundary, float upperBoundary, float xVelocity, float zVelocity) |
---|
| 426 | { |
---|
[10215] | 427 | JumpSpring* newSpring = new JumpSpring(center_->getContext()); |
---|
[11071] | 428 | if (newSpring != nullptr && center_ != nullptr) |
---|
[10215] | 429 | { |
---|
| 430 | newSpring->addTemplate(center_->getSpringTemplate()); |
---|
| 431 | newSpring->setPosition(Vector3(xPosition, 0.0, zPosition)); |
---|
| 432 | newSpring->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity); |
---|
| 433 | newSpring->setFigure(figure_); |
---|
| 434 | center_->attach(newSpring); |
---|
| 435 | } |
---|
[10078] | 436 | } |
---|
| 437 | |
---|
| 438 | void Jump::addSpring(JumpPlatform* platform) |
---|
| 439 | { |
---|
[10215] | 440 | JumpSpring* newSpring = new JumpSpring(center_->getContext()); |
---|
[11071] | 441 | if (newSpring != nullptr && center_ != nullptr) |
---|
[10215] | 442 | { |
---|
| 443 | newSpring->addTemplate(center_->getSpringTemplate()); |
---|
| 444 | newSpring->setPosition(Vector3(0.0, 0.0, 0.0)); |
---|
| 445 | newSpring->setProperties(-10.0, 10.0, -10.0, 10.0, 0.0, 0.0); |
---|
| 446 | newSpring->setFigure(figure_); |
---|
| 447 | platform->attach(newSpring); |
---|
| 448 | } |
---|
[10078] | 449 | } |
---|
| 450 | |
---|
| 451 | void Jump::addRocket(float xPosition, float zPosition, float leftBoundary, float rightBoundary, float lowerBoundary, float upperBoundary, float xVelocity, float zVelocity) |
---|
| 452 | { |
---|
[10215] | 453 | JumpRocket* newRocket = new JumpRocket(center_->getContext()); |
---|
[11071] | 454 | if (newRocket != nullptr && center_ != nullptr) |
---|
[10215] | 455 | { |
---|
| 456 | newRocket->addTemplate(center_->getRocketTemplate()); |
---|
| 457 | newRocket->setPosition(Vector3(xPosition, 0.0, zPosition)); |
---|
| 458 | newRocket->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity); |
---|
| 459 | newRocket->setFigure(figure_); |
---|
| 460 | center_->attach(newRocket); |
---|
| 461 | } |
---|
[10078] | 462 | } |
---|
| 463 | |
---|
| 464 | void Jump::addRocket(JumpPlatform* platform) |
---|
| 465 | { |
---|
[10215] | 466 | JumpRocket* newRocket = new JumpRocket(center_->getContext()); |
---|
[11071] | 467 | if (newRocket != nullptr && center_ != nullptr) |
---|
[10215] | 468 | { |
---|
| 469 | newRocket->addTemplate(center_->getRocketTemplate()); |
---|
| 470 | newRocket->setPosition(Vector3(0.0, 0.0, 0.0)); |
---|
| 471 | newRocket->setProperties(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); |
---|
| 472 | newRocket->setFigure(figure_); |
---|
| 473 | platform->attach(newRocket); |
---|
| 474 | } |
---|
[10078] | 475 | } |
---|
| 476 | |
---|
| 477 | void Jump::addPropeller(float xPosition, float zPosition, float leftBoundary, float rightBoundary, float lowerBoundary, float upperBoundary, float xVelocity, float zVelocity) |
---|
| 478 | { |
---|
[10215] | 479 | JumpPropeller* newPropeller = new JumpPropeller(center_->getContext()); |
---|
[11071] | 480 | if (newPropeller != nullptr && center_ != nullptr) |
---|
[10215] | 481 | { |
---|
| 482 | newPropeller->addTemplate(center_->getPropellerTemplate()); |
---|
| 483 | newPropeller->setPosition(Vector3(xPosition, 0.0, zPosition)); |
---|
| 484 | newPropeller->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity); |
---|
| 485 | newPropeller->setFigure(figure_); |
---|
| 486 | center_->attach(newPropeller); |
---|
| 487 | } |
---|
[10078] | 488 | } |
---|
| 489 | |
---|
| 490 | void Jump::addPropeller(JumpPlatform* platform) |
---|
| 491 | { |
---|
[10215] | 492 | JumpPropeller* newPropeller = new JumpPropeller(center_->getContext()); |
---|
[11071] | 493 | if (newPropeller != nullptr && center_ != nullptr) |
---|
[10215] | 494 | { |
---|
| 495 | newPropeller->addTemplate(center_->getPropellerTemplate()); |
---|
| 496 | newPropeller->setPosition(Vector3(0.0, 0.0, 0.0)); |
---|
| 497 | newPropeller->setProperties(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); |
---|
| 498 | newPropeller->setFigure(figure_); |
---|
| 499 | platform->attach(newPropeller); |
---|
| 500 | } |
---|
[10078] | 501 | } |
---|
| 502 | |
---|
| 503 | void Jump::addBoots(float xPosition, float zPosition, float leftBoundary, float rightBoundary, float lowerBoundary, float upperBoundary, float xVelocity, float zVelocity) |
---|
| 504 | { |
---|
[10215] | 505 | JumpBoots* newBoots = new JumpBoots(center_->getContext()); |
---|
[11071] | 506 | if (newBoots != nullptr && center_ != nullptr) |
---|
[10215] | 507 | { |
---|
| 508 | newBoots->addTemplate(center_->getBootsTemplate()); |
---|
| 509 | newBoots->setPosition(Vector3(xPosition, 0.0, zPosition)); |
---|
| 510 | newBoots->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity); |
---|
| 511 | newBoots->setFigure(figure_); |
---|
| 512 | center_->attach(newBoots); |
---|
| 513 | } |
---|
[10078] | 514 | } |
---|
| 515 | |
---|
| 516 | void Jump::addBoots(JumpPlatform* platform) |
---|
| 517 | { |
---|
[10215] | 518 | JumpBoots* newBoots = new JumpBoots(center_->getContext()); |
---|
[11071] | 519 | if (newBoots != nullptr && center_ != nullptr) |
---|
[10215] | 520 | { |
---|
| 521 | newBoots->addTemplate(center_->getBootsTemplate()); |
---|
| 522 | newBoots->setPosition(Vector3(0.0, 0.0, 0.0)); |
---|
| 523 | newBoots->setProperties(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); |
---|
| 524 | newBoots->setFigure(figure_); |
---|
| 525 | platform->attach(newBoots); |
---|
| 526 | } |
---|
[10078] | 527 | } |
---|
| 528 | |
---|
| 529 | void Jump::addShield(float xPosition, float zPosition, float leftBoundary, float rightBoundary, float lowerBoundary, float upperBoundary, float xVelocity, float zVelocity) |
---|
| 530 | { |
---|
[10215] | 531 | JumpShield* newShield = new JumpShield(center_->getContext()); |
---|
[11071] | 532 | if (newShield != nullptr && center_ != nullptr) |
---|
[10215] | 533 | { |
---|
| 534 | newShield->addTemplate(center_->getShieldTemplate()); |
---|
| 535 | newShield->setPosition(Vector3(xPosition, 0.0, zPosition)); |
---|
| 536 | newShield->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity); |
---|
| 537 | newShield->setFigure(figure_); |
---|
| 538 | center_->attach(newShield); |
---|
| 539 | } |
---|
[10078] | 540 | } |
---|
| 541 | |
---|
| 542 | void Jump::addShield(JumpPlatform* platform) |
---|
| 543 | { |
---|
[10215] | 544 | JumpShield* newShield = new JumpShield(center_->getContext()); |
---|
[11071] | 545 | if (newShield != nullptr && center_ != nullptr) |
---|
[10215] | 546 | { |
---|
| 547 | newShield->addTemplate(center_->getShieldTemplate()); |
---|
| 548 | newShield->setPosition(Vector3(0.0, 0.0, 0.0)); |
---|
| 549 | newShield->setProperties(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); |
---|
| 550 | newShield->setFigure(figure_); |
---|
| 551 | platform->attach(newShield); |
---|
| 552 | } |
---|
[10078] | 553 | } |
---|
| 554 | |
---|
| 555 | void Jump::addEnemy(int type, float xPosition, float zPosition, float leftBoundary, float rightBoundary, float lowerBoundary, float upperBoundary, float xVelocity, float zVelocity) |
---|
| 556 | { |
---|
[10215] | 557 | JumpEnemy* newEnemy = new JumpEnemy(center_->getContext()); |
---|
[11071] | 558 | if (newEnemy != nullptr && center_ != nullptr) |
---|
[10215] | 559 | { |
---|
| 560 | switch (type) |
---|
| 561 | { |
---|
| 562 | case 1: |
---|
| 563 | newEnemy->addTemplate(center_->getEnemy1Template()); |
---|
| 564 | break; |
---|
| 565 | case 2: |
---|
| 566 | newEnemy->addTemplate(center_->getEnemy2Template()); |
---|
| 567 | break; |
---|
| 568 | case 3: |
---|
| 569 | newEnemy->addTemplate(center_->getEnemy3Template()); |
---|
| 570 | break; |
---|
| 571 | case 4: |
---|
| 572 | newEnemy->addTemplate(center_->getEnemy4Template()); |
---|
| 573 | break; |
---|
| 574 | default: |
---|
| 575 | return; |
---|
| 576 | } |
---|
[10078] | 577 | |
---|
[10215] | 578 | newEnemy->setPosition(Vector3(xPosition, 0.0, zPosition)); |
---|
| 579 | newEnemy->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity); |
---|
| 580 | newEnemy->setFieldDimension(center_->getFieldDimension()); |
---|
| 581 | newEnemy->setFigure(this->figure_); |
---|
| 582 | center_->attach(newEnemy); |
---|
| 583 | } |
---|
[10078] | 584 | } |
---|
| 585 | |
---|
| 586 | void Jump::addStartSection() |
---|
| 587 | { |
---|
[10215] | 588 | JumpPlatform* newPlatform; |
---|
[10078] | 589 | |
---|
[10215] | 590 | float sectionLength = center_->getSectionLength(); |
---|
[10078] | 591 | |
---|
[10215] | 592 | newPlatform = new JumpPlatformStatic(center_->getContext()); |
---|
[10218] | 593 | addPlatform(newPlatform, center_->getPlatformStaticTemplate(), 0.0, -0.05f*sectionLength); |
---|
[10078] | 594 | |
---|
[10215] | 595 | platformWidth_ = newPlatform->getWidth(); |
---|
| 596 | platformHeight_ = newPlatform->getHeight(); |
---|
[10078] | 597 | |
---|
[10215] | 598 | for (float xPosition = platformWidth_; xPosition <= center_->getFieldDimension().x; xPosition += platformWidth_) |
---|
| 599 | { |
---|
| 600 | newPlatform = new JumpPlatformStatic(center_->getContext()); |
---|
[10218] | 601 | addPlatform(newPlatform, center_->getPlatformStaticTemplate(), xPosition, -0.05f*sectionLength); |
---|
[10215] | 602 | newPlatform = new JumpPlatformStatic(center_->getContext()); |
---|
[10218] | 603 | addPlatform(newPlatform, center_->getPlatformStaticTemplate(), -xPosition, -0.05f*sectionLength); |
---|
[10215] | 604 | } |
---|
[10078] | 605 | } |
---|
| 606 | |
---|
| 607 | void Jump::addSection() |
---|
| 608 | { |
---|
| 609 | float fieldWidth = center_->getFieldDimension().x; |
---|
| 610 | float sectionLength = center_->getSectionLength(); |
---|
| 611 | float sectionBegin = sectionNumber_ * sectionLength; |
---|
| 612 | float sectionEnd = (1 + sectionNumber_) * sectionLength; |
---|
| 613 | |
---|
[10218] | 614 | const int numI = 6; |
---|
| 615 | const int numJ = 4; |
---|
[10078] | 616 | |
---|
[11071] | 617 | enum class PlatformType |
---|
[10215] | 618 | { |
---|
[11071] | 619 | EMPTY, STATIC, HMOVE, VMOVE, DISAPPEAR, TIMER, FAKE |
---|
[10215] | 620 | }; |
---|
[10078] | 621 | |
---|
[11071] | 622 | enum class ItemType |
---|
[10215] | 623 | { |
---|
[11071] | 624 | NOTHING, SPRING, PROPELLER, ROCKET, BOOTS, SHIELD |
---|
[10215] | 625 | }; |
---|
[10078] | 626 | |
---|
| 627 | struct PlatformMatrix |
---|
| 628 | { |
---|
[10215] | 629 | PlatformType type; |
---|
[10078] | 630 | bool done; |
---|
| 631 | } matrix[numI][numJ]; |
---|
| 632 | |
---|
| 633 | |
---|
[10215] | 634 | for (int i = 0; i < numI; ++i) |
---|
| 635 | { |
---|
| 636 | for (int j = 0; j < numJ; ++j) |
---|
| 637 | { |
---|
[11071] | 638 | matrix[i][j].type = PlatformType::EMPTY; |
---|
[10215] | 639 | matrix[i][j].done = false; |
---|
| 640 | } |
---|
| 641 | } |
---|
| 642 | PlatformType platformtype1; |
---|
| 643 | PlatformType platformtype2; |
---|
[11071] | 644 | ItemType itemType = ItemType::NOTHING; |
---|
[10078] | 645 | |
---|
[10215] | 646 | if (rand()%2 == 0) |
---|
| 647 | { |
---|
[11071] | 648 | itemType = ItemType::SPRING; |
---|
[10215] | 649 | } |
---|
| 650 | else if (rand()%2 == 0 && sectionNumber_ > 3) |
---|
| 651 | { |
---|
| 652 | switch(rand()%4) |
---|
| 653 | { |
---|
| 654 | case 0: |
---|
[11071] | 655 | itemType = ItemType::PROPELLER; |
---|
[10215] | 656 | break; |
---|
| 657 | case 1: |
---|
[11071] | 658 | itemType = ItemType::ROCKET; |
---|
[10215] | 659 | break; |
---|
| 660 | case 2: |
---|
[11071] | 661 | itemType = ItemType::BOOTS; |
---|
[10215] | 662 | break; |
---|
| 663 | case 3: |
---|
[11071] | 664 | itemType = ItemType::SHIELD; |
---|
[10215] | 665 | break; |
---|
| 666 | default: |
---|
| 667 | break; |
---|
| 668 | } |
---|
| 669 | } |
---|
[10078] | 670 | |
---|
[10215] | 671 | switch((sectionNumber_ > 28) ? rand()%29 : rand()%(sectionNumber_+1)) |
---|
| 672 | { |
---|
| 673 | case 0: |
---|
[11071] | 674 | platformtype1 = PlatformType::STATIC; |
---|
| 675 | platformtype2 = PlatformType::STATIC; |
---|
[10215] | 676 | break; |
---|
| 677 | case 1: |
---|
[11071] | 678 | platformtype1 = PlatformType::STATIC; |
---|
| 679 | platformtype2 = PlatformType::STATIC; |
---|
[10215] | 680 | break; |
---|
| 681 | case 2: |
---|
[11071] | 682 | platformtype1 = PlatformType::STATIC; |
---|
| 683 | platformtype2 = PlatformType::HMOVE; |
---|
[10215] | 684 | break; |
---|
| 685 | case 3: |
---|
[11071] | 686 | platformtype1 = PlatformType::STATIC; |
---|
| 687 | platformtype2 = PlatformType::DISAPPEAR; |
---|
[10215] | 688 | break; |
---|
| 689 | case 4: |
---|
[11071] | 690 | platformtype1 = PlatformType::STATIC; |
---|
| 691 | platformtype2 = PlatformType::VMOVE; |
---|
[10215] | 692 | break; |
---|
| 693 | case 5: |
---|
[11071] | 694 | platformtype1 = PlatformType::STATIC; |
---|
| 695 | platformtype2 = PlatformType::TIMER; |
---|
[10215] | 696 | break; |
---|
| 697 | case 6: |
---|
[11071] | 698 | platformtype1 = PlatformType::HMOVE; |
---|
| 699 | platformtype2 = PlatformType::STATIC; |
---|
[10215] | 700 | break; |
---|
| 701 | case 7: |
---|
[11071] | 702 | platformtype1 = PlatformType::HMOVE; |
---|
| 703 | platformtype2 = PlatformType::HMOVE; |
---|
[10215] | 704 | break; |
---|
| 705 | case 8: |
---|
[11071] | 706 | platformtype1 = PlatformType::HMOVE; |
---|
| 707 | platformtype2 = PlatformType::HMOVE; |
---|
[10215] | 708 | break; |
---|
| 709 | case 9: |
---|
[11071] | 710 | platformtype1 = PlatformType::HMOVE; |
---|
| 711 | platformtype2 = PlatformType::DISAPPEAR; |
---|
[10215] | 712 | break; |
---|
| 713 | case 10: |
---|
[11071] | 714 | platformtype1 = PlatformType::HMOVE; |
---|
| 715 | platformtype2 = PlatformType::VMOVE; |
---|
[10215] | 716 | break; |
---|
| 717 | case 11: |
---|
[11071] | 718 | platformtype1 = PlatformType::HMOVE; |
---|
| 719 | platformtype2 = PlatformType::TIMER; |
---|
[10215] | 720 | break; |
---|
| 721 | case 12: |
---|
[11071] | 722 | platformtype1 = PlatformType::DISAPPEAR; |
---|
| 723 | platformtype2 = PlatformType::STATIC; |
---|
[10215] | 724 | break; |
---|
| 725 | case 13: |
---|
[11071] | 726 | platformtype1 = PlatformType::DISAPPEAR; |
---|
| 727 | platformtype2 = PlatformType::HMOVE; |
---|
[10215] | 728 | break; |
---|
| 729 | case 14: |
---|
[11071] | 730 | platformtype1 = PlatformType::DISAPPEAR; |
---|
| 731 | platformtype2 = PlatformType::DISAPPEAR; |
---|
[10215] | 732 | break; |
---|
| 733 | case 15: |
---|
[11071] | 734 | platformtype1 = PlatformType::DISAPPEAR; |
---|
| 735 | platformtype2 = PlatformType::DISAPPEAR; |
---|
[10215] | 736 | break; |
---|
| 737 | case 16: |
---|
[11071] | 738 | platformtype1 = PlatformType::DISAPPEAR; |
---|
| 739 | platformtype2 = PlatformType::VMOVE; |
---|
[10215] | 740 | break; |
---|
| 741 | case 17: |
---|
[11071] | 742 | platformtype1 = PlatformType::DISAPPEAR; |
---|
| 743 | platformtype2 = PlatformType::TIMER; |
---|
[10215] | 744 | break; |
---|
| 745 | case 18: |
---|
[11071] | 746 | platformtype1 = PlatformType::VMOVE; |
---|
| 747 | platformtype2 = PlatformType::STATIC; |
---|
[10215] | 748 | break; |
---|
| 749 | case 19: |
---|
[11071] | 750 | platformtype1 = PlatformType::VMOVE; |
---|
| 751 | platformtype2 = PlatformType::HMOVE; |
---|
[10215] | 752 | break; |
---|
| 753 | case 20: |
---|
[11071] | 754 | platformtype1 = PlatformType::VMOVE; |
---|
| 755 | platformtype2 = PlatformType::DISAPPEAR; |
---|
[10215] | 756 | break; |
---|
| 757 | case 21: |
---|
[11071] | 758 | platformtype1 = PlatformType::VMOVE; |
---|
| 759 | platformtype2 = PlatformType::VMOVE; |
---|
[10215] | 760 | break; |
---|
| 761 | case 22: |
---|
[11071] | 762 | platformtype1 = PlatformType::VMOVE; |
---|
| 763 | platformtype2 = PlatformType::VMOVE; |
---|
[10215] | 764 | break; |
---|
| 765 | case 23: |
---|
[11071] | 766 | platformtype1 = PlatformType::VMOVE; |
---|
| 767 | platformtype2 = PlatformType::TIMER; |
---|
[10215] | 768 | break; |
---|
| 769 | case 24: |
---|
[11071] | 770 | platformtype1 = PlatformType::TIMER; |
---|
| 771 | platformtype2 = PlatformType::STATIC; |
---|
[10215] | 772 | break; |
---|
| 773 | case 25: |
---|
[11071] | 774 | platformtype1 = PlatformType::TIMER; |
---|
| 775 | platformtype2 = PlatformType::HMOVE; |
---|
[10215] | 776 | break; |
---|
| 777 | case 26: |
---|
[11071] | 778 | platformtype1 = PlatformType::TIMER; |
---|
| 779 | platformtype2 = PlatformType::DISAPPEAR; |
---|
[10215] | 780 | break; |
---|
| 781 | case 27: |
---|
[11071] | 782 | platformtype1 = PlatformType::TIMER; |
---|
| 783 | platformtype2 = PlatformType::VMOVE; |
---|
[10215] | 784 | break; |
---|
| 785 | case 28: |
---|
[11071] | 786 | platformtype1 = PlatformType::TIMER; |
---|
| 787 | platformtype2 = PlatformType::TIMER; |
---|
[10215] | 788 | break; |
---|
| 789 | default: |
---|
[11071] | 790 | platformtype1 = PlatformType::TIMER; |
---|
| 791 | platformtype2 = PlatformType::TIMER; |
---|
[10215] | 792 | break; |
---|
| 793 | } |
---|
[10078] | 794 | |
---|
[10215] | 795 | // Fill matrix with selected platform types |
---|
| 796 | for (int i = 0; i < numI; ++ i) |
---|
| 797 | { |
---|
| 798 | for (int j = 0; j < numJ; ++ j) |
---|
| 799 | { |
---|
| 800 | if (rand()%3 == 0) |
---|
| 801 | { |
---|
| 802 | matrix[i][j].type = platformtype1; |
---|
| 803 | } |
---|
| 804 | else |
---|
| 805 | { |
---|
| 806 | matrix[i][j].type = platformtype2; |
---|
| 807 | } |
---|
| 808 | matrix[i][j].done = false; |
---|
| 809 | } |
---|
| 810 | } |
---|
[10078] | 811 | |
---|
[10215] | 812 | if (platformtype1 == platformtype2 && sectionNumber_ > 10 && rand()%2 == 0) |
---|
| 813 | { |
---|
[11071] | 814 | matrix[rand()%numI][rand()%numJ].type = PlatformType::EMPTY; |
---|
| 815 | matrix[rand()%numI][rand()%numJ].type = PlatformType::EMPTY; |
---|
[10215] | 816 | } |
---|
[10078] | 817 | |
---|
[10215] | 818 | // Delete some planned platforms or replace them with fake platforms |
---|
| 819 | if (sectionNumber_ > 5) |
---|
| 820 | { |
---|
| 821 | if (rand()%2 == 0) |
---|
| 822 | { |
---|
[11071] | 823 | matrix[rand()%numI][rand()%numJ].type = PlatformType::EMPTY; |
---|
[10215] | 824 | } |
---|
| 825 | else |
---|
| 826 | { |
---|
[11071] | 827 | matrix[rand()%numI][rand()%numJ].type = PlatformType::FAKE; |
---|
[10215] | 828 | } |
---|
| 829 | } |
---|
| 830 | else if (sectionNumber_ > 10) |
---|
| 831 | { |
---|
| 832 | if (rand()%2 == 0) |
---|
| 833 | { |
---|
[11071] | 834 | matrix[rand()%numI][rand()%numJ].type = PlatformType::EMPTY; |
---|
[10215] | 835 | } |
---|
| 836 | else |
---|
| 837 | { |
---|
[11071] | 838 | matrix[rand()%numI][rand()%numJ].type = PlatformType::FAKE; |
---|
[10215] | 839 | } |
---|
| 840 | if (rand()%2 == 0) |
---|
| 841 | { |
---|
[11071] | 842 | matrix[rand()%numI][rand()%numJ].type = PlatformType::EMPTY; |
---|
[10215] | 843 | } |
---|
| 844 | else |
---|
| 845 | { |
---|
[11071] | 846 | matrix[rand()%numI][rand()%numJ].type = PlatformType::FAKE; |
---|
[10215] | 847 | } |
---|
| 848 | } |
---|
| 849 | else if (sectionNumber_ > 15) |
---|
| 850 | { |
---|
| 851 | if (rand()%2 == 0) |
---|
| 852 | { |
---|
[11071] | 853 | matrix[rand()%numI][rand()%numJ].type = PlatformType::EMPTY; |
---|
[10215] | 854 | } |
---|
| 855 | else |
---|
| 856 | { |
---|
[11071] | 857 | matrix[rand()%numI][rand()%numJ].type = PlatformType::FAKE; |
---|
[10215] | 858 | } |
---|
| 859 | if (rand()%2 == 0) |
---|
| 860 | { |
---|
[11071] | 861 | matrix[rand()%numI][rand()%numJ].type = PlatformType::EMPTY; |
---|
[10215] | 862 | } |
---|
| 863 | else |
---|
| 864 | { |
---|
[11071] | 865 | matrix[rand()%numI][rand()%numJ].type = PlatformType::FAKE; |
---|
[10215] | 866 | } |
---|
| 867 | if (rand()%2 == 0) |
---|
| 868 | { |
---|
[11071] | 869 | matrix[rand()%numI][rand()%numJ].type = PlatformType::EMPTY; |
---|
[10215] | 870 | } |
---|
| 871 | else |
---|
| 872 | { |
---|
[11071] | 873 | matrix[rand()%numI][rand()%numJ].type = PlatformType::FAKE; |
---|
[10215] | 874 | } |
---|
| 875 | } |
---|
[10078] | 876 | |
---|
[10215] | 877 | std::vector<JumpPlatform*> platformList; |
---|
[10078] | 878 | |
---|
[10215] | 879 | for (int i = 0; i < numI; ++ i) |
---|
| 880 | { |
---|
| 881 | for (int j = 0; j < numJ; ++ j) |
---|
| 882 | { |
---|
| 883 | if (matrix[i][j].done == false) |
---|
| 884 | { |
---|
| 885 | float xPosition = 0.0; |
---|
| 886 | float zPosition = 0.0; |
---|
| 887 | float leftBoundary = 0.0; |
---|
| 888 | float rightBoundary = 0.0; |
---|
| 889 | float lowerBoundary = 0.0; |
---|
| 890 | float upperBoundary = 0.0; |
---|
| 891 | float xVelocity = 0.0; |
---|
| 892 | float zVelocity = 0.0; |
---|
[10078] | 893 | |
---|
[10215] | 894 | switch(matrix[i][j].type) |
---|
| 895 | { |
---|
[11071] | 896 | case PlatformType::EMPTY: |
---|
[10215] | 897 | matrix[i][j].done = true; |
---|
| 898 | break; |
---|
[11071] | 899 | case PlatformType::STATIC: |
---|
[10215] | 900 | xPosition = randomXPosition(numJ, j); |
---|
| 901 | zPosition = sectionBegin + i*sectionLength/numI; |
---|
| 902 | platformList.push_back(addPlatformStatic(xPosition, zPosition)); |
---|
| 903 | matrix[i][j].done = true; |
---|
| 904 | break; |
---|
[11071] | 905 | case PlatformType::FAKE: |
---|
[10215] | 906 | xPosition = randomXPosition(numJ, j); |
---|
| 907 | zPosition = sectionBegin + i*sectionLength/numI; |
---|
| 908 | platformList.push_back(addPlatformFake(xPosition, zPosition)); |
---|
| 909 | matrix[i][j].done = true; |
---|
| 910 | break; |
---|
[11071] | 911 | case PlatformType::TIMER: |
---|
[10215] | 912 | xPosition = randomXPosition(numJ, j); |
---|
| 913 | zPosition = sectionBegin + i*sectionLength/numI; |
---|
| 914 | platformList.push_back(addPlatformTimer(xPosition, zPosition, 12.0, 1.5)); |
---|
| 915 | matrix[i][j].done = true; |
---|
| 916 | break; |
---|
[11071] | 917 | case PlatformType::DISAPPEAR: |
---|
[10215] | 918 | xPosition = randomXPosition(numJ, j); |
---|
| 919 | zPosition = sectionBegin + i*sectionLength/numI; |
---|
| 920 | platformList.push_back(addPlatformDisappear(xPosition, zPosition)); |
---|
| 921 | matrix[i][j].done = true; |
---|
| 922 | break; |
---|
[11071] | 923 | case PlatformType::HMOVE: |
---|
[10215] | 924 | xVelocity = randomSpeed(); |
---|
[11071] | 925 | if (j <= numJ-3 && matrix[i][j+1].type == PlatformType::HMOVE && matrix[i][j+2].type == PlatformType::HMOVE && rand()%2 == 0) |
---|
[10215] | 926 | { |
---|
| 927 | leftBoundary = randomXPositionLeft(numJ, j); |
---|
| 928 | rightBoundary = randomXPositionRight(numJ, j+2); |
---|
| 929 | xPosition = randomPosition(leftBoundary, rightBoundary); |
---|
| 930 | zPosition = sectionBegin + i*sectionLength/numI; |
---|
| 931 | platformList.push_back(addPlatformHMove(xPosition, zPosition, leftBoundary, rightBoundary, xVelocity)); |
---|
| 932 | matrix[i][j].done = true; |
---|
| 933 | matrix[i][j+1].done = true; |
---|
| 934 | matrix[i][j+2].done = true; |
---|
| 935 | } |
---|
[11071] | 936 | else if (j <= numJ-2 && matrix[i][j+1].type == PlatformType::HMOVE && rand()%2 == 0) |
---|
[10215] | 937 | { |
---|
| 938 | leftBoundary = randomXPositionLeft(numJ, j); |
---|
| 939 | rightBoundary = randomXPositionRight(numJ, j+1); |
---|
| 940 | xPosition = randomPosition(leftBoundary, rightBoundary); |
---|
| 941 | zPosition = sectionBegin + i*sectionLength/numI; |
---|
| 942 | platformList.push_back(addPlatformHMove(xPosition, zPosition, leftBoundary, rightBoundary, xVelocity)); |
---|
| 943 | matrix[i][j].done = true; |
---|
| 944 | matrix[i][j+1].done = true; |
---|
| 945 | } |
---|
| 946 | else |
---|
| 947 | { |
---|
| 948 | leftBoundary = randomXPositionLeft(numJ, j); |
---|
| 949 | rightBoundary = randomXPositionRight(numJ, j); |
---|
| 950 | xPosition = randomPosition(leftBoundary, rightBoundary); |
---|
| 951 | zPosition = sectionBegin + i*sectionLength/numI; |
---|
| 952 | platformList.push_back(addPlatformHMove(xPosition, zPosition, leftBoundary, rightBoundary, xVelocity)); |
---|
| 953 | matrix[i][j].done = true; |
---|
| 954 | } |
---|
| 955 | break; |
---|
[11071] | 956 | case PlatformType::VMOVE: |
---|
[10215] | 957 | zVelocity = randomSpeed(); |
---|
[11071] | 958 | if (i <= numI-3 && matrix[i+1][j].type == PlatformType::VMOVE && matrix[i+2][j].type == PlatformType::VMOVE && rand()%2 == 0) |
---|
[10215] | 959 | { |
---|
| 960 | lowerBoundary = randomZPositionLower(numI, i, sectionBegin, sectionEnd); |
---|
| 961 | upperBoundary = randomZPositionUpper(numI, i+2, sectionBegin, sectionEnd); |
---|
| 962 | zPosition = randomPosition(lowerBoundary, upperBoundary); |
---|
| 963 | xPosition = randomXPosition(numJ, j); |
---|
| 964 | platformList.push_back(addPlatformVMove(xPosition, zPosition, lowerBoundary, upperBoundary, zVelocity)); |
---|
| 965 | matrix[i][j].done = true; |
---|
| 966 | matrix[i+1][j].done = true; |
---|
| 967 | matrix[i+2][j].done = true; |
---|
| 968 | } |
---|
[11071] | 969 | else if (i <= numI-2 && matrix[i+1][j].type == PlatformType::VMOVE && rand()%2 == 0) |
---|
[10215] | 970 | { |
---|
| 971 | lowerBoundary = randomZPositionLower(numI, i, sectionBegin, sectionEnd); |
---|
| 972 | upperBoundary = randomZPositionUpper(numI, i+1, sectionBegin, sectionEnd); |
---|
| 973 | zPosition = randomPosition(lowerBoundary, upperBoundary); |
---|
| 974 | xPosition = randomXPosition(numJ, j); |
---|
| 975 | platformList.push_back(addPlatformVMove(xPosition, zPosition, lowerBoundary, upperBoundary, zVelocity)); |
---|
| 976 | matrix[i][j].done = true; |
---|
| 977 | matrix[i+1][j].done = true; |
---|
| 978 | } |
---|
| 979 | else |
---|
| 980 | { |
---|
| 981 | lowerBoundary = randomZPositionLower(numI, i, sectionBegin, sectionEnd); |
---|
| 982 | upperBoundary = randomZPositionUpper(numI, i, sectionBegin, sectionEnd); |
---|
| 983 | zPosition = randomPosition(lowerBoundary, upperBoundary); |
---|
| 984 | xPosition = randomXPosition(numJ, j); |
---|
| 985 | platformList.push_back(addPlatformVMove(xPosition, zPosition, lowerBoundary, upperBoundary, zVelocity)); |
---|
| 986 | matrix[i][j].done = true; |
---|
| 987 | } |
---|
| 988 | break; |
---|
| 989 | default: |
---|
| 990 | //ERROR |
---|
| 991 | break; |
---|
[10078] | 992 | |
---|
[10215] | 993 | } |
---|
| 994 | } |
---|
| 995 | } |
---|
| 996 | } |
---|
[10078] | 997 | |
---|
[10215] | 998 | //Add items |
---|
| 999 | int numNewPlatforms = platformList.size(); |
---|
[10078] | 1000 | |
---|
[10215] | 1001 | if (rand()%4 == 0) |
---|
| 1002 | { |
---|
| 1003 | if (rand()%2 == 0) |
---|
| 1004 | { |
---|
| 1005 | switch (itemType) |
---|
| 1006 | { |
---|
[11071] | 1007 | case ItemType::ROCKET: |
---|
[10215] | 1008 | addRocket(0.0, randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/2, fieldWidth/2, 0.0, 0.0, randomSpeed(), 0.0); |
---|
| 1009 | break; |
---|
[11071] | 1010 | case ItemType::PROPELLER: |
---|
[10215] | 1011 | addPropeller(0.0, randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/2, fieldWidth/2, 0.0, 0.0, randomSpeed(), 0.0); |
---|
| 1012 | break; |
---|
[11071] | 1013 | case ItemType::BOOTS: |
---|
[10215] | 1014 | addBoots(0.0, randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/2, fieldWidth/2, 0.0, 0.0, randomSpeed(), 0.0); |
---|
| 1015 | break; |
---|
[11071] | 1016 | case ItemType::SHIELD: |
---|
[10215] | 1017 | addShield(0.0, randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/2, fieldWidth/2, 0.0, 0.0, randomSpeed(), 0.0); |
---|
| 1018 | break; |
---|
| 1019 | default: |
---|
| 1020 | break; |
---|
| 1021 | } |
---|
| 1022 | } |
---|
| 1023 | else |
---|
| 1024 | { |
---|
| 1025 | switch (itemType) |
---|
| 1026 | { |
---|
[11071] | 1027 | case ItemType::ROCKET: |
---|
[10215] | 1028 | addRocket(randomPosition(-fieldWidth/2, fieldWidth/2), sectionBegin + sectionLength/2, 0.0, 0.0, sectionBegin, sectionEnd, 0.0, randomSpeed()); |
---|
| 1029 | break; |
---|
[11071] | 1030 | case ItemType::PROPELLER: |
---|
[10215] | 1031 | addPropeller(randomPosition(-fieldWidth/2, fieldWidth/2), sectionBegin + sectionLength/2, 0.0, 0.0, sectionBegin, sectionEnd, 0.0, randomSpeed()); |
---|
| 1032 | break; |
---|
[11071] | 1033 | case ItemType::BOOTS: |
---|
[10215] | 1034 | addBoots(randomPosition(-fieldWidth/2, fieldWidth/2), sectionBegin + sectionLength/2, 0.0, 0.0, sectionBegin, sectionEnd, 0.0, randomSpeed()); |
---|
| 1035 | break; |
---|
[11071] | 1036 | case ItemType::SHIELD: |
---|
[10215] | 1037 | addShield(randomPosition(-fieldWidth/2, fieldWidth/2), sectionBegin + sectionLength/2, 0.0, 0.0, sectionBegin, sectionEnd, 0.0, randomSpeed()); |
---|
| 1038 | break; |
---|
| 1039 | default: |
---|
| 1040 | break; |
---|
| 1041 | } |
---|
| 1042 | } |
---|
| 1043 | } |
---|
| 1044 | else |
---|
| 1045 | { |
---|
| 1046 | if (numNewPlatforms > 0) |
---|
| 1047 | { |
---|
| 1048 | JumpPlatform* itemPlatform = platformList[rand()%numNewPlatforms]; |
---|
[10078] | 1049 | |
---|
[10215] | 1050 | switch (itemType) |
---|
| 1051 | { |
---|
[11071] | 1052 | case ItemType::SPRING: |
---|
[10215] | 1053 | addSpring(itemPlatform); |
---|
| 1054 | break; |
---|
[11071] | 1055 | case ItemType::ROCKET: |
---|
[10215] | 1056 | addRocket(itemPlatform); |
---|
| 1057 | break; |
---|
[11071] | 1058 | case ItemType::PROPELLER: |
---|
[10215] | 1059 | addPropeller(itemPlatform); |
---|
| 1060 | break; |
---|
[11071] | 1061 | case ItemType::BOOTS: |
---|
[10215] | 1062 | addBoots(itemPlatform); |
---|
| 1063 | break; |
---|
[11071] | 1064 | case ItemType::SHIELD: |
---|
[10215] | 1065 | addShield(itemPlatform); |
---|
| 1066 | break; |
---|
| 1067 | default: |
---|
| 1068 | break; |
---|
| 1069 | } |
---|
| 1070 | } |
---|
| 1071 | } |
---|
[10078] | 1072 | |
---|
| 1073 | if (sectionNumber_ >= 5 && rand()%3 == 0) |
---|
| 1074 | { |
---|
[10215] | 1075 | switch(rand()%4) |
---|
| 1076 | { |
---|
[10078] | 1077 | case 0: |
---|
[10215] | 1078 | addEnemy(1, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/3*2, fieldWidth/3*2, sectionBegin, sectionBegin + sectionLength, randomSpeed(), 0.0); |
---|
| 1079 | break; |
---|
[10078] | 1080 | case 1: |
---|
[10215] | 1081 | addEnemy(2, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/3*2, fieldWidth/3*2, sectionBegin, sectionBegin + sectionLength, randomSpeed(), 0.0); |
---|
| 1082 | break; |
---|
[10078] | 1083 | case 2: |
---|
[10215] | 1084 | addEnemy(3, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/3*2, fieldWidth/3*2, sectionBegin, sectionBegin + sectionLength, randomSpeed(), 0.0); |
---|
| 1085 | break; |
---|
[10078] | 1086 | case 3: |
---|
[10215] | 1087 | addEnemy(4, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/3*2, fieldWidth/3*2, sectionBegin, sectionBegin + sectionLength, randomSpeed(), 0.0); |
---|
| 1088 | break; |
---|
| 1089 | } |
---|
[10078] | 1090 | } |
---|
[10215] | 1091 | ++ sectionNumber_; |
---|
[10078] | 1092 | } |
---|
| 1093 | |
---|
| 1094 | bool Jump::addAdventure(int number) |
---|
| 1095 | { |
---|
| 1096 | float fieldWidth = center_->getFieldDimension().x; |
---|
| 1097 | float sectionLength = center_->getSectionLength(); |
---|
| 1098 | float sectionBegin = sectionNumber_ * sectionLength; |
---|
| 1099 | sectionLength *= 2; |
---|
| 1100 | |
---|
| 1101 | switch(number) |
---|
| 1102 | { |
---|
| 1103 | case 0: |
---|
[10215] | 1104 | { |
---|
| 1105 | int numI = 10; |
---|
| 1106 | if (rand()%2 == 0) |
---|
| 1107 | { |
---|
| 1108 | for (int i = 0; i < numI; ++ i) |
---|
| 1109 | { |
---|
| 1110 | addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth+platformWidth_/2, sectionBegin+i*sectionLength/numI); |
---|
| 1111 | } |
---|
| 1112 | } |
---|
| 1113 | else |
---|
| 1114 | { |
---|
| 1115 | for (int i = 0; i < numI; ++ i) |
---|
| 1116 | { |
---|
| 1117 | addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth+platformWidth_/2, sectionBegin+(numI-i)*sectionLength/numI); |
---|
| 1118 | } |
---|
| 1119 | } |
---|
| 1120 | break; |
---|
| 1121 | } |
---|
[10078] | 1122 | case 1: |
---|
[10215] | 1123 | { |
---|
| 1124 | int numI = 7; |
---|
[10078] | 1125 | |
---|
[10215] | 1126 | addPlatformStatic(0.0, sectionBegin); |
---|
| 1127 | if (rand()%2 == 0) |
---|
| 1128 | { |
---|
| 1129 | for (int i = 1; i < numI; ++ i) |
---|
| 1130 | { |
---|
| 1131 | addPlatformStatic((fieldWidth-platformWidth_/2)*i/numI, sectionBegin+i*sectionLength/numI); |
---|
| 1132 | addPlatformStatic(-(fieldWidth-platformWidth_/2)*i/numI, sectionBegin+i*sectionLength/numI); |
---|
| 1133 | } |
---|
| 1134 | } |
---|
| 1135 | else |
---|
| 1136 | { |
---|
| 1137 | for (int i = 1; i < numI; ++ i) |
---|
| 1138 | { |
---|
| 1139 | addPlatformStatic((fieldWidth-platformWidth_/2)*i/numI, sectionBegin+(numI-i)*sectionLength/numI); |
---|
| 1140 | addPlatformStatic(-(fieldWidth-platformWidth_/2)*i/numI, sectionBegin+(numI-i)*sectionLength/numI); |
---|
| 1141 | } |
---|
| 1142 | } |
---|
| 1143 | break; |
---|
| 1144 | } |
---|
[10078] | 1145 | case 2: |
---|
[10215] | 1146 | { |
---|
| 1147 | int numI = 5; |
---|
| 1148 | for (int i = 0; i <= numI; ++ i) |
---|
| 1149 | { |
---|
| 1150 | addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth, sectionBegin); |
---|
| 1151 | addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth, sectionBegin+sectionLength/5); |
---|
| 1152 | addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth, sectionBegin+sectionLength*2/5); |
---|
| 1153 | addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth, sectionBegin+sectionLength*3/5); |
---|
| 1154 | addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth, sectionBegin+sectionLength*4/5); |
---|
| 1155 | addEnemy(4, (2*fieldWidth-platformWidth_)*i/numI-fieldWidth+platformWidth_/2, sectionBegin+sectionLength/2, -fieldWidth, fieldWidth, sectionBegin, sectionBegin + sectionLength, 0.0, 0.0); |
---|
| 1156 | } |
---|
| 1157 | break; |
---|
| 1158 | } |
---|
[10078] | 1159 | case 3: |
---|
[10215] | 1160 | { |
---|
| 1161 | addRocket(addPlatformStatic(0.0, sectionBegin)); |
---|
| 1162 | addEnemy(2, 0.0, sectionBegin+sectionLength/5, 0.0,0.0, 0.0, 0.0, 0.0, 0.0); |
---|
| 1163 | break; |
---|
| 1164 | } |
---|
[10078] | 1165 | case 4: |
---|
[10215] | 1166 | { |
---|
| 1167 | addPropeller(addPlatformStatic(0.0, sectionBegin)); |
---|
| 1168 | addPropeller(addPlatformStatic(-fieldWidth/2, sectionBegin)); |
---|
| 1169 | addPropeller(addPlatformStatic(fieldWidth/2, sectionBegin)); |
---|
| 1170 | break; |
---|
| 1171 | } |
---|
[10078] | 1172 | default: |
---|
[10215] | 1173 | return false; |
---|
[10078] | 1174 | } |
---|
| 1175 | sectionNumber_ +=2; |
---|
| 1176 | return true; |
---|
| 1177 | } |
---|
| 1178 | |
---|
| 1179 | float Jump::randomXPosition() |
---|
| 1180 | { |
---|
| 1181 | float fieldWidth = center_->getFieldDimension().x; |
---|
| 1182 | |
---|
[10215] | 1183 | return (float)(rand()%(2*(int)fieldWidth)) - fieldWidth; |
---|
[10078] | 1184 | } |
---|
| 1185 | |
---|
| 1186 | float Jump::randomXPosition(int totalColumns, int culomn) |
---|
| 1187 | { |
---|
[10215] | 1188 | float fieldWidth = center_->getFieldDimension().x; |
---|
[10078] | 1189 | |
---|
[10215] | 1190 | float halfWidth = fieldWidth/totalColumns; |
---|
| 1191 | float leftBound = culomn*halfWidth*2-fieldWidth; |
---|
| 1192 | float rightBound = leftBound + 2*halfWidth; |
---|
[10078] | 1193 | |
---|
[10215] | 1194 | return randomPosition(leftBound+platformWidth_/2, rightBound-platformWidth_/2); |
---|
[10078] | 1195 | } |
---|
| 1196 | |
---|
| 1197 | float Jump::randomXPositionLeft(int totalColumns, int culomn) |
---|
| 1198 | { |
---|
[10215] | 1199 | float fieldWidth = center_->getFieldDimension().x; |
---|
[10078] | 1200 | |
---|
[10215] | 1201 | float halfWidth = fieldWidth/totalColumns; |
---|
| 1202 | float leftBound = culomn*halfWidth*2-fieldWidth; |
---|
| 1203 | float rightBound = leftBound + 2*halfWidth/3; |
---|
[10078] | 1204 | |
---|
[10215] | 1205 | return randomPosition(leftBound+platformWidth_/2, rightBound-platformWidth_/2); |
---|
[10078] | 1206 | } |
---|
| 1207 | |
---|
| 1208 | float Jump::randomXPositionRight(int totalColumns, int culomn) |
---|
| 1209 | { |
---|
[10215] | 1210 | float fieldWidth = center_->getFieldDimension().x; |
---|
[10078] | 1211 | |
---|
[10215] | 1212 | float halfWidth = fieldWidth/totalColumns; |
---|
| 1213 | float rightBound = (culomn+1)*halfWidth*2-fieldWidth; |
---|
| 1214 | float leftBound = rightBound - 2*halfWidth/3; |
---|
| 1215 | return randomPosition(leftBound+platformWidth_/2, rightBound-platformWidth_/2); |
---|
[10078] | 1216 | } |
---|
| 1217 | |
---|
| 1218 | float Jump::randomZPosition(int totalRows, int row, float sectionBegin, float SectionEnd) |
---|
| 1219 | { |
---|
[10215] | 1220 | float fieldHeight = SectionEnd - sectionBegin; |
---|
| 1221 | float halfHeight = fieldHeight/totalRows; |
---|
| 1222 | float lowerBound = row*halfHeight*2+sectionBegin; |
---|
| 1223 | float upperBound = lowerBound + 2*halfHeight; |
---|
[10078] | 1224 | |
---|
[10215] | 1225 | return randomPosition(lowerBound+platformHeight_/2, upperBound-platformHeight_/2); |
---|
[10078] | 1226 | } |
---|
| 1227 | |
---|
| 1228 | float Jump::randomZPositionLower(int totalRows, int row, float sectionBegin, float SectionEnd) |
---|
| 1229 | { |
---|
[10215] | 1230 | float fieldHeight = SectionEnd - sectionBegin; |
---|
| 1231 | float rowHeight = fieldHeight/totalRows; |
---|
| 1232 | float lowerBound = row*rowHeight+sectionBegin; |
---|
| 1233 | float upperBound = lowerBound + rowHeight/3; |
---|
[10078] | 1234 | |
---|
[10215] | 1235 | return randomPosition(lowerBound+platformHeight_/2, upperBound-platformHeight_/2); |
---|
[10078] | 1236 | } |
---|
| 1237 | |
---|
| 1238 | float Jump::randomZPositionUpper(int totalRows, int row, float sectionBegin, float SectionEnd) |
---|
| 1239 | { |
---|
[10215] | 1240 | float fieldHeight = SectionEnd - sectionBegin; |
---|
| 1241 | float rowHeight = fieldHeight/totalRows; |
---|
| 1242 | float lowerBound = (row+1)*rowHeight+sectionBegin; |
---|
| 1243 | float upperBound = lowerBound - rowHeight/3; |
---|
[10078] | 1244 | |
---|
[10215] | 1245 | return randomPosition(lowerBound+platformHeight_/2, upperBound-platformHeight_/2); |
---|
[10078] | 1246 | } |
---|
| 1247 | |
---|
| 1248 | float Jump::randomPosition(float lowerBoundary, float upperBoundary) |
---|
| 1249 | { |
---|
[10215] | 1250 | if (lowerBoundary >= upperBoundary) |
---|
| 1251 | { |
---|
| 1252 | return (lowerBoundary + upperBoundary)/2; |
---|
| 1253 | } |
---|
[10078] | 1254 | |
---|
[10215] | 1255 | return (float)(rand()%(int)(100*(upperBoundary - lowerBoundary)))/100 + lowerBoundary; |
---|
[10078] | 1256 | } |
---|
| 1257 | |
---|
| 1258 | float Jump::randomSpeed() |
---|
| 1259 | { |
---|
[10215] | 1260 | float platformSpeed = center_->getPlatformSpeed(); |
---|
[10218] | 1261 | return randomPosition(0.5f*platformSpeed, 1.5f*platformSpeed); |
---|
[10078] | 1262 | } |
---|
| 1263 | |
---|
| 1264 | int Jump::getScore(PlayerInfo* player) const |
---|
| 1265 | { |
---|
| 1266 | return sectionNumber_ - 2; |
---|
| 1267 | } |
---|
| 1268 | |
---|
[10260] | 1269 | float Jump::getFuel() const |
---|
| 1270 | { |
---|
[11071] | 1271 | if (this->figure_ != nullptr) |
---|
[10260] | 1272 | { |
---|
[11071] | 1273 | if (this->figure_->rocketActive_ != nullptr) |
---|
[10260] | 1274 | { |
---|
| 1275 | return this->figure_->rocketActive_->getFuelState(); |
---|
| 1276 | } |
---|
[11071] | 1277 | else if (this->figure_->propellerActive_ != nullptr) |
---|
[10260] | 1278 | { |
---|
| 1279 | return this->figure_->propellerActive_->getFuelState(); |
---|
| 1280 | } |
---|
[11071] | 1281 | else if (this->figure_->shieldActive_ != nullptr) |
---|
[10260] | 1282 | { |
---|
| 1283 | return this->figure_->shieldActive_->getFuelState(); |
---|
| 1284 | } |
---|
[11071] | 1285 | else if (this->figure_->bootsActive_ != nullptr) |
---|
[10260] | 1286 | { |
---|
| 1287 | return this->figure_->bootsActive_->getFuelState(); |
---|
| 1288 | } |
---|
| 1289 | } |
---|
| 1290 | |
---|
| 1291 | return 0.0; |
---|
| 1292 | } |
---|
| 1293 | |
---|
[10078] | 1294 | bool Jump::getDead(PlayerInfo* player) const |
---|
| 1295 | { |
---|
| 1296 | return figure_->dead_; |
---|
| 1297 | } |
---|
[11071] | 1298 | |
---|
| 1299 | void Jump::setCenterpoint(JumpCenterpoint* center) |
---|
| 1300 | { |
---|
| 1301 | center_ = center; |
---|
| 1302 | } |
---|
| 1303 | |
---|
[10078] | 1304 | } |
---|