Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/presentationHS12/src/modules/gametypes/RaceCheckPoint.h @ 9523

Last change on this file since 9523 was 9523, checked in by jo, 11 years ago

Merging the Racingbot branch into the presentationHS12 branch.

  • Property svn:eol-style set to native
File size: 4.5 KB
Line 
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#ifndef _RaceCheckPoint_H__
30#define _RaceCheckPoint_H__
31
32#include "gametypes/GametypesPrereqs.h"
33#include "objects/triggers/DistanceMultiTrigger.h"
34#include "interfaces/RadarViewable.h"
35
36namespace orxonox
37{
38    /**
39     @brief
40     The RaceCheckPoint class enables the creation of a check point to use in a SpaceRace level.
41     Don't forget to control the indexes of your check points and to set one last check point
42     */
43    class _GametypesExport RaceCheckPoint: public DistanceMultiTrigger,
44            public RadarViewable
45    {
46        public:
47            RaceCheckPoint(BaseObject* creator);
48            virtual ~RaceCheckPoint();
49
50            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
51
52            inline void setCheckpointIndex(int checkpointIndex)
53            {
54                this->checkpointIndex_ = checkpointIndex;
55            }
56            inline int getCheckpointIndex() const
57            {
58                return this->checkpointIndex_;
59            }
60
61            void setNextCheckpointsAsVector3(const Vector3& checkpoints);
62            Vector3 getNextCheckpointsAsVector3();
63            Vector3 getVirtualNextCheckpointsAsVector3() const;
64            void setNextVirtualCheckpointsAsVector3(const Vector3& checkpoints);
65            int changeVirtualToRealCheckPoint(int);
66
67            const std::set<int>& getVirtualNextCheckpoints() const
68            {
69                return this->nextCheckpointsVirtual_;
70            }
71
72            const std::set<int>& getNextCheckpoints()
73            {
74                return nextCheckpoints_;
75                std::set<int> temp;
76                std::set<int> temp2=getVirtualNextCheckpoints();
77                for (std::set<int>::iterator it = temp2.begin(); it!=temp2.end(); ++it){
78                    temp.insert(changeVirtualToRealCheckPoint((*it)));
79                }
80                return temp;
81            }
82            inline void setLast(bool isLast)
83            {
84                this->bIsLast_ = isLast;
85            }
86            inline bool isLast() const
87            {
88                return this->bIsLast_;
89            }
90
91            virtual void setTimelimit(float timeLimit);
92            inline float getTimeLimit() const
93            {
94                return this->timeLimit_;
95            }
96
97            PlayerInfo* getPlayer(unsigned int clientID) const;
98
99            bool playerWasHere(PlayerInfo* ) const;
100
101            inline void resetPlayer()
102            {
103                this->players_.clear();
104            }
105
106        protected:
107
108            virtual void fire(bool bIsTriggered, BaseObject* originator);
109
110            inline const WorldEntity* getWorldEntity() const
111            {
112                return this;
113            }
114
115        private:
116
117            int checkpointIndex_; ///< The index of this check point. The race starts with the check point with the index 0
118            std::set<int> nextCheckpoints_; ///< the indexes of the next check points
119            bool bIsLast_; ///< True if this check point is the last of the level. There can be only one last check point for each level and there must be a last check point in the level.
120            float timeLimit_; ///< The time limit (from the start of the level) to reach this check point. If the check point is reached after this time, the game ends and the player looses.
121            std::vector<PlayerInfo*> players_; ///< The player that reached the checkpoint
122            Vector3 myPosition_;
123            std::set<int>  nextCheckpointsVirtual_;
124            std::map<int,int> virtualToRealCheckPoints_; // if virtualChepoint was inserted the original can be reconstructed
125    };
126}
127
128#endif /* _RaceCheckPoint_H__ */
Note: See TracBrowser for help on using the repository browser.