Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/gametypes/src/orxonox/objects/worldentities/triggers/CheckPoint.cc @ 3019

Last change on this file since 3019 was 3019, checked in by landauf, 15 years ago

set eol-style:native, no codechanges

  • Property svn:eol-style set to native
File size: 2.7 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
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#include "OrxonoxStableHeaders.h"
30#include "CheckPoint.h"
31#include "objects/gametypes/Asteroids.h"
32
33#include <OgreNode.h>
34
35#include "core/CoreIncludes.h"
36#include "core/XMLPort.h"
37
38#include "orxonox/objects/worldentities/ControllableEntity.h"
39#include "orxonox/objects/worldentities/pawns/Pawn.h"
40
41namespace orxonox
42{
43  CreateFactory(CheckPoint);
44
45  CheckPoint::CheckPoint(BaseObject* creator) : DistanceTrigger(creator)
46  {
47    RegisterObject(CheckPoint);
48
49    this->setStayActive(true);
50    this->setDistance(50);
51    this->bIsFirst_ = false;
52    this->bIsDestination_ = false;
53    //this->setVisible(true);
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::triggered(bool bIsTriggered)
72  {
73    DistanceTrigger::triggered(bIsTriggered);
74
75    Asteroids* gametype = dynamic_cast<Asteroids*>(this->getGametype());
76    if (gametype)
77    { 
78        gametype->addTime(addTime_);
79
80        if (bIsTriggered && bIsFirst_)
81        {
82            gametype->setTimeLimit(addTime_);
83            gametype->firstCheckpointReached(true);
84        }
85     
86        if (bIsTriggered && bIsDestination_)
87        {
88            gametype->end();
89        }
90     }
91  }
92
93  void CheckPoint::notifyMaskUpdate()
94  {
95      this->targetMask_.exclude(Class(BaseObject));
96      this->targetMask_.include(Class(Pawn));
97  }
98}
Note: See TracBrowser for help on using the repository browser.