Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 12, 2016, 4:07:25 PM (8 years ago)
Author:
binderm
Message:

LevelStatus and levelmanager in two files, LevelStatus saves and changes the actual campaign progress

File:
1 edited

Legend:

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

    r11181 r11186  
    4747#include "PlayerManager.h"
    4848
     49
    4950namespace orxonox
    5051{
    5152
    52     LevelStatus::LevelStatus()
    53     {
    54         this->won = false;
    55         this->nextLevels.insert(this->nextLevels.begin(),1);
    56     }
    57 
    58     LevelStatus::~LevelStatus()
    59     {}
    60 
    61 
     53//Mission endmission true
    6254    //check if index level is activated...
    6355    int LevelManager::missionactivate(int index)
    6456    {
    65 
    66         if (allLevelStatus_[index].won)
    67             return 1;
    68 
    69         //check if level is activated
    70         for(unsigned int i=0;i<allLevelStatus_.size();i++)
    71         {
    72             std::vector<int> nextLevels=allLevelStatus_[i].nextLevels;
    73             bool won=allLevelStatus_[i].won;
    74             if(nextLevels[index]==1&&won)
    75                 return 1;
    76         };
    77 
    78         //check if level visible but not activated
    79         for(unsigned int i=0;i<allLevelStatus_.size();i++)
    80         {
    81             std::vector<int> nextLevels=allLevelStatus_[i].nextLevels;
    82             bool won=allLevelStatus_[i].won;
    83             if(nextLevels[index]==2&&won)
    84                 return 2;
    85         };
    86         return 0;
     57        updateAllLevelStatus();
     58        int activated = allLevelStatus_[index].activated;
     59        return activated;
     60    }
     61
     62    void LevelManager::updatewon(int lastwon)
     63    {
     64        allLevelStatus_[lastwon].won=true;
     65
     66    }
     67
     68    void LevelManager::updateAllLevelStatus()
     69    {
     70        for(unsigned int i =0;i<allLevelStatus_.size();i++)
     71        {
     72            if(allLevelStatus_[i].won)
     73            {
     74                allLevelStatus_[i].activated=1;
     75                std::vector<int> nextLevels=allLevelStatus_[i].nextLevels;
     76                for(unsigned int j=i+1;j<allLevelStatus_.size();j++)
     77                {
     78                    allLevelStatus_[j].activated=nextLevels[j];
     79                }
     80            }
     81        }
    8782    }
    8883
    8984    //updates the won variable of the corresponding LevelStatus in allLevelStatus_
    90     void LevelManager::setLevelStatus(const int completedLevel)
    91     {
    92         allLevelStatus_[completedLevel].won=true;   
    93     }
     85    void LevelManager::setLevelStatus(const std::string& LevelWon)
     86    {
     87        ModifyConfigValue(lastWonMission_, set, LevelWon); 
     88    }
     89
    9490
    9591    //build up allLevelStatus
     
    9995    {
    10096        LevelStatus level;
    101         allLevelStatus_.assign (10,level);
    102         allLevelStatus_[0].won=true;
    103 
    104        
    105         allLevelStatus_[1].nextLevels.push_back(2);
     97        allLevelStatus_.assign (campaignMissions_.size(),level);
     98        allLevelStatus_[0].activated=1;
     99        //allLevelStatus_[0].won=true;
     100
     101
     102        allLevelStatus_[0].nextLevels.push_back(1);
     103        allLevelStatus_[0].nextLevels.push_back(1);
     104        allLevelStatus_[0].nextLevels.push_back(0);
     105        allLevelStatus_[0].nextLevels.push_back(0);
     106        allLevelStatus_[0].nextLevels.push_back(0);
     107        allLevelStatus_[0].nextLevels.push_back(0);
     108        allLevelStatus_[0].nextLevels.push_back(0);
     109
     110        allLevelStatus_[1].nextLevels.push_back(1);
    106111        allLevelStatus_[1].nextLevels.push_back(2);
    107112        allLevelStatus_[1].nextLevels.push_back(1);
    108         allLevelStatus_[1].nextLevels.push_back(2);
     113        allLevelStatus_[1].nextLevels.push_back(0);
     114        allLevelStatus_[1].nextLevels.push_back(0);
     115        allLevelStatus_[1].nextLevels.push_back(0);
     116        allLevelStatus_[1].nextLevels.push_back(0);
     117
     118        allLevelStatus_[2].nextLevels.push_back(2);
     119        allLevelStatus_[2].nextLevels.push_back(1);
     120        allLevelStatus_[2].nextLevels.push_back(0);
     121        allLevelStatus_[2].nextLevels.push_back(0);
     122        allLevelStatus_[2].nextLevels.push_back(1);
     123        allLevelStatus_[2].nextLevels.push_back(0);
     124        allLevelStatus_[2].nextLevels.push_back(0);
     125
    109126
    110127
     
    159176        SetConfigValue(defaultLevelName_, "missionOne.oxw")
    160177            .description("Sets the pre selection of the level in the main menu.");
    161         SetConfigValue(lastFinishedCampaignMission_,  "")
     178        SetConfigValue(lastWonMission_,  "")
    162179            .description("The last finished mission of a campaign");
    163180        SetConfigValue(campaignMissions_,  std::vector<std::string>())
    164181            .description("The list of missions in the campaign");
     182        SetConfigValue(test_,  std::vector<int>())
     183            .description("The list of missions and their statuses");
     184           
    165185    }
    166186
     
    168188     * @brief Stores the argument in the corresponding config value.
    169189     */
    170     void LevelManager::setLastFinishedCampaignMission(const std::string& lastFinishedCampaignMission)
    171     {
    172         ModifyConfigValue(lastFinishedCampaignMission_, set, lastFinishedCampaignMission);
    173     }
    174 
     190/*    void LevelManager::setLastFinishedCampaignMission(const std::string& lastFinishedCampaignMission)
     191    {
     192        ModifyConfigValue(lastWonMission_, set, lastFinishedCampaignMission);
     193    }
     194*/
    175195
    176196
Note: See TracChangeset for help on using the changeset viewer.