Changeset 9269 for code/branches/presentation2012merge/src/orxonox
- Timestamp:
- Jun 3, 2012, 4:33:13 PM (12 years ago)
- Location:
- code/branches/presentation2012merge
- Files:
-
- 6 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation2012merge
- Property svn:ignore
-
old new 1 .project 1 2 build 2 3 codeblocks 4 dependencies 3 5 vs 4 dependencies
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
code/branches/presentation2012merge/src/orxonox/LevelInfo.cc
r9016 r9269 93 93 LevelInfoItem::possibleTags_s.insert("gametype"); 94 94 LevelInfoItem::possibleTags_s.insert("minigame"); 95 LevelInfoItem::possibleTags_s.insert("shipselection"); 95 96 } 96 97 } … … 110 111 111 112 this->tagsUpdated(); 113 } 114 /** 115 @brief 116 Set the starting ship models of the level 117 @param tags 118 A comma-seperated string of all the allowed ship models for the shipselection. 119 */ 120 void LevelInfoItem::setShips(const std::string& ships) 121 { 122 SubString substr = SubString(ships, ",", " "); // Split the string into tags. 123 const std::vector<std::string>& strings = substr.getAllStrings(); 124 for(std::vector<std::string>::const_iterator it = strings.begin(); it != strings.end(); it++) 125 this->addShip(*it, false); 126 127 this->shipsUpdated(); 112 128 } 113 129 … … 137 153 /** 138 154 @brief 155 Add a ship model to allowed models for the shipselection 156 @param ship 157 The ship model to be added. 158 @param update 159 Whether the comma-seperated string of all ship models should be updated. Default is true. 160 @return 161 Returns true if the ship was successfully added, if the ship was already present it returns false. 162 */ 163 bool LevelInfoItem::addShip(const std::string& ship, bool update) 164 { 165 bool success = this->ships_.insert(ship).second; 166 if(update && success) 167 this->shipsUpdated(); 168 169 return success; 170 } 171 172 173 /** 174 @brief 139 175 Updates the comma-seperated string of all tags, if the set of tags has changed. 140 176 */ … … 155 191 } 156 192 193 /** 194 @brief 195 Updates the comma-seperated string of all ships, if the set of tags has changed. 196 */ 197 void LevelInfoItem::shipsUpdated(void) 198 { 199 std::stringstream stream; 200 std::set<std::string>::iterator temp; 201 for(std::set<std::string>::iterator it = this->ships_.begin(); it != this->ships_.end(); ) 202 { 203 temp = it; 204 if(++it == this->ships_.end()) // If this is the last ship we don't add a comma. 205 stream << *temp; 206 else 207 stream << *temp << ", "; 208 } 209 210 this->startingShipsString_ = std::string(stream.str()); 211 } 157 212 // LevelInfo 158 213 … … 192 247 XMLPortParam(LevelInfo, "screenshot", setScreenshot, getScreenshot, xmlelement, mode); 193 248 XMLPortParam(LevelInfo, "tags", setTags, getTags, xmlelement, mode); 249 XMLPortParam(LevelInfo, "startingships", setShips, getShips, xmlelement, mode); 194 250 } 195 251 … … 207 263 info->setScreenshot(this->getScreenshot()); 208 264 info->setTags(this->getTags()); 265 info->setShips(this->getShips()); 209 266 return info; 210 267 } -
code/branches/presentation2012merge/src/orxonox/LevelInfo.h
r9016 r9269 24 24 * Co-authors: 25 25 * ... 26 * 26 * 27 27 */ 28 28 … … 43 43 44 44 #include "core/BaseObject.h" 45 #include <iostream> 46 #include <fstream> 45 47 #include "core/OrxonoxClass.h" 46 48 … … 115 117 */ 116 118 inline bool hasTag(const std::string& tag) const { return this->tags_.find(tag) != this->tags_.end(); } // tolua_export 117 119 120 void setShips(const std::string& ships); //!< Set the starting ship models of the level 121 bool addShip(const std::string& ship, bool update = true); //!< Add a model to shipselection 122 /** 123 @brief Get the set of starting ship models the Level allows 124 @return Returns a comma-seperated string of all the allowed ship models for the shipselection. 125 */ 126 inline const std::string& getShips(void) const 127 { return this->startingShipsString_; } 128 /** 129 @brief Get whether the Level allows a specific starting ship model 130 @param ship The ship model for which is checked. 131 @return Returns true if the Level allows the input ship model 132 */ 133 inline bool hasShip(const std::string& ship) const { return this->ships_.find(ship) != this->ships_.end(); } // tolua_export 118 134 /** 119 135 @brief Get the XML-filename of the Level. 120 136 @return Returns the XML-filename (including *.oxw extension) of the Level. 121 137 */ 138 122 139 inline const std::string& getXMLFilename(void) const { return this->xmlfilename_; } // tolua_export 140 inline void selectShip (const std::string& ship) { this->changeShip(ship); } // tolua_export 141 123 142 124 143 protected: … … 133 152 134 153 private: 154 155 inline void changeShip (const std::string& model) { 156 static std::string shipSelectionTag = "shipselection"; 157 //HACK: Read Level XML File, find "shipselection", replace with ship model 158 std::string levelPath = "../levels/"; 159 levelPath.append(this->getXMLFilename()); 160 std::string tempPath = "../levels/"; 161 tempPath.append("_temp.oxw"); 162 orxout(user_status) << levelPath << endl; 163 orxout(user_status) << tempPath << endl; 164 std::ifstream myLevel (levelPath.c_str()); 165 std::ofstream tempLevel (tempPath.c_str()); 166 while(!myLevel.eof()) 167 { 168 std::string buff; 169 std::getline(myLevel, buff); 170 std::string pawndesignString = "pawndesign="; 171 size_t found = buff.find(pawndesignString.append(shipSelectionTag)); 172 if (found!= std::string::npos) 173 buff = buff.substr(0, found + 11) + model + buff.substr(found+11+shipSelectionTag.length(), std::string::npos); 174 tempLevel.write(buff.c_str(), buff.length()); 175 tempLevel << std::endl; 176 } 177 myLevel.close(); 178 tempLevel.close(); 179 orxout(user_status) << "done" << endl; 180 } 135 181 void tagsUpdated(void); //!< Updates the comma-seperated string of all tags, if the set of tags has changed. 136 182 void shipsUpdated(void); //!< Updates the comma-seperated string of all tags, if the set of tags has changed. 137 183 static void initializeTags(void); //!< Initialize the set of allowed tags. 138 184 /** … … 152 198 std::set<std::string> tags_; //!< The set of tags the Level is tagged with. 153 199 std::string tagsString_; //!< The comma-seperated string of all the tags the Level is tagged with. 200 std::set<std::string> ships_; //!< The set of starting ship models the Level allows. 201 std::string startingShipsString_; //!< The comma-seperated string of all the allowed ship models for the shipselection. 154 202 }; // tolua_export 155 203 … … 161 209 - @b description The description of the level. 162 210 - @b screenshot The screenshot of the level. 163 - @b tags A comma-seperated string of tags. Allowed tags are: <em>test</em>, <em>singleplayer</em>, <em>multiplayer</em>, <em>showcase</em>, <em>tutorial</em>, <em>presentation</em> .164 211 - @b tags A comma-seperated string of tags. Allowed tags are: <em>test</em>, <em>singleplayer</em>, <em>multiplayer</em>, <em>showcase</em>, <em>tutorial</em>, <em>presentation</em>, <em>shipselection</em>. 212 - @b (optional) startingships The comma-seperated string of starting ship models 165 213 An example would be: 166 214 @code … … 176 224 @author 177 225 Damian 'Mozork' Frick 178 226 @edit 227 Matthias Hutter 179 228 @ingroup Orxonox 180 229 */ … … 223 272 inline const std::string& getTags(void) const 224 273 { return this->LevelInfoItem::getTags(); } 225 274 /** 275 @brief Set the starting ship models of the level 276 @param A comma-seperated string of all the allowed ship models for the shipselection. 277 */ 278 inline void setShips(const std::string& ships) 279 { this->LevelInfoItem::setShips(ships); } 280 /** 281 @brief Get the starting ship models of the level 282 @return Returns a comma-seperated string of all the allowed ship models for the shipselection. 283 */ 284 inline const std::string& getShips(void) const 285 { return this->LevelInfoItem::getShips(); } 226 286 LevelInfoItem* copy(void); //!< Copies the contents of this LevelInfo object to a new LevelInfoItem object. 227 228 287 }; 229 288 -
code/branches/presentation2012merge/src/orxonox/controllers/FormationController.cc
r9265 r9269 280 280 } 281 281 282 Vector2 coord = get2DView direction(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, target);282 Vector2 coord = get2DViewcoordinates(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, target); 283 283 float distance = (target - this->getControllableEntity()->getPosition()).length(); 284 284 if(coord.x < 0.0001 && coord.y < 0.0001) 285 { 286 // if the ship reaches a direction very close to the direct one, set it to the direct one 287 Vector3 v_temp = this->getControllableEntity()->getPosition(); 288 Quaternion quat = v_temp.getRotationTo(target); 289 this->getControllableEntity()->rotate(quat); 290 } 285 291 286 292 if(this->state_ == FREE) … … 289 295 { 290 296 // Multiply with ROTATEFACTOR_FREE to make them a bit slower 291 this->getControllableEntity()->rotateYaw(-1.0f * ROTATEFACTOR_FREE * sgn(coord.x) * coord.x*coord.x);292 this->getControllableEntity()->rotatePitch(ROTATEFACTOR_FREE * sgn(coord.y) * coord.y*coord.y);293 } 294 295 if (this->target_ && distance < 200 && this->getControllableEntity()->getVelocity().squaredLength() > this->target_->getVelocity().squaredLength())297 this->getControllableEntity()->rotateYaw(-1.0f * ROTATEFACTOR_FREE * coord.x * 2); 298 this->getControllableEntity()->rotatePitch(ROTATEFACTOR_FREE * coord.y * 2); 299 } 300 301 if (this->target_ && distance < 200 && this->getControllableEntity()->getVelocity().squaredLength() > this->target_->getVelocity().squaredLength()) 296 302 { 297 303 this->getControllableEntity()->moveFrontBack(-0.05f); // They don't brake with full power to give the player a chance … … 305 311 if (this->target_ || distance > 10) 306 312 { 307 this->getControllableEntity()->rotateYaw(-1.0f * ROTATEFACTOR_MASTER * sgn(coord.x) * coord.x*coord.x);308 this->getControllableEntity()->rotatePitch(ROTATEFACTOR_MASTER * sgn(coord.y) * coord.y*coord.y);313 this->getControllableEntity()->rotateYaw(-1.0f * ROTATEFACTOR_MASTER * coord.x * 2); 314 this->getControllableEntity()->rotatePitch(ROTATEFACTOR_MASTER * coord.y * 2); 309 315 } 310 316 … … 318 324 319 325 if(this->state_ == SLAVE) 320 321 322 this->getControllableEntity()->rotateYaw(-2.0f * ROTATEFACTOR_MASTER * sgn(coord.x) * coord.x*coord.x);323 this->getControllableEntity()->rotatePitch(2.0f * ROTATEFACTOR_MASTER * sgn(coord.y) * coord.y*coord.y);324 325 326 327 328 329 copyTargetOrientation();330 331 332 {//linear speed reduction333 334 335 336 337 338 339 340 326 { 327 328 this->getControllableEntity()->rotateYaw(-2.0f * ROTATEFACTOR_MASTER * coord.x * 2); 329 this->getControllableEntity()->rotatePitch(2.0f * ROTATEFACTOR_MASTER * coord.y * 2); 330 331 if (distance < 300) 332 { 333 if (bHasTargetOrientation_) 334 { 335 copyTargetOrientation(); 336 } 337 if (distance < 100) 338 { //linear speed reduction 339 this->getControllableEntity()->moveFrontBack(distance/100.0f*0.4f*SPEED_MASTER); 340 341 } else this->getControllableEntity()->moveFrontBack(1.2f*SPEED_MASTER); 342 343 } else { 344 this->getControllableEntity()->moveFrontBack(1.2f*SPEED_MASTER + distance/300.0f); 345 } 346 } 341 347 342 348 if (distance < 10) -
code/branches/presentation2012merge/src/orxonox/worldentities/pawns/Pawn.cc
r9257 r9269 75 75 this->lastHitOriginator_ = 0; 76 76 77 // set damage multiplier to default value 1, meaning nominal damage 78 this->damageMultiplier_ = 1; 79 77 80 this->spawnparticleduration_ = 3.0f; 78 81 … … 228 231 void Pawn::damage(float damage, float healthdamage, float shielddamage, Pawn* originator) 229 232 { 230 if (this->getGametype() && this->getGametype()->allowPawnDamage(this, originator)) 233 //Applies multiplier given by the DamageBoost Pickup. 234 Pawn *test = dynamic_cast<Pawn *>(originator); 235 if( test != NULL ) 236 { 237 damage *= originator->getDamageMultiplier(); 238 } 239 240 if (this->getGametype() && this->getGametype()->allowPawnDamage(this, originator)) 231 241 { 232 242 if (shielddamage >= this->getShieldHealth()) -
code/branches/presentation2012merge/src/orxonox/worldentities/pawns/Pawn.h
r9254 r9269 162 162 { return this->numexplosionchunks_; } 163 163 164 // These are used with the Damage Boost Pickup to use the damage multiplier. 165 inline void setDamageMultiplier(float multiplier) 166 { this->damageMultiplier_ = multiplier; } 167 inline float getDamageMultiplier() 168 { return this->damageMultiplier_; } 169 170 164 171 virtual void startLocalHumanControl(); 165 172 … … 208 215 float reloadWaitCountdown_; 209 216 217 // Modifier 218 float damageMultiplier_; // Used by the Damage Boost Pickup. 219 210 220 WeakPtr<Pawn> lastHitOriginator_; 211 221
Note: See TracChangeset
for help on using the changeset viewer.