Changeset 7583 for code/branches/lastmanstanding/src
- Timestamp:
- Oct 25, 2010, 11:11:04 PM (14 years ago)
- Location:
- code/branches/lastmanstanding/src/orxonox/gametypes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.cc
r7581 r7583 40 40 CreateUnloadableFactory(LastManStanding); 41 41 42 LastManStanding::LastManStanding(BaseObject* creator) : Gametype(creator)42 LastManStanding::LastManStanding(BaseObject* creator) : Deathmatch(creator) 43 43 { 44 44 RegisterObject(LastManStanding); … … 74 74 this->timeToAct_[originator->getPlayer()]=timeRemaining; 75 75 } 76 77 76 return true; 78 77 } … … 93 92 } 94 93 95 void LastManStanding::start()96 {97 Gametype::start();98 99 std::string message("Try to survive!");100 COUT(0) << message << std::endl;101 Host::Broadcast(message);102 }103 104 94 void LastManStanding::end() 105 95 { … … 122 112 if (!player)// only for safety 123 113 return; 124 Gametype::playerEntered(player);114 Deathmatch::playerEntered(player); 125 115 126 116 playerLives_[player]=lives; 127 117 this->playersAlive++; 128 118 this->timeToAct_[player]=timeRemaining; 129 const std::string& message = player->getName() + " entered the game";130 COUT(0) << message << std::endl;131 Host::Broadcast(message);132 119 //Update: EachPlayer's "Players in Game"-HUD 133 120 for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) … … 138 125 this->gtinfo_->sendStaticMessage(message1,it->first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f)); 139 126 } 140 141 127 } 142 128 143 129 bool LastManStanding::playerLeft(PlayerInfo* player) 144 130 { 145 bool valid_player = Gametype::playerLeft(player); 146 131 bool valid_player = Deathmatch::playerLeft(player); 147 132 if (valid_player) 148 133 { 149 134 this->playersAlive--; 150 135 //this->playerLives_[player].erase (player); not necessary? 151 //152 const std::string& message = player->getName() + " left the game";153 COUT(0) << message << std::endl;154 Host::Broadcast(message);155 136 //Update: EachPlayer's "Players in Game"-HUD 156 137 for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) … … 166 147 } 167 148 168 bool LastManStanding::playerChangedName(PlayerInfo* player)169 {170 bool valid_player = Gametype::playerChangedName(player);171 172 if (valid_player)173 {174 const std::string& message = player->getOldName() + " changed name to " + player->getName();175 COUT(0) << message << std::endl;176 Host::Broadcast(message);177 }178 179 return valid_player;180 }181 182 149 void LastManStanding::playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn) 183 150 { … … 190 157 const std::string& message = "Your Lives: " +multi_cast<std::string>(playerLives_[player]); 191 158 this->gtinfo_->sendFadingMessage(message,it2->first->getClientID()); 192 193 159 } 194 160 } … … 204 170 this->gtinfo_->sendStaticMessage(message1,it->first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f)); 205 171 } 206 207 }208 209 void LastManStanding::pawnKilled(Pawn* victim, Pawn* killer)210 {211 if (victim && victim->getPlayer())212 {213 std::string message;214 if (killer)215 {216 if (killer->getPlayer())217 message = victim->getPlayer()->getName() + " was killed by " + killer->getPlayer()->getName();218 else219 message = victim->getPlayer()->getName() + " was killed";220 }221 else222 message = victim->getPlayer()->getName() + " died";223 224 COUT(0) << message << std::endl;225 Host::Broadcast(message);226 }227 228 Gametype::pawnKilled(victim, killer);229 172 } 230 173 -
code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.h
r7579 r7583 35 35 36 36 #include "OrxonoxPrereqs.h" 37 #include " Gametype.h"37 #include "Deathmatch.h" 38 38 #include <map> 39 39 #include <vector> … … 41 41 namespace orxonox 42 42 { 43 class _OrxonoxExport LastManStanding : public Gametype43 class _OrxonoxExport LastManStanding : public Deathmatch 44 44 { 45 45 /** … … 65 65 virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0); //!< Manages each players lives. 66 66 67 virtual void start(); //!< Sends a start message.68 67 virtual void end(); //!< Sends an end message. 69 68 virtual void playerEntered(PlayerInfo* player); //!< Initializes values. Manages the gametype's HUD. #Players alive via StaticMessage. 70 69 virtual bool playerLeft(PlayerInfo* player); //!< Manages the gametype's HUD. #Players alive via StaticMessage. 71 virtual bool playerChangedName(PlayerInfo* player);72 70 virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn); //!< Manages the gametype's HUD. player's lives via FadingMessage. 73 71 virtual void playerStopsControllingPawn(PlayerInfo* player, Pawn* pawn); //!< Manages the gametype's HUD. #Players alive via StaticMessage. 74 virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);75 72 76 73 const int playerGetLives(PlayerInfo* player); //!< getFunction for the map "playerLives_".
Note: See TracChangeset
for help on using the changeset viewer.