/* * ORXONOX - the hottest 3D action shooter ever to exist * > www.orxonox.net < * * * License notice: * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * Author: * Mauro Salomon * Co-authors: * ... * */ #include "OldSpaceRace.h" #include "core/CoreIncludes.h" #include "chat/ChatManager.h" #include "util/Convert.h" #include "util/Math.h" #include "infos/Bot.h" #include "items/Engine.h" #include "controllers/HumanController.h" #include "core/CoreIncludes.h" #include "chat/ChatManager.h" #include "infos/PlayerInfo.h" #include "worldentities/pawns/Pawn.h" #include "core/config/ConfigValueIncludes.h" #include "infos/Bot.h" #include "SpaceRaceBot.h" namespace orxonox { RegisterUnloadableClass(OldSpaceRace); OldSpaceRace::OldSpaceRace(Context* context) : Gametype(context) { RegisterObject(OldSpaceRace); //this->botclass_ = Class(); this->botclass_ = Class(SpaceRaceBot);//ClassByString("") this->checkpointsReached_ = 0; this->bTimeIsUp_ = false; this->setConfigValues(); } void OldSpaceRace::setConfigValues() { } void OldSpaceRace::end() { this->Gametype::end(); if (this->bTimeIsUp_) { this->clock_.capture(); int s = this->clock_.getSeconds(); int ms = static_cast(this->clock_.getMilliseconds()-1000*s); const std::string& message = multi_cast(s) + "." + multi_cast(ms) + " seconds !!\n" + "You didn't reach the check point " + multi_cast(this->checkpointsReached_+1) + " before the time limit. You lose!"; this->getGametypeInfo()->sendAnnounceMessage(message); ChatManager::message(message); } else { this->clock_.capture(); int s = this->clock_.getSeconds(); int ms = static_cast(this->clock_.getMilliseconds()-1000*s); const std::string& message = "Congratulations! Last check point reached after "+ multi_cast(s) + "." + multi_cast(ms) + " seconds."; this->getGametypeInfo()->sendAnnounceMessage(message); ChatManager::message(message); /* float time = this->clock_.getSecondsPrecise(); this->scores_.insert(time); std::set::iterator it; for (it=this->scores_.begin(); it!=this->scores_.end(); it++) orxout(level::message) << multi_cast(*it) << endl; */ } } void OldSpaceRace::start() { Gametype::start(); if (true) { this->spawnPlayersIfRequested(); this->cantMove_ = true; for (Engine* engine : ObjectList()){ engine->setActive(false); } } std::string message("BE FAST BE FIRST"); this->getGametypeInfo()->sendAnnounceMessage(message); ChatManager::message(message); Timer* countdownTimer = new Timer(); countdownTimer->setTimer(11, false, createExecutor(createFunctor(&OldSpaceRace::countdownFinished, this))); } void OldSpaceRace::countdownFinished() { std::string message("RACE STARTED "); this->getGametypeInfo()->sendAnnounceMessage(message); ChatManager::message(message); for (Engine* engine : ObjectList()) engine->setActive(true); } void OldSpaceRace::playerEntered(PlayerInfo* player) { Gametype::playerEntered(player); const std::string& message = player->getName() + " entered the game"; ChatManager::message(message); } void OldSpaceRace::newCheckpointReached() { this->checkpointsReached_++; this->clock_.capture(); int s = this->clock_.getSeconds(); int ms = static_cast(this->clock_.getMilliseconds()-1000*s); const std::string& message = "Checkpoint " + multi_cast(this->getCheckpointsReached()) + " reached after " + multi_cast(s) + "." + multi_cast(ms) + " seconds."; this->getGametypeInfo()->sendAnnounceMessage(message); ChatManager::message(message); } /*void playerEntered(PlayerInfo* player) { Gametype::playerEntered(player); const std::string& message = player->getName() + " entered the game"; ChatManager::message(message); }*/ void OldSpaceRace::addBots(unsigned int amount) { for (unsigned int i = 0; i < amount; ++i) this->botclass_.fabricate(this->getContext()); } }