Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 26, 2016, 2:40:16 PM (8 years ago)
Author:
binderm
Message:

final commit

File:
1 edited

Legend:

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

    r11191 r11194  
    2424 *   Co-authors:
    2525 *      Damian 'Mozork' Frick
     26 *      Matthias Binder
    2627 *
    2728 */
     
    9192        for (LevelInfoItem* info : availableLevels_)
    9293            info->destroy();
     94        for(unsigned int i = 0; i<allLevelStatus_.size();++i)
     95        {
     96            allLevelStatus_[i]->destroy();
     97        }
    9398    }
    9499
     
    106111        SetConfigValue(campaignMissions_,  std::vector<std::string>())
    107112            .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    }
    121114
    122115
     
    337330
    338331
    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    */
    341337    int LevelManager::missionactivate(int index)
    342338    {
    343339        updateAllLevelStatus();
    344         int activated = allLevelStatus_[index].activated;
     340        int activated = allLevelStatus_[index]->activated;
    345341        return activated;
    346342    }
     343    /**
     344    @brief
     345        update the last won mission to won=true
     346    */
    347347
    348348    void LevelManager::updatewon(int lastwon)
    349349    {
    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    */
    353361
    354362    void LevelManager::updateAllLevelStatus()
     
    356364        for(unsigned int i =0;i<allLevelStatus_.size();i++)
    357365        {
    358             if(allLevelStatus_[i].won)
     366            if(allLevelStatus_[i]->won)
    359367            {
    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;
    362370                for(unsigned int j=0;j<allLevelStatus_.size();j++)
    363371                {
    364                     allLevelStatus_[j].activated=nextLevels[j];
     372                    allLevelStatus_[j]->activated=nextLevels[j];
    365373                }
    366374            }
     
    368376    }
    369377
     378    /**
     379    @brief
     380        the name of the last won mission is saved in the config file
     381    */
    370382
    371383    void LevelManager::setLevelStatus(const std::string& LevelWon)
     
    375387        ModifyConfigValue(lastWonMission_, set, LevelWon);
    376388
    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    */
    399402    void LevelManager::buildallLevelStatus()
    400403    {
    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;
    404415
    405416
    406417        std::vector<int> v={1,1,1,0,0,0,0,0,0};
    407         allLevelStatus_[0].nextLevels=v;
     418        allLevelStatus_[0]->nextLevels=v;
    408419
    409420        v={1,1,2,1,0,0,0,0,0};
    410         allLevelStatus_[1].nextLevels=v;
     421        allLevelStatus_[1]->nextLevels=v;
    411422
    412423        v={1,2,1,0,1,0,0,0,0};
    413         allLevelStatus_[2].nextLevels=v;
     424        allLevelStatus_[2]->nextLevels=v;
    414425
    415426        v={1,1,2,1,0,1,1,0,0};
    416         allLevelStatus_[3].nextLevels=v;
     427        allLevelStatus_[3]->nextLevels=v;
    417428
    418429        v={1,2,1,0,1,0,0,1,1};
    419         allLevelStatus_[4].nextLevels=v;
     430        allLevelStatus_[4]->nextLevels=v;
    420431
    421432        v={1,1,2,1,0,1,2,0,0};
    422         allLevelStatus_[5].nextLevels=v;
     433        allLevelStatus_[5]->nextLevels=v;
    423434
    424435        v={1,1,2,1,0,2,1,0,0};
    425         allLevelStatus_[6].nextLevels=v;
     436        allLevelStatus_[6]->nextLevels=v;
    426437
    427438        v={1,2,1,0,1,0,0,1,2};
    428         allLevelStatus_[7].nextLevels=v;
     439        allLevelStatus_[7]->nextLevels=v;
    429440
    430441        v={1,2,1,0,1,0,0,2,1};
    431         allLevelStatus_[8].nextLevels=v;
     442        allLevelStatus_[8]->nextLevels=v;
    432443
    433444    }
Note: See TracChangeset for help on using the changeset viewer.