[8494] | 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 | * Mauro Salomon |
---|
| 24 | * Co-authors: |
---|
| 25 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | #include "RaceCheckPoint.h" |
---|
| 30 | |
---|
[8858] | 31 | #include "util/Convert.h" |
---|
[8494] | 32 | #include "core/CoreIncludes.h" |
---|
| 33 | #include "core/XMLPort.h" |
---|
[8858] | 34 | #include "chat/ChatManager.h" |
---|
[8494] | 35 | |
---|
[9016] | 36 | #include <infos/PlayerInfo.h> |
---|
| 37 | #include <worldentities/ControllableEntity.h> |
---|
| 38 | |
---|
[8767] | 39 | #include "SpaceRace.h" |
---|
| 40 | |
---|
[8494] | 41 | namespace orxonox |
---|
| 42 | { |
---|
| 43 | CreateFactory(RaceCheckPoint); |
---|
[9016] | 44 | |
---|
| 45 | |
---|
[8767] | 46 | |
---|
[9016] | 47 | RaceCheckPoint::RaceCheckPoint(BaseObject* creator): DistanceMultiTrigger(creator), RadarViewable(creator, static_cast<WorldEntity*>(this)) |
---|
[8494] | 48 | { |
---|
[8630] | 49 | RegisterObject(RaceCheckPoint); |
---|
[9016] | 50 | this->setDistance(100); |
---|
| 51 | this->setBeaconMode("off"); |
---|
| 52 | this->setBroadcast(false); |
---|
| 53 | this->setSimultaneousTriggerers(100); |
---|
[8630] | 54 | this->bTimeLimit_ = 0; |
---|
| 55 | |
---|
| 56 | this->setRadarObjectColour(ColourValue::Blue); |
---|
[8616] | 57 | this->setRadarObjectShape(RadarViewable::Triangle); |
---|
[8494] | 58 | this->setRadarVisibility(false); |
---|
[9016] | 59 | this->settingsChanged(); |
---|
| 60 | this->reached_=NULL; |
---|
| 61 | |
---|
[8494] | 62 | } |
---|
[9016] | 63 | |
---|
[8767] | 64 | |
---|
[9016] | 65 | RaceCheckPoint::~RaceCheckPoint() |
---|
| 66 | { |
---|
| 67 | |
---|
| 68 | } |
---|
[8767] | 69 | |
---|
[8494] | 70 | void RaceCheckPoint::tick(float dt) |
---|
| 71 | { |
---|
[8630] | 72 | SUPER(RaceCheckPoint, tick, dt); |
---|
| 73 | |
---|
| 74 | SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get()); |
---|
[8767] | 75 | assert(gametype); |
---|
[8494] | 76 | } |
---|
| 77 | |
---|
| 78 | void RaceCheckPoint::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
---|
| 79 | { |
---|
[8630] | 80 | SUPER(RaceCheckPoint, XMLPort, xmlelement, mode); |
---|
[9016] | 81 | Vector3 v= Vector3(0,0,0); |
---|
[8630] | 82 | XMLPortParam(RaceCheckPoint, "checkpointindex", setCheckpointIndex, getCheckpointIndex, xmlelement, mode).defaultValues(0); |
---|
| 83 | XMLPortParam(RaceCheckPoint, "islast", setLast, getLast, xmlelement, mode).defaultValues(false); |
---|
| 84 | XMLPortParam(RaceCheckPoint, "timelimit", setTimelimit, getTimeLimit, xmlelement, mode).defaultValues(0); |
---|
[9016] | 85 | XMLPortParamTemplate(RaceCheckPoint, "nextcheckpoints", setNextcheckpoint, getNextcheckpoint, xmlelement, mode,const Vector3&).defaultValues(v); |
---|
[8494] | 86 | } |
---|
[8767] | 87 | |
---|
[9016] | 88 | void RaceCheckPoint::fire(bool bIsTriggered,BaseObject* player) |
---|
[8494] | 89 | { |
---|
[9016] | 90 | DistanceMultiTrigger::fire((bool)bIsTriggered,player); |
---|
| 91 | |
---|
[8630] | 92 | SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get()); |
---|
[9016] | 93 | assert(gametype); |
---|
| 94 | ControllableEntity* entity = (ControllableEntity*) player; |
---|
| 95 | |
---|
| 96 | PlayerInfo* player2 = entity->getPlayer(); |
---|
| 97 | |
---|
| 98 | if(bIsTriggered) |
---|
| 99 | this->reached_=player2; |
---|
[8494] | 100 | } |
---|
[8767] | 101 | |
---|
[8616] | 102 | void RaceCheckPoint::setTimelimit(float timeLimit) |
---|
[8630] | 103 | { |
---|
| 104 | this->bTimeLimit_ = timeLimit; |
---|
| 105 | if (this->bTimeLimit_ != 0) |
---|
| 106 | { |
---|
| 107 | SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get()); |
---|
[9016] | 108 | assert(gametype); |
---|
[8630] | 109 | if (gametype) |
---|
| 110 | { |
---|
| 111 | const std::string& message = "You have " + multi_cast<std::string>(this->bTimeLimit_) |
---|
[8858] | 112 | + " seconds to reach the check point " + multi_cast<std::string>(this->bCheckpointIndex_+1); |
---|
[8630] | 113 | const_cast<GametypeInfo*>(gametype->getGametypeInfo())->sendAnnounceMessage(message); |
---|
[8858] | 114 | ChatManager::message(message); |
---|
[8630] | 115 | } |
---|
| 116 | } |
---|
| 117 | } |
---|
[8767] | 118 | |
---|
[8494] | 119 | } |
---|