Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/Presentation_HS17_merge/src/modules/asteroids2D/Asteroids2DHUDinfo.cc @ 11823

Last change on this file since 11823 was 11781, checked in by landauf, 7 years ago

eol-style native (no changes in code)

  • Property svn:eol-style set to native
File size: 2.7 KB
RevLine 
[11593]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:
[11669]23 *      Viviane Yang
[11593]24 *
25 */
26
[11608]27#include "Asteroids2DHUDinfo.h"
[11593]28
29#include "core/CoreIncludes.h"
30#include "core/XMLPort.h"
31#include "util/Convert.h"
[11727]32#include "Asteroids2D.h"
[11593]33
34namespace orxonox
35{
[11608]36    RegisterClass(Asteroids2DHUDinfo);
[11593]37
[11608]38    Asteroids2DHUDinfo::Asteroids2DHUDinfo(Context* context) : OverlayText(context)
[11593]39    {
[11608]40        RegisterObject(Asteroids2DHUDinfo);
[11593]41
[11608]42        this->Asteroids2DGame = nullptr;
[11593]43        this->bShowPoints_ = true;
44    }
45
[11608]46    void Asteroids2DHUDinfo::XMLPort(Element& xmlelement, XMLPort::Mode mode)
[11593]47    {
[11608]48        SUPER(Asteroids2DHUDinfo, XMLPort, xmlelement, mode);
[11593]49
[11608]50        XMLPortParam(Asteroids2DHUDinfo,"showPoints", setShowPoints, getShowPoints, xmlelement, mode).defaultValues(false);
[11593]51    }
52
[11608]53    void Asteroids2DHUDinfo::tick(float dt)
[11593]54    {
[11608]55        SUPER(Asteroids2DHUDinfo, tick, dt);
[11593]56
57
58        if(this->bShowPoints_)
59        {
[11608]60            const std::string& points = multi_cast<std::string>(this->Asteroids2DGame->getPoints());
61            if (this->Asteroids2DGame->lives <= 0)
[11593]62            {
63                setTextSize(0.2);
64                setPosition(Vector2(0.1, 0.02));
65                this->setCaption("Final score:\n" + points);
66                this->setColour(ColourValue(1, 0, 0, 1));
67            }
68            else
69            {
70                setTextSize(0.04);
71                setPosition(Vector2(0.14, 0.02));
72                this->setColour(ColourValue(1, 1, 1, 1));
73                this->setCaption(points);
74            }
75        }
[11637]76
[11593]77    }
78
[11608]79    void Asteroids2DHUDinfo::changedOwner()
[11593]80    {
[11608]81        SUPER(Asteroids2DHUDinfo, changedOwner);
[11593]82
[11669]83        if (this->getOwner() && this->getOwner()->getGametype())
[11593]84        {
[11608]85            this->Asteroids2DGame = orxonox_cast<Asteroids2D*>(this->getOwner()->getGametype());
[11669]86
[11593]87        }
88        else
89        {
[11608]90            this->Asteroids2DGame = nullptr;
[11593]91        }
92    }
93}
Note: See TracBrowser for help on using the repository browser.