Add support for challenges in reverse mode
This commit is contained in:
parent
63ba99457e
commit
6af8f70b48
@ -39,6 +39,7 @@ ChallengeData::ChallengeData(const std::string& filename)
|
|||||||
m_mode = CM_SINGLE_RACE;
|
m_mode = CM_SINGLE_RACE;
|
||||||
m_minor = RaceManager::MINOR_MODE_NORMAL_RACE;
|
m_minor = RaceManager::MINOR_MODE_NORMAL_RACE;
|
||||||
m_num_laps = -1;
|
m_num_laps = -1;
|
||||||
|
m_reverse = false;
|
||||||
m_track_id = "";
|
m_track_id = "";
|
||||||
m_gp_id = "";
|
m_gp_id = "";
|
||||||
m_version = 0;
|
m_version = 0;
|
||||||
@ -182,6 +183,12 @@ ChallengeData::ChallengeData(const std::string& filename)
|
|||||||
{
|
{
|
||||||
error("laps");
|
error("laps");
|
||||||
}
|
}
|
||||||
|
if (!track_node->get("reverse", &m_reverse))
|
||||||
|
{
|
||||||
|
Log::warn("Challenge Data",
|
||||||
|
"No reverse mode specified for challenge %s, defaulting to normal",
|
||||||
|
filename.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (gp_node != NULL)
|
else if (gp_node != NULL)
|
||||||
{
|
{
|
||||||
@ -283,6 +290,10 @@ const irr::core::stringw ChallengeData::getChallengeDescription() const
|
|||||||
// Follow the leader mode:
|
// Follow the leader mode:
|
||||||
description = _("Follow the leader");
|
description = _("Follow the leader");
|
||||||
}
|
}
|
||||||
|
if (m_reverse == true)
|
||||||
|
{
|
||||||
|
description += _("Reverse");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return description;
|
return description;
|
||||||
} // getChallengeDescription
|
} // getChallengeDescription
|
||||||
@ -397,6 +408,7 @@ void ChallengeData::setRace(RaceManager::Difficulty d) const
|
|||||||
race_manager->setMinorMode(m_minor);
|
race_manager->setMinorMode(m_minor);
|
||||||
race_manager->setTrack(m_track_id);
|
race_manager->setTrack(m_track_id);
|
||||||
race_manager->setNumLaps(m_num_laps);
|
race_manager->setNumLaps(m_num_laps);
|
||||||
|
race_manager->setReverseTrack(m_reverse);
|
||||||
race_manager->setNumKarts(m_default_num_karts[d]);
|
race_manager->setNumKarts(m_default_num_karts[d]);
|
||||||
race_manager->setNumPlayers(1);
|
race_manager->setNumPlayers(1);
|
||||||
race_manager->setCoinTarget(m_energy[d]);
|
race_manager->setCoinTarget(m_energy[d]);
|
||||||
@ -460,7 +472,7 @@ bool ChallengeData::isChallengeFulfilled() const
|
|||||||
|
|
||||||
if (kart->isEliminated() ) return false;
|
if (kart->isEliminated() ) return false;
|
||||||
if (track_name != m_track_id ) return false;
|
if (track_name != m_track_id ) return false;
|
||||||
if ((int)world->getNumKarts() < m_default_num_karts[d] ) return false;
|
if ((int)world->getNumKarts() < m_default_num_karts[d] ) return false;
|
||||||
if (m_energy[d] > 0 && kart->getEnergy() < m_energy[d] ) return false;
|
if (m_energy[d] > 0 && kart->getEnergy() < m_energy[d] ) return false;
|
||||||
if (m_position[d] > 0 && kart->getPosition() > m_position[d]) return false;
|
if (m_position[d] > 0 && kart->getPosition() > m_position[d]) return false;
|
||||||
|
|
||||||
|
@ -94,6 +94,7 @@ private:
|
|||||||
RaceManager::MinorRaceModeType m_minor;
|
RaceManager::MinorRaceModeType m_minor;
|
||||||
|
|
||||||
int m_num_laps;
|
int m_num_laps;
|
||||||
|
bool m_reverse;
|
||||||
int m_position[RaceManager::DIFFICULTY_COUNT];
|
int m_position[RaceManager::DIFFICULTY_COUNT];
|
||||||
int m_default_num_karts[RaceManager::DIFFICULTY_COUNT];
|
int m_default_num_karts[RaceManager::DIFFICULTY_COUNT];
|
||||||
std::string m_ai_kart_ident[RaceManager::DIFFICULTY_COUNT];
|
std::string m_ai_kart_ident[RaceManager::DIFFICULTY_COUNT];
|
||||||
@ -184,6 +185,9 @@ public:
|
|||||||
return m_num_laps;
|
return m_num_laps;
|
||||||
} // getNumLaps
|
} // getNumLaps
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
/** Return reverse mode. */
|
||||||
|
bool getReverse() const { return m_reverse; }
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** Get number of required trophies to start this challenge */
|
/** Get number of required trophies to start this challenge */
|
||||||
int getNumTrophies() const { return m_num_trophies; }
|
int getNumTrophies() const { return m_num_trophies; }
|
||||||
|
@ -211,7 +211,6 @@ GUIEngine::EventPropagation SelectChallengeDialog::processEvent(const std::strin
|
|||||||
// Set up race manager appropriately
|
// Set up race manager appropriately
|
||||||
race_manager->setNumPlayers(1);
|
race_manager->setNumPlayers(1);
|
||||||
race_manager->setPlayerKart(0, UserConfigParams::m_default_kart);
|
race_manager->setPlayerKart(0, UserConfigParams::m_default_kart);
|
||||||
race_manager->setReverseTrack(false);
|
|
||||||
|
|
||||||
//int id = StateManager::get()->createActivePlayer( unlock_manager->getCurrentPlayer(), device );
|
//int id = StateManager::get()->createActivePlayer( unlock_manager->getCurrentPlayer(), device );
|
||||||
input_manager->getDeviceManager()->setSinglePlayer( StateManager::get()->getActivePlayer(0) );
|
input_manager->getDeviceManager()->setSinglePlayer( StateManager::get()->getActivePlayer(0) );
|
||||||
|
Loading…
Reference in New Issue
Block a user