Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/Presentation_HS17_merge/src/modules/flappyorx/FlappyOrxHUDinfo.cc @ 11758

Last change on this file since 11758 was 11758, checked in by landauf, 6 years ago

[FlappyOrx_HS17] removed unused variables

File size: 4.7 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 *      Leo Merholz
24 *      Pascal Schärli
25 *
26 *      Co-authors:
27 *      ...
28 */
29
30#include "FlappyOrxHUDinfo.h"
31
32#include "core/CoreIncludes.h"
33#include "core/XMLPort.h"
34#include "util/Convert.h"
35#include "FlappyOrx.h"
36
37namespace orxonox
38{
39    RegisterClass(FlappyOrxHUDinfo);
40
41    FlappyOrxHUDinfo::FlappyOrxHUDinfo(Context* context) : OverlayText(context)
42    {
43        RegisterObject(FlappyOrxHUDinfo);
44
45        this->FlappyOrxGame = nullptr;
46        this->bShowPoints_ = false;
47        this->bShowGameOver_ = false;
48    }
49
50    void FlappyOrxHUDinfo::XMLPort(Element& xmlelement, XMLPort::Mode mode)
51    {
52        SUPER(FlappyOrxHUDinfo, XMLPort, xmlelement, mode);
53
54        XMLPortParam(FlappyOrxHUDinfo, "showpoints",    setShowPoints,    getShowPoints,    xmlelement, mode).defaultValues(false);
55        XMLPortParam(FlappyOrxHUDinfo, "showmessage",   setShowMessage,   getShowMessage,   xmlelement, mode).defaultValues(false);
56        XMLPortParam(FlappyOrxHUDinfo, "messageID",     setMessageID,     getMessageID,     xmlelement, mode).defaultValues(0);
57       
58   
59    }
60
61    void FlappyOrxHUDinfo::tick(float dt)
62    {
63        SUPER(FlappyOrxHUDinfo, tick, dt);
64
65        if (this->FlappyOrxGame)
66        {
67            if(not this->FlappyOrxGame->isDead()){
68                if(this->bShowPoints_){
69                    const std::string& points = "Score: "+multi_cast<std::string>(this->FlappyOrxGame->getPoints());
70                    setTextSize(0.04);
71                    this->setCaption(points);
72                }
73                else if(this->bShowGameOver_){
74                    setTextSize(0);
75                }
76            }
77            else{
78                if(this->bShowPoints_){
79                    setTextSize(0);
80                }
81                else if(this->bShowGameOver_){
82                    if(this->FlappyOrxGame->firstGame){
83                        if(messageID==3){
84                            setTextSize(0.05);
85                            this->setCaption("First click, then press space to start");
86                        }
87                    }
88                    else{
89                        std::string message;
90                        setTextSize(0.05);
91                        switch(messageID){
92                            case 0:
93                                message = "Game Over";
94                                setTextSize(0.1);
95                                this->setCaption(message);
96                            break;
97                            case 1:
98                                message = this->FlappyOrxGame->sDeathMessage;
99                            break;
100                            case 2:
101                                message = "Your Score: "+multi_cast<std::string>(this->FlappyOrxGame->getPoints())+
102                                                        "  Local High Score: "+multi_cast<std::string>(Highscore::getInstance().getHighestScoreOfGame("Flappy Orx"));
103                            break;
104                            case 3:
105                                time_t time = this->FlappyOrxGame->getPlayer()->timeUntilRespawn();
106                                if(time<=0)
107                                    message = "Press space to restart.";
108                                else
109                                    message = "Please wait "+multi_cast<std::string>(time)+" seconds.";
110                            break;
111                        }
112                        this->setCaption(message);
113                    }
114                }
115            }   
116        }
117    }
118
119    void FlappyOrxHUDinfo::changedOwner()
120    {
121        SUPER(FlappyOrxHUDinfo, changedOwner);
122
123        if (this->getOwner() && this->getOwner()->getGametype())
124        {
125            this->FlappyOrxGame = orxonox_cast<FlappyOrx*>(this->getOwner()->getGametype());
126        }
127        else
128        {
129            this->FlappyOrxGame = nullptr;
130        }
131    }
132}
Note: See TracBrowser for help on using the repository browser.