Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/presentationFS16/src/modules/hover/TFlagsLivesLevelHUD.cc @ 11247

Last change on this file since 11247 was 11199, checked in by fvultier, 9 years ago

merged branch hover

File size: 4.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 *      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        levelUpgrade_ = true;
49    }
50
51    void TFlagsLivesLevelHUD::XMLPort(Element& xmlelement, XMLPort::Mode mode)
52    {
53        SUPER(TFlagsLivesLevelHUD, XMLPort, xmlelement, mode);
54
55        XMLPortParam(TFlagsLivesLevelHUD,"showPoints", setShowTot, getShowTot, xmlelement, mode);
56        XMLPortParam(TFlagsLivesLevelHUD, "showLives", setShowLives, getShowLives, xmlelement, mode);
57        XMLPortParam(TFlagsLivesLevelHUD, "showLevel", setShowLevel, getShowLevel, xmlelement, mode);
58        XMLPortParam(TFlagsLivesLevelHUD, "levelUpgrade", setLevelUpgrade, getLevelUpgrade, xmlelement, mode);
59    }
60
61    void TFlagsLivesLevelHUD::tick(float dt)
62    {
63        SUPER(TFlagsLivesLevelHUD, tick, dt);
64
65            const std::string& flags = multi_cast<std::string>(this->hoverGame_->getTotFlags());
66            const std::string& lives = multi_cast<std::string>(this->hoverGame_->getLives());
67            const std::string& level = multi_cast<std::string>(this->hoverGame_->getLevel());
68
69            //Display total Flags taken
70            if(showTotFlags_ == true){
71                setTextSize(0.04);
72                setPosition(Vector2(0.18, 0.08));
73                this->setColour(ColourValue(1, 1, 1, 1));
74                this->setCaption(flags);
75            }
76
77            //Display remaining lives
78            if(showLives_ == true){
79                setTextSize(0.04);
80                setPosition(Vector2(0.18, 0.12));
81                this->setColour(ColourValue(1, 1, 1, 1));
82                this->setCaption(lives);
83            }
84
85            //Display current level
86            if(showLevel_ == true){
87                setTextSize(0.04);
88                setPosition(Vector2(0.18, 0.16));
89                this->setColour(ColourValue(1, 1, 1, 1));
90                this->setCaption(level);
91               
92            }
93           
94            //New Level pop up
95            if(this->hoverGame_->bLevelUpgradeHUD  && levelUpgrade_)
96                {
97                setTextSize(0.2);
98                setPosition(Vector2(0.3, 0.45));
99                std::stringstream sstm;
100                sstm << "Level " << level;
101                this->setCaption(sstm.str());
102
103                //TODO
104                //make others stop blinking when new level pop-up is activated
105                }
106
107    }
108
109    void TFlagsLivesLevelHUD::changedOwner()
110    {
111        SUPER(TFlagsLivesLevelHUD, changedOwner);
112
113        if (this->getOwner() && this->getOwner()->getGametype())
114        {
115            this->hoverGame_ = orxonox_cast<Hover*>(this->getOwner()->getGametype());
116        }
117        else
118        {
119            this->hoverGame_ = nullptr;
120        }
121    }
122}
Note: See TracBrowser for help on using the repository browser.