Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/SpaceRace_HS16/src/modules/gametypes/OldSpaceRace.cc @ 11246

Last change on this file since 11246 was 11246, checked in by bberabi, 8 years ago

sound and countdown erledigt, flugzeuge konnen nicht mehr sich bewegen bevor countdown ends

  • Property svn:eol-style set to native
File size: 4.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 *     Mauro Salomon
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#include "OldSpaceRace.h"
30
31#include "core/CoreIncludes.h"
32#include "chat/ChatManager.h"
33#include "util/Convert.h"
34#include "util/Math.h"
35#include "SpaceRaceBot.h"
36#include "items/Engine.h"
37#include "controllers/HumanController.h"
38
39
40
41namespace orxonox
42{
43    RegisterUnloadableClass(OldSpaceRace);
44
45    OldSpaceRace::OldSpaceRace(Context* context) : Gametype(context)
46    {
47        RegisterObject(OldSpaceRace);
48        this->checkpointsReached_ = 0;
49        this->bTimeIsUp_ = false;
50        this->numberOfBots_ = 1;
51    }
52
53    void OldSpaceRace::end()
54    {
55        this->Gametype::end();
56
57        if (this->bTimeIsUp_)
58        {
59            this->clock_.capture();
60            int s = this->clock_.getSeconds();
61            int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s);
62            const std::string& message = multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) + " seconds !!\n"
63                        + "You didn't reach the check point " + multi_cast<std::string>(this->checkpointsReached_+1)
64                        + " before the time limit. You lose!";
65            this->getGametypeInfo()->sendAnnounceMessage(message);
66            ChatManager::message(message);
67        }
68        else
69        {
70            this->clock_.capture();
71            int s = this->clock_.getSeconds();
72            int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s);
73            const std::string& message = "You win!! You have reached the last check point after "+ multi_cast<std::string>(s)
74                        + "." + multi_cast<std::string>(ms) + " seconds.";
75            this->getGametypeInfo()->sendAnnounceMessage(message);
76            ChatManager::message(message);
77/*
78            float time = this->clock_.getSecondsPrecise();
79            this->scores_.insert(time);
80            std::set<float>::iterator it;
81            for (it=this->scores_.begin(); it!=this->scores_.end(); it++)
82                orxout(level::message) << multi_cast<std::string>(*it) << endl;
83*/
84        }
85    }
86
87    void OldSpaceRace::start()
88    {
89        Gametype::start();
90
91   if (true)
92        {
93            this->spawnPlayersIfRequested();
94            this->cantMove_ = true;
95
96            for (Engine* engine : ObjectList<Engine>()){
97                engine->setActive(false);
98               
99
100            }
101           
102        }
103
104       
105
106        std::string message("BE FAST BE FIRST");
107        this->getGametypeInfo()->sendAnnounceMessage(message);
108        ChatManager::message(message);
109
110Timer* countdownTimer = new Timer();
111        countdownTimer->setTimer(11, false, createExecutor(createFunctor(&OldSpaceRace::countdownFinished, this)));
112    }
113
114    void OldSpaceRace::countdownFinished()
115    {
116
117        std::string message("RACE STARTED ");
118        this->getGametypeInfo()->sendAnnounceMessage(message);
119        ChatManager::message(message);
120
121
122    for (Engine* engine : ObjectList<Engine>())
123                engine->setActive(true);
124   
125
126
127    }
128 
129    void OldSpaceRace::newCheckpointReached()
130    {
131        this->checkpointsReached_++;
132        this->clock_.capture();
133        int s = this->clock_.getSeconds();
134        int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s);
135        const std::string& message = "Checkpoint " + multi_cast<std::string>(this->getCheckpointsReached())
136                        + " reached after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms)
137                        + " seconds.";
138        this->getGametypeInfo()->sendAnnounceMessage(message);
139        ChatManager::message(message);
140    }
141
142
143}
Note: See TracBrowser for help on using the repository browser.