[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 | |
---|
| 36 | namespace orxonox |
---|
| 37 | { |
---|
[3064] | 38 | CreateFactory(CheckPoint); |
---|
[2905] | 39 | |
---|
[3064] | 40 | CheckPoint::CheckPoint(BaseObject* creator) : DistanceTrigger(creator) |
---|
| 41 | { |
---|
| 42 | RegisterObject(CheckPoint); |
---|
[2905] | 43 | |
---|
[3064] | 44 | this->setStayActive(true); |
---|
| 45 | this->setDistance(50); |
---|
| 46 | this->bIsFirst_ = false; |
---|
| 47 | this->bIsDestination_ = false; |
---|
[2986] | 48 | |
---|
[3064] | 49 | this->setRadarObjectColour(ColourValue::Green); |
---|
| 50 | this->setRadarObjectShape(RadarViewable::Dot); |
---|
| 51 | this->setRadarVisibility(false); |
---|
[2905] | 52 | |
---|
[3064] | 53 | this->notifyMaskUpdate(); |
---|
| 54 | } |
---|
[3020] | 55 | |
---|
[3064] | 56 | CheckPoint::~CheckPoint() |
---|
| 57 | { |
---|
| 58 | } |
---|
[2905] | 59 | |
---|
[3064] | 60 | void CheckPoint::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
---|
| 61 | { |
---|
| 62 | SUPER(CheckPoint, XMLPort, xmlelement, mode); |
---|
[3020] | 63 | |
---|
[3064] | 64 | XMLPortParam(CheckPoint, "isfirst", setFirst, getFirst, xmlelement, mode).defaultValues(false); |
---|
| 65 | XMLPortParam(CheckPoint, "isdestination", setDestination, getDestination, xmlelement, mode).defaultValues(false); |
---|
| 66 | XMLPortParam(CheckPoint, "addtime", setAddTime, getAddTime, xmlelement, mode).defaultValues(30); |
---|
| 67 | } |
---|
[2905] | 68 | |
---|
[3064] | 69 | void CheckPoint::changedActivity() |
---|
[3020] | 70 | { |
---|
[3064] | 71 | SUPER(CheckPoint, changedActivity); |
---|
[3099] | 72 | |
---|
[3064] | 73 | if (this->BaseObject::isActive()) |
---|
[2970] | 74 | { |
---|
[3064] | 75 | this->setRadarVisibility(true); |
---|
[2970] | 76 | } |
---|
[3064] | 77 | else |
---|
| 78 | { |
---|
| 79 | this->setRadarVisibility(false); |
---|
| 80 | } |
---|
| 81 | } |
---|
[3020] | 82 | |
---|
[3064] | 83 | void CheckPoint::triggered(bool bIsTriggered) |
---|
| 84 | { |
---|
| 85 | DistanceTrigger::triggered(bIsTriggered); |
---|
| 86 | |
---|
[3325] | 87 | Asteroids* gametype = orxonox_cast<Asteroids*>(this->getGametype()); |
---|
[3064] | 88 | if (gametype) |
---|
[2970] | 89 | { |
---|
[3064] | 90 | gametype->addTime(addTime_); |
---|
| 91 | this->setRadarVisibility(false); |
---|
| 92 | |
---|
[3099] | 93 | if (bIsTriggered) |
---|
[3064] | 94 | { |
---|
[3099] | 95 | if (bIsFirst_) |
---|
| 96 | { |
---|
| 97 | gametype->setTimeLimit(addTime_); |
---|
| 98 | gametype->firstCheckpointReached(true); |
---|
| 99 | } |
---|
[3064] | 100 | |
---|
[3099] | 101 | if (bIsDestination_) |
---|
| 102 | { |
---|
| 103 | const_cast<GametypeInfo*>(gametype->getGametypeInfo())->sendAnnounceMessage("Congratulations - you have won the match!"); |
---|
| 104 | gametype->end(); |
---|
| 105 | } |
---|
| 106 | |
---|
| 107 | if (!bIsFirst_ && !bIsDestination_) |
---|
| 108 | { |
---|
| 109 | const_cast<GametypeInfo*>(gametype->getGametypeInfo())->sendAnnounceMessage("Checkpoint reached"); |
---|
| 110 | } |
---|
[3064] | 111 | } |
---|
[2970] | 112 | } |
---|
[3064] | 113 | } |
---|
[2986] | 114 | |
---|
[3064] | 115 | void CheckPoint::notifyMaskUpdate() |
---|
| 116 | { |
---|
| 117 | this->targetMask_.exclude(Class(BaseObject)); |
---|
| 118 | this->targetMask_.include(Class(Pawn)); |
---|
| 119 | } |
---|
[2905] | 120 | } |
---|