Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/overlays/hud/UnderAttackHealthBar.cc @ 7922

Last change on this file since 7922 was 6417, checked in by rgrieder, 15 years ago

Merged presentation2 branch back to trunk.
Major new features:

  • Actual GUI with settings, etc.
  • Improved space ship steering (human interaction)
  • Rocket fire and more particle effects
  • Advanced sound framework
  • Property svn:eol-style set to native
File size: 3.3 KB
RevLine 
[3104]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 *      Fabian 'x3n' Landau
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#include "UnderAttackHealthBar.h"
30
31#include "core/CoreIncludes.h"
32#include "core/XMLPort.h"
[5735]33#include "infos/PlayerInfo.h"
34#include "gametypes/UnderAttack.h"
35#include "worldentities/pawns/Destroyer.h"
[6054]36#include "overlays/OverlayGroup.h"
[3104]37
38namespace orxonox
39{
40    CreateFactory(UnderAttackHealthBar);
41
42    UnderAttackHealthBar::UnderAttackHealthBar(BaseObject* creator) : HUDHealthBar(creator)
43    {
44        RegisterObject(UnderAttackHealthBar);
45
46        this->owner_ = 0;
47
48        this->text_ = new OverlayText(this);
49        this->text_->setFont("Monofur");
[3196]50        this->text_->setTextSize(0.04f);
[3104]51        this->text_->setAlignmentString("center");
52        this->text_->setColour(ColourValue::White);
53        this->text_->setPickPoint(Vector2(0.5, 0));
54
[5929]55        this->inittimer_.setTimer(0.0f, false, createExecutor(createFunctor(&UnderAttackHealthBar::init, this)));
[3104]56    }
57
58    UnderAttackHealthBar::~UnderAttackHealthBar()
59    {
60        if (this->isInitialized())
[6054]61        {
[5929]62            this->text_->destroy();
[6054]63            this->text_ = 0;
64        }
[3104]65    }
66
67    void UnderAttackHealthBar::XMLPort(Element& xmlelement, XMLPort::Mode mode)
68    {
69        SUPER(UnderAttackHealthBar, XMLPort, xmlelement, mode);
70
71        XMLPortParam(UnderAttackHealthBar, "descriptionpickpoint", setDescriptionPickPoint, getDescriptionPickPoint, xmlelement, mode);
72        XMLPortParam(UnderAttackHealthBar, "descriptionoffset", setDescriptionOffset, getDescriptionOffset, xmlelement, mode);
73    }
74
75    void UnderAttackHealthBar::changedOwner()
76    {
77        SUPER(UnderAttackHealthBar, changedOwner);
78
[3325]79        PlayerInfo* player = orxonox_cast<PlayerInfo*>(this->getOwner());
[3104]80        if (player)
81        {
82            this->owner_ = player;
83
[5929]84            UnderAttack* ua = orxonox_cast<UnderAttack*>(player->getGametype().get());
[3104]85            if (ua)
86            {
87                this->setOwner(ua->getDestroyer());
88
89                if (ua->getTeam(player) == 0)
90                    this->text_->setCaption("Attack the Transporter!");
91                else
92                    this->text_->setCaption("Defend the Transporter!");
93            }
94        }
95    }
[6417]96
[6054]97    void UnderAttackHealthBar::changedOverlayGroup()
98    {
99        SUPER(UnderAttackHealthBar, changedOverlayGroup);
[6417]100
[6054]101        this->getOverlayGroup()->addElement(this->text_.get());
102    }
[3104]103
104    void UnderAttackHealthBar::init()
105    {
106        this->setOwner(this->owner_);
107    }
108}
Note: See TracBrowser for help on using the repository browser.