Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 9837 was 9828, checked in by zifloria, 11 years ago

HUD + take damage

File size: 3.0 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    }
47
48    InvaderHUDinfo::~InvaderHUDinfo()
49    {
50    }
51
52    void InvaderHUDinfo::XMLPort(Element& xmlelement, XMLPort::Mode mode)
53    {
54        SUPER(InvaderHUDinfo, XMLPort, xmlelement, mode);
55
56        XMLPortParam(InvaderHUDinfo, "showlives",     setShowLives,     getShowLives,     xmlelement, mode).defaultValues(false);
57        XMLPortParam(InvaderHUDinfo, "showPoints",     setShowPoints,     getShowPoints,     xmlelement, mode).defaultValues(false);
58        XMLPortParam(InvaderHUDinfo, "showLevel",     setShowLevel,     getShowLevel,     xmlelement, mode).defaultValues(false);
59    }
60
61    void InvaderHUDinfo::tick(float dt)
62    {
63        SUPER(InvaderHUDinfo, tick, dt);
64
65        if (this->InvaderGame)
66        {
67            if (this->bShowLives_)
68            {
69                const std::string& lives = multi_cast<std::string>(this->InvaderGame->getLives());
70                this->setCaption(lives);
71            }
72            else if(this->bShowLevel_)
73            {
74                const std::string& Level = multi_cast<std::string>(this->InvaderGame->getLevel());
75                this->setCaption(Level);
76            }
77            else if(this->bShowPoints_)
78            {
79                const std::string& points = multi_cast<std::string>(this->InvaderGame->getPoints());
80                this->setCaption(points);
81            }
82        }
83    }
84
85    void InvaderHUDinfo::changedOwner()
86    {
87        SUPER(InvaderHUDinfo, changedOwner);
88
89        if (this->getOwner() && this->getOwner()->getGametype())
90        {
91            this->InvaderGame = orxonox_cast<Invader*>(this->getOwner()->getGametype().get());
92        }
93        else
94        {
95            this->InvaderGame = 0;
96        }
97    }
98}
Note: See TracBrowser for help on using the repository browser.