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 | * Fabien Vultier |
---|
24 | * Co-authors: |
---|
25 | * ... |
---|
26 | * |
---|
27 | */ |
---|
28 | |
---|
29 | #ifndef _JumpCenterpoint_H__ |
---|
30 | #define _JumpCenterpoint_H__ |
---|
31 | |
---|
32 | #include "jump/JumpPrereqs.h" |
---|
33 | |
---|
34 | #include <string> |
---|
35 | |
---|
36 | #include <util/Math.h> |
---|
37 | |
---|
38 | #include "worldentities/StaticEntity.h" |
---|
39 | |
---|
40 | namespace orxonox |
---|
41 | { |
---|
42 | |
---|
43 | /** |
---|
44 | @brief |
---|
45 | The JumpCenterpoint implements the playing field @ref orxonox::Jump "Jump" takes place in and allows for many parameters of the minigame to be set. |
---|
46 | 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. |
---|
47 | |
---|
48 | Various parameters can be set: |
---|
49 | - The <b>dimension</b> is a vector, that defines the width and height of the playing field. The default is <em>(200, 120)</em>. |
---|
50 | - 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. |
---|
51 | - 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. |
---|
52 | - The <b>ballspeed</b> is the speed with which the @ref orxonox::JumpPlatform "JumpPlatform" moves. The default is <em>100</em>. |
---|
53 | - The <b>ballaccfactor</b> is the acceleration factor for the @ref orxonox::JumpPlatform "JumpPlatform". The default is <em>1.0</em>. |
---|
54 | - The <b>batspeed</b> is the speed with which the @ref orxonox::JumpFigure "JumpFigures" move. The default is <em>60</em>. |
---|
55 | - 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>. |
---|
56 | |
---|
57 | An example in XML of the JumpCenterpoint would be: |
---|
58 | |
---|
59 | First the needed templates: |
---|
60 | The template for the @ref orxonox::JumpPlatform "JumpPlatform". |
---|
61 | @code |
---|
62 | <Template name="jumpball"> |
---|
63 | <JumpPlatform> |
---|
64 | <attached> |
---|
65 | <Model mesh="sphere.mesh" scale="2" /> |
---|
66 | <ParticleSpawner name="hiteffect" position="0,0,0" source="Orxonox/sparks2" lifetime="0.01" autostart="0" mainstate="spawn" /> |
---|
67 | </attached> |
---|
68 | <eventlisteners> |
---|
69 | <EventTarget target="hiteffect" /> |
---|
70 | </eventlisteners> |
---|
71 | </JumpPlatform> |
---|
72 | </Template> |
---|
73 | @endcode |
---|
74 | 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. |
---|
75 | |
---|
76 | Additionally the template for the @ref orxonox::JumpFigure "JumpFigure". |
---|
77 | @code |
---|
78 | <Template name="jumpbatcameras" defaults="0"> |
---|
79 | <JumpFigure> |
---|
80 | <camerapositions> |
---|
81 | <CameraPosition position="0,200,0" pitch="-90" absolute="true" /> |
---|
82 | </camerapositions> |
---|
83 | </JumpFigure> |
---|
84 | </Template> |
---|
85 | |
---|
86 | <Template name="jumpbat"> |
---|
87 | <JumpFigure camerapositiontemplate=jumpbatcameras> |
---|
88 | <attached> |
---|
89 | <Model position="0,0,3" mesh="cube.mesh" scale3D="14,2,2" /> |
---|
90 | </attached> |
---|
91 | </JumpFigure> |
---|
92 | </Template> |
---|
93 | @endcode |
---|
94 | 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. |
---|
95 | propellerTemplate_ |
---|
96 | Finally the JumpCenterpoint is created. |
---|
97 | @code |
---|
98 | <JumpCenterpoint name="jumpcenter" dimension="200,120" balltemplate="jumpball" battemplate="jumpbat" ballspeed="200" ballaccfactor="1.0" batspeed="130" batlength="0.25"> |
---|
99 | <attached> |
---|
100 | <Model position="0,0,60" mesh="cube.mesh" scale3D="105,1,1" /> |
---|
101 | <Model position="0,0,-60" mesh="cube.mesh" scale3D="105,1,1" /> |
---|
102 | </attached> |
---|
103 | </JumpCenterpoint> |
---|
104 | @endcode |
---|
105 | All parameters are specified. And also two @ref orxonox::Model "Models" (for the upper and lower boundary) are attached. |
---|
106 | |
---|
107 | For a more elaborate example, have a look at the <code>jump.oxw</code> level file. |
---|
108 | |
---|
109 | */ |
---|
110 | class _JumpExport JumpCenterpoint : public StaticEntity |
---|
111 | { |
---|
112 | public: |
---|
113 | JumpCenterpoint(Context* context); //!< Constructor. Registers and initializes the object and checks whether the gametype is actually Jump. |
---|
114 | virtual ~JumpCenterpoint() {} |
---|
115 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method to create a JumpCenterpoint through XML. |
---|
116 | virtual void changedGametype(); |
---|
117 | void setPlatformStaticTemplate(const std::string& balltemplate) |
---|
118 | { this->platformStaticTemplate_ = balltemplate; } |
---|
119 | const std::string& getPlatformStaticTemplate() const |
---|
120 | { return this->platformStaticTemplate_; } |
---|
121 | void setPlatformHMoveTemplate(const std::string& balltemplate) |
---|
122 | { this->platformHMoveTemplate_ = balltemplate; } |
---|
123 | const std::string& getPlatformHMoveTemplate() const |
---|
124 | { return this->platformHMoveTemplate_; } |
---|
125 | void setPlatformVMoveTemplate(const std::string& balltemplate) |
---|
126 | { this->platformVMoveTemplate_ = balltemplate; } |
---|
127 | const std::string& getPlatformVMoveTemplate() const |
---|
128 | { return this->platformVMoveTemplate_; } |
---|
129 | void setPlatformDisappearTemplate(const std::string& balltemplate) |
---|
130 | { this->platformDisappearTemplate_ = balltemplate; } |
---|
131 | const std::string& getPlatformDisappearTemplate() const |
---|
132 | { return this->platformDisappearTemplate_; } |
---|
133 | void setPlatformTimerTemplate(const std::string& balltemplate) |
---|
134 | { this->platformTimerTemplate_ = balltemplate; } |
---|
135 | const std::string& getPlatformTimerTemplate() const |
---|
136 | { return this->platformTimerTemplate_; } |
---|
137 | void setPlatformFakeTemplate(const std::string& balltemplate) |
---|
138 | { this->platformFakeTemplate_ = balltemplate; } |
---|
139 | const std::string& getPlatformFakeTemplate() const |
---|
140 | { return this->platformFakeTemplate_; } |
---|
141 | void setProjectileTemplate(const std::string& newTemplate) |
---|
142 | { this->projectileTemplate_ = newTemplate; } |
---|
143 | const std::string& getProjectileTemplate() const |
---|
144 | { return this->projectileTemplate_; } |
---|
145 | void setSpringTemplate(const std::string& newTemplate) |
---|
146 | { this->springTemplate_ = newTemplate; } |
---|
147 | const std::string& getSpringTemplate() const |
---|
148 | { return this->springTemplate_; } |
---|
149 | void setRocketTemplate(const std::string& newTemplate) |
---|
150 | { this->rocketTemplate_ = newTemplate; } |
---|
151 | const std::string& getRocketTemplate() const |
---|
152 | { return this->rocketTemplate_; } |
---|
153 | void setPropellerTemplate(const std::string& newTemplate) |
---|
154 | { this->propellerTemplate_ = newTemplate; } |
---|
155 | const std::string& getPropellerTemplate() const |
---|
156 | { return this->propellerTemplate_; } |
---|
157 | void setBootsTemplate(const std::string& newTemplate) |
---|
158 | { this->bootsTemplate_ = newTemplate; } |
---|
159 | const std::string& getBootsTemplate() const |
---|
160 | { return this->bootsTemplate_; } |
---|
161 | void setShieldTemplate(const std::string& newTemplate) |
---|
162 | { this->shieldTemplate_ = newTemplate; } |
---|
163 | const std::string& getShieldTemplate() const |
---|
164 | { return this->shieldTemplate_; } |
---|
165 | void setFigureTemplate(const std::string& newTemplate) |
---|
166 | { this->figureTemplate_ = newTemplate; } |
---|
167 | const std::string& getFigureTemplate() const |
---|
168 | { return this->figureTemplate_; } |
---|
169 | void setEnemy1Template(const std::string& newTemplate) |
---|
170 | { this->enemy1Template_ = newTemplate; } |
---|
171 | const std::string& getEnemy1Template() const |
---|
172 | { return this->enemy1Template_; } |
---|
173 | void setEnemy2Template(const std::string& newTemplate) |
---|
174 | { this->enemy2Template_ = newTemplate; } |
---|
175 | const std::string& getEnemy2Template() const |
---|
176 | { return this->enemy2Template_; } |
---|
177 | void setEnemy3Template(const std::string& newTemplate) |
---|
178 | { this->enemy3Template_ = newTemplate; } |
---|
179 | const std::string& getEnemy3Template() const |
---|
180 | { return this->enemy3Template_; } |
---|
181 | void setEnemy4Template(const std::string& newTemplate) |
---|
182 | { this->enemy4Template_ = newTemplate; } |
---|
183 | const std::string& getEnemy4Template() const |
---|
184 | { return this->enemy4Template_; } |
---|
185 | void setFieldDimension(const Vector2& dimension) |
---|
186 | { this->width_ = dimension.x; this->height_ = dimension.y; } |
---|
187 | Vector2 getFieldDimension() const |
---|
188 | { return Vector2(this->width_, this->height_); } |
---|
189 | void setSectionLength(const float sectionLength) |
---|
190 | { this->sectionLength_ = sectionLength; } |
---|
191 | float getSectionLength() const |
---|
192 | { return sectionLength_; } |
---|
193 | void setPlatformSpeed(const float platformSpeed) |
---|
194 | { this->platformSpeed_ = platformSpeed; } |
---|
195 | float getPlatformSpeed() const |
---|
196 | { return platformSpeed_; } |
---|
197 | void setCameraOffset(const float cameraOffset) |
---|
198 | { this->cameraOffset_ = cameraOffset; } |
---|
199 | float getCameraOffset() const |
---|
200 | { return cameraOffset_; } |
---|
201 | private: |
---|
202 | void checkGametype(); |
---|
203 | std::string platformStaticTemplate_; |
---|
204 | std::string platformHMoveTemplate_; |
---|
205 | std::string platformVMoveTemplate_; |
---|
206 | std::string platformDisappearTemplate_; |
---|
207 | std::string platformTimerTemplate_; |
---|
208 | std::string platformFakeTemplate_; |
---|
209 | std::string projectileTemplate_; |
---|
210 | std::string springTemplate_; |
---|
211 | std::string rocketTemplate_; |
---|
212 | std::string propellerTemplate_; |
---|
213 | std::string bootsTemplate_; |
---|
214 | std::string shieldTemplate_; |
---|
215 | std::string figureTemplate_; |
---|
216 | std::string enemy1Template_; |
---|
217 | std::string enemy2Template_; |
---|
218 | std::string enemy3Template_; |
---|
219 | std::string enemy4Template_; |
---|
220 | float width_; |
---|
221 | float height_; |
---|
222 | float sectionLength_; |
---|
223 | float platformSpeed_; |
---|
224 | float cameraOffset_; |
---|
225 | }; |
---|
226 | } |
---|
227 | |
---|
228 | #endif /* _JumpCenterpoint_H__ */ |
---|