Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/gamestates3/src/modules/overlays/hud/UnderAttackHealthBar.cc @ 6880

Last change on this file since 6880 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
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 *      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"
33#include "infos/PlayerInfo.h"
34#include "gametypes/UnderAttack.h"
35#include "worldentities/pawns/Destroyer.h"
36#include "overlays/OverlayGroup.h"
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");
50        this->text_->setTextSize(0.04f);
51        this->text_->setAlignmentString("center");
52        this->text_->setColour(ColourValue::White);
53        this->text_->setPickPoint(Vector2(0.5, 0));
54
55        this->inittimer_.setTimer(0.0f, false, createExecutor(createFunctor(&UnderAttackHealthBar::init, this)));
56    }
57
58    UnderAttackHealthBar::~UnderAttackHealthBar()
59    {
60        if (this->isInitialized())
61        {
62            this->text_->destroy();
63            this->text_ = 0;
64        }
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
79        PlayerInfo* player = orxonox_cast<PlayerInfo*>(this->getOwner());
80        if (player)
81        {
82            this->owner_ = player;
83
84            UnderAttack* ua = orxonox_cast<UnderAttack*>(player->getGametype().get());
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    }
96
97    void UnderAttackHealthBar::changedOverlayGroup()
98    {
99        SUPER(UnderAttackHealthBar, changedOverlayGroup);
100
101        this->getOverlayGroup()->addElement(this->text_.get());
102    }
103
104    void UnderAttackHealthBar::init()
105    {
106        this->setOwner(this->owner_);
107    }
108}
Note: See TracBrowser for help on using the repository browser.