Changeset 2820 for code/branches/miniprojects/src/orxonox
- Timestamp:
- Mar 23, 2009, 12:44:10 AM (16 years ago)
- Location:
- code/branches/miniprojects/src/orxonox/objects/gametypes
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/miniprojects/src/orxonox/objects/gametypes/CMakeLists.txt
r2768 r2820 1 1 ADD_SOURCE_FILES(ORXONOX_SRC_FILES 2 2 Gametype.cc 3 Deathmatch.cc 3 4 TeamGametype.cc 4 5 ) -
code/branches/miniprojects/src/orxonox/objects/gametypes/Gametype.cc
r2818 r2820 44 44 #include "objects/worldentities/Camera.h" 45 45 46 #include "network/Host.h"47 48 46 namespace orxonox 49 47 { … … 105 103 this->addBots(this->numberOfBots_); 106 104 107 COUT(0) << "game started" << std::endl;108 105 this->gtinfo_.bStarted_ = true; 109 106 … … 113 110 void Gametype::end() 114 111 { 115 COUT(0) << "game ended" << std::endl;116 112 this->gtinfo_.bEnded_ = true; 117 113 } … … 120 116 { 121 117 this->players_[player].state_ = PlayerState::Joined; 122 123 std::string message = player->getName() + " entered the game"; 124 COUT(0) << message << std::endl; 125 Host::Broadcast(message); 126 } 127 128 void Gametype::playerLeft(PlayerInfo* player) 118 } 119 120 bool Gametype::playerLeft(PlayerInfo* player) 129 121 { 130 122 std::map<PlayerInfo*, Player>::iterator it = this->players_.find(player); … … 132 124 { 133 125 this->players_.erase(it); 134 135 std::string message = player->getName() + " left the game"; 136 COUT(0) << message << std::endl; 137 Host::Broadcast(message); 138 } 126 return true; 127 } 128 return false; 139 129 } 140 130 … … 147 137 } 148 138 149 voidGametype::playerChangedName(PlayerInfo* player)139 bool Gametype::playerChangedName(PlayerInfo* player) 150 140 { 151 141 if (this->players_.find(player) != this->players_.end()) … … 153 143 if (player->getName() != player->getOldName()) 154 144 { 155 std::string message = player->getOldName() + " changed name to " + player->getName(); 156 COUT(0) << message << std::endl; 157 Host::Broadcast(message); 158 } 159 } 145 return true; 146 } 147 } 148 return false; 160 149 } 161 150 … … 201 190 void Gametype::pawnKilled(Pawn* victim, Pawn* killer) 202 191 { 203 if (victim && victim->getPlayer())204 {205 std::string message;206 if (killer)207 {208 if (killer->getPlayer())209 message = victim->getPlayer()->getName() + " was killed by " + killer->getPlayer()->getName();210 else211 message = victim->getPlayer()->getName() + " was killed";212 }213 else214 message = victim->getPlayer()->getName() + " died";215 216 COUT(0) << message << std::endl;217 Host::Broadcast(message);218 }219 220 192 if (victim && victim->getPlayer()) 221 193 { -
code/branches/miniprojects/src/orxonox/objects/gametypes/Gametype.h
r2818 r2820 84 84 virtual void end(); 85 85 virtual void playerEntered(PlayerInfo* player); 86 virtual voidplayerLeft(PlayerInfo* player);86 virtual bool playerLeft(PlayerInfo* player); 87 87 virtual void playerSwitched(PlayerInfo* player, Gametype* newgametype); 88 88 virtual void playerSwitchedBack(PlayerInfo* player, Gametype* oldgametype); 89 virtual voidplayerChangedName(PlayerInfo* player);89 virtual bool playerChangedName(PlayerInfo* player); 90 90 91 91 virtual void playerScored(Player& player); -
code/branches/miniprojects/src/orxonox/objects/gametypes/TeamGametype.cc
r2818 r2820 39 39 CreateUnloadableFactory(TeamGametype); 40 40 41 TeamGametype::TeamGametype(BaseObject* creator) : Gametype(creator)41 TeamGametype::TeamGametype(BaseObject* creator) : Deathmatch(creator) 42 42 { 43 43 RegisterObject(TeamGametype); … … 66 66 void TeamGametype::playerEntered(PlayerInfo* player) 67 67 { 68 Gametype::playerEntered(player);68 Deathmatch::playerEntered(player); 69 69 70 70 std::vector<unsigned int> playersperteam(this->teams_, 0); … … 88 88 } 89 89 90 voidTeamGametype::playerLeft(PlayerInfo* player)90 bool TeamGametype::playerLeft(PlayerInfo* player) 91 91 { 92 Gametype::playerLeft(player);92 bool valid_player = Deathmatch::playerLeft(player); 93 93 94 this->players_.erase(player); 94 if (valid_player) 95 this->players_.erase(player); 96 97 return valid_player; 95 98 } 96 99 -
code/branches/miniprojects/src/orxonox/objects/gametypes/TeamGametype.h
r2818 r2820 34 34 #include <vector> 35 35 36 #include " Gametype.h"36 #include "Deathmatch.h" 37 37 38 38 namespace orxonox 39 39 { 40 class _OrxonoxExport TeamGametype : public Gametype40 class _OrxonoxExport TeamGametype : public Deathmatch 41 41 { 42 42 public: … … 47 47 48 48 virtual void playerEntered(PlayerInfo* player); 49 virtual voidplayerLeft(PlayerInfo* player);49 virtual bool playerLeft(PlayerInfo* player); 50 50 51 51 virtual bool allowPawnHit(Pawn* victim, Pawn* originator = 0);
Note: See TracChangeset
for help on using the changeset viewer.