Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/tgidronFS16/src/modules/hover/TFlagsLivesLevelHUD.cc @ 11177

Last change on this file since 11177 was 11177, checked in by tgidron, 8 years ago

New Pickups (speed); Level Counter and Crate spawn (not working)

File size: 3.3 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 *      Tomer Gidron
24 *
25 */
26
27#include "TFlagsLivesLevelHUD.h"
28#include "HoverFlag.h"
29#include "Hover.h"
30
31#include "core/CoreIncludes.h"
32#include "core/XMLPort.h"
33#include "util/Convert.h"
34
35namespace orxonox
36{
37    RegisterClass(TFlagsLivesLevelHUD);
38
39    TFlagsLivesLevelHUD::TFlagsLivesLevelHUD(Context* context) : OverlayText(context)
40    {
41        RegisterObject(TFlagsLivesLevelHUD);
42
43        this->hoverGame_ = nullptr;
44        this->totFlags_ = 0;
45        showLives_ = true;
46        showLevel_ = true;
47        showTotFlags_= true;
48    }
49
50    void TFlagsLivesLevelHUD::XMLPort(Element& xmlelement, XMLPort::Mode mode)
51    {
52        SUPER(TFlagsLivesLevelHUD, XMLPort, xmlelement, mode);
53
54        XMLPortParam(TFlagsLivesLevelHUD,"showPoints", setShowTot, getShowTot, xmlelement, mode);
55        XMLPortParam(TFlagsLivesLevelHUD, "showLives", setShowLives, getShowLives, xmlelement, mode);
56        XMLPortParam(TFlagsLivesLevelHUD, "showLevel", setShowLevel, getShowLevel, xmlelement, mode);
57    }
58
59    void TFlagsLivesLevelHUD::tick(float dt)
60    {
61        SUPER(TFlagsLivesLevelHUD, tick, dt);
62
63            const std::string& flags = multi_cast<std::string>(this->hoverGame_->getTotFlags());
64            const std::string& lives = multi_cast<std::string>(this->hoverGame_->getLives());
65            const std::string& level = multi_cast<std::string>(this->hoverGame_->getLevel());
66
67            if(showTotFlags_ == true){
68                setTextSize(0.04);
69                setPosition(Vector2(0.18, 0.08));
70                this->setColour(ColourValue(1, 1, 1, 1));
71                this->setCaption(flags);
72            }
73
74
75            if(showLives_ == true){
76                setTextSize(0.04);
77                setPosition(Vector2(0.18, 0.12));
78                this->setColour(ColourValue(1, 1, 1, 1));
79                this->setCaption(lives);
80            }
81
82            if(showLevel_ == true){
83                setTextSize(0.04);
84                setPosition(Vector2(0.18, 0.16));
85                this->setColour(ColourValue(1, 1, 1, 1));
86                this->setCaption(level);
87            }
88           
89    }
90
91    void TFlagsLivesLevelHUD::changedOwner()
92    {
93        SUPER(TFlagsLivesLevelHUD, changedOwner);
94
95        if (this->getOwner() && this->getOwner()->getGametype())
96        {
97            this->hoverGame_ = orxonox_cast<Hover*>(this->getOwner()->getGametype());
98        }
99        else
100        {
101            this->hoverGame_ = nullptr;
102        }
103    }
104}
Note: See TracBrowser for help on using the repository browser.