Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10426 was 9667, checked in by landauf, 11 years ago

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