Changeset 8767 for code/trunk/src/modules/gametypes
- Timestamp:
- Jul 20, 2011, 11:27:45 PM (13 years ago)
- Location:
- code/trunk/src/modules/gametypes
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/modules/gametypes/RaceCheckPoint.cc
r8706 r8767 31 31 #include "core/CoreIncludes.h" 32 32 #include "core/XMLPort.h" 33 #include "util/Convert.h" 34 33 35 #include "SpaceRace.h" 34 #include "util/Convert.h"35 36 36 37 namespace orxonox 37 38 { 38 39 CreateFactory(RaceCheckPoint); 39 40 40 41 RaceCheckPoint::RaceCheckPoint(BaseObject* creator): DistanceTrigger(creator), RadarViewable(creator, static_cast<WorldEntity*>(this)) 41 42 { … … 50 51 this->setRadarVisibility(false); 51 52 } 52 53 53 54 RaceCheckPoint::~RaceCheckPoint() 54 55 { 55 56 } 56 57 57 58 void RaceCheckPoint::tick(float dt) 58 59 { … … 60 61 61 62 SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get()); 63 assert(gametype); 62 64 if (this->getCheckpointIndex() == gametype->getCheckpointsReached()) 63 65 this->setRadarVisibility(true); … … 66 68 } 67 69 68 69 70 void RaceCheckPoint::XMLPort(Element& xmlelement, XMLPort::Mode mode) 70 71 { … … 75 76 XMLPortParam(RaceCheckPoint, "timelimit", setTimelimit, getTimeLimit, xmlelement, mode).defaultValues(0); 76 77 } 77 78 78 79 void RaceCheckPoint::triggered(bool bIsTriggered) 79 80 { … … 99 100 } 100 101 } 101 102 102 103 void RaceCheckPoint::setTimelimit(float timeLimit) 103 104 { … … 115 116 } 116 117 } 117 118 118 119 } -
code/trunk/src/modules/gametypes/RaceCheckPoint.h
r8706 r8767 34 34 #include "objects/triggers/DistanceTrigger.h" 35 35 #include "interfaces/RadarViewable.h" 36 //#include <boost/concept_check.hpp>37 36 38 37 namespace orxonox 39 38 { 40 /**41 @brief42 The RaceCheckPoint class enables the creation of a check point to use in a SpaceRace level.43 !!! Don't forget to control the indexes of your check points and to set one last check point!!!44 */39 /** 40 @brief 41 The RaceCheckPoint class enables the creation of a check point to use in a SpaceRace level. 42 !!! Don't forget to control the indexes of your check points and to set one last check point!!! 43 */ 45 44 class _GametypesExport RaceCheckPoint : public DistanceTrigger, public RadarViewable 46 45 { -
code/trunk/src/modules/gametypes/SpaceRace.cc
r8706 r8767 31 31 #include "core/CoreIncludes.h" 32 32 #include "network/Host.h" 33 #include <util/Clock.h>34 #include <util/Math.h>35 33 #include "util/Convert.h" 34 #include "util/Math.h" 36 35 37 36 namespace orxonox 38 37 { 39 38 CreateUnloadableFactory(SpaceRace); 40 39 41 40 SpaceRace::SpaceRace(BaseObject* creator) : Gametype(creator) 42 41 { 43 42 RegisterObject(SpaceRace); 44 this-> bCheckpointsReached_ = 0;43 this->checkpointsReached_ = 0; 45 44 this->bTimeIsUp_ = false; 46 45 this->numberOfBots_ = 0; 47 46 } 48 47 49 48 void SpaceRace::end() 50 49 { 51 50 this->Gametype::end(); 52 51 53 52 if (this->bTimeIsUp_) 54 53 { … … 57 56 int ms = this->clock_.getMilliseconds()-1000*s; 58 57 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)58 + "You didn't reach the check point " + multi_cast<std::string>(this->checkpointsReached_+1) 60 59 + " before the time limit. You lose!"; 61 60 COUT(3) << message; 62 61 const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message); 63 Host::Broadcast(message);64 62 } 65 63 else … … 72 70 COUT(3) << message << std::endl; 73 71 const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message); 74 Host::Broadcast(message);75 72 float time = this->clock_.getSecondsPrecise(); 76 73 this->scores_.insert(time); … … 87 84 std::string message("The match has started! Reach the check points as quickly as possible!"); 88 85 COUT(3) << message << std::endl; 89 Host::Broadcast(message);86 const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message); 90 87 } 91 88 92 89 void SpaceRace::newCheckpointReached() 93 90 { 94 this-> bCheckpointsReached_++;91 this->checkpointsReached_++; 95 92 this->clock_.capture(); 96 93 int s = this->clock_.getSeconds(); … … 101 98 COUT(3) << message; 102 99 const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message); 103 Host::Broadcast(message);104 100 } 105 101 -
code/trunk/src/modules/gametypes/SpaceRace.h
r8706 r8767 30 30 #define _SpaceRace_H__ 31 31 32 #include "gametypes/GametypesPrereqs.h" 33 34 #include <set> 35 #include <string> 36 37 #include <util/Clock.h> 38 32 39 #include "gametypes/Gametype.h" 33 #include "gametypes/GametypesPrereqs.h" 40 34 41 #include "RaceCheckPoint.h" 35 #include <boost/concept_check.hpp>36 #include <util/Clock.h>37 #include <string.h>38 #include <set>39 42 40 43 namespace orxonox … … 47 50 { 48 51 friend class RaceCheckPoint; 49 52 50 53 public: 51 54 SpaceRace(BaseObject* creator); … … 53 56 54 57 virtual void start(); 55 58 virtual void end(); 56 59 57 60 virtual void newCheckpointReached(); 58 61 59 62 inline void setCheckpointsReached(int n) 60 { this->bCheckpointsReached_ = n;}63 { this->checkpointsReached_ = n;} 61 64 inline int getCheckpointsReached() 62 { return this->bCheckpointsReached_; }65 { return this->checkpointsReached_; } 63 66 inline void timeIsUp() 64 { this->bTimeIsUp_ = true;}67 { this->bTimeIsUp_ = true;} 65 68 66 69 protected: 67 70 68 71 private: 69 int bCheckpointsReached_; //The current number of check points reached by the player.72 int checkpointsReached_; //The current number of check points reached by the player. 70 73 std::set<float> scores_; //The times of the players are saved in a set. 71 74 bool bTimeIsUp_; //True if one of the check points is reached too late.
Note: See TracChangeset
for help on using the changeset viewer.