Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/objects/triggers/CheckPoint.cc @ 7561

Last change on this file since 7561 was 7163, checked in by dafrick, 14 years ago

Merged presentation3 branch into trunk.

  • Property svn:eol-style set to native
File size: 3.6 KB
RevLine 
[2905]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:
[3020]23 *      Aurelian Jaggi
[2905]24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#include "CheckPoint.h"
30
31#include "core/CoreIncludes.h"
32#include "core/XMLPort.h"
[5735]33#include "gametypes/Asteroids.h"
34#include "worldentities/pawns/Pawn.h"
[2905]35
36namespace orxonox
37{
[3064]38    CreateFactory(CheckPoint);
[2905]39
[7163]40    CheckPoint::CheckPoint(BaseObject* creator)
41        : DistanceTrigger(creator)
42        , RadarViewable(creator, static_cast<WorldEntity*>(this))
[3064]43    {
44        RegisterObject(CheckPoint);
[2905]45
[3064]46        this->setStayActive(true);
47        this->setDistance(50);
48        this->bIsFirst_ = false;
49        this->bIsDestination_ = false;
[2986]50
[3064]51        this->setRadarObjectColour(ColourValue::Green);
52        this->setRadarObjectShape(RadarViewable::Dot);
53        this->setRadarVisibility(false);
[2905]54
[3064]55        this->notifyMaskUpdate();
56    }
[3020]57
[3064]58    CheckPoint::~CheckPoint()
59    {
60    }
[2905]61
[3064]62    void CheckPoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
63    {
64        SUPER(CheckPoint, XMLPort, xmlelement, mode);
[3020]65
[3064]66        XMLPortParam(CheckPoint, "isfirst", setFirst, getFirst, xmlelement, mode).defaultValues(false);
67        XMLPortParam(CheckPoint, "isdestination", setDestination, getDestination, xmlelement, mode).defaultValues(false);
68        XMLPortParam(CheckPoint, "addtime", setAddTime, getAddTime, xmlelement, mode).defaultValues(30);
69    }
[2905]70
[3064]71    void CheckPoint::changedActivity()
[3020]72    {
[3064]73        SUPER(CheckPoint, changedActivity);
[3099]74
[3064]75        if (this->BaseObject::isActive())
[2970]76        {
[3064]77            this->setRadarVisibility(true);
[2970]78        }
[3064]79        else
80        {
81            this->setRadarVisibility(false);
82        }
83    }
[3020]84
[3064]85    void CheckPoint::triggered(bool bIsTriggered)
86    {
87        DistanceTrigger::triggered(bIsTriggered);
88
[5929]89        Asteroids* gametype = orxonox_cast<Asteroids*>(this->getGametype().get());
[3064]90        if (gametype)
[2970]91        {
[3064]92            gametype->addTime(addTime_);
93            this->setRadarVisibility(false);
94
[3099]95            if (bIsTriggered)
[3064]96            {
[3099]97                if (bIsFirst_)
98                {
99                    gametype->setTimeLimit(addTime_);
100                    gametype->firstCheckpointReached(true);
101                }
[3064]102
[3099]103                if (bIsDestination_)
104                {
105                    const_cast<GametypeInfo*>(gametype->getGametypeInfo())->sendAnnounceMessage("Congratulations - you have won the match!");
106                    gametype->end();
107                }
108
109                if (!bIsFirst_ && !bIsDestination_)
110                {
111                    const_cast<GametypeInfo*>(gametype->getGametypeInfo())->sendAnnounceMessage("Checkpoint reached");
112                }
[3064]113            }
[2970]114        }
[3064]115    }
[2986]116
[3064]117    void CheckPoint::notifyMaskUpdate()
118    {
119        this->targetMask_.exclude(Class(BaseObject));
120        this->targetMask_.include(Class(Pawn));
121    }
[2905]122}
Note: See TracBrowser for help on using the repository browser.