Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/jump/JumpScore.cc @ 12277

Last change on this file since 12277 was 11071, checked in by landauf, 9 years ago

merged branch cpp11_v3 back to trunk

  • Property svn:eol-style set to native
File size: 3.7 KB
RevLine 
[10078]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 *      Fabien Vultier
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30    @file JumpScore.cc
31    @brief HUD of thejump minigame. If showScore_ is set, it displays the score. If showMessages_ is set, it displays the game over message.
32*/
33
34#include "JumpScore.h"
[11071]35
[10078]36#include "core/CoreIncludes.h"
37#include "core/XMLPort.h"
38#include "util/Convert.h"
39#include "infos/PlayerInfo.h"
40#include "Jump.h"
41
42namespace orxonox
43{
44    RegisterClass(JumpScore);
45
46    JumpScore::JumpScore(Context* context) : OverlayText(context)
47    {
48        RegisterObject(JumpScore);
49
[11071]50        owner_ = nullptr;
[10078]51        showScore_ = false;
[10260]52        showFuel_ = false;
[10078]53        showMessages_ = false;
54    }
55
56    JumpScore::~JumpScore()
57    {
58
59    }
60
61    void JumpScore::XMLPort(Element& xmlelement, XMLPort::Mode mode)
62    {
63        SUPER(JumpScore, XMLPort, xmlelement, mode);
64
65        XMLPortParam(JumpScore, "showScore", setShowScore, getShowScore, xmlelement, mode);
[10260]66        XMLPortParam(JumpScore, "showFuel", setShowFuel, getShowFuel, xmlelement, mode);
[10078]67        XMLPortParam(JumpScore, "showMessages", setShowMessages, getShowMessages, xmlelement, mode);
68        XMLPortParam(JumpScore, "gameOverText", setGameOverText, getGameOverText, xmlelement, mode);
69    }
70
71    void JumpScore::tick(float dt)
72    {
73        SUPER(JumpScore, tick, dt);
74
[11071]75        if (owner_ != nullptr)
[10078]76        {
77            if (!owner_->hasEnded())
78            {
79                player_ = owner_->getPlayer();
80
[11071]81                if (player_ != nullptr)
[10078]82                {
[10215]83                    if (showScore_ == true)
84                    {
85                        int score = owner_->getScore(player_);
[10078]86
[10215]87                        std::string str = multi_cast<std::string>(score);
88                        setCaption(str);
89                    }
[10260]90                    else if (showFuel_ == true)
91                    {
92                        float fuel = owner_->getFuel();
93                        std::string str;
94
95                        if (fuel <= 0.0)
96                        {
97                            str = "";
98                        }
99                        else
100                        {
101                            str = multi_cast<std::string>(fuel);
102                        }
103                        setCaption(str);
104                    }
[10215]105                    else if (showMessages_ == true)
106                    {
107                        setCaption(owner_->getDead(player_) == true ? gameOverText_ : "");
108                    }
[10078]109                }
110            }
111        }
112    }
113
114    void JumpScore::changedOwner()
115    {
116        SUPER(JumpScore, changedOwner);
117
[11071]118        if (this->getOwner() != nullptr && this->getOwner()->getGametype())
[10078]119        {
[10624]120            this->owner_ = orxonox_cast<Jump*>(this->getOwner()->getGametype());
[10078]121        }
122        else
123        {
[11071]124            this->owner_ = nullptr;
[10078]125        }
126    }
127}
Note: See TracBrowser for help on using the repository browser.