SuperTuxKart
Loading...
Searching...
No Matches
three_strikes_battle.hpp
1//
2// SuperTuxKart - a fun racing game with go-kart
3// Copyright (C) 2004-2015 SuperTuxKart-Team
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 THREE_STRIKES_BATTLE_HPP
20#define THREE_STRIKES_BATTLE_HPP
21
22
23#include "modes/world_with_rank.hpp"
24#include "tracks/track_object.hpp"
25#include "states_screens/race_gui_base.hpp"
26
27#include <string>
28
29class PhysicalObject;
30
37{
38private:
39
40 // This struct is used to sort karts by time/lives
42 {
43 int id;
44 int time;
45 int lives;
46
47 bool operator < (const KartValues& k) const
48 {
49 return (time == k.time) ? (lives < k.lives) : (time < k.time);
50 } // operator <
51 }; // KartValues
52
54 {
55 int m_lives;
56 };
57
60 std::vector<BattleInfo> m_kart_info;
61
63 irr::scene::IMesh* m_tire;
64
68
70 core::vector3df m_tire_position;
71
73 core::vector3df m_tire_offsets[4];
74
76 float m_tire_radius[4];
77
79 std::string m_tire_dir;
80
83
85
88 int m_frame_count;
89 int m_start_time;
90 int m_total_hit;
91
92 std::vector<AbstractKart*> m_spare_tire_karts;
93 int m_next_sta_spawn_ticks;
94
95public:
98 {
99 float m_time;
100 std::vector<BattleInfo> m_kart_info;
101 };
102 // ------------------------------------------------------------------------
103 std::vector<BattleEvent> m_battle_events;
104 // ------------------------------------------------------------------------
106 // ------------------------------------------------------------------------
107 virtual ~ThreeStrikesBattle();
108 // ------------------------------------------------------------------------
109 virtual void init() OVERRIDE;
110 // ------------------------------------------------------------------------
111 // clock events
112 virtual bool isRaceOver() OVERRIDE;
113 // ------------------------------------------------------------------------
114 virtual void terminateRace() OVERRIDE;
115 // ------------------------------------------------------------------------
116 // overriding World methods
117 virtual void reset(bool restart=false) OVERRIDE;
118 // ------------------------------------------------------------------------
119 virtual void getKartsDisplayInfo(
120 std::vector<RaceGUIBase::KartIconDisplayInfo> *info) OVERRIDE;
121 // ------------------------------------------------------------------------
122 virtual bool raceHasLaps() OVERRIDE { return false; }
123 // ------------------------------------------------------------------------
124 virtual const std::string& getIdent() const OVERRIDE;
125 // ------------------------------------------------------------------------
126 virtual bool kartHit(int kart_id, int hitter = -1) OVERRIDE;
127 // ------------------------------------------------------------------------
128 virtual void update(int ticks) OVERRIDE;
129 // ------------------------------------------------------------------------
130 virtual void kartAdded(AbstractKart* kart, scene::ISceneNode* node)
131 OVERRIDE;
132 // ------------------------------------------------------------------------
133 virtual void enterRaceOverState() OVERRIDE;
134 // ------------------------------------------------------------------------
135 virtual void loadCustomModels() OVERRIDE;
136 // ------------------------------------------------------------------------
137 void updateKartRanks();
138 // ------------------------------------------------------------------------
139 void increaseRescueCount() { m_total_rescue++; }
140 // ------------------------------------------------------------------------
141 void addKartLife(unsigned int id);
142 // ------------------------------------------------------------------------
143 int getKartLife(unsigned int id) const { return m_kart_info[id].m_lives; }
144 // ------------------------------------------------------------------------
145 bool spareTireKartsSpawned() const;
146 // ------------------------------------------------------------------------
147 void spawnSpareTireKarts();
148
149}; // ThreeStrikesBattles
150
151
152#endif
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:62
Definition: physical_object.hpp:40
Definition: ptr_vector.hpp:44
An abstract base class for the two race guis (race_gui and race_result gui)
Definition: race_gui_base.hpp:50
An implementation of WorldWithRank, to provide the 3 strikes battle game mode.
Definition: three_strikes_battle.hpp:37
virtual bool kartHit(int kart_id, int hitter=-1) OVERRIDE
Called when a kart is hit.
Definition: three_strikes_battle.cpp:216
virtual void terminateRace() OVERRIDE
Called when the race finishes, i.e.
Definition: three_strikes_battle.cpp:498
float m_tire_radius[4]
The radius of the karts original tires.
Definition: three_strikes_battle.hpp:76
virtual void kartAdded(AbstractKart *kart, scene::ISceneNode *node) OVERRIDE
Adds two tires to each of the kart.
Definition: three_strikes_battle.cpp:178
virtual void reset(bool restart=false) OVERRIDE
Called when a battle is restarted.
Definition: three_strikes_battle.cpp:98
int m_total_rescue
Profiling usage.
Definition: three_strikes_battle.hpp:87
virtual bool raceHasLaps() OVERRIDE
Called when it is needed to know whether this kind of race involves counting laps.
Definition: three_strikes_battle.hpp:122
virtual void enterRaceOverState() OVERRIDE
Called when the race is finished, but it still leaves some time for an end of race animation,...
Definition: three_strikes_battle.cpp:542
int m_insert_tire
Indicates the number of tires that should be inserted into the track.
Definition: three_strikes_battle.hpp:67
virtual bool isRaceOver() OVERRIDE
The battle is over if only one kart is left, or no player kart.
Definition: three_strikes_battle.cpp:477
virtual void getKartsDisplayInfo(std::vector< RaceGUIBase::KartIconDisplayInfo > *info) OVERRIDE
Returns the data to display in the race gui.
Definition: three_strikes_battle.cpp:507
std::string m_tire_dir
The directory of the original kart tires.
Definition: three_strikes_battle.hpp:79
core::vector3df m_tire_position
For tires that are blown away.
Definition: three_strikes_battle.hpp:70
std::vector< BattleInfo > m_kart_info
This vector contains an 'BattleInfo' struct for every kart in the race.
Definition: three_strikes_battle.hpp:60
float m_tire_rotation
A rotation to apply to the tires when inserting them.
Definition: three_strikes_battle.hpp:82
virtual void update(int ticks) OVERRIDE
Update the world and the track.
Definition: three_strikes_battle.cpp:357
ThreeStrikesBattle()
Constructor.
Definition: three_strikes_battle.cpp:51
virtual void init() OVERRIDE
Initialises the three strikes battle.
Definition: three_strikes_battle.cpp:72
virtual ~ThreeStrikesBattle()
Destructor.
Definition: three_strikes_battle.cpp:83
core::vector3df m_tire_offsets[4]
The original locations of the tires of a kart.
Definition: three_strikes_battle.hpp:73
irr::scene::IMesh * m_tire
The mesh of the tire which is displayed when a kart loses a life.
Definition: three_strikes_battle.hpp:63
void updateKartRanks()
Updates the ranking of the karts.
Definition: three_strikes_battle.cpp:445
virtual const std::string & getIdent() const OVERRIDE
Returns the internal identifier for this race.
Definition: three_strikes_battle.cpp:348
A WorldWithRank is a world where the karts are ranked.
Definition: world_with_rank.hpp:39
Used to show a nice graph when battle is over.
Definition: three_strikes_battle.hpp:98
Definition: three_strikes_battle.hpp:54
Definition: three_strikes_battle.hpp:42