Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 12339 was 12339, checked in by jeromela, 5 years ago

spielfeldgroesse

File size: 3.4 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        this->batspeed_ = 60;
63        this->batlength_ = 0.25;
64
65        this->checkGametype();
66    }
67
68    /**
69    @brief
70        Method to create a OrxoBloxCenterpoint through XML.
71    */
72    void OrxoBloxCenterpoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
73    {
74        SUPER(OrxoBloxCenterpoint, XMLPort, xmlelement, mode);
75
76        XMLPortParam(OrxoBloxCenterpoint, "dimension", setFieldDimension, getFieldDimension, xmlelement, mode);
77        XMLPortParam(OrxoBloxCenterpoint, "balltemplate", setBalltemplate, getBalltemplate, xmlelement, mode);
78        XMLPortParam(OrxoBloxCenterpoint, "battemplate", setBattemplate, getBattemplate, xmlelement, mode);
79        XMLPortParam(OrxoBloxCenterpoint, "ballspeed", setBallSpeed, getBallSpeed, xmlelement, mode);
80        XMLPortParam(OrxoBloxCenterpoint, "ballaccfactor", setBallAccelerationFactor, getBallAccelerationFactor, xmlelement, mode);
81        XMLPortParam(OrxoBloxCenterpoint, "batspeed", setBatSpeed, getBatSpeed, xmlelement, mode);
82        XMLPortParam(OrxoBloxCenterpoint, "stoneTemplate", setStoneTemplate, getStoneTemplate, xmlelement, mode);
83        XMLPortParam(OrxoBloxCenterpoint, "WallTemplate", setWallTemplate, getWallTemplate, xmlelement, mode);
84        XMLPortParam(OrxoBloxCenterpoint, "batlength", setBatLength, getBatLength, xmlelement, mode);
85    }
86
87    /**
88    @brief
89        Checks whether the gametype is OrxoBlox and if it is, sets its centerpoint.
90    */
91    void OrxoBloxCenterpoint::checkGametype()
92    {
93        if (this->getGametype() != nullptr && this->getGametype()->isA(Class(OrxoBlox)))
94        {
95            OrxoBlox* OrxoBloxGametype = orxonox_cast<OrxoBlox*>(this->getGametype());
96            OrxoBloxGametype->setCenterpoint(this);
97        }
98    }
99}
Note: See TracBrowser for help on using the repository browser.