Changeset 3099 for code/trunk/src
- Timestamp:
- May 28, 2009, 1:58:22 AM (16 years ago)
- Location:
- code/trunk/src/orxonox
- Files:
-
- 10 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/OrxonoxPrereqs.h
r3089 r3099 268 268 class OverlayGroup; 269 269 class OverlayText; 270 class FadeoutText; 270 271 class GametypeStatus; 272 class AnnounceMessage; 273 class KillMessage; 274 class DeathMessage; 271 275 class CreateLines; 272 276 class Scoreboard; -
code/trunk/src/orxonox/objects/CMakeLists.txt
r3084 r3099 3 3 EventDispatcher.cc 4 4 EventTarget.cc 5 GametypeMessageListener.cc 5 6 GlobalShader.cc 6 7 Level.cc -
code/trunk/src/orxonox/objects/gametypes/Asteroids.cc
r3056 r3099 57 57 if (this->time_ < 0 && !this->hasEnded() && this->timerIsActive_) 58 58 { 59 this->gtinfo_.sendAnnounceMessage("Time's up - you have lost the match!"); 59 60 this->end(); 60 61 } … … 65 66 if (victim && victim->getPlayer()) 66 67 { 68 this->gtinfo_.sendAnnounceMessage("You're dead - you have lost the match!"); 67 69 this->end(); 68 70 } … … 73 75 Gametype::start(); 74 76 75 std::string message = "The match has started! Reach the first chekpoint within 60seconds! But be aware, there may be pirates around...";77 std::string message = "The match has started! Reach the first chekpoint within 15 seconds! But be aware, there may be pirates around..."; 76 78 COUT(0) << message << std::endl; 77 79 Host::Broadcast(message); -
code/trunk/src/orxonox/objects/gametypes/Gametype.cc
r3038 r3099 236 236 237 237 // Reward killer 238 if (killer )238 if (killer && killer->getPlayer()) 239 239 { 240 240 std::map<PlayerInfo*, Player>::iterator it = this->players_.find(killer->getPlayer()); 241 241 if (it != this->players_.end()) 242 { 242 243 it->second.frags_++; 244 245 if (killer->getPlayer()->getClientID() != CLIENTID_UNKNOWN) 246 this->gtinfo_.sendKillMessage("You killed " + victim->getPlayer()->getName(), killer->getPlayer()->getClientID()); 247 if (victim->getPlayer()->getClientID() != CLIENTID_UNKNOWN) 248 this->gtinfo_.sendDeathMessage("You were killed by " + killer->getPlayer()->getName(), victim->getPlayer()->getClientID()); 249 } 243 250 } 244 251 -
code/trunk/src/orxonox/objects/gametypes/Pong.cc
r2890 r3099 160 160 { 161 161 this->center_->fireEvent(); 162 163 if (player) 164 this->gtinfo_.sendAnnounceMessage(player->getName() + " scored"); 162 165 } 163 166 -
code/trunk/src/orxonox/objects/gametypes/TeamBaseMatch.cc
r3086 r3099 31 31 #include "objects/worldentities/pawns/TeamBaseMatchBase.h" 32 32 #include "core/CoreIncludes.h" 33 #include "objects/infos/PlayerInfo.h" 33 34 34 35 namespace orxonox … … 58 59 int teamnr = this->getTeam(originator->getPlayer()); 59 60 if (teamnr == 0) 61 { 60 62 base->setState(BaseState::controlTeam1); 63 this->gtinfo_.sendAnnounceMessage("The red team captured a base"); 64 } 61 65 if (teamnr == 1) 66 { 62 67 base->setState(BaseState::controlTeam2); 68 this->gtinfo_.sendAnnounceMessage("The blue team captured a base"); 69 } 63 70 } 64 71 … … 125 132 void TeamBaseMatch::showPoints() 126 133 { 134 if (!this->hasStarted() || this->hasEnded()) 135 return; 136 127 137 COUT(0) << "Points standing:" << std::endl << "Team 1: "<< pointsTeam1_ << std::endl << "Team 2: " << pointsTeam2_ << std::endl; 128 138 if(pointsTeam1_ >=1700 && pointsTeam1_ < 2000) COUT(0) << "Team 1 is near victory!" << std::endl; … … 159 169 if (this->pointsTeam1_ >= 2000 || this->pointsTeam2_ >= 2000) 160 170 { 171 int winningteam = -1; 172 161 173 if (this->pointsTeam1_ > this->pointsTeam2_) 174 { 162 175 COUT(0) << "Team 1 has won the match" << std::endl; 176 winningteam = 0; 177 } 163 178 else 179 { 164 180 COUT(0) << "Team 2 has won the match" << std::endl; 181 winningteam = 1; 182 } 183 184 for (std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it) 185 { 186 if (it->first->getClientID() == CLIENTID_UNKNOWN) 187 continue; 188 189 if (it->second == winningteam) 190 this->gtinfo_.sendAnnounceMessage("You have won the match!", it->first->getClientID()); 191 else 192 this->gtinfo_.sendAnnounceMessage("You have lost the match!", it->first->getClientID()); 193 } 165 194 166 195 this->end(); -
code/trunk/src/orxonox/objects/gametypes/UnderAttack.cc
r3057 r3099 36 36 37 37 #include "objects/worldentities/pawns/Destroyer.h" 38 #include "objects/infos/PlayerInfo.h" 38 39 39 40 namespace orxonox … … 73 74 Host::Broadcast(message); 74 75 this->gameEnded_ = true; 76 77 for (std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it) 78 { 79 if (it->first->getClientID() == CLIENTID_UNKNOWN) 80 continue; 81 82 if (it->second == 0) 83 this->gtinfo_.sendAnnounceMessage("You have won the match!", it->first->getClientID()); 84 else 85 this->gtinfo_.sendAnnounceMessage("You have lost the match!", it->first->getClientID()); 86 } 75 87 } 76 88 } … … 145 157 COUT(0) << message << std::endl; 146 158 Host::Broadcast(message); 159 160 for (std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it) 161 { 162 if (it->first->getClientID() == CLIENTID_UNKNOWN) 163 continue; 164 165 if (it->second == 1) 166 this->gtinfo_.sendAnnounceMessage("You have won the match!", it->first->getClientID()); 167 else 168 this->gtinfo_.sendAnnounceMessage("You have lost the match!", it->first->getClientID()); 169 } 147 170 } 148 171 149 172 //prints gametime 150 if ( gameTime_ <= timesequence_ )173 if ( gameTime_ <= timesequence_ && gameTime_ > 0) 151 174 { 152 std::string message = convertToString(timesequence_) + " sec left!"; 175 std::string message = convertToString(timesequence_) + " seconds left!"; 176 /* 153 177 COUT(0) << message << std::endl; 154 178 Host::Broadcast(message); 179 */ 180 this->gtinfo_.sendAnnounceMessage(message); 181 155 182 if (timesequence_ >= 30 && timesequence_ <= 60) 156 183 { -
code/trunk/src/orxonox/objects/infos/GametypeInfo.cc
r2826 r3099 31 31 32 32 #include "core/CoreIncludes.h" 33 #include "core/GameMode.h" 34 #include "network/NetworkFunction.h" 35 #include "network/Host.h" 36 #include "objects/GametypeMessageListener.h" 33 37 34 38 namespace orxonox 35 39 { 36 40 CreateUnloadableFactory(GametypeInfo); 41 42 registerMemberNetworkFunction(GametypeInfo, dispatchAnnounceMessage); 43 registerMemberNetworkFunction(GametypeInfo, dispatchKillMessage); 44 registerMemberNetworkFunction(GametypeInfo, dispatchDeathMessage); 37 45 38 46 GametypeInfo::GametypeInfo(BaseObject* creator) : Info(creator) … … 60 68 registerVariable(this->hudtemplate_, variableDirection::toclient); 61 69 } 70 71 void GametypeInfo::sendAnnounceMessage(const std::string& message) const 72 { 73 if (GameMode::isMaster()) 74 { 75 callMemberNetworkFunction(GametypeInfo, dispatchAnnounceMessage, this->getObjectID(), CLIENTID_UNKNOWN, message); 76 this->dispatchAnnounceMessage(message); 77 } 78 } 79 80 void GametypeInfo::sendAnnounceMessage(const std::string& message, unsigned int clientID) const 81 { 82 if (GameMode::isMaster()) 83 { 84 if (clientID == CLIENTID_SERVER) 85 this->dispatchAnnounceMessage(message); 86 else 87 callMemberNetworkFunction(GametypeInfo, dispatchAnnounceMessage, this->getObjectID(), clientID, message); 88 } 89 } 90 91 void GametypeInfo::sendKillMessage(const std::string& message, unsigned int clientID) const 92 { 93 if (GameMode::isMaster()) 94 { 95 if (clientID == CLIENTID_SERVER) 96 this->dispatchKillMessage(message); 97 else 98 callMemberNetworkFunction(GametypeInfo, dispatchKillMessage, this->getObjectID(), clientID, message); 99 } 100 } 101 102 void GametypeInfo::sendDeathMessage(const std::string& message, unsigned int clientID) const 103 { 104 if (GameMode::isMaster()) 105 { 106 if (clientID == CLIENTID_SERVER) 107 this->dispatchDeathMessage(message); 108 else 109 callMemberNetworkFunction(GametypeInfo, dispatchDeathMessage, this->getObjectID(), clientID, message); 110 } 111 } 112 113 void GametypeInfo::dispatchAnnounceMessage(const std::string& message) const 114 { 115 for (ObjectList<GametypeMessageListener>::iterator it = ObjectList<GametypeMessageListener>::begin(); it != ObjectList<GametypeMessageListener>::end(); ++it) 116 it->announcemessage(this, message); 117 } 118 119 void GametypeInfo::dispatchKillMessage(const std::string& message) const 120 { 121 for (ObjectList<GametypeMessageListener>::iterator it = ObjectList<GametypeMessageListener>::begin(); it != ObjectList<GametypeMessageListener>::end(); ++it) 122 it->killmessage(this, message); 123 } 124 125 void GametypeInfo::dispatchDeathMessage(const std::string& message) const 126 { 127 for (ObjectList<GametypeMessageListener>::iterator it = ObjectList<GametypeMessageListener>::begin(); it != ObjectList<GametypeMessageListener>::end(); ++it) 128 it->deathmessage(this, message); 129 } 62 130 } -
code/trunk/src/orxonox/objects/infos/GametypeInfo.h
r2826 r3099 59 59 { return this->hudtemplate_; } 60 60 61 void sendAnnounceMessage(const std::string& message) const; 62 void sendAnnounceMessage(const std::string& message, unsigned int clientID) const; 63 void sendKillMessage(const std::string& message, unsigned int clientID) const; 64 void sendDeathMessage(const std::string& message, unsigned int clientID) const; 65 66 void dispatchAnnounceMessage(const std::string& message) const; 67 void dispatchKillMessage(const std::string& message) const; 68 void dispatchDeathMessage(const std::string& message) const; 69 61 70 private: 62 71 bool bStarted_; -
code/trunk/src/orxonox/objects/worldentities/triggers/CheckPoint.cc
r3067 r3099 72 72 { 73 73 SUPER(CheckPoint, changedActivity); 74 74 75 75 if (this->BaseObject::isActive()) 76 76 { … … 93 93 this->setRadarVisibility(false); 94 94 95 if (bIsTriggered && bIsFirst_)95 if (bIsTriggered) 96 96 { 97 gametype->setTimeLimit(addTime_); 98 gametype->firstCheckpointReached(true); 99 } 97 if (bIsFirst_) 98 { 99 gametype->setTimeLimit(addTime_); 100 gametype->firstCheckpointReached(true); 101 } 100 102 101 if (bIsTriggered && bIsDestination_) 102 { 103 gametype->end(); 103 if (bIsDestination_) 104 { 105 const_cast<GametypeInfo*>(gametype->getGametypeInfo())->sendAnnounceMessage("Congratulations - you have won the match!"); 106 gametype->end(); 107 } 108 109 if (!bIsFirst_ && !bIsDestination_) 110 { 111 const_cast<GametypeInfo*>(gametype->getGametypeInfo())->sendAnnounceMessage("Checkpoint reached"); 112 } 104 113 } 105 114 } -
code/trunk/src/orxonox/overlays/CMakeLists.txt
r3089 r3099 3 3 OverlayGroup.cc 4 4 OverlayText.cc 5 FadeoutText.cc 5 6 GUIOverlay.cc 6 7 ) -
code/trunk/src/orxonox/overlays/OverlayText.h
r2662 r3099 47 47 virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); 48 48 49 inline void setCaption(const std::string& caption) { this->text_->setCaption(caption); }49 inline void setCaption(const std::string& caption) { this->text_->setCaption(caption); this->changedCaption(); } 50 50 inline std::string getCaption() const { return this->text_->getCaption(); } 51 51 … … 56 56 inline float getSpaceWidth() const { return this->text_->getSpaceWidth(); } 57 57 58 inline void setColour(const ColourValue& colour) { this->text_->setColour(colour); }58 inline void setColour(const ColourValue& colour) { this->text_->setColour(colour); this->changedColour(); } 59 59 inline const ColourValue& getColour() const { return this->text_->getColour(); } 60 60 … … 70 70 protected: 71 71 virtual void sizeChanged(); 72 virtual void changedColour() {} 73 virtual void changedCaption() {} 72 74 73 75 Ogre::TextAreaOverlayElement* text_; -
code/trunk/src/orxonox/overlays/hud/CMakeLists.txt
r3033 r3099 8 8 ChatOverlay.cc 9 9 GametypeStatus.cc 10 AnnounceMessage.cc 11 KillMessage.cc 12 DeathMessage.cc 10 13 PongScore.cc 11 14 )
Note: See TracChangeset
for help on using the changeset viewer.