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 | |
---|
38 | namespace 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 | { |
---|
77 | this->setRadarVisibility(true); |
---|
78 | } |
---|
79 | else |
---|
80 | { |
---|
81 | this->setRadarVisibility(false); |
---|
82 | } |
---|
83 | } |
---|
84 | |
---|
85 | void CheckPoint::triggered(bool bIsTriggered) |
---|
86 | { |
---|
87 | DistanceTrigger::triggered(bIsTriggered); |
---|
88 | |
---|
89 | Asteroids* gametype = dynamic_cast<Asteroids*>(this->getGametype()); |
---|
90 | if (gametype) |
---|
91 | { |
---|
92 | gametype->addTime(addTime_); |
---|
93 | this->setRadarVisibility(false); |
---|
94 | |
---|
95 | if (bIsTriggered && bIsFirst_) |
---|
96 | { |
---|
97 | gametype->setTimeLimit(addTime_); |
---|
98 | gametype->firstCheckpointReached(true); |
---|
99 | } |
---|
100 | |
---|
101 | if (bIsTriggered && bIsDestination_) |
---|
102 | { |
---|
103 | gametype->end(); |
---|
104 | } |
---|
105 | } |
---|
106 | } |
---|
107 | |
---|
108 | void CheckPoint::notifyMaskUpdate() |
---|
109 | { |
---|
110 | this->targetMask_.exclude(Class(BaseObject)); |
---|
111 | this->targetMask_.include(Class(Pawn)); |
---|
112 | } |
---|
113 | } |
---|