Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/MouseAPI_FS19/src/modules/asteroids2D/Asteroids2DHUDinfo.cc

Last change on this file 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
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 *      Viviane Yang
24 *
25 */
26
27#include "Asteroids2DHUDinfo.h"
28
29#include "core/CoreIncludes.h"
30#include "core/XMLPort.h"
31#include "util/Convert.h"
32#include "Asteroids2D.h"
33
34namespace orxonox
35{
36    RegisterClass(Asteroids2DHUDinfo);
37
38    Asteroids2DHUDinfo::Asteroids2DHUDinfo(Context* context) : OverlayText(context)
39    {
40        RegisterObject(Asteroids2DHUDinfo);
41
42        this->Asteroids2DGame = nullptr;
43        this->bShowPoints_ = true;
44    }
45
46    void Asteroids2DHUDinfo::XMLPort(Element& xmlelement, XMLPort::Mode mode)
47    {
48        SUPER(Asteroids2DHUDinfo, XMLPort, xmlelement, mode);
49
50        XMLPortParam(Asteroids2DHUDinfo,"showPoints", setShowPoints, getShowPoints, xmlelement, mode).defaultValues(false);
51    }
52
53    void Asteroids2DHUDinfo::tick(float dt)
54    {
55        SUPER(Asteroids2DHUDinfo, tick, dt);
56
57
58        if(this->bShowPoints_)
59        {
60            const std::string& points = multi_cast<std::string>(this->Asteroids2DGame->getPoints());
61            if (this->Asteroids2DGame->lives <= 0)
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        }
76
77    }
78
79    void Asteroids2DHUDinfo::changedOwner()
80    {
81        SUPER(Asteroids2DHUDinfo, changedOwner);
82
83        if (this->getOwner() && this->getOwner()->getGametype())
84        {
85            this->Asteroids2DGame = orxonox_cast<Asteroids2D*>(this->getOwner()->getGametype());
86
87        }
88        else
89        {
90            this->Asteroids2DGame = nullptr;
91        }
92    }
93}
Note: See TracBrowser for help on using the repository browser.