Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/3DPacman_FS18/src/modules/pacman/PacmanHUDinfo.cc @ 11958

Last change on this file since 11958 was 11958, checked in by dreherm, 6 years ago

HUD test 1

File size: 2.6 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 "PacmanHUDinfo.h"
31
32#include "core/CoreIncludes.h"
33#include "core/XMLPort.h"
34#include "util/Convert.h"
35
36namespace orxonox
37{
38    RegisterClass(PacmanHUDinfo);
39
40    PacmanHUDinfo::PacmanHUDinfo(Context* context) : OverlayText(context)
41    {
42        RegisterObject(PacmanHUDinfo);
43
44        this->PacmanGame = nullptr;
45        this->bShowPoints_ = false;
46        this->bShowMessage_ = false;
47        this->messageID = 0;
48    }
49
50    void PacmanHUDinfo::XMLPort(Element& xmlelement, XMLPort::Mode mode)
51    {
52        SUPER(PacmanHUDinfo, XMLPort, xmlelement, mode);
53
54        XMLPortParam(PacmanHUDinfo, "showpoints",    setShowPoints,    getShowPoints,    xmlelement, mode).defaultValues(false);
55        XMLPortParam(PacmanHUDinfo, "showmessage",   setShowMessage,   getShowMessage,   xmlelement, mode).defaultValues(false);
56        XMLPortParam(PacmanHUDinfo, "messageID",     setMessageID,     getMessageID,     xmlelement, mode).defaultValues(0);
57       
58   
59    }
60
61    void PacmanHUDinfo::tick(float dt)
62    {
63        SUPER(PacmanHUDinfo, tick, dt);
64
65        if (this->PacmanGame)
66        {
67                if(this->bShowPoints_){
68                    const std::string& points = "Score: "+multi_cast<std::string>(this->PacmanGame->getPoints());
69                    setTextSize(0.04);
70                    this->setCaption(points);
71                }
72        }
73    }   
74
75    void PacmanHUDinfo::changedOwner()
76    {
77        SUPER(PacmanHUDinfo, changedOwner);
78
79        if (this->getOwner() && this->getOwner()->getGametype())
80        {
81            this->PacmanGame = orxonox_cast<Pacman*>(this->getOwner()->getGametype());
82        }
83        else
84        {
85            this->PacmanGame = nullptr;
86        }
87    }
88}
Note: See TracBrowser for help on using the repository browser.