Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/output/src/modules/gametypes/SpaceRace.cc @ 8848

Last change on this file since 8848 was 8829, checked in by landauf, 13 years ago

enhanced chat system. chat related code is now separated into network-side code (located in Host, Client, Server) and client-side code (located in ChatManager).
note that there are now two chat related listeners: NetworkChatListener, which is used to send chat from the network to ChatManager, and ChatListener, which is used to send online and offline chat from ChatManager to the actual chat interfaces (ChatOverlay, ChatInputHandler, …).
the "chat" console command now supports a second argument which is the clientID of the receiver. this allows private messages (or gameplay messages directed to only one specific player).

  • Property svn:eol-style set to native
File size: 3.7 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 "SpaceRace.h"
30
31#include "core/CoreIncludes.h"
32#include "chat/ChatManager.h"
33#include "util/Clock.h"
34#include "util/Math.h"
35#include "util/Convert.h"
36
37namespace orxonox
38{
39    CreateUnloadableFactory(SpaceRace);
40
41    SpaceRace::SpaceRace(BaseObject* creator) : Gametype(creator)
42    {
43        RegisterObject(SpaceRace);
44        this->bCheckpointsReached_ = 0;
45        this->bTimeIsUp_ = false;
46        this->numberOfBots_ = 0;
47    }
48
49    void SpaceRace::end()
50    {
51        this->Gametype::end();
52
53        if (this->bTimeIsUp_)
54        {
55            this->clock_.capture();
56            int s = this->clock_.getSeconds();
57            int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s);
58            const std::string& message = multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) + " seconds !!\n"
59                        + "You didn't reach the check point " + multi_cast<std::string>(this->bCheckpointsReached_+1)
60                        + " before the time limit. You lose!";
61            const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
62            ChatManager::message(message);
63        }
64        else
65        {
66            this->clock_.capture();
67            int s = this->clock_.getSeconds();
68            int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s);
69            const std::string& message = "You win!! You have reached the last check point after "+ multi_cast<std::string>(s)
70                        + "." + multi_cast<std::string>(ms) + " seconds.";
71            const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
72            ChatManager::message(message);
73/*
74            float time = this->clock_.getSecondsPrecise();
75            this->scores_.insert(time);
76            std::set<float>::iterator it;
77            for (it=this->scores_.begin(); it!=this->scores_.end(); it++)
78                orxout(level::message) << multi_cast<std::string>(*it) << endl;
79*/
80        }
81    }
82
83    void SpaceRace::start()
84    {
85        Gametype::start();
86
87        std::string message("The match has started! Reach the check points as quickly as possible!");
88        ChatManager::message(message);
89    }
90
91    void SpaceRace::newCheckpointReached()
92    {
93        this->bCheckpointsReached_++;
94        this->clock_.capture();
95        int s = this->clock_.getSeconds();
96        int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s);
97        const std::string& message = "Checkpoint " + multi_cast<std::string>(this->getCheckpointsReached())
98                        + " reached after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms)
99                        + " seconds.";
100        const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
101        ChatManager::message(message);
102    }
103
104}
Note: See TracBrowser for help on using the repository browser.