Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/WorldMap_HS18/src/orxonox/controllers/StoryModeController.cc @ 12131

Last change on this file since 12131 was 12131, checked in by linggj, 5 years ago

it works but needs some beuty to be added

File size: 5.4 KB
Line 
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
31
32#include "core/CoreIncludes.h"
33#include "worldentities/ControllableEntity.h"
34#include "graphics/Camera.h"
35#include "SMCoord.h"
36#include "core/XMLPort.h"
37#include "gamestates/GSLevel.h"
38namespace orxonox
39{
40    RegisterClass(StoryModeController);
41
42   StoryModeController::StoryModeController(Context* context) : SpaceShip(context)
43    {
44        RegisterObject(StoryModeController);
45        float time_;
46        selectedPos_ = new SMCoord(0);
47        moveForward_= false;
48        moveBackward_=false;                     
49        boostPressed_=false;
50        dtime_=50;
51
52     
53    }
54    StoryModeController::~StoryModeController()
55    {
56        delete selectedPos_;
57        selectedPos_ = nullptr;
58
59    }
60    //void StoryModeController:: switchCamera(){};
61    void StoryModeController::updatePosition(){
62        Vector3 pos = selectedPos_->get3dcoordinate();
63        setPosition(pos);
64    }
65    void StoryModeController::setLocation(int index){
66         selectedPos_->set(index);
67    }
68
69    void StoryModeController::tick(float dt)
70    {
71        //orxout(internal_error) << "Hi" << endl;
72        SUPER(StoryModeController, tick, dt);
73        time_ +=dt;
74           Camera* camera = this->getCamera();
75           
76       
77
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);
86                updatePosition();
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       }
112       
113    }
114
115    void StoryModeController::moveFrontBack(const Vector2& value)
116    {
117          // orxout(internal_error) << "moveFrontBack" << endl;         
118    }
119
120    void StoryModeController::chooseGame()
121    {
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();     
159    }
160
161
162    void StoryModeController::moveRightLeft(const Vector2& value)
163    {
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            }
174        }
175
176    }
177
178    void StoryModeController::rotateYaw(const Vector2& value){
179        //orxout(internal_error) << "RightLeft" << endl;
180    }
181    void StoryModeController::rotatePitch(const Vector2& value){
182        //orxout(internal_error) << "RightLeft" << endl;
183    }
184    void StoryModeController::rotateRoll(const Vector2& value){
185        //orxout(internal_error) << "RightLeft" << endl;
186    }
187    void StoryModeController::fire(unsigned int a){}
188    void StoryModeController::fired(unsigned int b){}
189    void StoryModeController::boost(bool bBoost){
190        orxout(internal_error) << "Boost" << endl; 
191        boostPressed_ = true;
192    }
193}
Note: See TracBrowser for help on using the repository browser.