Changeset 10050 for code/branches/pickupsFS14/src
- Timestamp:
- May 8, 2014, 4:14:31 PM (11 years ago)
- Location:
- code/branches/pickupsFS14/src/modules/jump
- Files:
-
- 24 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pickupsFS14/src/modules/jump/CMakeLists.txt
r10041 r10050 6 6 JumpPlatformHMove.cc 7 7 JumpPlatformVMove.cc 8 JumpPlatformDisappear.cc 9 JumpPlatformTimer.cc 10 JumpPlatformFake.cc 11 JumpProjectile.cc 12 JumpEnemy.cc 8 13 JumpFigure.cc 14 JumpItem.cc 9 15 JumpCenterpoint.cc 10 16 JumpScore.cc -
code/branches/pickupsFS14/src/modules/jump/Jump.cc
r10041 r10050 47 47 #include "JumpPlatformHMove.h" 48 48 #include "JumpPlatformVMove.h" 49 #include "JumpPlatformDisappear.h" 50 #include "JumpPlatformTimer.h" 51 #include "JumpPlatformFake.h" 52 #include "JumpProjectile.h" 53 #include "JumpEnemy.h" 49 54 #include "JumpFigure.h" 50 55 … … 70 75 this->figure_ = 0; 71 76 this->camera = 0; 72 73 platformList.clear(); 77 this->fakeAdded_ = false; 74 78 75 79 this->setHUDTemplate("JumpHUD"); … … 78 82 this->starttimer_.setTimer(1.0, false, createExecutor(createFunctor(&Jump::startBall, this))); 79 83 this->starttimer_.stopTimer(); 80 81 84 82 85 this->scoreLimit_ = 10; … … 111 114 112 115 // Falls noetig neue Platformen im neuen Bereich einfuegen 113 if (screenShiftSinceLastUpdate > sectionLength)116 if (screenShiftSinceLastUpdate > center_->getSectionLength()) 114 117 { 115 screenShiftSinceLastUpdate -= sectionLength;118 screenShiftSinceLastUpdate -= center_->getSectionLength(); 116 119 addSection(); 117 120 } … … 124 127 } 125 128 129 // Schiessen 130 if (figure_->fireSignal) 131 { 132 figure_->fireSignal = false; 133 addProjectile(figurePosition.x, figurePosition.z, 0.0, 150.0); 134 } 135 126 136 127 137 if (this->camera != NULL) … … 133 143 { 134 144 orxout() << "No camera found." << endl; 135 // this->camera = this->figure_->getCamera();145 //camera = figure_->getCamera(); 136 146 } 137 147 } … … 142 152 143 153 // Platformen, die zu weit unten sind entfernen 154 ObjectList<JumpPlatform>::iterator beginPlatform = ObjectList<JumpPlatform>::begin(); 155 ObjectList<JumpPlatform>::iterator endPlatform = ObjectList<JumpPlatform>::end(); 156 ObjectList<JumpPlatform>::iterator itPlatform = beginPlatform; 144 157 Vector3 platformPosition; 145 for (std::list<JumpPlatform*>::iterator it = platformList.begin(); it != platformList.end(); it++) 146 {147 // IDEE: Statt durch alle platformen in der Liste, wie im Tutorial durch alle objekte im Spiel iterieren --> eigene liste unnoetig148 platformPosition = (**it).getPosition();158 159 while (itPlatform != endPlatform) 160 { 161 platformPosition = itPlatform->getPosition(); 149 162 if (platformPosition.z < totalScreenShift - center_->getFieldDimension().y) 150 163 { 164 ObjectList<JumpPlatform>::iterator temp = itPlatform; 165 ++ itPlatform; 166 center_->detach(*temp); 167 temp->destroy(); 168 } 169 else 170 { 171 ++ itPlatform; 172 } 173 } 174 175 // DAS GEHT NICHT!!! it++ funktioniert nicht, falls eine Platform geloescht wurde -> Segmentation Error 176 /* 177 for (ObjectList<JumpPlatformDisappear>::iterator it = ObjectList<JumpPlatformDisappear>::begin(); orxout() << "E" << endl, it != ObjectList<JumpPlatformDisappear>::end(); orxout() << "F" << endl, ++it) 178 { 179 if (!it->isActive()) 180 { 151 181 // Entferne Platform 152 orxout() << "position = " << (**it).getPosition().y << endl;153 182 center_->detach(*it); 154 it = platformList.erase(it); 155 } 156 } 157 } 158 183 it->destroy(); 184 } 185 } 186 */ 187 188 // Deaktivierte Platformen entfernen 189 ObjectList<JumpPlatformDisappear>::iterator beginDisappear = ObjectList<JumpPlatformDisappear>::begin(); 190 ObjectList<JumpPlatformDisappear>::iterator endDisappear = ObjectList<JumpPlatformDisappear>::end(); 191 ObjectList<JumpPlatformDisappear>::iterator itDisappear = beginDisappear; 192 193 while (itDisappear != endDisappear) 194 { 195 if (!itDisappear->isActive()) 196 { 197 ObjectList<JumpPlatformDisappear>::iterator temp = itDisappear; 198 ++ itDisappear; 199 center_->detach(*temp); 200 temp->destroy(); 201 } 202 else 203 { 204 ++ itDisappear; 205 } 206 } 207 208 // Abgelaufene Timer-Platformen entfernen 209 ObjectList<JumpPlatformTimer>::iterator beginTimer = ObjectList<JumpPlatformTimer>::begin(); 210 ObjectList<JumpPlatformTimer>::iterator endTimer = ObjectList<JumpPlatformTimer>::end(); 211 ObjectList<JumpPlatformTimer>::iterator itTimer = beginTimer; 212 213 while (itTimer != endTimer) 214 { 215 if (!itTimer->isActive()) 216 { 217 ObjectList<JumpPlatformTimer>::iterator temp = itTimer; 218 ++ itTimer; 219 center_->detach(*temp); 220 temp->destroy(); 221 } 222 else 223 { 224 ++ itTimer; 225 } 226 } 227 228 // Projektile, die zu weit oben sind entfernen 229 ObjectList<JumpProjectile>::iterator beginProjectile = ObjectList<JumpProjectile>::begin(); 230 ObjectList<JumpProjectile>::iterator endProjectile = ObjectList<JumpProjectile>::end(); 231 ObjectList<JumpProjectile>::iterator itProjectile = beginProjectile; 232 Vector3 projectilePosition; 233 234 while (itProjectile != endProjectile) 235 { 236 projectilePosition = itProjectile->getPosition(); 237 if (projectilePosition.z > totalScreenShift + 5*center_->getFieldDimension().y) 238 { 239 ObjectList<JumpProjectile>::iterator temp = itProjectile; 240 ++ itProjectile; 241 center_->detach(*temp); 242 temp->destroy(); 243 } 244 else 245 { 246 ++ itProjectile; 247 } 248 } 249 250 251 252 } 159 253 160 254 void Jump::setConfigValues() … … 169 263 void Jump::cleanup() 170 264 { 171 /*if (this->ball_ != NULL) // Destroy the ball, if present.172 {173 this->ball_->destroy();174 this->ball_ = 0;175 }*/176 177 // Destroy both bats, if present.178 265 if (this->figure_ != NULL) 179 266 { 180 this->figure_->destroy();181 this->figure_ = 0;267 //this->figure_->destroy(); 268 //this->figure_ = 0; 182 269 } 183 270 this->camera = 0; … … 207 294 { 208 295 this->figure_ = new JumpFigure(this->center_->getContext()); 209 this->figure_->addTemplate(this->center_->get Battemplate());296 this->figure_->addTemplate(this->center_->getFigureTemplate()); 210 297 } 211 298 … … 213 300 this->center_->attach(this->figure_); 214 301 this->figure_->setPosition(-this->center_->getFieldDimension().x / 2, 0, 0); 215 this->figure_->yaw(Degree(-90));216 this->figure_->setSpeed(this->center_->getBatSpeed());217 302 this->figure_->setFieldDimension(this->center_->getFieldDimension()); 218 this->figure_->setLength(this->center_->getBatLength());219 220 221 303 } 222 304 else // If no centerpoint was specified, an error is thrown and the level is exited. … … 248 330 screenShiftSinceLastUpdate = 0.0; 249 331 sectionNumber = 0; 250 sectionLength = 100.0;251 332 252 333 addStartSection(); … … 261 342 void Jump::end() 262 343 { 263 this->cleanup(); 344 cleanup(); 345 GSLevel::startMainMenu(); 264 346 265 347 // Call end for the parent class. … … 393 475 } 394 476 395 void Jump::addPlatform(JumpPlatform* newPlatform, float xPosition, float zPosition) 396 { 397 if (newPlatform != NULL) 398 { 477 void Jump::addPlatform(JumpPlatform* newPlatform, std::string platformTemplate, float xPosition, float zPosition) 478 { 479 if (newPlatform != NULL && center_ != NULL) 480 { 481 newPlatform->addTemplate(platformTemplate); 399 482 newPlatform->setPosition(Vector3(xPosition, 0.0, zPosition)); 400 483 newPlatform->setFieldDimension(center_->getFieldDimension()); 401 484 newPlatform->setFigure(this->figure_); 402 485 center_->attach(newPlatform); 403 platformList.push_front(newPlatform); 486 } 487 } 488 489 void Jump::addPlatformStatic(float xPosition, float zPosition) 490 { 491 if (fakeAdded_ == false && rand()%5 == 0) 492 { 493 addPlatformFake(xPosition, zPosition); 494 } 495 else 496 { 497 JumpPlatformStatic* newPlatform = new JumpPlatformStatic(center_->getContext()); 498 addPlatform(newPlatform, center_->getPlatformStaticTemplate(), xPosition, zPosition); 499 } 500 } 501 502 void Jump::addPlatformHMove(float xPosition, float zPosition, float leftBoundary, float rightBoundary, float speed) 503 { 504 JumpPlatformHMove* newPlatform = new JumpPlatformHMove(center_->getContext()); 505 newPlatform->setProperties(leftBoundary, rightBoundary, speed); 506 addPlatform(newPlatform, center_->getPlatformHMoveTemplate(), xPosition, zPosition); 507 } 508 509 void Jump::addPlatformVMove(float xPosition, float zPosition, float lowerBoundary, float upperBoundary, float speed) 510 { 511 JumpPlatformVMove* newPlatform = new JumpPlatformVMove(center_->getContext()); 512 newPlatform->setProperties(lowerBoundary, upperBoundary, speed); 513 addPlatform(newPlatform, center_->getPlatformVMoveTemplate(), xPosition, zPosition); 514 } 515 516 void Jump::addPlatformDisappear(float xPosition, float zPosition) 517 { 518 JumpPlatformDisappear* newPlatform = new JumpPlatformDisappear(center_->getContext()); 519 newPlatform->setProperties(true); 520 addPlatform(newPlatform, center_->getPlatformDisappearTemplate(), xPosition, zPosition); 521 } 522 523 void Jump::addPlatformTimer(float xPosition, float zPosition, float time, float variance) 524 { 525 float additionalTime = (float)(rand()%100)/(100*variance) - variance/2; 526 527 JumpPlatformTimer* newPlatform = new JumpPlatformTimer(center_->getContext()); 528 newPlatform->setProperties(time + additionalTime); 529 addPlatform(newPlatform, center_->getPlatformTimerTemplate(), xPosition, zPosition); 530 } 531 532 void Jump::addPlatformFake(float xPosition, float zPosition) 533 { 534 fakeAdded_ = true; 535 536 JumpPlatformFake* newPlatform = new JumpPlatformFake(center_->getContext()); 537 addPlatform(newPlatform, center_->getPlatformFakeTemplate(), xPosition, zPosition); 538 newPlatform->setAngularVelocity(Vector3(0, 0, 2.0)); 539 } 540 541 542 void Jump::addProjectile(float xPosition, float zPosition, float xVelocity, float zVelocity) 543 { 544 JumpProjectile* newProjectile = new JumpProjectile(center_->getContext()); 545 if (newProjectile != NULL && center_ != NULL) 546 { 547 newProjectile->addTemplate(center_->getProjectileTemplate()); 548 newProjectile->setPosition(Vector3(xPosition, 0.0, zPosition)); 549 newProjectile->setVelocity(Vector3(xVelocity, 0.0, zVelocity)); 550 newProjectile->setFieldDimension(center_->getFieldDimension()); 551 newProjectile->setFigure(this->figure_); 552 center_->attach(newProjectile); 553 } 554 } 555 556 void Jump::addEnemy1(float xPosition, float zPosition, float leftBoundary, float rightBoundary, float lowerBoundary, float upperBoundary, float xVelocity, float zVelocity) 557 { 558 JumpEnemy* newEnemy = new JumpEnemy(center_->getContext()); 559 if (newEnemy != NULL && center_ != NULL) 560 { 561 newEnemy->addTemplate(center_->getEnemy1Template()); 562 newEnemy->setPosition(Vector3(xPosition, 0.0, zPosition)); 563 newEnemy->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity); 564 newEnemy->setFieldDimension(center_->getFieldDimension()); 565 newEnemy->setFigure(this->figure_); 566 center_->attach(newEnemy); 404 567 } 405 568 } … … 409 572 JumpPlatform* newPlatform; 410 573 411 for (float xPosition = -center_->getFieldDimension().x; xPosition <= center_->getFieldDimension().x; xPosition += 12.0) 574 float sectionLength = center_->getSectionLength(); 575 float platformLength = center_->getPlatformLength(); 576 577 for (float xPosition = -center_->getFieldDimension().x; xPosition <= center_->getFieldDimension().x; xPosition += platformLength) 412 578 { 413 579 newPlatform = new JumpPlatformStatic(center_->getContext()); 414 addPlatform(newPlatform, xPosition, -0.05*sectionLength);580 addPlatform(newPlatform, center_->getPlatformStaticTemplate(), xPosition, -0.05*sectionLength); 415 581 } 416 582 } … … 419 585 { 420 586 float fieldWidth = center_->getFieldDimension().x; 421 float fieldHeight = center_->getFieldDimension().y; 587 float sectionLength = center_->getSectionLength(); 588 float platformLength = center_->getPlatformLength(); 422 589 423 590 float sectionBegin = sectionNumber * sectionLength; 424 591 float sectionEnd = (1.0 + sectionNumber) * sectionLength; 425 592 426 JumpPlatformStatic* newPlatformStatic; 427 JumpPlatformHMove* newPlatformHMove; 428 JumpPlatformVMove* newPlatformVMove; 429 430 switch (rand()%3) 593 int randPos1 = rand()%10; 594 int randPos2 = rand()%10; 595 int randPos3 = rand()%10; 596 int randPos4 = rand()%10; 597 598 if (rand()%5 == 0) 599 { 600 addEnemy1(randomXPosition(), sectionBegin + sectionLength/10, -fieldWidth, fieldWidth, sectionBegin + sectionLength/10, sectionBegin + sectionLength/10, 5.0, 0.0); 601 } 602 603 switch (rand()%12) 431 604 { 432 605 case 0: 433 for (int i = 0; i < 10; ++i) 434 { 435 newPlatformStatic = new JumpPlatformStatic(center_->getContext()); 436 addPlatform(newPlatformStatic, randomXPosition(), sectionBegin + i*sectionLength/10); 606 // Doppelt statisch 607 for (int i = 0; i < 10; ++i) 608 { 609 for (int j = 0; j < 2; ++j) 610 { 611 addPlatformStatic(randomXPosition(2, j), sectionBegin + i*sectionLength/10); 612 } 437 613 } 438 614 break; 439 615 case 1: 440 for (int i = 0; i < 10; ++i) 441 { 442 newPlatformHMove = new JumpPlatformHMove(center_->getContext()); 443 newPlatformHMove->setProperties(-fieldWidth, fieldWidth, 30.0); 444 addPlatform(newPlatformHMove, randomXPosition(), sectionBegin + i*sectionLength/10); 445 } 446 616 // Dreifach statisch 617 for (int i = 0; i < 10; ++i) 618 { 619 for (int j = 0; j < 3; ++j) 620 { 621 addPlatformStatic(randomXPosition(3, j), sectionBegin + i*sectionLength/10); 622 } 623 } 447 624 break; 448 625 case 2: 449 for (int i = 0; i < 10; ++i) 450 { 451 newPlatformVMove = new JumpPlatformVMove(center_->getContext()); 452 newPlatformVMove->setProperties(sectionBegin, sectionEnd, 20.0); 453 addPlatform(newPlatformVMove, -fieldWidth + i*fieldWidth*2/10, randomYPosition(sectionBegin, sectionEnd)); 626 // statisch mit 1 horizontal 627 for (int i = 0; i < 10; ++i) 628 { 629 if (i == randPos1) 630 { 631 addPlatformHMove(randomXPosition(), sectionBegin + i*sectionLength/10, -fieldWidth, fieldWidth, 30.0); 632 } 633 else 634 { 635 addPlatformStatic(randomXPosition(), sectionBegin + i*sectionLength/10); 636 } 637 } 638 break; 639 case 3: 640 // statisch mit 2 horizontal 641 for (int i = 0; i < 10; ++i) 642 { 643 if (i == randPos1 || i == randPos2) 644 { 645 addPlatformHMove(randomXPosition(), sectionBegin + i*sectionLength/10, -fieldWidth, fieldWidth, 30.0); 646 } 647 else 648 { 649 addPlatformStatic(randomXPosition(), sectionBegin + i*sectionLength/10); 650 } 651 } 652 break; 653 case 4: 654 // statisch mit 3 horizontal 655 for (int i = 0; i < 10; ++i) 656 { 657 if (i == randPos1 || i == randPos2 || i == randPos3) 658 { 659 addPlatformHMove(randomXPosition(), sectionBegin + i*sectionLength/10, -fieldWidth, fieldWidth, 30.0); 660 } 661 else 662 { 663 addPlatformStatic(randomXPosition(), sectionBegin + i*sectionLength/10); 664 } 665 } 666 break; 667 case 5: 668 // statisch mit 4 horizontal 669 for (int i = 0; i < 10; ++i) 670 { 671 if (i == randPos1 || i == randPos2 || i == randPos3 || i == randPos4) 672 { 673 addPlatformHMove(randomXPosition(), sectionBegin + i*sectionLength/10, -fieldWidth, fieldWidth, 30.0); 674 } 675 else 676 { 677 addPlatformStatic(randomXPosition(), sectionBegin + i*sectionLength/10); 678 } 679 } 680 break; 681 // Einfach horizontal 682 case 6: 683 for (int i = 0; i < 10; ++i) 684 { 685 addPlatformHMove(randomXPosition(), sectionBegin + i*sectionLength/10, -fieldWidth, fieldWidth, 30.0); 686 } 687 break; 688 // Doppelt horizontal 689 case 7: 690 for (int i = 0; i < 10; ++i) 691 { 692 float mediumPos = randomXPosition(3, 1); 693 addPlatformHMove(randomXPosition(3, 0), sectionBegin + i*sectionLength/10, -fieldWidth, mediumPos - platformLength/2, 30.0); 694 addPlatformHMove(randomXPosition(3, 2), sectionBegin + i*sectionLength/10, mediumPos+platformLength/2, fieldWidth, 30.0); 695 } 696 break; 697 // Einfach vertikal 698 case 8: 699 for (int i = 0; i < 7; ++i) 700 { 701 addPlatformVMove(-fieldWidth + i*fieldWidth*2/10, randomYPosition(sectionBegin, sectionEnd), sectionBegin, sectionEnd, 20.0); 702 } 703 break; 704 // Doppelt vertikal 705 case 9: 706 for (int i = 0; i < 14; ++i) 707 { 708 addPlatformVMove(-fieldWidth + i*fieldWidth*2/10, randomYPosition(sectionBegin, sectionEnd), sectionBegin, sectionEnd, 20.0); 709 } 710 break; 711 // Doppelt verschwindend 712 case 10: 713 for (int i = 0; i < 10; ++i) 714 { 715 for (int j = 0; j < 2; ++j) 716 { 717 addPlatformDisappear(randomXPosition(2, j), randomYPosition(sectionBegin, sectionEnd)); 718 } 719 } 720 break; 721 // Doppelt Timer 722 case 11: 723 for (int i = 0; i < 10; ++i) 724 { 725 for (int j = 0; j < 2; ++j) 726 { 727 addPlatformTimer(randomXPosition(2, j), randomYPosition(sectionBegin, sectionEnd), 6.0, 1.5); 728 } 454 729 } 455 730 break; … … 457 732 orxout() << "new section added with number "<< sectionNumber << endl; 458 733 734 fakeAdded_ = false; 735 459 736 ++ sectionNumber; 460 737 } … … 462 739 float Jump::randomXPosition() 463 740 { 464 return (float)(rand()%(2*(int)center_->getFieldDimension().x)) - center_->getFieldDimension().x; 741 float fieldWidth = center_->getFieldDimension().x; 742 743 return (float)(rand()%(2*(int)fieldWidth)) - fieldWidth; 744 } 745 746 float Jump::randomXPosition(int totalColumns, int culomn) 747 { 748 float fieldWidth = center_->getFieldDimension().x; 749 750 float width = 2*fieldWidth/totalColumns; 751 float leftBound = culomn*width-fieldWidth; 752 float platformLength = center_->getPlatformLength(); 753 754 return (float)(rand()%(int)(width-platformLength)) + leftBound + platformLength/2; 465 755 } 466 756 467 757 float Jump::randomYPosition(float lowerBoundary, float upperBoundary) 468 758 { 469 return (float)(rand()%(int)( upperBoundary - lowerBoundary))+ lowerBoundary;759 return (float)(rand()%(int)(100*(upperBoundary - lowerBoundary)))/100 + lowerBoundary; 470 760 } 471 761 -
code/branches/pickupsFS14/src/modules/jump/Jump.h
r10041 r10050 80 80 virtual void playerScored(PlayerInfo* player, int score = 1); //!< Is called when the player scored. 81 81 82 virtual void addPlatform(JumpPlatform* newPlatform, float xPosition, float zPosition);83 virtual void addStartSection();84 virtual void addSection();85 virtual float randomXPosition();86 virtual float randomYPosition(float lowerBoundary, float upperBoundary);87 88 82 int getScore(PlayerInfo* player) const; 89 83 … … 104 98 void cleanup(); //!< Cleans up the Gametype by destroying the ball and the bats. 105 99 100 virtual void addPlatform(JumpPlatform* newPlatform, std::string platformTemplate, float xPosition, float zPosition); 101 102 virtual void addPlatformStatic(float xPosition, float zPosition); 103 virtual void addPlatformHMove(float xPosition, float zPosition, float leftBoundary, float rightBoundary, float speed); 104 virtual void addPlatformVMove(float xPosition, float zPosition, float lowerBoundary, float upperBoundary, float speed); 105 virtual void addPlatformDisappear(float xPosition, float zPosition); 106 virtual void addPlatformTimer(float xPosition, float zPosition, float time, float variance); 107 virtual void addPlatformFake(float xPosition, float zPosition); 108 virtual void addProjectile(float xPosition, float zPosition, float xVelocity, float zVelocity); 109 virtual void addEnemy1(float xPosition, float zPosition, float leftBoundary, float rightBoundary, float lowerBoundary, float upperBoundary, float xVelocity, float zVelocity); 110 111 virtual void addStartSection(); 112 virtual void addSection(); 113 114 virtual float randomXPosition(); 115 virtual float randomXPosition(int totalColumns, int culomn); 116 virtual float randomYPosition(float lowerBoundary, float upperBoundary); 117 106 118 WeakPtr<JumpCenterpoint> center_; //!< The playing field. 107 //WeakPtr<JumpPlatform> ball_; //!< The Jump ball.108 119 WeakPtr<JumpFigure> figure_; //!< The two bats. 109 120 WeakPtr<Camera> camera; … … 113 124 float totalScreenShift; 114 125 float screenShiftSinceLastUpdate; 115 float sectionLength;116 126 int sectionNumber; 117 std::list<JumpPlatform*> platformList; 127 128 bool fakeAdded_; 118 129 }; 119 130 } -
code/branches/pickupsFS14/src/modules/jump/JumpPlatform.cc
r10041 r10050 59 59 60 60 this->figure_ = 0; 61 this->bDeleteBats_ = false;62 this->batID_ = new unsigned int[1];63 this->batID_[0] = OBJECTID_UNKNOWN;64 this->relMercyOffset_ = 0.05f;65 66 this->registerVariables();67 61 68 62 //initialize sound … … 86 80 this->setVelocity(Vector3(0,0,0)); 87 81 this->setAcceleration(Vector3(0,0,0)); 88 89 model = NULL;90 82 } 91 83 … … 116 108 /** 117 109 @brief 118 Register variables to synchronize over the network.119 */120 void JumpPlatform::registerVariables()121 {122 registerVariable( this->fieldWidth_ );123 registerVariable( this->fieldHeight_ );124 registerVariable( this->relMercyOffset_ );125 registerVariable( this->batID_[0] );126 //registerVariable( this->batID_[1], VariableDirection::ToClient, new NetworkCallback<JumpPlatform>( this, &JumpPlatform::applyBats) );127 }128 129 /**130 @brief131 110 Is called every tick. 132 111 Handles the movement of the ball and its interaction with the boundaries and bats. … … 147 126 if(figureVelocity.z < 0 && figurePosition.x > platformPosition.x-10 && figurePosition.x < platformPosition.x+10 && figurePosition.z > platformPosition.z-4 && figurePosition.z < platformPosition.z+4) 148 127 { 149 figure_->JumpFromPlatform(200.0f);128 touchFigure(); 150 129 } 151 130 } … … 249 228 void JumpPlatform::setFigure(WeakPtr<JumpFigure> newFigure) 250 229 { 251 if (this->bDeleteBats_) // If there are already some bats, delete them. 252 { 253 delete this->figure_; 254 this->bDeleteBats_ = false; 255 } 256 257 this->figure_ = newFigure; 258 // Also store their object IDs, for synchronization. 259 this->batID_[0] = this->figure_->getObjectID(); 260 } 261 262 /** 263 @brief 264 Get the bats over the network. 265 */ 266 void JumpPlatform::applyBats() 267 { 268 // Make space for the bats, if they don't exist, yet. 269 if (this->figure_ == NULL) 270 { 271 this->figure_ = *(new WeakPtr<JumpFigure>); 272 this->bDeleteBats_ = true; 273 } 274 275 if (this->batID_[0] != OBJECTID_UNKNOWN) 276 { 277 // WAR IM PONG NICHT AUSKOMMENTIERT!!! 278 //this->figure_ = orxonox_cast<JumpFigure>(Synchronisable::getSynchronisable(this->batID_[0])); 279 } 230 figure_ = newFigure; 231 } 232 233 void JumpPlatform::accelerateFigure() 234 { 235 figure_->JumpFromPlatform(this); 236 } 237 238 void JumpPlatform::touchFigure() 239 { 240 280 241 } 281 242 -
code/branches/pickupsFS14/src/modules/jump/JumpPlatform.h
r10041 r10050 89 89 90 90 void setFigure(WeakPtr<JumpFigure> bats); //!< Set the bats for the ball. 91 void applyBats(); //!< Get the bats over the network. 91 92 virtual void accelerateFigure(); 93 virtual void touchFigure(); 92 94 93 95 static const float MAX_REL_Z_VELOCITY; … … 101 103 102 104 protected: 103 void registerVariables();104 105 105 float fieldWidth_; //!< The width of the playing field. 106 106 float fieldHeight_; //!< The height of the playing field. 107 107 WeakPtr<JumpFigure> figure_; //!< An array with the two bats. 108 bool bDeleteBats_; //!< Bool, to keep track, of whether this->bat_ exists or not.109 unsigned int* batID_; //!< The object IDs of the bats, to be able to synchronize them over the network.110 float relMercyOffset_; //!< Offset, that makes the player not loose, when, in all fairness, he would have.111 108 WorldSound* defScoreSound_; 112 109 WorldSound* defBatSound_; 113 Model* model;114 110 WorldSound* defBoundarySound_; 115 111 }; -
code/branches/pickupsFS14/src/modules/jump/JumpPrereqs.h
r10041 r10050 73 73 class JumpPlatformHMove; 74 74 class JumpPlatformVMove; 75 class JumpPlatformDisappear; 76 class JumpPlatformTimer; 77 class JumpPlatformFake; 78 class JumpProjectile; 79 class JumpEnemy; 80 class JumpItem; 75 81 class JumpFigure; 76 82 class JumpCenterpoint;
Note: See TracChangeset
for help on using the changeset viewer.