Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/pickupsFS14/src/modules/jump/Jump.cc @ 10035

Last change on this file since 10035 was 10032, checked in by fvultier, 11 years ago

Neue Platformen werden zur Laufzeit hinzugefugt, wenn sich die Ansicht nach oben verschiebt. Eigene Modelle importieren funktioniert.

File size: 6.2 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 *      Florian Zinggeler
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30    @file Jump.cc
31    @brief Implementation of the Jump class.
32*/
33
34#include "Jump.h"
35#include "core/CoreIncludes.h"
36#include "core/EventIncludes.h"
37#include "core/command/Executor.h"
38#include "core/config/ConfigValueIncludes.h"
39
40#include "gamestates/GSLevel.h"
41#include "chat/ChatManager.h"
42
43// ! HACK
44#include "infos/PlayerInfo.h"
45
46#include "JumpCenterPoint.h"
47#include "JumpShip.h"
48/*
49#include "JumpEnemy.h"
50#include "JumpEnemyShooter.h"*/
51
52#include "core/command/ConsoleCommand.h"
53#include "worldentities/BigExplosion.h"
54
55namespace orxonox
56{
57    RegisterUnloadableClass(Jump);
58
59    Jump::Jump(Context* context) : Deathmatch(context)
60    {
61        RegisterObject(Jump);
62        platformList.clear();
63        yScreenPosition = 0;
64        screenShiftSinceLastUpdate = 0;
65
66        //this->numberOfBots_ = 0; //sets number of default bots temporarly to 0
67        //this->center_ = 0;
68        //this->setHUDTemplate("JumpHUD");
69
70
71    }
72
73
74    /*void Jump::levelUp()
75    {
76        level++;
77        if (getPlayer() != NULL)
78        {
79            for (int i = 0; i < 7; i++)
80            {
81                WeakPtr<BigExplosion> chunk = new BigExplosion(this->center_->getContext());
82                chunk->setPosition(Vector3(600, 0, 100.f * i - 300));
83                chunk->setVelocity(Vector3(1000, 0, 0));  //player->getVelocity()
84                chunk->setScale(20);
85            }
86        }
87        addPoints(multiplier * 42);
88        multiplier *= 2;
89        toggleShowLevel();
90        showLevelTimer.setTimer(1.0f, false, createExecutor(createFunctor(&Jump::toggleShowLevel, this)));
91    }*/
92
93    WeakPtr<JumpShip> Jump::getPlayer()
94    {
95        if (player == NULL)
96        {
97                for (ObjectList<JumpShip>::iterator it = ObjectList<JumpShip>::begin(); it != ObjectList<JumpShip>::end(); ++it)
98                {
99                player = *it;
100                }
101        }
102        return player;
103    }
104
105    void Jump::tick(float dt)
106    {
107
108
109        if (getPlayer() != NULL)
110        {
111            Vector3 shipPosition = getPlayer()->getPosition();
112
113                // Bildschirmposition kann nur nach oben verschoben werden
114                if (shipPosition.y > yScreenPosition)
115                {
116                        screenShiftSinceLastUpdate += shipPosition.y - yScreenPosition;
117
118                        yScreenPosition = shipPosition.y;
119                }
120
121                // Kameraposition nachfuehren
122                if (camera == NULL)
123                {
124                        camera = getPlayer()->getCamera();
125                }
126            if (camera != NULL)
127            {
128                camera->setPosition(Vector3(-shipPosition.x, yScreenPosition-shipPosition.y, 100));
129                //camera->setOrientation(Vector3::UNIT_Z, Degree(180));
130            }
131
132            if (screenShiftSinceLastUpdate > 200.0)
133            {
134                screenShiftSinceLastUpdate -= 200.0;
135                orxout() << "new section added" << endl;
136                addPlatform(shipPosition.x, shipPosition.y + 300.0);
137            }
138
139        }
140
141        SUPER(Jump, tick, dt);
142    }
143
144
145    /*void Jump::spawnEnemy()
146    {
147        if (getPlayer() == NULL)
148            return;
149
150        for (int i = 0; i < (3*log10(static_cast<double>(level)) + 1); i++)
151        {
152            WeakPtr<JumpEnemy> newPawn;
153            if (rand() % 42/(1 + level*level) == 0)
154            {
155                newPawn = new JumpEnemyShooter(this->center_->getContext());
156                newPawn->addTemplate("enemyjumpshooter");
157            }
158            else
159            {
160                newPawn = new JumpEnemy(this->center_->getContext());
161                newPawn->addTemplate("enemyjump");
162            }
163            newPawn->setPlayer(player);
164            newPawn->level = level;
165            // spawn enemy at random points in front of player.
166            newPawn->setPosition(player->getPosition() + Vector3(500.f + 100 * i, 0, float(rand())/RAND_MAX * 400 - 200));
167        }
168    }*/
169
170    /*void Jump::costLife()
171    {
172        lives--;
173        multiplier = 1;
174        // end the game in 30 seconds.
175        if (lives <= 0)
176            enemySpawnTimer.setTimer(30.0f, false, createExecutor(createFunctor(&Jump::end, this)));
177    };*/
178
179    /*void Jump::comboControll()
180    {
181        if (b_combo)
182            multiplier++;
183        // if no combo was performed before, reset multiplier
184        else
185            multiplier = 1;
186        b_combo = false;
187    }*/
188
189
190    void Jump::start()
191    {
192        // Call start for the parent class.
193        Deathmatch::start();
194
195        /*
196        // Set variable to temporarily force the player to spawn.
197        this->bForceSpawn_ = true;
198
199        if (this->center_ == NULL)  // abandon mission!
200        {
201            orxout(internal_error) << "Jump: No Centerpoint specified." << endl;
202            GSLevel::startMainMenu();
203            return;
204        }
205        */
206
207        //addPlatform(0,0);
208
209    }
210
211
212    /*void Jump::addPoints(int numPoints)
213    {
214        if (!bEndGame)
215        {
216            point += numPoints * multiplier;
217            b_combo = true;
218        }
219    }*/
220
221    /*void Jump::end()
222    {
223        // DON'T CALL THIS!
224        //      Deathmatch::end();
225        // It will misteriously crash the game!
226        // Instead startMainMenu, this won't crash.
227        GSLevel::startMainMenu();
228    }*/
229
230    void Jump::addPlatform(float xPosition, float yPosition)
231    {
232                JumpPlatform* newPlatform = new JumpPlatform(center_->getContext());
233                newPlatform->setPosition(Vector3(xPosition, yPosition, 0));
234                platformList.push_front(newPlatform);
235    }
236
237}
Note: See TracBrowser for help on using the repository browser.