Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/LevelManager.cc @ 3132

Last change on this file since 3132 was 3110, checked in by rgrieder, 15 years ago

Removed old msvc specific support for precompiled header files.

  • Property svn:eol-style set to native
File size: 2.7 KB
RevLine 
[2072]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 *      Fabian 'x3n' Landau
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#include "LevelManager.h"
30
[2171]31#include "PlayerManager.h"
32#include "objects/Level.h"
[2072]33#include "objects/infos/HumanPlayer.h"
34
35namespace orxonox
36{
37    LevelManager* LevelManager::singletonRef_s = 0;
38
39    LevelManager::LevelManager()
40    {
41        assert(singletonRef_s == 0);
42        singletonRef_s = this;
43    }
44
45    LevelManager::~LevelManager()
46    {
47        assert(singletonRef_s != 0);
48        singletonRef_s = 0;
49    }
50
51    void LevelManager::requestActivity(Level* level)
52    {
53        this->levels_s.push_back(level);
54        if (this->levels_s.size() == 1)
55            this->activateNextLevel();
56    }
57
58    void LevelManager::releaseActivity(Level* level)
59    {
60        if (this->levels_s.size() > 0)
61        {
62            if (this->levels_s.front() == level)
63            {
64                level->setActive(false);
65                this->levels_s.pop_front();
66                this->activateNextLevel();
67            }
68            else
69            {
70                for (std::list<Level*>::iterator it = this->levels_s.begin(); it != this->levels_s.end(); ++it)
71                    if ((*it) == level)
72                        this->levels_s.erase(it);
73            }
74        }
75    }
76
77    Level* LevelManager::getActiveLevel()
78    {
79        if (this->levels_s.size() > 0)
80            return this->levels_s.front();
81        else
82            return 0;
83    }
84
85    void LevelManager::activateNextLevel()
86    {
87        if (this->levels_s.size() > 0)
88        {
89            this->levels_s.front()->setActive(true);
[2171]90            for (std::map<unsigned int, PlayerInfo*>::const_iterator it = PlayerManager::getInstance().getClients().begin(); it != PlayerManager::getInstance().getClients().end(); ++it)
[2072]91                this->levels_s.front()->playerEntered(it->second);
92        }
93    }
94}
Note: See TracBrowser for help on using the repository browser.