Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/AI_HS15/src/modules/dodgerace/DodgeRaceHUDinfo.cc @ 10859

Last change on this file since 10859 was 10624, checked in by landauf, 9 years ago

merged branch core7 back to trunk

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