[Orxonox-commit 4240] r8911 - code/branches/spaceraceTwo/src/modules/gametypes
eceline at orxonox.net
eceline at orxonox.net
Wed Nov 2 13:23:27 CET 2011
Author: eceline
Date: 2011-11-02 13:23:26 +0100 (Wed, 02 Nov 2011)
New Revision: 8911
Added:
code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.cc
code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.h
Modified:
code/branches/spaceraceTwo/src/modules/gametypes/CMakeLists.txt
code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.cc
code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.h
Log:
countdown
Modified: code/branches/spaceraceTwo/src/modules/gametypes/CMakeLists.txt
===================================================================
--- code/branches/spaceraceTwo/src/modules/gametypes/CMakeLists.txt 2011-11-01 18:25:24 UTC (rev 8910)
+++ code/branches/spaceraceTwo/src/modules/gametypes/CMakeLists.txt 2011-11-02 12:23:26 UTC (rev 8911)
@@ -1,6 +1,7 @@
SET_SOURCE_FILES(GAMETYPES_SRC_FILES
SpaceRace.cc
RaceCheckPoint.cc
+ SpaceRaceManager.cc
)
ORXONOX_ADD_LIBRARY(gametypes
Modified: code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.cc
===================================================================
--- code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.cc 2011-11-01 18:25:24 UTC (rev 8910)
+++ code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.cc 2011-11-02 12:23:26 UTC (rev 8911)
@@ -28,6 +28,8 @@
#include "SpaceRace.h"
+#include "items/Engine.h"
+
#include "core/CoreIncludes.h"
#include "chat/ChatManager.h"
#include "util/Convert.h"
@@ -45,7 +47,7 @@
this->checkpointsReached_ = 0;
this->bTimeIsUp_ = false;
this->numberOfBots_ = 0;
-
+ this->cantMove_=false;
}
// void SpaceRace::SetConfigValues(){
@@ -87,47 +89,50 @@
}
void SpaceRace::start()
- { int i=0;
- for(ObjectList<Engine>::iterator it = ObjectList<Engine>::begin(); it; ++it)
- {this->maxSpeedBack_[i]=it->getMaxSpeedBack();
- this->maxSpeedFront_[i]=it->getMaxSpeedFront();
- this->maxSpeedLeftRight_[i]=it->getMaxSpeedLeftRight();
- this->maxSpeedUpDown_[i]=(it->getMaxSpeedUpDown());
-
- it->setMaxSpeedBack(0);
- it->setMaxSpeedFront(0);
- it->setMaxSpeedLeftRight(0);
- it->setMaxSpeedUpDown(0);
-
- i++;
- }
- //Gametype::start();
- this->addBots(this->numberOfBots_);
- this->spawnPlayersIfRequested();
-
-
- Gametype::checkStart();
-
- i=0;
- for(ObjectList<Engine>::iterator it = ObjectList<Engine>::begin(); it; ++it)
- {
- it->setMaxSpeedBack(this->maxSpeedBack_[i]);
- it->setMaxSpeedFront(this->maxSpeedFront_[i]);
- it->setMaxSpeedLeftRight(this->maxSpeedLeftRight_[i]);
- it->setMaxSpeedUpDown(this->maxSpeedUpDown_[i]);
- i++;
-
-
- }
- delete &this->maxSpeedBack_;
- delete &this->maxSpeedFront_;
- delete &this->maxSpeedLeftRight_;
- delete &this->maxSpeedUpDown_;
- std::string message("The match has started! Reach the check points as quickly as possible!");
+ {
+ this->spawnPlayersIfRequested(); Gametype::checkStart();
+ this->cantMove_=true;
+
+ for(ObjectList<Engine>::iterator it = ObjectList<Engine>::begin(); it; ++it)
+ {if(it->getMaxSpeedFront()>0){this->maxSpeedBack_=it->getMaxSpeedBack();
+ this->maxSpeedFront_=it->getMaxSpeedFront();
+ this->maxSpeedLeftRight_=it->getMaxSpeedLeftRight();
+ this->maxSpeedUpDown_=(it->getMaxSpeedUpDown());
+ }
+ it->setMaxSpeedBack(0);
+ it->setMaxSpeedFront(0);
+ it->setMaxSpeedLeftRight(0);
+ it->setMaxSpeedUpDown(0);
+
+
+ }
+
+ this->addBots(this->numberOfBots_);
+
+ }
+
+ void SpaceRace::tick(float dt){
+ SUPER(SpaceRace,tick,dt);
+
+ if(!this->isStartCountdownRunning() && this->cantMove_){
+
+ for(ObjectList<Engine>::iterator it = ObjectList<Engine>::begin(); it; ++it)
+ {
+ it->setMaxSpeedBack(this->maxSpeedBack_);
+ it->setMaxSpeedFront(this->maxSpeedFront_);
+ it->setMaxSpeedLeftRight(this->maxSpeedLeftRight_);
+ it->setMaxSpeedUpDown(this->maxSpeedUpDown_);
+ }
+ this->cantMove_= false;
+
+ std::string message("The match has started! Reach the check points as quickly as possible!");
const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
- ChatManager::message(message);
+ ChatManager::message(message);
}
+
+
+ }
void SpaceRace::tick(float dt)
{SUPER(SpaceRace,tick,dt);
Modified: code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.h
===================================================================
--- code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.h 2011-11-01 18:25:24 UTC (rev 8910)
+++ code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.h 2011-11-02 12:23:26 UTC (rev 8911)
@@ -33,7 +33,7 @@
#include <set>
#include <string>
-#include <vector>
+# include <vector>
#include <util/Clock.h>
@@ -68,9 +68,10 @@
{ this->bTimeIsUp_ = true;}
void tick(float dt);
protected:
-
+
private:
- std::vector<float> maxSpeedBack_; std::vector<float> maxSpeedFront_; std::vector<float> maxSpeedLeftRight_; std::vector<float> maxSpeedUpDown_;
+ float maxSpeedBack_; float maxSpeedFront_; float maxSpeedLeftRight_; float maxSpeedUpDown_;
+ bool cantMove_;
int checkpointsReached_; //The current number of check points reached by the player.
std::set<float> scores_; //The times of the players are saved in a set.
bool bTimeIsUp_; //True if one of the check points is reached too late.
Added: code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.cc
===================================================================
--- code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.cc (rev 0)
+++ code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.cc 2011-11-02 12:23:26 UTC (rev 8911)
@@ -0,0 +1,70 @@
+/*
+ * 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 "SpaceRaceManager.h"
+
+
+#include "core/XMLPort.h"
+
+#include "core/CoreIncludes.h"
+
+#include "util/Convert.h"
+#include "util/Math.h"
+
+namespace orxonox
+{
+ CreateUnloadableFactory(SpaceRaceManager);
+
+ SpaceRaceManager::SpaceRaceManager(BaseObject* creator) : BaseObject(creator)
+ {
+ RegisterObject(SpaceRaceManager);
+
+
+ }
+
+
+ void SpaceRaceManager::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(SpaceRaceManager, XMLPort, xmlelement, mode);
+
+ //XMLPortParam(WaypointController, "accuracy", setAccuracy, getAccuracy, xmlelement, mode).defaultValues(100.0f);
+ //XMLPortObject(WaypointController, WorldEntity, "waypoints", addWaypoint, getWaypoint, xmlelement, mode);
+ }
+
+ void SpaceRaceManager::tick(float dt)
+ {
+ SUPER(SpaceRaceManager,tick,dt);
+
+ }
+
+
+
+
+
+
+}
Added: code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.h
===================================================================
--- code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.h (rev 0)
+++ code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.h 2011-11-02 12:23:26 UTC (rev 8911)
@@ -0,0 +1,69 @@
+/*
+ * 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:
+ * ...
+ *
+ */
+
+#ifndef _SpaceRaceManager_H__
+#define _SpaceRaceManager_H__
+
+#include "gametypes/GametypesPrereqs.h"
+
+#include <set>
+#include <string>
+# include <vector>
+
+#include <util/Clock.h>
+
+#include "gametypes/Gametype.h"
+#include "tools/interfaces/Tickable.h"
+#include "RaceCheckPoint.h"
+
+namespace orxonox
+{
+ /**
+ @brief
+ The SpaceRaceManager class controls a space race level, where the player has to reach check points in a given order.
+ */
+ class _GametypesExport SpaceRaceManager : public BaseObject, public Tickable
+ {
+ friend class RaceCheckPoint;
+
+
+ public:
+ SpaceRaceManager(BaseObject* creator);
+ virtual ~SpaceRaceManager() {}
+
+ void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+
+ void tick(float dt);
+ protected:
+
+ private:
+ };
+}
+
+#endif /* _SpaceRaceManager_H__ */
More information about the Orxonox-commit
mailing list