[11400] | 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 SOBQBlock.cc |
---|
| 31 | @brief If this QBlock is created, attachedToFigure_ is set to false. When the figure picks it up, the variable is set to true and the figure starts flying fast until the fuel is reduced to zero. |
---|
| 32 | */ |
---|
| 33 | |
---|
| 34 | #include "SOBQBlock.h" |
---|
| 35 | |
---|
| 36 | #include "core/CoreIncludes.h" |
---|
[11405] | 37 | #include "core/XMLPort.h" |
---|
| 38 | #include "SOB.h" |
---|
| 39 | #include "SOBMushroom.h" |
---|
[11400] | 40 | |
---|
| 41 | namespace orxonox |
---|
| 42 | { |
---|
| 43 | RegisterClass(SOBQBlock); |
---|
| 44 | |
---|
| 45 | SOBQBlock::SOBQBlock(Context* context) : SOBItem(context) |
---|
| 46 | { |
---|
| 47 | RegisterObject(SOBQBlock); |
---|
| 48 | used_ = false; |
---|
| 49 | |
---|
| 50 | // setPosition(Vector3(0,0,0)); |
---|
| 51 | // setVelocity(Vector3(0,0,0)); |
---|
| 52 | // setAcceleration(Vector3(0,0,0)); |
---|
| 53 | // setProperties(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | SOBQBlock::~SOBQBlock() |
---|
| 57 | { |
---|
| 58 | |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | |
---|
| 62 | bool SOBQBlock::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) { |
---|
| 63 | |
---|
| 64 | float v_z = otherObject->getVelocity().z; |
---|
| 65 | if (!used_ && v_z > 50.0) { |
---|
| 66 | used_ = true; |
---|
| 67 | |
---|
[11405] | 68 | for (WorldEntity* object : this->getAttachedObjects()) |
---|
| 69 | object->setVisible(!object->isVisible()); |
---|
| 70 | |
---|
| 71 | SOB* SOBGame = orxonox_cast<SOB*>(getGametype()); |
---|
| 72 | if (type_ == "Coin") { |
---|
| 73 | SOBGame->addCoin(); |
---|
[11400] | 74 | } |
---|
[11405] | 75 | if (type_ == "Mushroom") { |
---|
| 76 | spawnMushroom(); |
---|
| 77 | } |
---|
[11400] | 78 | |
---|
| 79 | } |
---|
| 80 | return true; |
---|
| 81 | } |
---|
| 82 | |
---|
| 83 | |
---|
[11405] | 84 | void SOBQBlock::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
---|
| 85 | { |
---|
| 86 | SUPER(SOBQBlock, XMLPort, xmlelement, mode); |
---|
| 87 | XMLPortParam(SOBQBlock, "type", setType, getType, xmlelement, mode).defaultValues(false); |
---|
| 88 | |
---|
| 89 | |
---|
| 90 | } |
---|
| 91 | |
---|
| 92 | |
---|
| 93 | void SOBQBlock::spawnMushroom() { |
---|
| 94 | SOBCenterpoint* center_ = ((SOB*)getGametype())->center_; |
---|
| 95 | |
---|
| 96 | SOBMushroom* mush = new SOBMushroom(center_->getContext()); |
---|
| 97 | Vector3 spawnpos = this->getWorldPosition(); |
---|
| 98 | spawnpos.z += 0; |
---|
| 99 | |
---|
| 100 | if (mush != nullptr && center_ != nullptr) |
---|
| 101 | { |
---|
| 102 | mush->addTemplate("mushroom"); |
---|
| 103 | |
---|
| 104 | |
---|
| 105 | |
---|
| 106 | //newBoots->addTemplate(center_->getBootsTemplate()); |
---|
| 107 | mush->setPosition(spawnpos); |
---|
| 108 | //newBoots->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity); |
---|
| 109 | //newBoots->setFigure(figure_); |
---|
| 110 | //center_->attach(newBoots); |
---|
| 111 | } |
---|
| 112 | } |
---|
| 113 | |
---|
| 114 | |
---|
[11400] | 115 | } |
---|