| 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 | //this->setVisible(true); |
|---|
| 51 | |
|---|
| 52 | this->notifyMaskUpdate(); |
|---|
| 53 | } |
|---|
| 54 | |
|---|
| 55 | CheckPoint::~CheckPoint() |
|---|
| 56 | { |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | void CheckPoint::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
|---|
| 60 | { |
|---|
| 61 | SUPER(CheckPoint, XMLPort, xmlelement, mode); |
|---|
| 62 | |
|---|
| 63 | XMLPortParam(CheckPoint, "isfirst", setFirst, getFirst, xmlelement, mode).defaultValues(false); |
|---|
| 64 | XMLPortParam(CheckPoint, "isdestination", setDestination, getDestination, xmlelement, mode).defaultValues(false); |
|---|
| 65 | XMLPortParam(CheckPoint, "addtime", setAddTime, getAddTime, xmlelement, mode).defaultValues(30); |
|---|
| 66 | } |
|---|
| 67 | |
|---|
| 68 | void CheckPoint::triggered(bool bIsTriggered) |
|---|
| 69 | { |
|---|
| 70 | DistanceTrigger::triggered(bIsTriggered); |
|---|
| 71 | |
|---|
| 72 | Asteroids* gametype = dynamic_cast<Asteroids*>(this->getGametype()); |
|---|
| 73 | if (gametype) |
|---|
| 74 | { |
|---|
| 75 | gametype->addTime(addTime_); |
|---|
| 76 | |
|---|
| 77 | if (bIsTriggered && bIsFirst_) |
|---|
| 78 | { |
|---|
| 79 | gametype->setTimeLimit(addTime_); |
|---|
| 80 | gametype->firstCheckpointReached(true); |
|---|
| 81 | } |
|---|
| 82 | |
|---|
| 83 | if (bIsTriggered && bIsDestination_) |
|---|
| 84 | { |
|---|
| 85 | gametype->end(); |
|---|
| 86 | } |
|---|
| 87 | } |
|---|
| 88 | } |
|---|
| 89 | |
|---|
| 90 | void CheckPoint::notifyMaskUpdate() |
|---|
| 91 | { |
|---|
| 92 | this->targetMask_.exclude(Class(BaseObject)); |
|---|
| 93 | this->targetMask_.include(Class(Pawn)); |
|---|
| 94 | } |
|---|
| 95 | } |
|---|