1 /**
2  * @file handler_levels.h
3  * @brief manage levels data
4  * @created 2004-04-06
5  * @date 2012-09-08
6  * @copyright 1991-2014 TLK Games
7  * @author Bruno Ethvignot
8  * @version $Revision: 24 $
9  */
10 /*
11  * copyright (c) 1991-2014 TLK Games all rights reserved
12  * $Id: handler_levels.h 24 2014-09-28 15:30:04Z bruno.ethvignot@gmail.com $
13  *
14  * TecnoballZ is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 3 of the License, or
17  * (at your option) any later version.
18  *
19  * TecnoballZ is distributed in the hope that it will be useful, but
20  * WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program; if not, write to the Free Software
26  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
27  * MA  02110-1301, USA.
28  */
29 #ifndef __LEVEL_DATA__
30 #define __LEVEL_DATA__
31 
32 class handler_levels;
33 
34 #include "../include/tecnoballz.h"
35 #include <tinyxml.h>
36 #include <string.h>
37 
38 typedef struct
39   {
40     /* 0 = bricks level */
41     Uint32 level_type;
42     Uint32 id;
43     /** Delay time before first appearance of ship 1 and 5 */
44     Uint32 ship_appearance_delay1;
45     /** Delay time before first appearance of ship 2 and 6 */
46     Uint32 ship_appearance_delay2;
47     /** Delay time before first appearance of ship 3 and 7 */
48     Uint32 ship_appearance_delay3;
49     /** Delay time before first appearance of ship 4 and 8 */
50     Uint32 ship_appearance_delay4;
51     /** Delay time of the reappearance of any ship after its destruction */
52     Uint32 reappearance;
53     /** strength of the ships */
54     Uint32 ships_strength;
55     /** Appearance frequency of the penalty capsules */
56     Uint32 penalties_frequency;
57     /** Appearance frequency of the money capsules */
58     Uint32 moneys_frequency;
59     /** List of the capsules */
60     const Uint32 *malusListe;
61     /** First speed table */
62     Uint32 starting_speed;
63     /** Delay time before the ball accelerates */
64     Uint32 acceleration_delay;
65     /** Delay time before the ball leaves paddle, at the level beginning */
66     Uint32 ball_release_time;
67     /** Delay time before the ball leaves paddle with glue option */
68     Uint32 glue_time;
69     /** Delay time before tilt is available */
70     Uint32 tilt_delay;
71   }
72 bricks_level_desc;
73 
74 
75 typedef struct
76   {
77     /* 1 = guard level */
78     Uint32 level_type;
79     Uint32 id;
80     Uint32 starting_speed;
81     Uint32 ball_release_time;
82     Uint32 tilt_delay;
83     /** Delay time before the scrolling starts */
84     Uint32 scroll_delay;
85     /** Determines the behavior of the scrolling */
86     Uint32 scroll_id;
87     /** Appearance frequency of the capsules */
88     Uint32 capsules_frequency;
89     /** List of the capsules */
90     const Uint32 *capsules_list;
91   }
92 guardians_level_desc;
93 
94 typedef struct
95   {
96     Uint32 id;
97     Uint32 type;
98   }
99 level_desc;
100 
101 class handler_levels:public virtual tecnoballz
102   {
103 
104   public:
105     static const Uint32 MAX_OF_AREAS = 5;
106     static const Uint32 NUM_OF_LEVELS_PER_AREA = 12;
107     static const Uint32 TIME_MULTIPLIER = 50;
108     static const Uint32 MAX_OF_CASPULES = 64;
109     typedef struct
110       {
111         Uint32 id;
112         Uint32 codes[handler_levels::MAX_OF_CASPULES];
113       } capsules_struct;
114 
115   public:
116     handler_levels ();
117     ~handler_levels ();
118     const bricks_level_desc *get_bricks_levels_params (Uint32, Uint32);
119     const guardians_level_desc *get_guardians_levels_params (Uint32, Uint32);
120 
121   private:
122     typedef enum
123     {
124       BRICKS_LEVEL,
125       GUARDIANS_LEVEL,
126       MAX_OF_LEVEL_TYPES
127     }
128     LEVEL_TYPES;
129     typedef enum
130     {
131       ROOT,
132       LEVEL_NODE,
133       BRICKS_LEVEL_NODE,
134       CAPSULES_NODE,
135       GUARDIANS_LEVEL_NODE
136     }
137     NODES_ENUM;
138     void check_levels ();
139     void check_xml (TiXmlNode * parent, Uint32 node);
140     void parse (TiXmlNode * parent, Uint32 node);
141     Uint32 *get_capsules_list (Uint32 id);
142     guardians_level_desc *get_guardians_level (Uint32 id);
143     bricks_level_desc *get_bricks_level (Uint32 id);
144 
145   private:
146     Uint32 time_multiplier;
147     Uint32 levels_counter;
148     Uint32 bricks_levels_counter;
149     Uint32 guardians_levels_counter;
150     Uint32 capsules_lists_counter;
151     Uint32 capsules_counter;
152     Sint32 level_index;
153     Sint32 bricks_level_index;
154     Sint32 guardians_level_index;
155     Sint32 appearance_index;
156     Sint32 capsule_list_index;
157     Sint32 capsule_index;
158     std::string last_element;
159 
160   private:
161     TiXmlDocument * xml_levels;
162     guardians_level_desc *guardians_levels;
163     bricks_level_desc *bricks_levels;
164     capsules_struct *capsules_list;
165     level_desc *levels_list;
166   };
167 #endif
168