Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/pickupsFS14/src/modules/jump/JumpCenterpoint.h @ 10074

Last change on this file since 10074 was 10074, checked in by fvultier, 10 years ago

new items added. improved level generator.

File size: 13.5 KB
Line 
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/**
30    @file JumpCenterpoint.h
31    @brief Declaration of the JumpCenterpoint class.
32    @ingroup Jump
33*/
34
35#ifndef _JumpCenterpoint_H__
36#define _JumpCenterpoint_H__
37
38#include "jump/JumpPrereqs.h"
39
40#include <string>
41
42#include <util/Math.h>
43
44#include "worldentities/StaticEntity.h"
45
46namespace orxonox
47{
48   
49    /**
50    @brief
51        The JumpCenterpoint implements the playing field @ref orxonox::Jump "Jump" takes place in and allows for many parameters of the minigame to be set.
52        The playing field resides in the x,z-plane, with the x-axis being the horizontal axis and the z-axis being the vertical axis.
53       
54        Various parameters can be set:
55        - The <b>dimension</b> is a vector, that defines the width and height of the playing field. The default is <em>(200, 120)</em>.
56        - The <b>balltemplate</b> is a template that is applied to the @ref orxonox::JumpPlatform "JumpPlatform", it can be used to attach different things to it, e.g. its @ref orxonox::Model "Model". See below for a usage example.
57        - The <b>battemplate</b> is a template that is applied to the @ref orxonox::JumpPlatform "JumpFigure", it can be used to attach different things to it, e.g. its @ref orxonox::Model "Model". See below for a usage example.
58        - The <b>ballspeed</b> is the speed with which the @ref orxonox::JumpPlatform "JumpPlatform" moves. The default is <em>100</em>.
59        - The <b>ballaccfactor</b> is the acceleration factor for the @ref orxonox::JumpPlatform "JumpPlatform". The default is <em>1.0</em>.
60        - The <b>batspeed</b> is the speed with which the @ref orxonox::JumpFigure "JumpFigures" move. The default is <em>60</em>.
61        - The <b>batlength</b> is the length of the @ref orxonox::JumpFigure "JumpFigures" as the percentage of the height of the playing field. The default is <em>0.25</em>.
62       
63        An example in XML of the JumpCenterpoint would be:
64       
65        First the needed templates:
66        The template for the @ref orxonox::JumpPlatform "JumpPlatform".
67        @code
68        <Template name="jumpball">
69          <JumpPlatform>
70            <attached>
71              <Model mesh="sphere.mesh" scale="2" />
72              <ParticleSpawner name="hiteffect" position="0,0,0" source="Orxonox/sparks2" lifetime="0.01" autostart="0" mainstate="spawn" />
73            </attached>
74            <eventlisteners>
75              <EventTarget target="hiteffect" />
76            </eventlisteners>
77          </JumpPlatform>
78        </Template>
79        @endcode
80        As can be seen, a sphere is attached as the @ref orxonox::Model "Model" for the @ref orxonox::JumpPlatform "JumpPlatform", and also an @ref orxonox::EventListener "EventListener" that triggers a @ref orxonox::ParticleSpawner "ParticleSpawner", whenever the ball hits the boundaries is attached.
81       
82        Additionally the template for the @ref orxonox::JumpFigure "JumpFigure".
83        @code
84        <Template name="jumpbatcameras" defaults="0">
85          <JumpFigure>
86            <camerapositions>
87              <CameraPosition position="0,200,0" pitch="-90" absolute="true" />
88            </camerapositions>
89          </JumpFigure>
90        </Template>
91
92        <Template name="jumpbat">
93          <JumpFigure camerapositiontemplate=jumpbatcameras>
94            <attached>
95              <Model position="0,0,3" mesh="cube.mesh" scale3D="14,2,2" />
96            </attached>
97          </JumpFigure>
98        </Template>
99        @endcode
100        As can be seen, there are actually two templates. The first template is needed to set the camera for the @ref orxonox::JumpFigure "JumpFigure". The second template ist the actual template for the @ref orxonox::JumpFigure "JumpFigure", the template for the camera position is added and a @ref orxonox::Model "Model" for the @ref orxonox::JumpFigure "JumpFigure" is attached.
101        propellerTemplate_
102        Finally the JumpCenterpoint is created.
103        @code
104        <JumpCenterpoint name="jumpcenter" dimension="200,120" balltemplate="jumpball" battemplate="jumpbat" ballspeed="200" ballaccfactor="1.0" batspeed="130" batlength="0.25">
105          <attached>
106            <Model position="0,0,60" mesh="cube.mesh" scale3D="105,1,1" />
107            <Model position="0,0,-60" mesh="cube.mesh" scale3D="105,1,1" />
108          </attached>
109        </JumpCenterpoint>
110        @endcode
111        All parameters are specified. And also two @ref orxonox::Model "Models" (for the upper and lower boundary) are attached.
112       
113        For a more elaborate example, have a look at the <code>jump.oxw</code> level file.
114   
115    @author
116        Fabian 'x3n' Landau
117       
118    @ingroup Jump
119    */
120    class _JumpExport JumpCenterpoint : public StaticEntity
121    {
122        public:
123            JumpCenterpoint(Context* context); //!< Constructor. Registers and initializes the object and checks whether the gametype is actually Jump.
124            virtual ~JumpCenterpoint() {}
125
126            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method to create a JumpCenterpoint through XML.
127
128            virtual void changedGametype(); //!< Is called when the gametype has changed.
129
130
131            void setPlatformStaticTemplate(const std::string& balltemplate)
132                { this->platformStaticTemplate_ = balltemplate; }
133
134            const std::string& getPlatformStaticTemplate() const
135                { return this->platformStaticTemplate_; }
136
137            void setPlatformHMoveTemplate(const std::string& balltemplate)
138                { this->platformHMoveTemplate_ = balltemplate; }
139
140            const std::string& getPlatformHMoveTemplate() const
141                { return this->platformHMoveTemplate_; }
142
143            void setPlatformVMoveTemplate(const std::string& balltemplate)
144                { this->platformVMoveTemplate_ = balltemplate; }
145
146            const std::string& getPlatformVMoveTemplate() const
147                { return this->platformVMoveTemplate_; }
148
149            void setPlatformDisappearTemplate(const std::string& balltemplate)
150                { this->platformDisappearTemplate_ = balltemplate; }
151
152            const std::string& getPlatformDisappearTemplate() const
153                { return this->platformDisappearTemplate_; }
154
155            void setPlatformTimerTemplate(const std::string& balltemplate)
156                { this->platformTimerTemplate_ = balltemplate; }
157
158            const std::string& getPlatformTimerTemplate() const
159                { return this->platformTimerTemplate_; }
160
161            void setPlatformFakeTemplate(const std::string& balltemplate)
162                { this->platformFakeTemplate_ = balltemplate; }
163
164            const std::string& getPlatformFakeTemplate() const
165                { return this->platformFakeTemplate_; }
166
167            void setProjectileTemplate(const std::string& newTemplate)
168                { this->projectileTemplate_ = newTemplate; }
169
170            const std::string& getProjectileTemplate() const
171                { return this->projectileTemplate_; }
172
173            void setSpringTemplate(const std::string& newTemplate)
174                { this->springTemplate_ = newTemplate; }
175
176            const std::string& getSpringTemplate() const
177                { return this->springTemplate_; }
178
179            void setRocketTemplate(const std::string& newTemplate)
180                { this->rocketTemplate_ = newTemplate; }
181
182            const std::string& getRocketTemplate() const
183                { return this->rocketTemplate_; }
184
185            void setPropellerTemplate(const std::string& newTemplate)
186                { this->propellerTemplate_ = newTemplate; }
187
188            const std::string& getPropellerTemplate() const
189                { return this->propellerTemplate_; }
190
191            void setBootsTemplate(const std::string& newTemplate)
192                { this->bootsTemplate_ = newTemplate; }
193
194            const std::string& getBootsTemplate() const
195                { return this->bootsTemplate_; }
196
197            void setShieldTemplate(const std::string& newTemplate)
198                { this->shieldTemplate_ = newTemplate; }
199
200            const std::string& getShieldTemplate() const
201                { return this->shieldTemplate_; }
202
203            void setFigureTemplate(const std::string& newTemplate)
204                { this->figureTemplate_ = newTemplate; }
205
206            const std::string& getFigureTemplate() const
207                { return this->figureTemplate_; }
208
209            void setEnemy1Template(const std::string& newTemplate)
210                { this->enemy1Template_ = newTemplate; }
211
212            const std::string& getEnemy1Template() const
213                { return this->enemy1Template_; }
214
215            void setEnemy2Template(const std::string& newTemplate)
216                { this->enemy2Template_ = newTemplate; }
217
218            const std::string& getEnemy2Template() const
219                { return this->enemy2Template_; }
220
221            void setEnemy3Template(const std::string& newTemplate)
222                { this->enemy3Template_ = newTemplate; }
223
224            const std::string& getEnemy3Template() const
225                { return this->enemy3Template_; }
226
227            void setEnemy4Template(const std::string& newTemplate)
228                { this->enemy4Template_ = newTemplate; }
229
230            const std::string& getEnemy4Template() const
231                { return this->enemy4Template_; }
232
233
234            /**
235            @brief Set the dimensions of the playing field.
236            @param dimension A vector with the width of the playing field as first component and the height as second.
237            */
238            void setFieldDimension(const Vector2& dimension)
239                { this->width_ = dimension.x; this->height_ = dimension.y; }
240            /**
241            @brief Get the dimensions of the playing field.
242            @return Returns a vector with the width of the playing field as first component and the height as second.
243            */
244            Vector2 getFieldDimension() const
245                { return Vector2(this->width_, this->height_); }
246
247            /**
248            @brief Set the dimensions of the playing field.
249            @param dimension A vector with the width of the playing field as first component and the height as second.
250            */
251            void setSectionLength(const float sectionLength)
252                { this->sectionLength_ = sectionLength; }
253            /**
254            @brief Get the dimensions of the playing field.
255            @return Returns a vector with the width of the playing field as first component and the height as second.
256            */
257            float getSectionLength() const
258                { return sectionLength_; }
259
260            void setPlatformSpeed(const float platformSpeed)
261                { this->platformSpeed_ = platformSpeed; }
262
263            float getPlatformSpeed() const
264                { return platformSpeed_; }
265
266            void setCameraOffset(const float cameraOffset)
267                { this->cameraOffset_ = cameraOffset; }
268
269            float getCameraOffset() const
270                { return cameraOffset_; }
271
272
273        private:
274            void checkGametype(); //!< Checks whether the gametype is Jump and if it is, sets its centerpoint.
275
276            std::string platformStaticTemplate_; //!< The template for the ball.
277            std::string platformHMoveTemplate_; //!< The template for the ball.
278            std::string platformVMoveTemplate_; //!< The template for the ball.
279            std::string platformDisappearTemplate_; //!< The template for the ball.
280            std::string platformTimerTemplate_; //!< The template for the ball.
281            std::string platformFakeTemplate_; //!< The template for the ball.
282            std::string projectileTemplate_; //!< The template for the ball.
283            std::string springTemplate_; //!< The template for the ball.
284            std::string rocketTemplate_; //!< The template for the ball.
285            std::string propellerTemplate_; //!< The template for the ball.
286            std::string bootsTemplate_; //!< The template for the ball.
287            std::string shieldTemplate_; //!< The template for the ball.
288            std::string figureTemplate_; //!< The template for the bats.
289            std::string enemy1Template_; //!< The template for the bats.
290            std::string enemy2Template_; //!< The template for the bats.
291            std::string enemy3Template_; //!< The template for the bats.
292            std::string enemy4Template_; //!< The template for the bats.
293
294            float width_; //!< The height of the playing field.
295            float height_; //!< The width of the playing field.
296            float sectionLength_; //!< Height of one section
297            float platformSpeed_; //!< Height of one section
298            float cameraOffset_; //!< Height of one section
299    };
300}
301
302#endif /* _JumpCenterpoint_H__ */
Note: See TracBrowser for help on using the repository browser.