Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/invaders/src/modules/invader/InvaderHUDinfo.cc @ 9854

Last change on this file since 9854 was 9854, checked in by zifloria, 10 years ago

yeaHHH

File size: 3.4 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 "InvaderHUDinfo.h"
28
29#include "core/CoreIncludes.h"
30#include "core/XMLPort.h"
31#include "util/Convert.h"
32// #include "Invader.h"
33
34namespace orxonox
35{
36    RegisterClass(InvaderHUDinfo);
37
38    InvaderHUDinfo::InvaderHUDinfo(Context* context) : OverlayText(context)
39    {
40        RegisterObject(InvaderHUDinfo);
41
42        this->InvaderGame = 0;
43        this->bShowLives_ = false;
44        this->bShowLevel_ = false;
45        this->bShowPoints_ = false;
46        this->bShowMultiplier_ = false;
47    }
48
49    InvaderHUDinfo::~InvaderHUDinfo()
50    {
51    }
52
53    void InvaderHUDinfo::XMLPort(Element& xmlelement, XMLPort::Mode mode)
54    {
55        SUPER(InvaderHUDinfo, XMLPort, xmlelement, mode);
56
57        XMLPortParam(InvaderHUDinfo, "showlives",     setShowLives,     getShowLives,     xmlelement, mode).defaultValues(false);
58        XMLPortParam(InvaderHUDinfo, "showPoints",     setShowPoints,     getShowPoints,     xmlelement, mode).defaultValues(false);
59        XMLPortParam(InvaderHUDinfo, "showLevel",     setShowLevel,     getShowLevel,     xmlelement, mode).defaultValues(false);
60        XMLPortParam(InvaderHUDinfo, "showMultiplier",     setShowMultiplier,     getShowMultiplier,     xmlelement, mode).defaultValues(false);
61    }
62
63    void InvaderHUDinfo::tick(float dt)
64    {
65        SUPER(InvaderHUDinfo, tick, dt);
66
67        if (this->InvaderGame)
68        {
69            if (this->bShowLives_)
70            {
71                const std::string& lives = multi_cast<std::string>(this->InvaderGame->getLives());
72                this->setCaption(lives);
73            }
74            else if(this->bShowLevel_)
75            {
76                const std::string& Level = multi_cast<std::string>(this->InvaderGame->getLevel());
77                this->setCaption(Level);
78            }
79            else if(this->bShowPoints_)
80            {
81                const std::string& points = multi_cast<std::string>(this->InvaderGame->getPoints());
82                this->setCaption(points);
83            }
84            else if(this->bShowMultiplier_)
85            {
86                const std::string& Multiplier = multi_cast<std::string>(this->InvaderGame->getMultiplier());
87                this->setCaption(Multiplier);
88            }
89        }
90    }
91
92    void InvaderHUDinfo::changedOwner()
93    {
94        SUPER(InvaderHUDinfo, changedOwner);
95
96        if (this->getOwner() && this->getOwner()->getGametype())
97        {
98            this->InvaderGame = orxonox_cast<Invader*>(this->getOwner()->getGametype().get());
99        }
100        else
101        {
102            this->InvaderGame = 0;
103        }
104    }
105}
Note: See TracBrowser for help on using the repository browser.