Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 11272 was 11272, checked in by bberabi, 7 years ago

bots are finally added; controller has to be implemented

  • Property svn:eol-style set to native
File size: 5.5 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 "infos/Bot.h"
36#include "items/Engine.h"
37#include "controllers/HumanController.h"
38
39#include "core/CoreIncludes.h"
40#include "chat/ChatManager.h"
41#include "infos/PlayerInfo.h"
42#include "worldentities/pawns/Pawn.h"
43#include "core/config/ConfigValueIncludes.h"
44#include "infos/Bot.h"
45#include "SpaceRaceBot.h"
46
47
48
49namespace orxonox
50{
51    RegisterUnloadableClass(OldSpaceRace);
52
53
54    OldSpaceRace::OldSpaceRace(Context* context) : Gametype(context)
55    {
56        RegisterObject(OldSpaceRace);
57       
58        //this->botclass_ = Class();
59        this->botclass_ = Class(SpaceRaceBot);//ClassByString("")
60
61        this->checkpointsReached_ = 0;
62        this->bTimeIsUp_ = false;
63        this->setConfigValues();
64    }
65
66    void OldSpaceRace::setConfigValues()
67    {
68       
69   
70    }
71
72    void OldSpaceRace::end()
73    {
74        this->Gametype::end();
75
76        if (this->bTimeIsUp_)
77        {
78            this->clock_.capture();
79            int s = this->clock_.getSeconds();
80            int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s);
81            const std::string& message = multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) + " seconds !!\n"
82                        + "You didn't reach the check point " + multi_cast<std::string>(this->checkpointsReached_+1)
83                        + " before the time limit. You lose!";
84            this->getGametypeInfo()->sendAnnounceMessage(message);
85            ChatManager::message(message);
86        }
87        else
88        {
89            this->clock_.capture();
90            int s = this->clock_.getSeconds();
91            int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s);
92            const std::string& message = "Congratulations! Last check point reached after "+ multi_cast<std::string>(s)
93                        + "." + multi_cast<std::string>(ms) + " seconds.";
94            this->getGametypeInfo()->sendAnnounceMessage(message);
95            ChatManager::message(message);
96/*
97            float time = this->clock_.getSecondsPrecise();
98            this->scores_.insert(time);
99            std::set<float>::iterator it;
100            for (it=this->scores_.begin(); it!=this->scores_.end(); it++)
101                orxout(level::message) << multi_cast<std::string>(*it) << endl;
102*/
103        }
104    }
105
106    void OldSpaceRace::start()
107    {
108        Gametype::start();
109
110   if (true)
111        {
112            this->spawnPlayersIfRequested();
113            this->cantMove_ = true;
114
115            for (Engine* engine : ObjectList<Engine>()){
116                engine->setActive(false);
117               
118
119            }
120           
121        }
122
123       
124
125        std::string message("BE FAST BE FIRST");
126        this->getGametypeInfo()->sendAnnounceMessage(message);
127        ChatManager::message(message);
128
129Timer* countdownTimer = new Timer();
130        countdownTimer->setTimer(11, false, createExecutor(createFunctor(&OldSpaceRace::countdownFinished, this)));
131    }
132
133    void OldSpaceRace::countdownFinished()
134    {
135
136        std::string message("RACE STARTED ");
137        this->getGametypeInfo()->sendAnnounceMessage(message);
138        ChatManager::message(message);
139
140
141    for (Engine* engine : ObjectList<Engine>())
142                engine->setActive(true);
143   
144
145
146    }
147 
148
149 void OldSpaceRace::playerEntered(PlayerInfo* player)
150    {
151        Gametype::playerEntered(player);
152
153        const std::string& message = player->getName() + " entered the game";
154        ChatManager::message(message);
155    }
156
157
158
159    void OldSpaceRace::newCheckpointReached()
160    {
161        this->checkpointsReached_++;
162        this->clock_.capture();
163        int s = this->clock_.getSeconds();
164        int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s);
165        const std::string& message = "Checkpoint " + multi_cast<std::string>(this->getCheckpointsReached())
166                        + " reached after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms)
167                        + " seconds.";
168        this->getGametypeInfo()->sendAnnounceMessage(message);
169        ChatManager::message(message);
170    }
171
172        /*void playerEntered(PlayerInfo* player) {
173
174
175                  Gametype::playerEntered(player);
176
177        const std::string& message = player->getName() + " entered the game";
178        ChatManager::message(message);
179           
180        }*/
181
182
183
184
185 void OldSpaceRace::addBots(unsigned int amount)
186    {
187        for (unsigned int i = 0; i < amount; ++i)
188            this->botclass_.fabricate(this->getContext());
189    }
190
191
192
193
194
195}
Note: See TracBrowser for help on using the repository browser.