Changeset 8998 for code/branches/presentation2011/src
- Timestamp:
- Dec 18, 2011, 2:35:02 PM (13 years ago)
- Location:
- code/branches/presentation2011
- Files:
-
- 12 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation2011
- Property svn:mergeinfo changed
/code/branches/spaceraceTwo (added) merged: 8881,8898,8911,8915,8918,8921,8928,8934,8940,8944,8949,8954,8959-8960,8968,8970-8971,8979,8983
- Property svn:mergeinfo changed
-
code/branches/presentation2011/src/modules/gametypes/CMakeLists.txt
r8706 r8998 2 2 SpaceRace.cc 3 3 RaceCheckPoint.cc 4 SpaceRaceManager.cc 4 5 ) 5 6 -
code/branches/presentation2011/src/modules/gametypes/RaceCheckPoint.cc
r8858 r8998 34 34 #include "chat/ChatManager.h" 35 35 36 #include <infos/PlayerInfo.h> 37 #include <worldentities/ControllableEntity.h> 38 36 39 #include "SpaceRace.h" 37 40 … … 39 42 { 40 43 CreateFactory(RaceCheckPoint); 44 45 41 46 42 RaceCheckPoint::RaceCheckPoint(BaseObject* creator): Distance Trigger(creator), RadarViewable(creator, static_cast<WorldEntity*>(this))47 RaceCheckPoint::RaceCheckPoint(BaseObject* creator): DistanceMultiTrigger(creator), RadarViewable(creator, static_cast<WorldEntity*>(this)) 43 48 { 44 49 RegisterObject(RaceCheckPoint); 45 46 this->bCheckpointIndex_ = 0; 47 this->bIsLast_ = false; 50 this->setDistance(100); 51 this->setBeaconMode("off"); 52 this->setBroadcast(false); 53 this->setSimultaneousTriggerers(100); 48 54 this->bTimeLimit_ = 0; 49 55 … … 51 57 this->setRadarObjectShape(RadarViewable::Triangle); 52 58 this->setRadarVisibility(false); 59 this->settingsChanged(); 60 this->reached_=NULL; 61 53 62 } 63 54 64 55 RaceCheckPoint::~RaceCheckPoint() 56 { 57 } 65 RaceCheckPoint::~RaceCheckPoint() 66 { 67 68 } 58 69 59 70 void RaceCheckPoint::tick(float dt) … … 63 74 SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get()); 64 75 assert(gametype); 65 if (this->getCheckpointIndex() == gametype->getCheckpointsReached())66 this->setRadarVisibility(true);67 else68 this->setRadarVisibility(false);69 76 } 70 77 … … 72 79 { 73 80 SUPER(RaceCheckPoint, XMLPort, xmlelement, mode); 74 81 Vector3 v= Vector3(0,0,0); 75 82 XMLPortParam(RaceCheckPoint, "checkpointindex", setCheckpointIndex, getCheckpointIndex, xmlelement, mode).defaultValues(0); 76 83 XMLPortParam(RaceCheckPoint, "islast", setLast, getLast, xmlelement, mode).defaultValues(false); 77 84 XMLPortParam(RaceCheckPoint, "timelimit", setTimelimit, getTimeLimit, xmlelement, mode).defaultValues(0); 85 XMLPortParamTemplate(RaceCheckPoint, "nextcheckpoints", setNextcheckpoint, getNextcheckpoint, xmlelement, mode,const Vector3&).defaultValues(v); 78 86 } 79 87 80 void RaceCheckPoint:: triggered(bool bIsTriggered)88 void RaceCheckPoint::fire(bool bIsTriggered,BaseObject* player) 81 89 { 82 Distance Trigger::triggered(bIsTriggered);83 90 DistanceMultiTrigger::fire((bool)bIsTriggered,player); 91 84 92 SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get()); 85 if (gametype && this->getCheckpointIndex() == gametype->getCheckpointsReached() && bIsTriggered) 86 { 87 gametype->clock_.capture(); 88 float time = gametype->clock_.getSecondsPrecise(); 89 if (this->bTimeLimit_!=0 && time > this->bTimeLimit_) 90 { 91 gametype->timeIsUp(); 92 gametype->end(); 93 } 94 else if (this->getLast()) 95 gametype->end(); 96 else 97 { 98 gametype->newCheckpointReached(); 99 this->setRadarObjectColour(ColourValue::Green); //sets the radar colour of the checkpoint to green if it is reached, else it is red. 100 } 101 } 93 assert(gametype); 94 ControllableEntity* entity = (ControllableEntity*) player; 95 96 PlayerInfo* player2 = entity->getPlayer(); 97 98 if(bIsTriggered) 99 this->reached_=player2; 102 100 } 103 101 … … 108 106 { 109 107 SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get()); 108 assert(gametype); 110 109 if (gametype) 111 110 { -
code/branches/presentation2011/src/modules/gametypes/RaceCheckPoint.h
r8767 r8998 32 32 #include "gametypes/GametypesPrereqs.h" 33 33 34 #include "objects/triggers/DistanceTrigger.h" 34 35 36 #include "objects/triggers/DistanceMultiTrigger.h" 35 37 #include "interfaces/RadarViewable.h" 36 38 … … 40 42 @brief 41 43 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!!!44 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 Distance Trigger, public RadarViewable46 class _GametypesExport RaceCheckPoint : public DistanceMultiTrigger, public RadarViewable 45 47 { 46 48 public: … … 50 52 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 51 53 virtual void tick(float dt); 54 inline void setCheckpointIndex(int checkpointIndex) 55 { this->bCheckpointIndex_ = checkpointIndex; } 56 inline int getCheckpointIndex() 57 { return this->bCheckpointIndex_; } 52 58 53 protected: 54 virtual void triggered(bool bIsTriggered); 59 inline void setNextcheckpoint(const Vector3& checkpoints) 60 { this->nextcheckpoints_=checkpoints; } 61 inline void setNextcheckpoint(float x, float y, float z) 62 { this->setNextcheckpoint(Vector3(x, y, z)); } 63 inline const Vector3& getNextcheckpoint() const 64 { return this->nextcheckpoints_; } 55 65 inline void setLast(bool isLast) 56 66 { this->bIsLast_ = isLast; } 57 67 inline bool getLast() 58 68 { return this->bIsLast_; } 59 inline void setCheckpointIndex(int checkpointIndex) 60 { this->bCheckpointIndex_ = checkpointIndex; } 61 inline int getCheckpointIndex() 62 { return this->bCheckpointIndex_; } 69 70 bool bIsLast_; //True if this check point is the last of the level. There can be only one last check point for each level and there must be a last check point in the level. 71 float bTimeLimit_; //The time limit (from the start of the level) to reach this check point. If the check point is reached after this time, the game ends and the player looses. 72 PlayerInfo* reached_; 73 74 inline float getTimeLimit() 75 { return this->bTimeLimit_; } 76 77 protected: 78 virtual void fire(bool bIsTriggered,BaseObject* player); 63 79 virtual void setTimelimit(float timeLimit); 64 inline float getTimeLimit() 65 { return this->bTimeLimit_;} 80 66 81 inline const WorldEntity* getWorldEntity() const 67 82 { return this; } 68 83 69 84 private: 70 int bCheckpointIndex_; //The index of this check point. This value will be compared with the number of check points reached in the level. The check points must be indexed in ascending order beginning from zero and without any jumps between the indexes. 71 bool bIsLast_; //True if this check point is the last of the level. There can be only one last check point for each level and there must be a last check point in the level. 72 float bTimeLimit_; //The time limit (from the start of the level) to reach this check point. If the check point is reached after this time, the game ends and the player looses. 73 85 int bCheckpointIndex_; //The index of this check point. The race starts with the check point with the index 0 86 Vector3 nextcheckpoints_; //the indexes of the next check points 87 74 88 }; 75 89 } -
code/branches/presentation2011/src/modules/gametypes/SpaceRace.cc
r8858 r8998 29 29 #include "SpaceRace.h" 30 30 31 32 #include "items/Engine.h" 33 31 34 #include "core/CoreIncludes.h" 32 35 #include "chat/ChatManager.h" 33 36 #include "util/Convert.h" 34 37 #include "util/Math.h" 38 39 #include "items/Engine.h" 35 40 36 41 namespace orxonox … … 41 46 { 42 47 RegisterObject(SpaceRace); 43 this->checkpointsReached_ = 0;48 44 49 this->bTimeIsUp_ = false; 45 50 this->numberOfBots_ = 0; 51 this->cantMove_=false; 52 46 53 } 54 55 56 // void SpaceRace::SetConfigValues(){ 57 //SUPER(Gametype,setConfigValues); 58 //this->Gametype::SetConfigValue(initialStartCountdown_, 3.0f);} 47 59 48 60 void SpaceRace::end() … … 56 68 int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s); 57 69 const std::string& message = multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) + " seconds !!\n" 58 + "You didn't reach the check point " + multi_cast<std::string>(this->checkpointsReached_+1) 59 + " before the time limit. You lose!"; 70 + "You didn't reach the check point before the time limit. You lose!"; 60 71 const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message); 61 72 ChatManager::message(message); … … 70 81 const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message); 71 82 ChatManager::message(message); 72 /* 83 73 84 float time = this->clock_.getSecondsPrecise(); 74 85 this->scores_.insert(time); 75 86 std::set<float>::iterator it; 76 for (it=this->scores_.begin(); it!=this->scores_.end(); it++) 77 orxout(level::message) << multi_cast<std::string>(*it) << endl; 78 */ 87 88 79 89 } 80 90 } … … 82 92 void SpaceRace::start() 83 93 { 84 Gametype::start();85 94 86 std::string message("The match has started! Reach the check points as quickly as possible!"); 95 this->spawnPlayersIfRequested(); 96 Gametype::checkStart(); 97 this->cantMove_=true; 98 99 for(ObjectList<Engine>::iterator it = ObjectList<Engine>::begin(); it; ++it) 100 { 101 it->setActive(false); 102 103 } 104 this->addBots(this->numberOfBots_); 105 } 106 107 void SpaceRace::tick(float dt) 108 { 109 SUPER(SpaceRace,tick,dt); 110 111 if(!this->isStartCountdownRunning() && this->cantMove_) 112 { 113 for(ObjectList<Engine>::iterator it = ObjectList<Engine>::begin(); it; ++it) 114 { 115 it->setActive(true); 116 117 } 118 this->cantMove_= false; 119 120 std::string message("The match has started! Reach the check points as quickly as possible!"); 121 const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message); 122 ChatManager::message(message); 123 } 124 125 } 126 127 128 129 void SpaceRace::newCheckpointReached(SpaceRaceManager* p, int index,PlayerInfo* pl) 130 { 131 this->checkpointReached_[pl]=index; 132 this->clock_.capture(); 133 int s = this->clock_.getSeconds(); 134 int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s); 135 const std::string& message = "Checkpoint " + multi_cast<std::string>(index) 136 + " reached after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) 137 + " seconds.";// Message is too long for a normal screen. 87 138 const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message); 88 139 ChatManager::message(message); 89 140 } 90 91 void SpaceRace::newCheckpointReached() 92 { 93 this->checkpointsReached_++; 141 142 void SpaceRace::newCheckpointReached(RaceCheckPoint* p, PlayerInfo* pl) 143 { 144 int index = p->getCheckpointIndex(); 145 this->checkpointReached_[pl]=index; 94 146 this->clock_.capture(); 95 147 int s = this->clock_.getSeconds(); 96 148 int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s); 97 const std::string& message = "Checkpoint " + multi_cast<std::string>( this->getCheckpointsReached())98 99 149 const std::string& message = "Checkpoint " + multi_cast<std::string>(index) 150 + " reached after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) 151 + " seconds."; 100 152 const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message); 101 153 ChatManager::message(message); 102 154 } 155 156 157 void SpaceRace::playerEntered(PlayerInfo* player) 158 { 159 Gametype::playerEntered(player); 160 161 this->checkpointReached_[player]=-1; 162 //this->playersAlive_++; 163 } 164 165 bool SpaceRace::playerLeft(PlayerInfo* player) 166 { 167 return Gametype::playerLeft(player); 168 // bool valid_player = true; 169 //if (valid_player) 170 // { 171 // this->playersAlive_--; 172 //} 103 173 174 // return valid_player; 175 } 176 177 bool SpaceRace::allowPawnHit(Pawn* victim, Pawn* originator) 178 { 179 return false; 180 } 181 182 bool SpaceRace::allowPawnDamage(Pawn* victim, Pawn* originator) 183 { 184 return false; 185 } 186 187 bool SpaceRace::allowPawnDeath(Pawn* victim, Pawn* originator) 188 { 189 return false; 190 } 104 191 } -
code/branches/presentation2011/src/modules/gametypes/SpaceRace.h
r8767 r8998 34 34 #include <set> 35 35 #include <string> 36 # include <vector> 36 37 37 38 #include <util/Clock.h> … … 39 40 #include "gametypes/Gametype.h" 40 41 41 #include " RaceCheckPoint.h"42 #include "SpaceRaceManager.h" 42 43 43 44 namespace orxonox … … 50 51 { 51 52 friend class RaceCheckPoint; 53 52 54 53 55 public: … … 58 60 virtual void end(); 59 61 60 virtual void newCheckpointReached(); 62 virtual void newCheckpointReached(SpaceRaceManager* p, int index,PlayerInfo* pl); 63 virtual void newCheckpointReached(RaceCheckPoint* p, PlayerInfo* pl); 61 64 62 inline void setCheckpointsReached(int n) 63 { this->checkpointsReached_ = n;} 64 inline int getCheckpointsReached() 65 { return this->checkpointsReached_; } 65 inline void setCheckpointReached(int n, PlayerInfo* p) 66 { this->checkpointReached_[p] = n;} 67 inline int getCheckpointReached(PlayerInfo* p) 68 { return this->checkpointReached_[p]; } 69 66 70 inline void timeIsUp() 67 71 { this->bTimeIsUp_ = true;} 72 void tick(float dt); 73 Clock clock_; //The clock starts running at the beginning of the game. It is used to give the time at each check point, the give the time at the end of the game, and to stop the game if a check point is reached too late. 68 74 75 76 bool allowPawnHit(Pawn* victim, Pawn* originator); 77 78 bool allowPawnDamage(Pawn* victim, Pawn* originator); 79 80 bool allowPawnDeath(Pawn* victim, Pawn* originator); 69 81 protected: 70 82 virtual void playerEntered(PlayerInfo* player); //!< Initializes values. 83 virtual bool playerLeft(PlayerInfo* player); //!< Manages all local variables. 71 84 private: 72 int checkpointsReached_; //The current number of check points reached by the player. 85 bool cantMove_; 86 std::map<PlayerInfo*, int>checkpointReached_; //The number of the last check point reached by each player. 73 87 std::set<float> scores_; //The times of the players are saved in a set. 74 88 bool bTimeIsUp_; //True if one of the check points is reached too late. 75 Clock clock_; //The clock starts running at the beginning of the game. It is used to give the time at each check point, the give the time at the end of the game, and to stop the game if a check point is reached too late. 89 90 int playersAlive_; 76 91 }; 77 92 } -
code/branches/presentation2011/src/modules/objects/triggers/DistanceMultiTrigger.h
r8706 r8998 91 91 @ingroup MultiTrigger 92 92 */ 93 class _ObjectsExport DistanceMultiTrigger : public MultiTrigger 93 class _ObjectsExport DistanceMultiTrigger : public MultiTrigger 94 94 { 95 95 -
code/branches/presentation2011/src/modules/objects/triggers/MultiTrigger.h
r8457 r8998 157 157 bool isTriggered(BaseObject* triggerer = NULL); //!< Get whether the MultiTrigger is triggered for a given object. 158 158 159 v oid fire(bool status, BaseObject* originator = NULL); //!< Helper method. Creates an Event for the given status and originator and fires it.159 virtual void fire(bool status, BaseObject* originator = NULL); //!< Helper method. Creates an Event for the given status and originator and fires it. 160 160 void broadcast(bool status); //!< Helper method. Broadcasts an Event for every object that is a target. 161 161 -
code/branches/presentation2011/src/orxonox/gametypes/Gametype.cc
r8980 r8998 85 85 this->dedicatedKillBots_ = createConsoleCommand( "dedicatedKillBots", createExecutor( createFunctor(&Gametype::killBots, this) ) ); 86 86 /* HACK HACK HACK */ 87 //this->numberOfPlayers_ = 0;88 87 } 89 88 … … 124 123 if (this->gtinfo_->isStartCountdownRunning() && !this->gtinfo_->hasStarted()) 125 124 this->gtinfo_->countdownStartCountdown(dt); 126 125 127 126 if (!this->gtinfo_->hasStarted()) 128 127 { … … 132 131 if(it->first->isHumanPlayer() && it->first->isReadyToSpawn()) 133 132 this->gtinfo_->playerReadyToSpawn(it->first); 134 } 135 133 134 135 } 136 136 this->checkStart(); 137 137 } … … 144 144 void Gametype::start() 145 145 { 146 146 147 this->addBots(this->numberOfBots_); 147 148 … … 149 150 150 151 this->spawnPlayersIfRequested(); 152 153 151 154 } 152 155 … … 377 380 { 378 381 this->gtinfo_->stopStartCountdown(); 379 this->gtinfo_->setStartCountdown(0.0f); ;382 this->gtinfo_->setStartCountdown(0.0f); 380 383 this->start(); 381 384 } … … 398 401 hashumanplayers = true; 399 402 } 403 400 404 if (allplayersready && hashumanplayers) 401 405 { … … 409 413 } 410 414 } 415 411 416 } 412 417 } -
code/branches/presentation2011/src/orxonox/gametypes/Gametype.h
r8980 r8998 155 155 { return this->gtinfo_->getNumberOfPlayers(); } 156 156 157 158 157 159 protected: 158 160 virtual SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const; -
code/branches/presentation2011/src/orxonox/infos/GametypeInfo.cc
r8858 r8998 71 71 this->bStarted_ = false; 72 72 this->bEnded_ = false; 73 this->startCountdown_ = 0.0f;73 this->startCountdown_ = 10.0f; 74 74 this->bStartCountdownRunning_ = false; 75 this->counter_ = 0;75 this->counter_ = 10; 76 76 this->spawned_ = false; 77 77 this->readyToSpawn_ = false; … … 164 164 { 165 165 if(this->bStarted_) 166 return;166 { return;} 167 167 168 168 this->bStarted_ = true; 169 169 this->changedStarted(); 170 171 170 172 } 171 173 -
code/branches/presentation2011/src/orxonox/infos/PlayerInfo.cc
r8988 r8998 58 58 59 59 this->registerVariables(); 60 60 61 } 61 62
Note: See TracChangeset
for help on using the changeset viewer.