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