1 #pragma once
2 // Description:
3 //   Stage manager controls movement from levelpack to levelpack and
4 //   level to level.
5 //
6 // Copyright (C) 2001 Frank Becker
7 //
8 // This program is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU General Public License as published by the Free Software
10 // Foundation;  either version 2 of the License,  or (at your option) any  later
11 // version.
12 //
13 // This program is distributed in the hope that it will be useful,  but  WITHOUT
14 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details
16 //
17 
18 #include <Singleton.hpp>
19 #include <GameState.hpp>
20 #include <LevelPack.hpp>
21 
22 #include <tinyxml.h>
23 
24 #include <string>
25 #include <vector>
26 
27 class StageManager
28 {
29 friend class Singleton<StageManager>;
30 public:
31     bool init( void);
32     void reset( void);
33     void update( void);
34 
levelStartTime(void)35     float levelStartTime( void)
36     {
37         return _levelStartTime;
38     }
39 
getActiveLevelName(void)40     const std::string &getActiveLevelName( void)
41     {
42 	return _activeLevelName;
43     }
44 
45 private:
StageManager(void)46     StageManager( void):
47         _activeLevelPack(0),
48 	_activeLevel(0),
49         _delayEndOfLevel(30)
50     {
51     }
~StageManager()52     ~StageManager()
53     {
54 	delete _activeLevelPack;
55 	_activeLevelPack = 0;
56 	_activeLevel = 0;
57     }
58 
59     StageManager( const StageManager&);
60     StageManager &operator=(const StageManager&);
61 
62     TiXmlDocument *_activeLevelPack;
63     TiXmlNode *_activeLevel;
64     int _delayEndOfLevel;
65     float _levelStartTime;
66     std::string _activeLevelName;
67 
68     list<std::string> _levelPackList;
69     list<std::string>::iterator _levelPackIterator;
70     std::vector<TiXmlNode*> _levelList;
71     unsigned int _activeLevelIndex;
72 
73     bool findLevelPacks( void);
74     bool loadNextLevelPack( void);
75     bool activateLevel( void);
76 };
77 
78 typedef Singleton<StageManager> StageManagerS;
79