SuperTuxKart
easter_egg_hunt.hpp
1 //
2 // SuperTuxKart - a fun racing game with go-kart
3 // Copyright (C) 2012-2015 Joerg Henrichs
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 3
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 
19 #ifndef EASTER_EGG_HUNT_HPP
20 #define EASTER_EGG_HUNT_HPP
21 
22 #include "modes/linear_world.hpp"
23 #include "states_screens/race_gui_base.hpp"
24 #include "utils/cpp2011.hpp"
25 
26 #include <string>
27 #include <vector>
28 
29 class AbstractKart;
30 
36 {
37 private:
39  std::vector<int> m_eggs_collected;
40 
43 
46 
47  bool m_only_ghosts;
48 
49  float m_finish_time;
50 public:
51  EasterEggHunt();
52  virtual ~EasterEggHunt();
53 
54  virtual void init() OVERRIDE;
55 
56  virtual bool isRaceOver() OVERRIDE;
57 
58  // overriding World methods
59  virtual void reset(bool restart=false) OVERRIDE;
60 
61  virtual bool raceHasLaps() OVERRIDE { return false; }
62 
63  virtual const std::string& getIdent() const OVERRIDE;
64  virtual void terminateRace() OVERRIDE;
65  virtual void update(int ticks) OVERRIDE;
66  virtual void getKartsDisplayInfo(
67  std::vector<RaceGUIBase::KartIconDisplayInfo> *info) OVERRIDE;
68  virtual void collectedItem(const AbstractKart *kart,
69  const ItemState *item ) OVERRIDE;
70  void collectedEasterEggGhost(int world_id);
71 
72  const int numberOfEggsFound() { return m_eggs_found; }
73  const int numberOfEggsToFind() { return m_number_of_eggs; }
74 
75  void updateKartRanks();
76  void readData(const std::string &filename);
77 
78  virtual void checkForWrongDirection(unsigned int i, float dt) OVERRIDE;
79  virtual float estimateFinishTimeForKart(AbstractKart* kart) OVERRIDE;
80 
81 }; // EasterEggHunt
82 
83 
84 #endif
An abstract base class for the two race guis (race_gui and race_result gui)
Definition: race_gui_base.hpp:49
EasterEggHunt()
Constructor.
Definition: easter_egg_hunt.cpp:32
virtual bool isRaceOver() OVERRIDE
The hunt is over once all eggs are found.
Definition: easter_egg_hunt.cpp:181
virtual void terminateRace() OVERRIDE
Called at the end of a race.
Definition: easter_egg_hunt.cpp:243
virtual void reset(bool restart=false) OVERRIDE
Called when an egg hunt is restarted.
Definition: easter_egg_hunt.cpp:205
An implementation of World to provide an easter egg hunt like mode.
Definition: easter_egg_hunt.hpp:35
virtual bool raceHasLaps() OVERRIDE
Returns if this race mode has laps.
Definition: easter_egg_hunt.hpp:61
virtual void update(int ticks) OVERRIDE
Update the world and the track.
Definition: easter_egg_hunt.cpp:172
int m_number_of_eggs
Overall number of easter eggs.
Definition: easter_egg_hunt.hpp:42
virtual void init() OVERRIDE
Initialises the easer egg hunt.
Definition: easter_egg_hunt.cpp:44
virtual ~EasterEggHunt()
Destructor.
Definition: easter_egg_hunt.cpp:70
void readData(const std::string &filename)
Check if a file easter_eggs.xml exists in the track directory, and if so loads that file and makes th...
Definition: easter_egg_hunt.cpp:78
virtual float estimateFinishTimeForKart(AbstractKart *kart) OVERRIDE
In Easter Egg mode the finish time is just the time the race is over, since there are no AI karts and...
Definition: easter_egg_hunt.cpp:252
std::vector< int > m_eggs_collected
Keeps track of how many eggs each kart has found.
Definition: easter_egg_hunt.hpp:39
virtual void checkForWrongDirection(unsigned int i, float dt) OVERRIDE
Override the base class method to change behavior.
Definition: easter_egg_hunt.cpp:237
Definition: linear_world.hpp:35
void collectedEasterEggGhost(int world_id)
Called when a ghost kart has collected an egg.
Definition: easter_egg_hunt.cpp:163
virtual void collectedItem(const AbstractKart *kart, const ItemState *item) OVERRIDE
Called when a kart has collected an egg.
Definition: easter_egg_hunt.cpp:150
virtual const std::string & getIdent() const OVERRIDE
Returns the internal identifier for this race.
Definition: easter_egg_hunt.cpp:141
virtual void getKartsDisplayInfo(std::vector< RaceGUIBase::KartIconDisplayInfo > *info) OVERRIDE
Returns the data to display in the race gui.
Definition: easter_egg_hunt.cpp:218
int m_eggs_found
Number of eggs found so far by players.
Definition: easter_egg_hunt.hpp:45
Contains the state information of an item, i.e.
Definition: item.hpp:52
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:61