Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DHUDinfo.cc @ 11668

Last change on this file since 11668 was 11645, checked in by vyang, 8 years ago

Asteroids2DShip ist 3s immun, nachdem es von einem Asteroiden getroffen wurde. Das Raumschiff hat nun eine Waffe → Richtung der Projektile muss noch angepasst werden

File size: 3.5 KB
RevLine 
[11593]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 *      Florian Zinggeler
24 *
25 */
26
[11608]27#include "Asteroids2DHUDinfo.h"
[11593]28
29#include "core/CoreIncludes.h"
30#include "core/XMLPort.h"
31#include "util/Convert.h"
[11608]32//#include "Asteroids2D.h"
[11593]33
34namespace orxonox
35{
[11608]36    RegisterClass(Asteroids2DHUDinfo);
[11593]37
[11608]38    Asteroids2DHUDinfo::Asteroids2DHUDinfo(Context* context) : OverlayText(context)
[11593]39    {
[11608]40        RegisterObject(Asteroids2DHUDinfo);
[11593]41
[11608]42        this->Asteroids2DGame = nullptr;
[11645]43        //this->Ship = nullptr;
[11593]44        this->bShowPoints_ = true;
[11637]45        this->bShowHealth_ = true;
[11593]46    }
47
[11608]48    void Asteroids2DHUDinfo::XMLPort(Element& xmlelement, XMLPort::Mode mode)
[11593]49    {
[11608]50        SUPER(Asteroids2DHUDinfo, XMLPort, xmlelement, mode);
[11593]51
[11608]52        XMLPortParam(Asteroids2DHUDinfo,"showPoints", setShowPoints, getShowPoints, xmlelement, mode).defaultValues(false);
[11593]53    }
54
[11608]55    void Asteroids2DHUDinfo::tick(float dt)
[11593]56    {
[11608]57        SUPER(Asteroids2DHUDinfo, tick, dt);
[11593]58
59
60        if(this->bShowPoints_)
61        {
[11608]62            const std::string& points = multi_cast<std::string>(this->Asteroids2DGame->getPoints());
63            if (this->Asteroids2DGame->lives <= 0)
[11593]64            {
65                setTextSize(0.2);
66                setPosition(Vector2(0.1, 0.02));
67                this->setCaption("Final score:\n" + points);
68                this->setColour(ColourValue(1, 0, 0, 1));
69            }
70            else
71            {
72                setTextSize(0.04);
73                setPosition(Vector2(0.14, 0.02));
74                this->setColour(ColourValue(1, 1, 1, 1));
75                this->setCaption(points);
76            }
77        }
[11637]78
79        /*if(this->bShowHealth_)
80        {
81            const std::string& health = multi_cast<std::string>(this->Ship->getHealth());
82            if (this->Asteroids2DGame->lives <= 0)
83            {
84                setTextSize(0.2);
85                setPosition(Vector2(0.1, 0.02));
86                this->setCaption("Final score:\n" + health);
87                this->setColour(ColourValue(1, 0, 0, 1));
88            }
89            else
90            {
91                setTextSize(0.04);
92                setPosition(Vector2(0.2, 0.02));
93                this->setColour(ColourValue(1, 1, 1, 1));
94                this->setCaption(health);
95            }
96        }*/
[11593]97    }
98
[11608]99    void Asteroids2DHUDinfo::changedOwner()
[11593]100    {
[11608]101        SUPER(Asteroids2DHUDinfo, changedOwner);
[11593]102
[11637]103        if (this->getOwner() && this->getOwner()->getGametype())//&& this->getOwner->getPlayer())
[11593]104        {
[11608]105            this->Asteroids2DGame = orxonox_cast<Asteroids2D*>(this->getOwner()->getGametype());
[11637]106            //this->Ship = orxonox_cast<Asteroids2DShip*>(this->getOwner()->getPlayer());
[11593]107        }
108        else
109        {
[11608]110            this->Asteroids2DGame = nullptr;
[11593]111        }
112    }
113}
Note: See TracBrowser for help on using the repository browser.