Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/pickupsFS14/src/modules/jump/JumpCenterpoint.cc @ 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: 5.0 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.cc
31    @brief Implementation of the JumpCenterpoint class.
32*/
33
34#include "JumpCenterpoint.h"
35
36#include "core/CoreIncludes.h"
37#include "core/XMLPort.h"
38
39#include "Jump.h"
40
41namespace orxonox
42{
43    RegisterClass(JumpCenterpoint);
44
45    /**
46    @brief
47        Constructor. Registers and initializes the object and checks whether the gametype is actually Jump.
48    */
49    JumpCenterpoint::JumpCenterpoint(Context* context) : StaticEntity(context)
50    {
51        RegisterObject(JumpCenterpoint);
52
53        // Variablen hier veraendern nuetzt nichts! Diese Variablen koennen in Level-File initialisiert werden.
54        width_ = 200;
55        height_ = 120;
56        sectionLength_ = 120;
57        platformSpeed_ = 20.0;
58
59        checkGametype();
60    }
61
62    /**
63    @brief
64        Method to create a JumpCenterpoint through XML.
65    */
66    void JumpCenterpoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
67    {
68        SUPER(JumpCenterpoint, XMLPort, xmlelement, mode);
69
70        XMLPortParam(JumpCenterpoint, "dimension", setFieldDimension, getFieldDimension, xmlelement, mode);
71        XMLPortParam(JumpCenterpoint, "sectionLength", setSectionLength, getSectionLength, xmlelement, mode);
72        XMLPortParam(JumpCenterpoint, "platformSpeed", setPlatformSpeed, getPlatformSpeed, xmlelement, mode);
73        XMLPortParam(JumpCenterpoint, "cameraOffset", setCameraOffset, getCameraOffset, xmlelement, mode);
74        XMLPortParam(JumpCenterpoint, "platformStaticTemplate", setPlatformStaticTemplate, getPlatformStaticTemplate, xmlelement, mode);
75        XMLPortParam(JumpCenterpoint, "platformHMoveTemplate", setPlatformHMoveTemplate, getPlatformHMoveTemplate, xmlelement, mode);
76        XMLPortParam(JumpCenterpoint, "platformVMoveTemplate", setPlatformVMoveTemplate, getPlatformVMoveTemplate, xmlelement, mode);
77        XMLPortParam(JumpCenterpoint, "platformDisappearTemplate", setPlatformDisappearTemplate, getPlatformDisappearTemplate, xmlelement, mode);
78        XMLPortParam(JumpCenterpoint, "platformTimerTemplate", setPlatformTimerTemplate, getPlatformTimerTemplate, xmlelement, mode);
79        XMLPortParam(JumpCenterpoint, "platformFakeTemplate", setPlatformFakeTemplate, getPlatformFakeTemplate, xmlelement, mode);
80        XMLPortParam(JumpCenterpoint, "figureTemplate", setFigureTemplate, getFigureTemplate, xmlelement, mode);
81        XMLPortParam(JumpCenterpoint, "projectileTemplate", setProjectileTemplate, getProjectileTemplate, xmlelement, mode);
82        XMLPortParam(JumpCenterpoint, "springTemplate", setSpringTemplate, getSpringTemplate, xmlelement, mode);
83        XMLPortParam(JumpCenterpoint, "rocketTemplate", setRocketTemplate, getRocketTemplate, xmlelement, mode);
84        XMLPortParam(JumpCenterpoint, "propellerTemplate", setPropellerTemplate, getPropellerTemplate, xmlelement, mode);
85        XMLPortParam(JumpCenterpoint, "bootsTemplate", setBootsTemplate, getBootsTemplate, xmlelement, mode);
86        XMLPortParam(JumpCenterpoint, "shieldTemplate", setShieldTemplate, getShieldTemplate, xmlelement, mode);
87        XMLPortParam(JumpCenterpoint, "enemy1Template", setEnemy1Template, getEnemy1Template, xmlelement, mode);
88        XMLPortParam(JumpCenterpoint, "enemy2Template", setEnemy2Template, getEnemy2Template, xmlelement, mode);
89        XMLPortParam(JumpCenterpoint, "enemy3Template", setEnemy3Template, getEnemy3Template, xmlelement, mode);
90        XMLPortParam(JumpCenterpoint, "enemy4Template", setEnemy4Template, getEnemy4Template, xmlelement, mode);
91    }
92
93    /**
94    @brief
95        Is called when the gametype has changed.
96    */
97    void JumpCenterpoint::changedGametype()
98    {
99        SUPER(JumpCenterpoint, changedGametype);
100
101        // Check, whether it's still Jump.
102        checkGametype();
103    }
104
105    /**
106    @brief
107        Checks whether the gametype is Jump and if it is, sets its centerpoint.
108    */
109    void JumpCenterpoint::checkGametype()
110    {
111        if (this->getGametype() != NULL && this->getGametype()->isA(Class(Jump)))
112        {
113            Jump* jumpGametype = orxonox_cast<Jump*>(this->getGametype().get());
114            jumpGametype->setCenterpoint(this);
115        }
116    }
117}
Note: See TracBrowser for help on using the repository browser.