[12177] | 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 | * Julien Kindle |
---|
| 24 | * Co-authors: |
---|
| 25 | * |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | /** |
---|
| 30 | @file SOBGumba.cc |
---|
| 31 | @brief All items in this minigame inherit from this class. Items can move around like platforms and enemies. |
---|
| 32 | */ |
---|
| 33 | |
---|
| 34 | #include "SOBCactus.h" |
---|
| 35 | |
---|
| 36 | #include "core/CoreIncludes.h" |
---|
| 37 | #include "core/XMLPort.h" |
---|
| 38 | #include "SOBFigure.h" |
---|
| 39 | #include "util/Output.h" |
---|
| 40 | #include "objects/collisionshapes/BoxCollisionShape.h" |
---|
| 41 | |
---|
| 42 | |
---|
| 43 | namespace orxonox |
---|
| 44 | { |
---|
| 45 | RegisterClass(SOBCactus); |
---|
| 46 | |
---|
| 47 | SOBCactus::SOBCactus(Context* context) : MovableEntity(context) |
---|
| 48 | { |
---|
| 49 | RegisterObject(SOBCactus); |
---|
| 50 | //a=CollisionType::None; //initializing Collisiontypes for tick function |
---|
| 51 | //b=CollisionType::Dynamic; //initializing Collisiontypes for tick function |
---|
| 52 | |
---|
| 53 | a = new BoxCollisionShape(context); //BoxCollisionshape initialized for tube (here in Programm not in SOB.oxw as others) |
---|
| 54 | a->setPosition(Vector3(0,0,25)); |
---|
| 55 | a->setHalfExtents(Vector3(5, 5, 7)); |
---|
| 56 | |
---|
| 57 | |
---|
| 58 | b = new BoxCollisionShape(context); //BoxCollisionshape initialized for tube (here in Programm not in SOB.oxw as others) |
---|
| 59 | b->setPosition(Vector3(0,0,16)); |
---|
| 60 | b->setHalfExtents(Vector3(5, 5, 15)); |
---|
| 61 | |
---|
| 62 | |
---|
| 63 | setAngularFactor(0.0); |
---|
| 64 | this->enableCollisionCallback(); |
---|
| 65 | gravityAcceleration_ = 350.0; |
---|
| 66 | speed_ = 0.0; |
---|
| 67 | hasCollided_=false; |
---|
| 68 | goesUp_ = true; |
---|
| 69 | changeAllowed_ = true; |
---|
| 70 | changedOn_ = 0.0; |
---|
| 71 | creator_ = nullptr; |
---|
| 72 | maxLifetime_ = 10; |
---|
| 73 | lifetime_ = 0; |
---|
| 74 | k = 0; |
---|
| 75 | |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | |
---|
| 79 | |
---|
| 80 | void SOBCactus::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
---|
| 81 | { |
---|
| 82 | SUPER(SOBCactus, XMLPort, xmlelement, mode); |
---|
| 83 | XMLPortParam(SOBCactus, "speed", setSpeed, getSpeed, xmlelement, mode); |
---|
| 84 | |
---|
| 85 | |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | |
---|
| 89 | bool SOBCactus::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) { |
---|
| 90 | |
---|
| 91 | return true; |
---|
| 92 | } |
---|
| 93 | |
---|
| 94 | |
---|
| 95 | void SOBCactus::setDirection(const bool direction) |
---|
| 96 | { |
---|
| 97 | |
---|
| 98 | } |
---|
| 99 | |
---|
| 100 | void SOBCactus::die(){ |
---|
| 101 | Vector3 velocity = this->getVelocity(); |
---|
| 102 | velocity.y = speed_; |
---|
| 103 | this->setVelocity(velocity); |
---|
| 104 | } |
---|
| 105 | |
---|
| 106 | void SOBCactus::tick(float dt) |
---|
| 107 | { |
---|
| 108 | SUPER(SOBCactus, tick, dt); |
---|
| 109 | |
---|
| 110 | k++; |
---|
| 111 | |
---|
| 112 | Vector3 velocity = getVelocity(); |
---|
| 113 | |
---|
| 114 | velocity.y = 0; |
---|
| 115 | |
---|
| 116 | |
---|
| 117 | if (k > -5 && k < 100 ) |
---|
| 118 | { |
---|
| 119 | velocity.z = -speed_; |
---|
| 120 | } |
---|
| 121 | else if(k >= 100 && k < 200) |
---|
| 122 | { |
---|
| 123 | velocity.z = speed_; |
---|
| 124 | } |
---|
| 125 | else |
---|
| 126 | { |
---|
| 127 | k=0; |
---|
| 128 | } |
---|
| 129 | |
---|
| 130 | if( k > 2 && k < 198){ |
---|
| 131 | //CollisionType a = CollisionType::None; |
---|
| 132 | //this->setCollisionType(a); |
---|
| 133 | detachCollisionShape(getAttachedCollisionShape(0)); |
---|
| 134 | attachCollisionShape(a); |
---|
| 135 | } |
---|
| 136 | else{ |
---|
| 137 | //this->setCollisionType(b); |
---|
| 138 | detachCollisionShape(getAttachedCollisionShape(0)); |
---|
| 139 | attachCollisionShape(b); |
---|
| 140 | } |
---|
| 141 | this->setVelocity(velocity); |
---|
| 142 | } |
---|
| 143 | } |
---|