Add heart billboard with red kart for spare tire karts
This commit is contained in:
parent
8889654d96
commit
71359a087d
BIN
data/gui/heart.png
Normal file
BIN
data/gui/heart.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.5 KiB |
@ -142,7 +142,8 @@ void KartGFX::addEffect(KartGFXType type, const std::string &file_name,
|
||||
const Vec3 &position, bool important)
|
||||
{
|
||||
if (!UserConfigParams::m_graphical_effects &&
|
||||
(!important || m_kart->getType() == RaceManager::KT_AI))
|
||||
(!important || m_kart->getType() == RaceManager::KT_AI ||
|
||||
m_kart->getType() == RaceManager::KT_SPARE_TIRE))
|
||||
{
|
||||
m_all_emitters.push_back(NULL);
|
||||
return;
|
||||
|
@ -494,7 +494,7 @@ const std::vector<int> KartPropertiesManager::getKartsInGroup(
|
||||
* to this list.
|
||||
*/
|
||||
void KartPropertiesManager::getRandomKartList(int count,
|
||||
RemoteKartInfoList& existing_karts,
|
||||
RemoteKartInfoList* existing_karts,
|
||||
std::vector<std::string> *ai_list)
|
||||
{
|
||||
// First: set up flags (based on global kart
|
||||
@ -504,18 +504,22 @@ void KartPropertiesManager::getRandomKartList(int count,
|
||||
used.resize(getNumberOfKarts(), false);
|
||||
|
||||
std::vector<std::string> random_kart_queue;
|
||||
for (unsigned int i=0; i<existing_karts.size(); i++)
|
||||
if (existing_karts != NULL)
|
||||
{
|
||||
try
|
||||
for (unsigned int i=0; i<existing_karts->size(); i++)
|
||||
{
|
||||
int id = getKartId(existing_karts[i].getKartName());
|
||||
used[id] = true;
|
||||
}
|
||||
catch (std::runtime_error& ex)
|
||||
{
|
||||
(void)ex;
|
||||
Log::error("[KartPropertiesManager]", "getRandomKartList : WARNING, "
|
||||
"can't find kart '%s'", existing_karts[i].getKartName().c_str());
|
||||
try
|
||||
{
|
||||
int id = getKartId((*existing_karts)[i].getKartName());
|
||||
used[id] = true;
|
||||
}
|
||||
catch (std::runtime_error& ex)
|
||||
{
|
||||
(void)ex;
|
||||
Log::error("[KartPropertiesManager]", "getRandomKartList : "
|
||||
"WARNING, can't find kart '%s'",
|
||||
(*existing_karts)[i].getKartName().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
for(unsigned int i=0; i<ai_list->size(); i++)
|
||||
|
@ -94,7 +94,7 @@ public:
|
||||
void selectKartName(const std::string &kart_name);
|
||||
bool testAndSetKart(int kartid);
|
||||
void getRandomKartList(int count,
|
||||
RemoteKartInfoList& existing_karts,
|
||||
RemoteKartInfoList* existing_karts,
|
||||
std::vector<std::string> *ai_list);
|
||||
void setHatMeshName(const std::string &hat_name);
|
||||
// ------------------------------------------------------------------------
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "karts/kart_properties.hpp"
|
||||
#include "karts/rescue_animation.hpp"
|
||||
#include "karts/controller/local_player_controller.hpp"
|
||||
#include "karts/controller/network_player_controller.hpp"
|
||||
#include "physics/physics.hpp"
|
||||
#include "states_screens/race_gui_base.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
@ -421,11 +422,9 @@ AbstractKart *SoccerWorld::createKart(const std::string &kart_ident, int index,
|
||||
m_num_players ++;
|
||||
break;
|
||||
case RaceManager::KT_NETWORK_PLAYER:
|
||||
break; // Avoid compiler warning about enum not handled.
|
||||
//controller = new NetworkController(kart_ident, position, init_pos,
|
||||
// global_player_id);
|
||||
//m_num_players++;
|
||||
//break;
|
||||
controller = new NetworkPlayerController(new_kart);
|
||||
m_num_players++;
|
||||
break;
|
||||
case RaceManager::KT_AI:
|
||||
controller = loadAIController(new_kart);
|
||||
break;
|
||||
@ -433,6 +432,8 @@ AbstractKart *SoccerWorld::createKart(const std::string &kart_ident, int index,
|
||||
break;
|
||||
case RaceManager::KT_LEADER:
|
||||
break;
|
||||
case RaceManager::KT_SPARE_TIRE:
|
||||
break;
|
||||
}
|
||||
|
||||
new_kart->setController(controller);
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "karts/controller/spare_tire_ai.hpp"
|
||||
#include "karts/kart_model.hpp"
|
||||
#include "karts/kart_properties.hpp"
|
||||
#include "karts/kart_properties_manager.hpp"
|
||||
#include "physics/physics.hpp"
|
||||
#include "states_screens/race_gui_base.hpp"
|
||||
#include "tracks/arena_graph.hpp"
|
||||
@ -102,12 +103,10 @@ void ThreeStrikesBattle::reset()
|
||||
|
||||
for(unsigned int n=0; n<kart_amount; n++)
|
||||
{
|
||||
bool is_sta = false;
|
||||
if (dynamic_cast<SpareTireAI*>(m_karts[n]->getController()) != NULL)
|
||||
{
|
||||
// STA has no life
|
||||
m_kart_info[n].m_lives = 0;
|
||||
is_sta = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -127,11 +126,11 @@ void ThreeStrikesBattle::reset()
|
||||
|
||||
if (core::stringc(curr->getName()) == "tire1")
|
||||
{
|
||||
curr->setVisible(!is_sta);
|
||||
curr->setVisible(true);
|
||||
}
|
||||
else if (core::stringc(curr->getName()) == "tire2")
|
||||
{
|
||||
curr->setVisible(!is_sta);
|
||||
curr->setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -174,6 +173,20 @@ void ThreeStrikesBattle::reset()
|
||||
*/
|
||||
void ThreeStrikesBattle::kartAdded(AbstractKart* kart, scene::ISceneNode* node)
|
||||
{
|
||||
if (kart->getType() == RaceManager::KartType::KT_SPARE_TIRE)
|
||||
{
|
||||
// Add heart billboard above it
|
||||
video::ITexture *heart =
|
||||
irr_driver->getTexture(FileManager::GUI, "heart.png");
|
||||
float height = kart->getKartHeight() + 0.5f;
|
||||
|
||||
scene::ISceneNode* billboard = irr_driver->addBillboard
|
||||
(core::dimension2d<irr::f32>(0.8f, 0.8f), heart, kart->getNode(),
|
||||
true);
|
||||
billboard->setPosition(core::vector3df(0, height, 0));
|
||||
return;
|
||||
}
|
||||
|
||||
float coord = -kart->getKartLength()*0.5f;
|
||||
|
||||
scene::IMeshSceneNode* tire_node = irr_driver->addMesh(m_tire, "3strikestire", node);
|
||||
@ -346,18 +359,6 @@ void ThreeStrikesBattle::update(float dt)
|
||||
WorldWithRank::update(dt);
|
||||
WorldWithRank::updateTrack(dt);
|
||||
|
||||
if (getPhase() == World::GO_PHASE)
|
||||
{
|
||||
// Eliminate all spare tire karts first, they will be spawned if needed
|
||||
for (unsigned int i = 0; i < m_spare_tire_karts.size(); i++)
|
||||
{
|
||||
if (!m_spare_tire_karts[i]->isEliminated())
|
||||
{
|
||||
m_spare_tire_karts[i]->eliminate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
spawnSpareTireKarts();
|
||||
if (m_track->hasNavMesh())
|
||||
updateSectorForKarts();
|
||||
@ -682,7 +683,8 @@ void ThreeStrikesBattle::loadCustomModels()
|
||||
if (all_nodes > 200)
|
||||
{
|
||||
const unsigned int max_sta_num = unsigned(m_karts.size() * 0.8f);
|
||||
unsigned int sta_created = 0;
|
||||
unsigned int pos_created = 0;
|
||||
std::vector<btTransform> pos;
|
||||
for (int i = 0; i < all_nodes; i++)
|
||||
{
|
||||
// Pre-spawn the spare tire karts on the item position,
|
||||
@ -692,22 +694,33 @@ void ThreeStrikesBattle::loadCustomModels()
|
||||
btTransform t;
|
||||
t.setOrigin(item->getXYZ());
|
||||
t.setRotation(item->getRotation());
|
||||
pos.push_back(t);
|
||||
pos_created++;
|
||||
if (pos_created >= max_sta_num) break;
|
||||
}
|
||||
|
||||
AbstractKart* sta = new Kart("nolok", m_karts.size(),
|
||||
m_karts.size() + 1, t, PLAYER_DIFFICULTY_NORMAL, KRT_RED);
|
||||
sta->init(RaceManager::KartType::KT_AI);
|
||||
// Compute a random kart list
|
||||
std::vector<std::string> sta_list;
|
||||
kart_properties_manager->getRandomKartList(pos.size(), NULL,
|
||||
&sta_list);
|
||||
|
||||
assert(sta_list.size() == pos.size());
|
||||
// Now add them
|
||||
for (unsigned int i = 0; i < pos.size(); i++)
|
||||
{
|
||||
AbstractKart* sta = new Kart(sta_list[i], m_karts.size(),
|
||||
m_karts.size() + 1, pos[i], PLAYER_DIFFICULTY_NORMAL,
|
||||
KRT_RED);
|
||||
sta->init(RaceManager::KartType::KT_SPARE_TIRE);
|
||||
sta->setController(new SpareTireAI(sta));
|
||||
|
||||
m_karts.push_back(sta);
|
||||
race_manager->addSpareTireKartStatus();
|
||||
race_manager->addSpareTireKartStatus(sta_list[i]);
|
||||
m_track->adjustForFog(sta->getNode());
|
||||
|
||||
// Copy STA pointer to m_spare_tire_karts array, allowing them
|
||||
// to respawn easily
|
||||
m_spare_tire_karts.push_back(sta);
|
||||
|
||||
sta_created++;
|
||||
if (sta_created >= max_sta_num) break;
|
||||
}
|
||||
race_manager->setNumKarts(m_karts.size());
|
||||
}
|
||||
|
@ -372,6 +372,8 @@ AbstractKart *World::createKart(const std::string &kart_ident, int index,
|
||||
break;
|
||||
case RaceManager::KT_LEADER:
|
||||
break;
|
||||
case RaceManager::KT_SPARE_TIRE:
|
||||
break;
|
||||
}
|
||||
|
||||
new_kart->setController(controller);
|
||||
|
@ -288,7 +288,7 @@ void RaceManager::computeRandomKartList()
|
||||
}
|
||||
|
||||
if(n>0)
|
||||
kart_properties_manager->getRandomKartList(n, m_player_karts,
|
||||
kart_properties_manager->getRandomKartList(n, &m_player_karts,
|
||||
&m_ai_kart_list );
|
||||
|
||||
if (m_ai_kart_override != "")
|
||||
|
@ -236,9 +236,10 @@ public:
|
||||
DIFFICULTY_COUNT};
|
||||
|
||||
/** Different kart types: A local player, a player connected via network,
|
||||
* an AI kart, the leader kart (currently not used), a ghost kart. */
|
||||
* an AI kart, the leader kart (currently not used), a ghost kart and
|
||||
* spare tire karts which allow gain life in battle mode */
|
||||
enum KartType { KT_PLAYER, KT_NETWORK_PLAYER, KT_AI, KT_LEADER,
|
||||
KT_GHOST };
|
||||
KT_GHOST, KT_SPARE_TIRE };
|
||||
private:
|
||||
|
||||
bool m_started_from_overworld;
|
||||
@ -752,10 +753,10 @@ public:
|
||||
return m_watching_replay;
|
||||
} // isWatchingReplay
|
||||
// ------------------------------------------------------------------------
|
||||
void addSpareTireKartStatus()
|
||||
void addSpareTireKartStatus(const std::string& name)
|
||||
{
|
||||
m_kart_status.push_back(KartStatus("nolok", 0, -1, -1,
|
||||
-1, KT_AI, PLAYER_DIFFICULTY_NORMAL));
|
||||
m_kart_status.push_back(KartStatus(name, 0, -1, -1,
|
||||
-1, KT_SPARE_TIRE, PLAYER_DIFFICULTY_NORMAL));
|
||||
} // addSpareTireKartStatus
|
||||
|
||||
}; // RaceManager
|
||||
|
@ -385,7 +385,9 @@ void RaceGUI::drawGlobalMiniMap()
|
||||
world->getTrack()->mapPoint2MiniMap(xyz, &draw_at);
|
||||
draw_at *= UserConfigParams::m_scale_rtts_factor;
|
||||
|
||||
video::ITexture* icon = kart->getKartProperties()->getMinimapIcon();
|
||||
video::ITexture* icon = sta ?
|
||||
irr_driver->getTexture(FileManager::GUI, "heart.png") :
|
||||
kart->getKartProperties()->getMinimapIcon();
|
||||
|
||||
// int marker_height = m_marker->getSize().Height;
|
||||
core::rect<s32> source(core::position2di(0, 0), icon->getSize());
|
||||
|
Loading…
Reference in New Issue
Block a user