1 //  SuperTuxKart - a fun racing game with go-kart
2 //  Copyright (C) 2004-2015 SuperTuxKart-Team
3 //
4 //  This program is free software; you can redistribute it and/or
5 //  modify it under the terms of the GNU General Public License
6 //  as published by the Free Software Foundation; either version 3
7 //  of the License, or (at your option) any later version.
8 //
9 //  This program is distributed in the hope that it will be useful,
10 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 //  GNU General Public License for more details.
13 //
14 //  You should have received a copy of the GNU General Public License
15 //  along with this program; if not, write to the Free Software
16 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17 
18 #ifndef _follow_the_leader_hpp_
19 #define _follow_the_leader_hpp_
20 
21 #include "modes/linear_world.hpp"
22 
23 /**
24   * \brief An implementation of World, based on LinearWorld, to provide the Follow-the-leader game mode
25   * \ingroup modes
26   */
27 class FollowTheLeaderRace : public LinearWorld
28 {
29 private:
30         // time till elimination in follow leader
31     std::vector<float>  m_leader_intervals;
32 
33     /** A timer used before terminating the race. */
34     float m_is_over_delay;
35 
36     /** Time the last kart was eliminated. It is used to assign each
37      *  kart a 'finish' time (i.e. how long they lasted). */
38     float m_last_eliminated_time;
39 public:
40 
41              FollowTheLeaderRace();
42     virtual ~FollowTheLeaderRace();
43 
44     // clock events
45     virtual void countdownReachedZero() OVERRIDE;
46     virtual int  getScoreForPosition(int p) OVERRIDE;
47 
48     // overriding World methods
49     virtual void reset(bool restart=false) OVERRIDE;
50     virtual const std::string& getIdent() const OVERRIDE;
51     virtual const btTransform &getStartTransform(int index) OVERRIDE;
52     virtual void getKartsDisplayInfo(
53                  std::vector<RaceGUIBase::KartIconDisplayInfo> *info) OVERRIDE;
54     virtual void init() OVERRIDE;
55     virtual void terminateRace() OVERRIDE;
56     virtual bool isRaceOver() OVERRIDE;
57     // ------------------------------------------------------------------------
58     /** Returns if this type of race has laps. */
raceHasLaps()59     virtual bool raceHasLaps() OVERRIDE { return false; }
60     // ------------------------------------------------------------------------
61     /** Returns if faster music should be used at the end. */
useFastMusicNearEnd() const62     virtual bool useFastMusicNearEnd() const OVERRIDE { return false; }
63 
isLeader(int kart_id)64     bool isLeader(int kart_id) { return (kart_id == 0); }
65     void leaderHit();
66     // For now, use a similar countdown change as with leaderHit
leaderRescued()67     void leaderRescued() { leaderHit(); }
68 };   // FollowTheLeader
69 
70 
71 #endif
72