Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/tetris/TetrisCenterpoint.cc @ 9348

Last change on this file since 9348 was 9348, checked in by landauf, 12 years ago

merged branch presentation2012merge back to trunk

  • Property svn:eol-style set to native
File size: 3.2 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 *      ...
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30    @file TetrisCenterpoint.cc
31    @brief Implementation of the TetrisCenterpoint class.
32    @ingroup Tetris
33*/
34
35#include "TetrisCenterpoint.h"
36
37#include "core/CoreIncludes.h"
38#include "core/XMLPort.h"
39
40#include "Tetris.h"
41
42namespace orxonox
43{
44    CreateFactory(TetrisCenterpoint);
45
46    /**
47    @brief
48        Constructor. Registers and initializes the object and checks whether the gametype is actually Tetris.
49    */
50    TetrisCenterpoint::TetrisCenterpoint(BaseObject* creator) : StaticEntity(creator)
51    {
52        RegisterObject(TetrisCenterpoint);
53
54        this->width_ = 10;
55        this->height_ = 11;
56        this->stoneSize_ = 10.0f;
57        this->stoneTemplate_ = "";
58        this->brickTemplate_ = "";
59        this->stoneSpeed_ = 20.0f;
60       
61        this->checkGametype();
62    }
63
64    /**
65    @brief
66        Method to create a TetrisCenterpoint through XML.
67    */
68    void TetrisCenterpoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
69    {
70        SUPER(TetrisCenterpoint, XMLPort, xmlelement, mode);
71
72        XMLPortParam(TetrisCenterpoint, "width", setWidth, getWidth, xmlelement, mode); // die Breite
73        XMLPortParam(TetrisCenterpoint, "height", setHeight, getHeight, xmlelement, mode); // die Grösse //was sollte das mit setWidth??
74        XMLPortParam(TetrisCenterpoint, "stoneSize", setStoneSize, getStoneSize, xmlelement, mode); 
75        XMLPortParam(TetrisCenterpoint, "stoneTemplate", setStoneTemplate, getStoneTemplate, xmlelement, mode);
76        XMLPortParam(TetrisCenterpoint, "brickTemplate", setBrickTemplate, getBrickTemplate, xmlelement, mode);
77        XMLPortParam(TetrisCenterpoint, "stoneSpeed", setStoneSpeed, getStoneSpeed, xmlelement, mode);
78    }
79
80    /**
81    @brief
82        Is called when the gametype has changed.
83    */
84    void TetrisCenterpoint::changedGametype()
85    {
86        SUPER(TetrisCenterpoint, changedGametype);
87
88        // Check, whether it's still Tetris.
89        this->checkGametype();
90    }
91
92    /**
93    @brief
94        Checks whether the gametype is Tetris and if it is, sets its centerpoint.
95    */
96    void TetrisCenterpoint::checkGametype()
97    {
98        if (this->getGametype() != NULL && this->getGametype()->isA(Class(Tetris)))
99        {
100            Tetris* tetrisGametype = orxonox_cast<Tetris*>(this->getGametype().get());
101            tetrisGametype->setCenterpoint(this);
102        }
103    }
104}
Note: See TracBrowser for help on using the repository browser.