Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/objects/worldentities/triggers/CheckPoint.cc @ 3064

Last change on this file since 3064 was 3064, checked in by Aurelian, 15 years ago

Final commit of gametype asteroids for presentation. everything working. New gadget: Radar displays the next checkpoint to reach!

  • Property svn:eol-style set to native
File size: 3.2 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 *      Aurelian Jaggi
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#include "OrxonoxStableHeaders.h"
30#include "CheckPoint.h"
31
32#include "core/CoreIncludes.h"
33#include "core/XMLPort.h"
34
35#include "objects/gametypes/Asteroids.h"
36#include "orxonox/objects/worldentities/pawns/Pawn.h"
37
38namespace orxonox
39{
40    CreateFactory(CheckPoint);
41
42    CheckPoint::CheckPoint(BaseObject* creator) : DistanceTrigger(creator)
43    {
44        RegisterObject(CheckPoint);
45
46        this->setStayActive(true);
47        this->setDistance(50);
48        this->bIsFirst_ = false;
49        this->bIsDestination_ = false;
50
51        this->setRadarObjectColour(ColourValue::Green);
52        this->setRadarObjectShape(RadarViewable::Dot);
53        this->setRadarVisibility(false);
54
55        this->notifyMaskUpdate();
56    }
57
58    CheckPoint::~CheckPoint()
59    {
60    }
61
62    void CheckPoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
63    {
64        SUPER(CheckPoint, XMLPort, xmlelement, mode);
65
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    }
70
71    void CheckPoint::changedActivity()
72    {
73        SUPER(CheckPoint, changedActivity);
74       
75        if (this->BaseObject::isActive())
76        {
77COUT(0) << "active " << this << std::endl;
78            this->setRadarVisibility(true);
79        }
80        else
81        {
82COUT(0) << "inactive " << this << std::endl;
83            this->setRadarVisibility(false);
84        }
85    }
86
87    void CheckPoint::triggered(bool bIsTriggered)
88    {
89        DistanceTrigger::triggered(bIsTriggered);
90
91        Asteroids* gametype = dynamic_cast<Asteroids*>(this->getGametype());
92        if (gametype)
93        {
94            gametype->addTime(addTime_);
95            this->setRadarVisibility(false);
96
97            if (bIsTriggered && bIsFirst_)
98            {
99                gametype->setTimeLimit(addTime_);
100                gametype->firstCheckpointReached(true);
101            }
102
103            if (bIsTriggered && bIsDestination_)
104            {
105                gametype->end();
106            }
107        }
108    }
109
110    void CheckPoint::notifyMaskUpdate()
111    {
112        this->targetMask_.exclude(Class(BaseObject));
113        this->targetMask_.include(Class(Pawn));
114    }
115}
Note: See TracBrowser for help on using the repository browser.