Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 19, 2016, 5:37:05 PM (9 years ago)
Author:
binderm
Message:

The Campaign menu now works. The levels are structured in a tree. If one goes the left branch, the right one can't be taken anymore. The last challenge is to save the progress in the config variables. to set does work, but not to modify those variables.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/bindermFS16/src/orxonox/LevelManager.cc

    r11188 r11191  
    9999    void LevelManager::setConfigValues()
    100100    {
     101
    101102        SetConfigValue(defaultLevelName_, "missionOne.oxw")
    102103            .description("Sets the pre selection of the level in the main menu.");
     
    105106        SetConfigValue(campaignMissions_,  std::vector<std::string>())
    106107            .description("The list of missions in the campaign");
    107         //SetConfigValue(test_,  std::vector<int>())
    108          //   .description("The list of missions and their statuses");
    109            
     108        //std::vector<int> v (allLevelStatus_.size(),0);
     109        //SetConfigValue(allLevelWon_, v)
     110        //    .description("The list of all won missions");
    110111    }
    111112
     
    185186    void LevelManager::activateNextLevel()
    186187    {
     188
    187189        if (this->levels_.size() > 0)
    188190        {
     
    358360                allLevelStatus_[i].activated=1;
    359361                std::vector<int> nextLevels=allLevelStatus_[i].nextLevels;
    360                 for(unsigned int j=i+1;j<allLevelStatus_.size();j++)
     362                for(unsigned int j=0;j<allLevelStatus_.size();j++)
    361363                {
    362364                    allLevelStatus_[j].activated=nextLevels[j];
     
    366368    }
    367369
    368     //updates the won variable of the corresponding LevelStatus in allLevelStatus_
     370
    369371    void LevelManager::setLevelStatus(const std::string& LevelWon)
    370372    {
    371         ModifyConfigValue(lastWonMission_, set, LevelWon); 
    372     }
    373 
    374 
    375     //build up allLevelStatus
     373       
     374           
     375        ModifyConfigValue(lastWonMission_, set, LevelWon);
     376
     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_
    376396    //has to be done once per game (not per level)
    377     //all connections between the levels are saved in here
     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
    378399    void LevelManager::buildallLevelStatus()
    379400    {
    380         LevelStatus* level = new LevelStatus(this->getContext());
    381 
    382         /*LevelStatus level;
    383         allLevelStatus_.assign (campaignMissions_.size(),level);
     401        LevelStatus* level=new LevelStatus(this->getContext());
     402        allLevelStatus_.assign (campaignMissions_.size(),*level);
    384403        allLevelStatus_[0].activated=1;
    385         //allLevelStatus_[0].won=true;
    386 
    387 
    388         allLevelStatus_[0].nextLevels.push_back(1);
    389         allLevelStatus_[0].nextLevels.push_back(1);
    390         allLevelStatus_[0].nextLevels.push_back(0);
    391         allLevelStatus_[0].nextLevels.push_back(0);
    392         allLevelStatus_[0].nextLevels.push_back(0);
    393         allLevelStatus_[0].nextLevels.push_back(0);
    394         allLevelStatus_[0].nextLevels.push_back(0);
    395 
    396         allLevelStatus_[1].nextLevels.push_back(1);
    397         allLevelStatus_[1].nextLevels.push_back(2);
    398         allLevelStatus_[1].nextLevels.push_back(1);
    399         allLevelStatus_[1].nextLevels.push_back(0);
    400         allLevelStatus_[1].nextLevels.push_back(0);
    401         allLevelStatus_[1].nextLevels.push_back(0);
    402         allLevelStatus_[1].nextLevels.push_back(0);
    403 
    404         allLevelStatus_[2].nextLevels.push_back(2);
    405         allLevelStatus_[2].nextLevels.push_back(1);
    406         allLevelStatus_[2].nextLevels.push_back(0);
    407         allLevelStatus_[2].nextLevels.push_back(0);
    408         allLevelStatus_[2].nextLevels.push_back(1);
    409         allLevelStatus_[2].nextLevels.push_back(0);
    410         allLevelStatus_[2].nextLevels.push_back(0);*/
    411 
    412 
     404
     405
     406        std::vector<int> v={1,1,1,0,0,0,0,0,0};
     407        allLevelStatus_[0].nextLevels=v;
     408
     409        v={1,1,2,1,0,0,0,0,0};
     410        allLevelStatus_[1].nextLevels=v;
     411
     412        v={1,2,1,0,1,0,0,0,0};
     413        allLevelStatus_[2].nextLevels=v;
     414
     415        v={1,1,2,1,0,1,1,0,0};
     416        allLevelStatus_[3].nextLevels=v;
     417
     418        v={1,2,1,0,1,0,0,1,1};
     419        allLevelStatus_[4].nextLevels=v;
     420
     421        v={1,1,2,1,0,1,2,0,0};
     422        allLevelStatus_[5].nextLevels=v;
     423
     424        v={1,1,2,1,0,2,1,0,0};
     425        allLevelStatus_[6].nextLevels=v;
     426
     427        v={1,2,1,0,1,0,0,1,2};
     428        allLevelStatus_[7].nextLevels=v;
     429
     430        v={1,2,1,0,1,0,0,2,1};
     431        allLevelStatus_[8].nextLevels=v;
    413432
    414433    }
Note: See TracChangeset for help on using the changeset viewer.