/* * 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: * Manuel Meier * Co-authors: * Cyrill Burgener * */ /** @file OrxoKart.cc @brief Implementation of the OrxoKart class. Sets up the whole Minigame */ #include "OrxoKart.h" #include "OrxoKartFlag.h" #include "OrxoKartKart.h" #include "OrxoKartOrigin.h" #include "OrxoKartTile.h" #include "core/CoreIncludes.h" namespace orxonox { RegisterUnloadableClass(OrxoKart); OrxoKart::OrxoKart(Context* context) : Gametype(context) { RegisterObject(OrxoKart); this->origin_ = nullptr; this->raceFinished = false; this->firstTick_ = true; this->numberOfShrooms = 3; this->player = nullptr; this->setHUDTemplate("OrxoKartHUD"); } void OrxoKart::tick(float dt) { SUPER(OrxoKart, tick, dt); if(this->firstTick_ && this->origin_) { this->firstTick_ = false; this->wayPoints = std::vector(3, nullptr); this->n = this->origin_->getNumCells(); this->s = this->origin_->getCellSize(); this->level = this->origin_->getLevel(); int map_1[] = {1,1,1,1,1,1,1,1,0,0,0 ,1,0,0,0,0,0,0,1,1,1,0 ,1,0,1,1,1,1,0,0,0,1,1 ,1,1,1,0,0,1,1,0,0,0,1 ,0,0,0,0,0,0,1,0,1,1,1 ,1,1,1,1,1,1,1,0,1,0,0 ,1,0,0,0,0,0,0,0,1,0,0 ,1,0,0,0,0,0,0,0,1,0,0 ,1,1,1,1,1,0,0,0,1,1,1 ,0,0,0,0,1,0,0,0,0,0,1 ,0,0,0,0,1,1,1,2,1,1,1}; int map_2[] = {1,1,1,1,1,1,1,1,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0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, 0,1,0,1,0,1,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1, 0,1,1,1,0,1,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1, 0,0,0,0,0,1,1,1,0,0,0,1,0,0,0,0,0,0,0,0,1,1,1,0,1, 0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,2,1,1,1,0,1,1,1}; int *levelcodeArray = level==1 ? map_1 : map_2; // int z = 0; //Generate floor according to levelcode for(int i=0; igetContext()); tile->init((n-1-i)*s, j*s, s, 0, type); // tiles.push_back(tile); //++z; if (level == 1) { //map 1 if ( i == 9 && j == 4 ) wayPoints.at(0) = tile; if ( i == 0 && j == 1) wayPoints.at(1) = tile; if ( i == 10 && j == 7) wayPoints.at(2) = tile; } else if (level == 2) { //map 2 if ( i == 23 && j == 11 ) wayPoints.at(0) = tile; if ( i == 0 && j == 1) wayPoints.at(1) = tile; if ( i == 24 && j == 17) wayPoints.at(2) = tile; } } } } //bottom flag OrxoKartFlag* flag = new OrxoKartFlag(origin_->getContext()); flag->init(n, s); flag_ = flag; } //firsttick end if (wayPointCounter >= 3) raceFinished = true; else if (wayPointCounter < 3 && wayPointCounter >= 0 && wayPoints.at(wayPointCounter) != nullptr) { if (wayPoints.at(wayPointCounter)->getCollided()) { for (int i = 0; i < 3; ++i) { wayPoints.at(i)->setCollided(false); } ++wayPointCounter; } } else { //orxout() << " Should not happen, look in OrxoKart.cc"; } //orxout() << numberOfShrooms << endl; // Check if ship collided with the flag, flag is the bottom that is responsible for the game to detect the spaceship falling. if(flag_->getCollided()){ //orxout() << numberOfShrooms << endl; player = flag_->getObjectofCollision(); if (level == 1) player->setPosition(Vector3(s*0, 20, s*8.5)); if (level == 2) player->setPosition(Vector3(s*0, 20, s*18.5)); player->setOrientation(Quaternion(1, 0, 0, 0)); // 0, 0, 0 player->setVelocity(Vector3(0,0,0)); player->setAcceleration(Vector3(0,0,0)); flag_->setCollided(false); wayPointCounter = 0; } if (player && player->isBoosting()) { //orxout() << "Boosting" << endl; if(!numberOfShrooms) numberOfShrooms--; } } }