Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/overlays/hud/GametypeStatus.cc @ 3110

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

Removed old msvc specific support for precompiled header files.

  • Property svn:eol-style set to native
File size: 2.8 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 "GametypeStatus.h"
30
31#include <OgreTextAreaOverlayElement.h>
32
33#include "core/CoreIncludes.h"
34#include "util/Convert.h"
35#include "objects/infos/GametypeInfo.h"
36#include "objects/infos/PlayerInfo.h"
37#include "objects/worldentities/ControllableEntity.h"
38#include "objects/worldentities/pawns/Spectator.h"
39
40namespace orxonox
41{
42    CreateFactory(GametypeStatus);
43
44    GametypeStatus::GametypeStatus(BaseObject* creator) : OverlayText(creator)
45    {
46        RegisterObject(GametypeStatus);
47
48        this->owner_ = 0;
49    }
50
51    GametypeStatus::~GametypeStatus()
52    {
53    }
54
55    void GametypeStatus::tick(float dt)
56    {
57        SUPER(GametypeStatus, tick, dt);
58
59        if (this->owner_ && this->owner_->getGametypeInfo() && this->owner_->getControllableEntity())
60        {
61            const GametypeInfo* gtinfo = this->owner_->getGametypeInfo();
62            ControllableEntity* ce = this->owner_->getControllableEntity();
63
64            if (!gtinfo->hasStarted() && !gtinfo->isStartCountdownRunning())
65            {
66                if (!this->owner_->isReadyToSpawn())
67                    this->setCaption("Press [Fire] to start the match");
68                else
69                    this->setCaption("Waiting for other players");
70            }
71            else if (!gtinfo->hasEnded())
72            {
73                if (gtinfo->isStartCountdownRunning())
74                    this->setCaption(convertToString((int)ceil(gtinfo->getStartCountdown())));
75                else if (ce->isA(Class(Spectator)))
76                    this->setCaption("Press [Fire] to respawn");
77                else
78                    this->setCaption("");
79            }
80            else
81                this->setCaption("Game has ended");
82        }
83    }
84
85
86    void GametypeStatus::changedOwner()
87    {
88        SUPER(GametypeStatus, changedOwner);
89
90        this->owner_ = dynamic_cast<PlayerInfo*>(this->getOwner());
91    }
92}
Note: See TracBrowser for help on using the repository browser.