/* * 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: * Fabian 'x3n' Landau * Co-authors: * ... * */ #include "StoryModeController.h" #include "core/CoreIncludes.h" #include "worldentities/ControllableEntity.h" #include "graphics/Camera.h" #include "SMCoord.h" #include "core/XMLPort.h" #include "gamestates/GSLevel.h" namespace orxonox { RegisterClass(StoryModeController); StoryModeController::StoryModeController(Context* context) : SpaceShip(context) { RegisterObject(StoryModeController); float time_; selectedPos_ = new SMCoord(0); moveForward_= false; moveBackward_=false; boostPressed_=false; dtime_=50; } StoryModeController::~StoryModeController() { delete selectedPos_; selectedPos_ = nullptr; } //void StoryModeController:: switchCamera(){}; void StoryModeController::updatePosition(){ Vector3 pos = selectedPos_->get3dcoordinate(); setPosition(pos); } void StoryModeController::setLocation(int index){ selectedPos_->set(index); } void StoryModeController::tick(float dt) { //orxout(internal_error) << "Hi" << endl; SUPER(StoryModeController, tick, dt); time_ +=dt; Camera* camera = this->getCamera(); if(time_>= dtime_*dt){ time_=0; if(moveForward_ == true){ orxout(internal_error) << "Position update" << endl; moveForward_ = false; selectedPos_->set(selectedPos_->getIndex()+1); updatePosition(); } if(moveBackward_ == true){ orxout(internal_error) << "Position update" << endl; moveBackward_ = false; selectedPos_->set(selectedPos_->getIndex()-1); updatePosition(); } if(boostPressed_ == true){ boostPressed_ = false; chooseGame(); } if (camera != nullptr) { Vector3 epos = selectedPos_->get3dcoordinate(); orxout(internal_error) << "ex: "<< epos.x <<" ey: "<< epos.y << " ez: " << epos.z<< endl; camera->setPosition(-(epos.x),-(epos.y),-(epos.z)+1000); camera->setOrientation(Vector3::UNIT_Z, Degree(0)); } } } void StoryModeController::moveFrontBack(const Vector2& value) { // orxout(internal_error) << "moveFrontBack" << endl; } void StoryModeController::chooseGame() { int ind = selectedPos_->getIndex(); std::string name = "changeGame "; switch(ind){ case 0: name = name + "pong.oxw"; break; case 1: break; case 2: break; case 3: break; case 4: break; case 5: break; case 6: break; case 7: break; case 8: break; default: break; } CommandExecutor::execute(name); /*for (GSLevel* level : ObjectList()) level->changeGame(name);*/ //hideAllMenuSheets(); } void StoryModeController::moveRightLeft(const Vector2& value) { if(!moveForward_&&!moveBackward_){ if (value.x>0){ orxout(internal_error) << "Right" << endl; moveForward_ =true; moveBackward_ =false; } else { orxout(internal_error) << "Left" << endl; moveBackward_ = true; moveForward_ = false; } } } void StoryModeController::rotateYaw(const Vector2& value){ //orxout(internal_error) << "RightLeft" << endl; } void StoryModeController::rotatePitch(const Vector2& value){ //orxout(internal_error) << "RightLeft" << endl; } void StoryModeController::rotateRoll(const Vector2& value){ //orxout(internal_error) << "RightLeft" << endl; } void StoryModeController::fire(unsigned int a){} void StoryModeController::fired(unsigned int b){} void StoryModeController::boost(bool bBoost){ orxout(internal_error) << "Boost" << endl; boostPressed_ = true; } }