- Timestamp:
- May 23, 2012, 5:56:57 PM (13 years ago)
- Location:
- code/branches/captureTheFlag
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
code/branches/captureTheFlag
- Property svn:mergeinfo changed
/code/branches/waypoints (added) merged: 9032,9043,9054,9093,9105,9159,9177,9219
- Property svn:mergeinfo changed
-
code/branches/captureTheFlag/src/modules/pickup/items/FlagPickup.cc
r9220 r9232 39 39 40 40 #include "pickup/PickupIdentifier.h" 41 #include "worldentities/pawns/Pawn.h"42 41 43 42 namespace orxonox 44 43 { 45 46 /*static*/ const std::string FlagPickup::flagTypeBlue_s = "blue";47 /*static*/ const std::string FlagPickup::flagTypeRed_s = "red";48 /*static*/ const std::string FlagPickup::flagTypeNeutral_s = "neutral";49 44 50 45 CreateFactory(FlagPickup); … … 76 71 void FlagPickup::initialize(void) 77 72 { 78 this->flagType_ = pickupFlagType::0;73 this->flagType_ = 0; 79 74 80 75 this->addTarget(ClassIdentifier<Pawn>::getIdentifier()); … … 87 82 void FlagPickup::initializeIdentifier(void) 88 83 { 89 std::string val1 = this->getFlagType(); 84 std::stringstream stream; 85 int type = this->getFlagType(); 86 stream << type; 87 std::string val = stream.str(); 88 90 89 std::string type1 = "flagType"; 91 this->pickupIdentifier_->addParameter(type1, val 1);90 this->pickupIdentifier_->addParameter(type1, val); 92 91 } 93 92 … … 113 112 Returns the falg type as a string. 114 113 */ 115 const std::string&FlagPickup::getFlagType(void) const114 const int FlagPickup::getFlagType(void) const 116 115 { 117 switch(this->getFlagTypeDirect()) 118 { 119 case pickupFlagType::blue: 120 return FlagPickup::flagTypeBlue_s; 121 case pickupFlagType::red: 122 return FlagPickup::flagTypeRed_s; 123 case pickupFlagType::neutral: 124 return FlagPickup::flagTypeNeutral_s; 125 default: 126 orxout(internal_error, context::pickups) << "Invalid flagType in FlagPickup." << endl; 127 return BLANKSTRING; 128 } 129 } 116 return this->flagType_; 117 } 130 118 131 119 /** … … 135 123 The type as a string. 136 124 */ 137 void FlagPickup::setFlagType( std::stringtype)125 void FlagPickup::setFlagType(int type) 138 126 { 139 if(type == FlagPickup::flagTypeRed_s) 140 this->setFlagTypeDirect(pickupFlagType::2); 141 else if(type == FlagPickup::flagTypeBlue_s) 142 this->setFlagTypeDirect(pickupFlagType::1); 143 else if(type == FlagPickup::flagTypeNeutral_s) 144 this->setFlagTypeDirect(pickupFlagType::0); 145 else 127 if(type<3){ 128 this->flagType_ = type; 129 } 130 131 else{ 146 132 orxout(internal_error, context::pickups) << "Invalid flagType '" << type << "' in FlagPickup." << endl; 133 } 147 134 } 148 135 … … 163 150 if(this->isUsed()) 164 151 { 165 int team = getTeam(pawn->getPlayer); 166 167 if(this->flagType_ == team){ 168 if(pawn->hasFlag_){ 169 teamScore_ = TeamScore_ + 1000; 170 pawn->hasFlag_ = false; 171 } 172 this->Pickupable::destroy(); 173 }else{ 174 pawn->hasFlag_ = true; 175 } 152 this->bPickedUp_ = true; 153 this->pickedUpBy_ = pawn; 176 154 } 177 155 } 178 179 180 156 181 157 /** … … 196 172 } 197 173 198 int FlagPickup::getTeam(PlayerInfo* player)199 {200 std::map<PlayerInfo*, int>::const_iterator it_player = this->teamnumbers_.find(player);201 if (it_player != this->teamnumbers_.end())202 return it_player->second;203 else204 return -1;205 }206 174 207 }208 175 209 176 void FlagPickup::tick(float dt) … … 213 180 Pawn* pawn = this->carrierToPawnHelper(); 214 181 215 if(pawn->isAlive() && pawn->hasFlag _){182 if(pawn->isAlive() && pawn->hasFlag()){ 216 183 this->Pickupable::destroy(); 217 184 } 218 185 219 186 } 187 }
Note: See TracChangeset
for help on using the changeset viewer.