[12060] | 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 | * Fabian 'x3n' Landau |
---|
| 24 | * Co-authors: |
---|
| 25 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | #include "StoryModeController.h" |
---|
| 30 | |
---|
[12131] | 31 | |
---|
[12060] | 32 | #include "core/CoreIncludes.h" |
---|
| 33 | #include "worldentities/ControllableEntity.h" |
---|
[12110] | 34 | #include "graphics/Camera.h" |
---|
[12106] | 35 | #include "SMCoord.h" |
---|
[12110] | 36 | #include "core/XMLPort.h" |
---|
[12131] | 37 | #include "gamestates/GSLevel.h" |
---|
[12060] | 38 | namespace orxonox |
---|
| 39 | { |
---|
| 40 | RegisterClass(StoryModeController); |
---|
| 41 | |
---|
[12110] | 42 | StoryModeController::StoryModeController(Context* context) : SpaceShip(context) |
---|
[12060] | 43 | { |
---|
| 44 | RegisterObject(StoryModeController); |
---|
[12106] | 45 | float time_; |
---|
[12110] | 46 | selectedPos_ = new SMCoord(0); |
---|
| 47 | moveForward_= false; |
---|
[12106] | 48 | moveBackward_=false; |
---|
| 49 | boostPressed_=false; |
---|
[12131] | 50 | dtime_=50; |
---|
[12110] | 51 | |
---|
[12106] | 52 | |
---|
[12060] | 53 | } |
---|
| 54 | StoryModeController::~StoryModeController() |
---|
| 55 | { |
---|
[12110] | 56 | delete selectedPos_; |
---|
| 57 | selectedPos_ = nullptr; |
---|
[12101] | 58 | |
---|
[12060] | 59 | } |
---|
[12131] | 60 | //void StoryModeController:: switchCamera(){}; |
---|
[12106] | 61 | void StoryModeController::updatePosition(){ |
---|
[12110] | 62 | Vector3 pos = selectedPos_->get3dcoordinate(); |
---|
| 63 | setPosition(pos); |
---|
[12106] | 64 | } |
---|
[12110] | 65 | void StoryModeController::setLocation(int index){ |
---|
| 66 | selectedPos_->set(index); |
---|
[12106] | 67 | } |
---|
| 68 | |
---|
[12060] | 69 | void StoryModeController::tick(float dt) |
---|
| 70 | { |
---|
[12131] | 71 | //orxout(internal_error) << "Hi" << endl; |
---|
[12110] | 72 | SUPER(StoryModeController, tick, dt); |
---|
| 73 | time_ +=dt; |
---|
[12131] | 74 | Camera* camera = this->getCamera(); |
---|
| 75 | |
---|
| 76 | |
---|
[12110] | 77 | |
---|
[12131] | 78 | if(time_>= dtime_*dt){ |
---|
| 79 | |
---|
| 80 | time_=0; |
---|
| 81 | |
---|
| 82 | if(moveForward_ == true){ |
---|
| 83 | orxout(internal_error) << "Position update" << endl; |
---|
| 84 | moveForward_ = false; |
---|
| 85 | selectedPos_->set(selectedPos_->getIndex()+1); |
---|
[12110] | 86 | updatePosition(); |
---|
[12131] | 87 | } |
---|
| 88 | |
---|
| 89 | if(moveBackward_ == true){ |
---|
| 90 | orxout(internal_error) << "Position update" << endl; |
---|
| 91 | moveBackward_ = false; |
---|
| 92 | selectedPos_->set(selectedPos_->getIndex()-1); |
---|
| 93 | updatePosition(); |
---|
| 94 | } |
---|
| 95 | |
---|
| 96 | if(boostPressed_ == true){ |
---|
| 97 | boostPressed_ = false; |
---|
| 98 | chooseGame(); |
---|
| 99 | } |
---|
| 100 | |
---|
| 101 | |
---|
| 102 | if (camera != nullptr) |
---|
| 103 | { |
---|
| 104 | |
---|
| 105 | Vector3 epos = selectedPos_->get3dcoordinate(); |
---|
| 106 | orxout(internal_error) << "ex: "<< epos.x <<" ey: "<< epos.y << " ez: " << epos.z<< endl; |
---|
| 107 | camera->setPosition(-(epos.x),-(epos.y),-(epos.z)+1000); |
---|
| 108 | camera->setOrientation(Vector3::UNIT_Z, Degree(0)); |
---|
| 109 | |
---|
| 110 | } |
---|
| 111 | } |
---|
[12106] | 112 | |
---|
[12060] | 113 | } |
---|
| 114 | |
---|
[12101] | 115 | void StoryModeController::moveFrontBack(const Vector2& value) |
---|
| 116 | { |
---|
[12131] | 117 | // orxout(internal_error) << "moveFrontBack" << endl; |
---|
[12101] | 118 | } |
---|
[12110] | 119 | |
---|
| 120 | void StoryModeController::chooseGame() |
---|
| 121 | { |
---|
[12131] | 122 | int ind = selectedPos_->getIndex(); |
---|
| 123 | std::string name = "changeGame "; |
---|
| 124 | switch(ind){ |
---|
| 125 | case 0: |
---|
| 126 | name = name + "pong.oxw"; |
---|
| 127 | break; |
---|
| 128 | case 1: |
---|
| 129 | |
---|
| 130 | break; |
---|
| 131 | case 2: |
---|
| 132 | |
---|
| 133 | break; |
---|
| 134 | case 3: |
---|
| 135 | |
---|
| 136 | break; |
---|
| 137 | case 4: |
---|
| 138 | |
---|
| 139 | break; |
---|
| 140 | case 5: |
---|
| 141 | |
---|
| 142 | break; |
---|
| 143 | case 6: |
---|
| 144 | |
---|
| 145 | break; |
---|
| 146 | case 7: |
---|
| 147 | |
---|
| 148 | break; |
---|
| 149 | case 8: |
---|
| 150 | |
---|
| 151 | break; |
---|
| 152 | default: |
---|
| 153 | break; |
---|
| 154 | } |
---|
| 155 | CommandExecutor::execute(name); |
---|
| 156 | /*for (GSLevel* level : ObjectList<GSLevel>()) |
---|
| 157 | level->changeGame(name);*/ |
---|
| 158 | //hideAllMenuSheets(); |
---|
[12110] | 159 | } |
---|
| 160 | |
---|
| 161 | |
---|
[12101] | 162 | void StoryModeController::moveRightLeft(const Vector2& value) |
---|
| 163 | { |
---|
[12131] | 164 | if(!moveForward_&&!moveBackward_){ |
---|
| 165 | if (value.x>0){ |
---|
| 166 | orxout(internal_error) << "Right" << endl; |
---|
| 167 | moveForward_ =true; |
---|
| 168 | moveBackward_ =false; |
---|
| 169 | } else { |
---|
| 170 | orxout(internal_error) << "Left" << endl; |
---|
| 171 | moveBackward_ = true; |
---|
| 172 | moveForward_ = false; |
---|
| 173 | } |
---|
[12106] | 174 | } |
---|
[12101] | 175 | |
---|
| 176 | } |
---|
| 177 | |
---|
[12110] | 178 | void StoryModeController::rotateYaw(const Vector2& value){ |
---|
[12131] | 179 | //orxout(internal_error) << "RightLeft" << endl; |
---|
[12110] | 180 | } |
---|
| 181 | void StoryModeController::rotatePitch(const Vector2& value){ |
---|
[12131] | 182 | //orxout(internal_error) << "RightLeft" << endl; |
---|
[12110] | 183 | } |
---|
| 184 | void StoryModeController::rotateRoll(const Vector2& value){ |
---|
[12131] | 185 | //orxout(internal_error) << "RightLeft" << endl; |
---|
[12110] | 186 | } |
---|
[12101] | 187 | void StoryModeController::fire(unsigned int a){} |
---|
| 188 | void StoryModeController::fired(unsigned int b){} |
---|
[12106] | 189 | void StoryModeController::boost(bool bBoost){ |
---|
[12110] | 190 | orxout(internal_error) << "Boost" << endl; |
---|
[12106] | 191 | boostPressed_ = true; |
---|
| 192 | } |
---|
[12060] | 193 | } |
---|