Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

final commit

Location:
code/branches/bindermFS16/src/orxonox
Files:
4 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    }
  • code/branches/bindermFS16/src/orxonox/LevelManager.h

    r11191 r11194  
    8282            virtual ~LevelManager();
    8383
    84             //void setLevelStatus(const int integer);
    8584            void buildallLevelStatus();
    8685            void updateAllLevelStatus();
     
    108107            LevelInfoItem* getAvailableLevelListItem(unsigned int index); //!< Get the LevelInfoItem at the given index in the list of available Levels.
    109108
    110             //void setLastFinishedCampaignMission(const std::string& lastFinishedCampaignMission);
    111109            inline const std::string& getLastWonMission() const
    112110                { return this->lastWonMission_; }
     
    148146            std::string lastWonMission_;
    149147            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_;
    152150
    153151
  • 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
    128
    229
     
    2047    RegisterClass(LevelStatus);
    2148
     49
     50    /**
     51    @brief
     52        Constructor. sets config values and initializes variables.
     53    */
    2254    LevelStatus::LevelStatus(Context* context) : BaseObject(context)
    2355    {
     
    3062    LevelStatus::~LevelStatus()
    3163    {}
    32 
    33 
    3464}
  • code/branches/bindermFS16/src/orxonox/LevelStatus.h

    r11191 r11194  
    4949    @brief
    5050        LevelStatus:
    51         In the LevelStatus class all necessary information off a mission in the campaign can be saved.
    52         It is only used in the LevelManager to steer 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.
    5353       
    5454    */
Note: See TracChangeset for help on using the changeset viewer.