/* * ORXONOX - the hottest 3D action shooter ever to exist * > www.orxonox.net < * * * License notice: * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * Author: * Julien Kindle * Co-authors: * * */ /** @file SOBGumba.cc @brief All items in this minigame inherit from this class. Items can move around like platforms and enemies. */ #include "SOBCactus.h" #include "core/CoreIncludes.h" #include "core/XMLPort.h" #include "SOBFigure.h" #include "util/Output.h" #include "objects/collisionshapes/BoxCollisionShape.h" namespace orxonox { RegisterClass(SOBCactus); SOBCactus::SOBCactus(Context* context) : MovableEntity(context) { RegisterObject(SOBCactus); //a=CollisionType::None; //initializing Collisiontypes for tick function //b=CollisionType::Dynamic; //initializing Collisiontypes for tick function a = new BoxCollisionShape(context); //BoxCollisionshape initialized for tube (here in Programm not in SOB.oxw as others) a->setPosition(Vector3(0,0,25)); a->setHalfExtents(Vector3(5, 5, 7)); b = new BoxCollisionShape(context); //BoxCollisionshape initialized for tube (here in Programm not in SOB.oxw as others) b->setPosition(Vector3(0,0,16)); b->setHalfExtents(Vector3(5, 5, 15)); setAngularFactor(0.0); this->enableCollisionCallback(); gravityAcceleration_ = 350.0; speed_ = 0.0; hasCollided_=false; goesUp_ = true; changeAllowed_ = true; changedOn_ = 0.0; creator_ = nullptr; maxLifetime_ = 10; lifetime_ = 0; k = 0; } void SOBCactus::XMLPort(Element& xmlelement, XMLPort::Mode mode) { SUPER(SOBCactus, XMLPort, xmlelement, mode); XMLPortParam(SOBCactus, "speed", setSpeed, getSpeed, xmlelement, mode); } bool SOBCactus::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) { return true; } void SOBCactus::setDirection(const bool direction) { } void SOBCactus::die(){ Vector3 velocity = this->getVelocity(); velocity.y = speed_; this->setVelocity(velocity); } void SOBCactus::tick(float dt) { SUPER(SOBCactus, tick, dt); k++; Vector3 velocity = getVelocity(); velocity.y = 0; if (k > -5 && k < 100 ) { velocity.z = -speed_; } else if(k >= 100 && k < 200) { velocity.z = speed_; } else { k=0; } if( k > 2 && k < 198){ //CollisionType a = CollisionType::None; //this->setCollisionType(a); detachCollisionShape(getAttachedCollisionShape(0)); attachCollisionShape(a); } else{ //this->setCollisionType(b); detachCollisionShape(getAttachedCollisionShape(0)); attachCollisionShape(b); } this->setVelocity(velocity); } }