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 | |
---|
31 | #include "util/Convert.h" |
---|
32 | #include "core/CoreIncludes.h" |
---|
33 | #include "core/XMLPort.h" |
---|
34 | #include "chat/ChatManager.h" |
---|
35 | |
---|
36 | #include <infos/PlayerInfo.h> |
---|
37 | #include <worldentities/ControllableEntity.h> |
---|
38 | |
---|
39 | #include "SpaceRace.h" |
---|
40 | |
---|
41 | namespace orxonox |
---|
42 | { |
---|
43 | CreateFactory(RaceCheckPoint); |
---|
44 | |
---|
45 | RaceCheckPoint::RaceCheckPoint(BaseObject* creator): DistanceMultiTrigger(creator), RadarViewable(creator, static_cast<WorldEntity*>(this)) |
---|
46 | { |
---|
47 | RegisterObject(RaceCheckPoint); |
---|
48 | |
---|
49 | this->setDistance(100); |
---|
50 | this->setBeaconMode("off"); |
---|
51 | this->setBroadcast(false); |
---|
52 | this->setSimultaneousTriggerers(100); |
---|
53 | |
---|
54 | this->setRadarObjectColour(ColourValue::Blue); |
---|
55 | this->setRadarObjectShape(RadarViewable::Triangle); |
---|
56 | this->setRadarVisibility(false); |
---|
57 | this->settingsChanged(); |
---|
58 | |
---|
59 | this->checkpointIndex_ = 0; |
---|
60 | this->nextcheckpoints_ = Vector3::ZERO; |
---|
61 | this->bIsLast_ = false; |
---|
62 | this->timeLimit_ = 0; |
---|
63 | this->player_ = NULL; |
---|
64 | } |
---|
65 | |
---|
66 | |
---|
67 | RaceCheckPoint::~RaceCheckPoint() |
---|
68 | { |
---|
69 | } |
---|
70 | |
---|
71 | void RaceCheckPoint::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
---|
72 | { |
---|
73 | SUPER(RaceCheckPoint, XMLPort, xmlelement, mode); |
---|
74 | |
---|
75 | XMLPortParam(RaceCheckPoint, "checkpointindex", setCheckpointIndex, getCheckpointIndex, xmlelement, mode).defaultValues(0); |
---|
76 | XMLPortParam(RaceCheckPoint, "islast", setLast, isLast, xmlelement, mode).defaultValues(false); |
---|
77 | XMLPortParam(RaceCheckPoint, "timelimit", setTimelimit, getTimeLimit, xmlelement, mode).defaultValues(0); |
---|
78 | XMLPortParamTemplate(RaceCheckPoint, "nextcheckpoints", setNextcheckpoint, getNextcheckpoint, xmlelement, mode, const Vector3&).defaultValues(Vector3::ZERO); |
---|
79 | } |
---|
80 | |
---|
81 | void RaceCheckPoint::fire(bool bIsTriggered, BaseObject* originator) |
---|
82 | { |
---|
83 | DistanceMultiTrigger::fire(bIsTriggered, originator); |
---|
84 | |
---|
85 | if (bIsTriggered) |
---|
86 | { |
---|
87 | ControllableEntity* entity = orxonox_cast<ControllableEntity*>(originator); |
---|
88 | if (entity) |
---|
89 | this->player_ = entity->getPlayer(); |
---|
90 | } |
---|
91 | } |
---|
92 | |
---|
93 | void RaceCheckPoint::setTimelimit(float timeLimit) |
---|
94 | { |
---|
95 | this->timeLimit_ = timeLimit; |
---|
96 | if (this->timeLimit_ != 0) |
---|
97 | { |
---|
98 | std::string message = "You have " + multi_cast<std::string>(this->timeLimit_) |
---|
99 | + " seconds to reach the check point " + multi_cast<std::string>(this->checkpointIndex_ + 1); |
---|
100 | const_cast<GametypeInfo*>(this->getGametype()->getGametypeInfo())->sendAnnounceMessage(message); |
---|
101 | ChatManager::message(message); |
---|
102 | } |
---|
103 | } |
---|
104 | } |
---|