Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxCenterpoint.cc @ 12366

Last change on this file since 12366 was 12366, checked in by ahuwyler, 5 years ago

Here and there

File size: 3.0 KB
Line 
1/**
2    Centerpoint: Konstruktion Spielfeld. Wird in orxoblox.oxw definiert.
3*/
4
5
6/*
7 *   ORXONOX - the hottest 3D action shooter ever to exist
8 *                    > www.orxonox.net <
9 *
10 *
11 *   License notice:
12 *
13 *   This program is free software; you can redistribute it and/or
14 *   modify it under the terms of the GNU General Public License
15 *   as published by the Free Software Foundation; either version 2
16 *   of the License, or (at your option) any later version.
17 *
18 *   This program is distributed in the hope that it will be useful,
19 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
20 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 *   GNU General Public License for more details.
22 *
23 *   You should have received a copy of the GNU General Public License
24 *   along with this program; if not, write to the Free Software
25 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
26 *
27 *   Author:
28 *      Fabian 'x3n' Landau
29 *   Co-authors:
30 *      ...
31 *
32 */
33
34/**
35    @file OrxoBloxCenterpoint.cc
36    @brief Implementation of the OrxoBloxCenterpoint class.
37*/
38
39#include "OrxoBloxCenterpoint.h"
40
41#include "core/CoreIncludes.h"
42#include "core/XMLPort.h"
43
44#include "OrxoBlox.h"
45
46namespace orxonox
47{
48    RegisterClass(OrxoBloxCenterpoint);
49
50    /**
51    @brief
52        Constructor. Registers and initializes the object and checks whether the gametype is actually OrxoBlox.
53    */
54    OrxoBloxCenterpoint::OrxoBloxCenterpoint(Context* context) : StaticEntity(context)
55    {
56        RegisterObject(OrxoBloxCenterpoint);
57
58        this->width_ = 100;
59        this->height_ = 50;
60        this->ballspeed_ = 100;
61        this->ballaccfactor_ = 1.0;
62       
63        this->checkGametype();
64    }
65
66    /**
67    @brief
68        Method to create a OrxoBloxCenterpoint through XML.
69    */
70    void OrxoBloxCenterpoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
71    {
72        SUPER(OrxoBloxCenterpoint, XMLPort, xmlelement, mode);
73
74        XMLPortParam(OrxoBloxCenterpoint, "dimension", setFieldDimension, getFieldDimension, xmlelement, mode);
75        XMLPortParam(OrxoBloxCenterpoint, "balltemplate", setBalltemplate, getBalltemplate, xmlelement, mode);
76        XMLPortParam(OrxoBloxCenterpoint, "ballspeed", setBallSpeed, getBallSpeed, xmlelement, mode);
77        XMLPortParam(OrxoBloxCenterpoint, "ballaccfactor", setBallAccelerationFactor, getBallAccelerationFactor, xmlelement, mode);
78
79        XMLPortParam(OrxoBloxCenterpoint, "stoneTemplate", setStoneTemplate, getStoneTemplate, xmlelement, mode);
80        XMLPortParam(OrxoBloxCenterpoint, "WallTemplate", setWallTemplate, getWallTemplate, xmlelement, mode);
81    }
82
83    /**
84    @brief
85        Checks whether the gametype is OrxoBlox and if it is, sets its centerpoint.
86    */
87    void OrxoBloxCenterpoint::checkGametype()
88    {
89        if (this->getGametype() != nullptr && this->getGametype()->isA(Class(OrxoBlox)))
90        {
91            OrxoBlox* OrxoBloxGametype = orxonox_cast<OrxoBlox*>(this->getGametype());
92            OrxoBloxGametype->setCenterpoint(this);
93        }
94    }
95}
Note: See TracBrowser for help on using the repository browser.