Changeset 11194
- Timestamp:
- May 26, 2016, 2:40:16 PM (8 years ago)
- Location:
- code/branches/bindermFS16/src/orxonox
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/bindermFS16/src/orxonox/LevelManager.cc
r11191 r11194 24 24 * Co-authors: 25 25 * Damian 'Mozork' Frick 26 * Matthias Binder 26 27 * 27 28 */ … … 91 92 for (LevelInfoItem* info : availableLevels_) 92 93 info->destroy(); 94 for(unsigned int i = 0; i<allLevelStatus_.size();++i) 95 { 96 allLevelStatus_[i]->destroy(); 97 } 93 98 } 94 99 … … 106 111 SetConfigValue(campaignMissions_, std::vector<std::string>()) 107 112 .description("The list of missions in the campaign"); 108 //std::vector<int> v (allLevelStatus_.size(),0); 109 //SetConfigValue(allLevelWon_, v) 110 // .description("The list of all won missions"); 111 } 112 113 /** 114 * @brief Stores the argument in the corresponding config value. 115 */ 116 /* void LevelManager::setLastFinishedCampaignMission(const std::string& lastFinishedCampaignMission) 117 { 118 ModifyConfigValue(lastWonMission_, set, lastFinishedCampaignMission); 119 } 120 */ 113 } 121 114 122 115 … … 337 330 338 331 339 //Mission endmission true 340 //check if index level is activated... 332 333 /** 334 @brief 335 first updates allLevelStatus and then check if the level with index i is activated 336 */ 341 337 int LevelManager::missionactivate(int index) 342 338 { 343 339 updateAllLevelStatus(); 344 int activated = allLevelStatus_[index] .activated;340 int activated = allLevelStatus_[index]->activated; 345 341 return activated; 346 342 } 343 /** 344 @brief 345 update the last won mission to won=true 346 */ 347 347 348 348 void LevelManager::updatewon(int lastwon) 349 349 { 350 allLevelStatus_[lastwon].won=true; 351 352 } 350 allLevelStatus_[lastwon]->won=true; 351 352 } 353 354 /** 355 @brief 356 checks if a level is won 357 if a level is won, the other levels should be shown as saved in 'nextLevels' of the won level 358 therefore 'activated' of all other levels will be updated to the correct value 359 if more than one level is won, the level with the highes index decides which other levels will be shown, activated or not activated 360 */ 353 361 354 362 void LevelManager::updateAllLevelStatus() … … 356 364 for(unsigned int i =0;i<allLevelStatus_.size();i++) 357 365 { 358 if(allLevelStatus_[i] .won)366 if(allLevelStatus_[i]->won) 359 367 { 360 allLevelStatus_[i] .activated=1;361 std::vector<int> nextLevels=allLevelStatus_[i] .nextLevels;368 allLevelStatus_[i]->activated=1; 369 std::vector<int> nextLevels=allLevelStatus_[i]->nextLevels; 362 370 for(unsigned int j=0;j<allLevelStatus_.size();j++) 363 371 { 364 allLevelStatus_[j] .activated=nextLevels[j];372 allLevelStatus_[j]->activated=nextLevels[j]; 365 373 } 366 374 } … … 368 376 } 369 377 378 /** 379 @brief 380 the name of the last won mission is saved in the config file 381 */ 370 382 371 383 void LevelManager::setLevelStatus(const std::string& LevelWon) … … 375 387 ModifyConfigValue(lastWonMission_, set, LevelWon); 376 388 377 std::vector<int> v (allLevelStatus_.size(),0); 378 for(unsigned int i = 0;i<allLevelStatus_.size();i++) 379 { 380 if(allLevelStatus_[i].won) 381 v[i] =1; 382 } 383 384 SetConfigValue(allLevelWon_, v) 385 .description("The list of all won missions"); 386 387 for (unsigned int i = 0; i < allLevelWon_.size(); ++i) 388 { 389 ModifyConfigValue(allLevelWon_[i], set, v[i]); 390 } 391 392 } 393 394 395 //build up allLevelStatus_ 396 //has to be done once per game (not per level) 397 //all connections between the levels are saved in the allLevelStatus_ 398 //also the won variable of the LevelStatus is set to the corresponding allLevelWon_ value 389 /** 390 TODO: save allLevelWon_ into the config file 391 */ 392 } 393 394 395 /** 396 @brief 397 build up allLevelStatus_ 398 has to be done once per game (not per level) 399 all connections between the levels are saved in the allLevelStatus_ 400 also the won variable of the LevelStatus have to be set to the corresponding allLevelWon_ values 401 */ 399 402 void LevelManager::buildallLevelStatus() 400 403 { 401 LevelStatus* level=new LevelStatus(this->getContext()); 402 allLevelStatus_.assign (campaignMissions_.size(),*level); 403 allLevelStatus_[0].activated=1; 404 for(unsigned int i =0;i<campaignMissions_.size();++i) 405 { 406 LevelStatus* level= new LevelStatus(this->getContext()); 407 allLevelStatus_.push_back(level); 408 } 409 410 /** 411 TODO: allLevelWon_ should be loaded into the allLevelSatus_ such that the progress of the campaign can be saved 412 */ 413 414 allLevelStatus_[0]->activated=1; 404 415 405 416 406 417 std::vector<int> v={1,1,1,0,0,0,0,0,0}; 407 allLevelStatus_[0] .nextLevels=v;418 allLevelStatus_[0]->nextLevels=v; 408 419 409 420 v={1,1,2,1,0,0,0,0,0}; 410 allLevelStatus_[1] .nextLevels=v;421 allLevelStatus_[1]->nextLevels=v; 411 422 412 423 v={1,2,1,0,1,0,0,0,0}; 413 allLevelStatus_[2] .nextLevels=v;424 allLevelStatus_[2]->nextLevels=v; 414 425 415 426 v={1,1,2,1,0,1,1,0,0}; 416 allLevelStatus_[3] .nextLevels=v;427 allLevelStatus_[3]->nextLevels=v; 417 428 418 429 v={1,2,1,0,1,0,0,1,1}; 419 allLevelStatus_[4] .nextLevels=v;430 allLevelStatus_[4]->nextLevels=v; 420 431 421 432 v={1,1,2,1,0,1,2,0,0}; 422 allLevelStatus_[5] .nextLevels=v;433 allLevelStatus_[5]->nextLevels=v; 423 434 424 435 v={1,1,2,1,0,2,1,0,0}; 425 allLevelStatus_[6] .nextLevels=v;436 allLevelStatus_[6]->nextLevels=v; 426 437 427 438 v={1,2,1,0,1,0,0,1,2}; 428 allLevelStatus_[7] .nextLevels=v;439 allLevelStatus_[7]->nextLevels=v; 429 440 430 441 v={1,2,1,0,1,0,0,2,1}; 431 allLevelStatus_[8] .nextLevels=v;442 allLevelStatus_[8]->nextLevels=v; 432 443 433 444 } -
code/branches/bindermFS16/src/orxonox/LevelManager.h
r11191 r11194 82 82 virtual ~LevelManager(); 83 83 84 //void setLevelStatus(const int integer);85 84 void buildallLevelStatus(); 86 85 void updateAllLevelStatus(); … … 108 107 LevelInfoItem* getAvailableLevelListItem(unsigned int index); //!< Get the LevelInfoItem at the given index in the list of available Levels. 109 108 110 //void setLastFinishedCampaignMission(const std::string& lastFinishedCampaignMission);111 109 inline const std::string& getLastWonMission() const 112 110 { return this->lastWonMission_; } … … 148 146 std::string lastWonMission_; 149 147 std::vector<std::string> campaignMissions_; 150 std::vector<int> allLevelWon_; 151 std::vector<LevelStatus > allLevelStatus_;148 std::vector<int> allLevelWon_; //level i is won if allLevelWon_[i]=1 149 std::vector<LevelStatus*> allLevelStatus_; 152 150 153 151 -
code/branches/bindermFS16/src/orxonox/LevelStatus.cc
r11188 r11194 1 /* 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * > www.orxonox.net < 4 * 5 * 6 * License notice: 7 * 8 * This program is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU General Public License 10 * as published by the Free Software Foundation; either version 2 11 * of the License, or (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 * 22 * Author: 23 * Matthias Binder 24 * 25 */ 26 27 1 28 2 29 … … 20 47 RegisterClass(LevelStatus); 21 48 49 50 /** 51 @brief 52 Constructor. sets config values and initializes variables. 53 */ 22 54 LevelStatus::LevelStatus(Context* context) : BaseObject(context) 23 55 { … … 30 62 LevelStatus::~LevelStatus() 31 63 {} 32 33 34 64 } -
code/branches/bindermFS16/src/orxonox/LevelStatus.h
r11191 r11194 49 49 @brief 50 50 LevelStatus: 51 In the LevelStatus class all necessary information of f a mission in the campaign can besaved.52 It is only used in the LevelManager to s teer the campaign menu. It is now possible to have a treelike campaign menu structure.51 In the LevelStatus class all necessary information of a mission in the campaign is saved. 52 It is only used in the LevelManager to save the progress of the campaign. It is now possible to have a treelike campaign menu structure. 53 53 54 54 */
Note: See TracChangeset
for help on using the changeset viewer.