Add indication for collected flags in GUI and map
This commit is contained in:
parent
1becb50cf8
commit
73ac4f165b
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
@ -44,6 +44,7 @@ const int g_captured_score = 10;
|
||||
CaptureTheFlag::CaptureTheFlag() : FreeForAll()
|
||||
{
|
||||
m_red_flag_node = m_blue_flag_node = NULL;
|
||||
m_red_flag_indicator = m_blue_flag_indicator = NULL;
|
||||
m_red_flag_mesh = m_blue_flag_mesh = NULL;
|
||||
m_scored_sound = NULL;
|
||||
#ifndef SERVER_ONLY
|
||||
@ -87,6 +88,20 @@ void CaptureTheFlag::init()
|
||||
"blue_flag");
|
||||
assert(m_red_flag_node);
|
||||
assert(m_blue_flag_node);
|
||||
|
||||
std::string red_path =
|
||||
file_manager->getAsset(FileManager::GUI, "red_arrow.png");
|
||||
std::string blue_path =
|
||||
file_manager->getAsset(FileManager::GUI, "blue_arrow.png");
|
||||
|
||||
m_red_flag_indicator = irr_driver->addBillboard(
|
||||
core::dimension2df(1.5f, 1.5f), red_path, NULL);
|
||||
m_red_flag_indicator->setPosition(Vec3(
|
||||
m_orig_red_trans(Vec3(0.0f, 2.5f, 0.0f))).toIrrVector());
|
||||
m_blue_flag_indicator = irr_driver->addBillboard(
|
||||
core::dimension2df(1.5f, 1.5f), blue_path, NULL);
|
||||
m_blue_flag_indicator->setPosition(Vec3(
|
||||
m_orig_blue_trans(Vec3(0.0f, 2.5f, 0.0f))).toIrrVector());
|
||||
#endif
|
||||
} // init
|
||||
|
||||
@ -128,6 +143,8 @@ void CaptureTheFlag::updateGraphics(float dt)
|
||||
}
|
||||
else
|
||||
m_blue_flag_node->setAnimationSpeed(25.0f);
|
||||
m_red_flag_indicator->setVisible(!isRedFlagInBase());
|
||||
m_blue_flag_indicator->setVisible(!isBlueFlagInBase());
|
||||
}
|
||||
} // updateGraphics
|
||||
|
||||
|
@ -27,7 +27,7 @@ namespace irr
|
||||
{
|
||||
namespace scene
|
||||
{
|
||||
class IAnimatedMeshSceneNode; class IAnimatedMesh;
|
||||
class IAnimatedMeshSceneNode; class IAnimatedMesh; class ISceneNode;
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,9 +38,13 @@ private:
|
||||
|
||||
scene::IAnimatedMeshSceneNode* m_blue_flag_node;
|
||||
|
||||
irr::scene::IAnimatedMesh* m_red_flag_mesh;
|
||||
scene::IAnimatedMesh* m_red_flag_mesh;
|
||||
|
||||
irr::scene::IAnimatedMesh* m_blue_flag_mesh;
|
||||
scene::IAnimatedMesh* m_blue_flag_mesh;
|
||||
|
||||
scene::ISceneNode* m_red_flag_indicator;
|
||||
|
||||
scene::ISceneNode* m_blue_flag_indicator;
|
||||
|
||||
SFXBase* m_scored_sound;
|
||||
|
||||
@ -110,6 +114,18 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
int getBlueHolder() const { return m_blue_holder; }
|
||||
// ------------------------------------------------------------------------
|
||||
bool isRedFlagInBase() const
|
||||
{
|
||||
return m_red_holder == -1 &&
|
||||
m_red_trans.getOrigin() == m_orig_red_trans.getOrigin();
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
bool isBlueFlagInBase() const
|
||||
{
|
||||
return m_blue_holder == -1 &&
|
||||
m_blue_trans.getOrigin() == m_orig_blue_trans.getOrigin();
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
const Vec3& getRedFlag() const { return (Vec3&)m_red_trans.getOrigin(); }
|
||||
// ------------------------------------------------------------------------
|
||||
const Vec3& getBlueFlag() const { return (Vec3&)m_blue_trans.getOrigin(); }
|
||||
|
@ -1512,9 +1512,9 @@ void World::initTeamArrows()
|
||||
|
||||
//Loading the indicator textures
|
||||
std::string red_path =
|
||||
file_manager->getAsset(FileManager::GUI, "soccer_player_red.png");
|
||||
file_manager->getAsset(FileManager::GUI, "red_arrow.png");
|
||||
std::string blue_path =
|
||||
file_manager->getAsset(FileManager::GUI, "soccer_player_blue.png");
|
||||
file_manager->getAsset(FileManager::GUI, "blue_arrow.png");
|
||||
|
||||
//Assigning indicators
|
||||
for(unsigned int i = 0; i < kart_amount; i++)
|
||||
|
@ -519,11 +519,21 @@ void RaceGUI::drawGlobalMiniMap()
|
||||
if (ctf)
|
||||
{
|
||||
Vec3 draw_at;
|
||||
track->mapPoint2MiniMap(ctf->getRedFlag(), &draw_at);
|
||||
|
||||
video::ITexture* icon =
|
||||
irr_driver->getTexture(FileManager::GUI, "red_flag.png");
|
||||
if (!ctf->isRedFlagInBase())
|
||||
{
|
||||
track->mapPoint2MiniMap(Track::getCurrentTrack()->getRedFlag().getOrigin(),
|
||||
&draw_at);
|
||||
core::rect<s32> rs(core::position2di(0, 0), icon->getSize());
|
||||
core::rect<s32> rp(m_map_left+(int)(draw_at.getX()-(m_minimap_player_size/1.4f)),
|
||||
lower_y -(int)(draw_at.getY()+(m_minimap_player_size/2.2f)),
|
||||
m_map_left+(int)(draw_at.getX()+(m_minimap_player_size/1.4f)),
|
||||
lower_y -(int)(draw_at.getY()-(m_minimap_player_size/2.2f)));
|
||||
draw2DImage(icon, rp, rs, NULL, NULL, true, true);
|
||||
}
|
||||
|
||||
track->mapPoint2MiniMap(ctf->getRedFlag(), &draw_at);
|
||||
core::rect<s32> rs(core::position2di(0, 0), icon->getSize());
|
||||
core::rect<s32> rp(m_map_left+(int)(draw_at.getX()-(m_minimap_player_size/1.4f)),
|
||||
lower_y -(int)(draw_at.getY()+(m_minimap_player_size/2.2f)),
|
||||
@ -531,10 +541,20 @@ void RaceGUI::drawGlobalMiniMap()
|
||||
lower_y -(int)(draw_at.getY()-(m_minimap_player_size/2.2f)));
|
||||
draw2DImage(icon, rp, rs, NULL, NULL, true);
|
||||
|
||||
track->mapPoint2MiniMap(ctf->getBlueFlag(), &draw_at);
|
||||
|
||||
icon = irr_driver->getTexture(FileManager::GUI, "blue_flag.png");
|
||||
if (!ctf->isBlueFlagInBase())
|
||||
{
|
||||
track->mapPoint2MiniMap(Track::getCurrentTrack()->getBlueFlag().getOrigin(),
|
||||
&draw_at);
|
||||
core::rect<s32> rs(core::position2di(0, 0), icon->getSize());
|
||||
core::rect<s32> rp(m_map_left+(int)(draw_at.getX()-(m_minimap_player_size/1.4f)),
|
||||
lower_y -(int)(draw_at.getY()+(m_minimap_player_size/2.2f)),
|
||||
m_map_left+(int)(draw_at.getX()+(m_minimap_player_size/1.4f)),
|
||||
lower_y -(int)(draw_at.getY()-(m_minimap_player_size/2.2f)));
|
||||
draw2DImage(icon, rp, rs, NULL, NULL, true, true);
|
||||
}
|
||||
|
||||
track->mapPoint2MiniMap(ctf->getBlueFlag(), &draw_at);
|
||||
core::rect<s32> bs(core::position2di(0, 0), icon->getSize());
|
||||
core::rect<s32> bp(m_map_left+(int)(draw_at.getX()-(m_minimap_player_size/1.4f)),
|
||||
lower_y -(int)(draw_at.getY()+(m_minimap_player_size/2.2f)),
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "io/file_manager.hpp"
|
||||
#include "io/xml_node.hpp"
|
||||
#include "modes/world.hpp"
|
||||
#include "race/race_manager.hpp"
|
||||
#include "tracks/check_lap.hpp"
|
||||
#include "tracks/check_line.hpp"
|
||||
#include "tracks/check_manager.hpp"
|
||||
@ -724,3 +725,13 @@ DriveNode* DriveGraph::getNode(unsigned int j) const
|
||||
assert(n != NULL);
|
||||
return n;
|
||||
} // getNode
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
bool DriveGraph::hasLapLine() const
|
||||
{
|
||||
if (Track::getCurrentTrack()->isCTF() &&
|
||||
race_manager->getMajorMode() ==
|
||||
RaceManager::MAJOR_MODE_CAPTURE_THE_FLAG)
|
||||
return false;
|
||||
return true;
|
||||
} // hasLapLine
|
||||
|
@ -69,7 +69,7 @@ private:
|
||||
// ------------------------------------------------------------------------
|
||||
unsigned int getStartNode() const;
|
||||
// ------------------------------------------------------------------------
|
||||
virtual bool hasLapLine() const OVERRIDE { return true; }
|
||||
virtual bool hasLapLine() const OVERRIDE;
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void differentNodeColor(int n, video::SColor* c) const OVERRIDE;
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "graphics/sp/sp_mesh.hpp"
|
||||
#include "graphics/sp/sp_mesh_buffer.hpp"
|
||||
#include "modes/profile_world.hpp"
|
||||
#include "race/race_manager.hpp"
|
||||
#include "tracks/arena_node_3d.hpp"
|
||||
#include "tracks/drive_node_2d.hpp"
|
||||
#include "tracks/drive_node_3d.hpp"
|
||||
@ -420,6 +421,21 @@ RenderTarget* Graph::makeMiniMap(const core::dimension2du &dimension,
|
||||
}
|
||||
#endif
|
||||
|
||||
// Adjust bounding boxes for flags in CTF
|
||||
if (Track::getCurrentTrack()->isCTF() &&
|
||||
race_manager->getMajorMode() == RaceManager::MAJOR_MODE_CAPTURE_THE_FLAG)
|
||||
{
|
||||
Vec3 red_flag = Track::getCurrentTrack()->getRedFlag().getOrigin();
|
||||
Vec3 blue_flag = Track::getCurrentTrack()->getBlueFlag().getOrigin();
|
||||
// In case the flag is placed outside of the graph, we scale it a bit
|
||||
red_flag *= 1.1f;
|
||||
blue_flag *= 1.1f;
|
||||
m_bb_max.max(red_flag);
|
||||
m_bb_max.max(blue_flag);
|
||||
m_bb_min.min(red_flag);
|
||||
m_bb_min.min(blue_flag);
|
||||
}
|
||||
|
||||
m_node = irr_driver->addMesh(m_mesh, "mini_map");
|
||||
#ifdef DEBUG
|
||||
m_node->setName("minimap-mesh");
|
||||
|
@ -1826,6 +1826,25 @@ void Track::loadTrackModel(bool reverse_track, unsigned int mode_id)
|
||||
// the race gui was created. The race gui is needed since it stores
|
||||
// the information about the size of the texture to render the mini
|
||||
// map to.
|
||||
// Load the un-raycasted flag position first (for minimap)
|
||||
if (m_is_ctf &&
|
||||
race_manager->getMajorMode() == RaceManager::MAJOR_MODE_CAPTURE_THE_FLAG)
|
||||
{
|
||||
for (unsigned int i=0; i<root->getNumNodes(); i++)
|
||||
{
|
||||
const XMLNode *node = root->getNode(i);
|
||||
const std::string &name = node->getName();
|
||||
if (name == "red-flag")
|
||||
{
|
||||
m_red_flag.setOrigin(flagCommand(node));
|
||||
}
|
||||
else if (name == "blue-flag")
|
||||
{
|
||||
m_blue_flag.setOrigin(flagCommand(node));
|
||||
}
|
||||
} // for i<root->getNumNodes()
|
||||
}
|
||||
|
||||
if (!m_is_arena && !m_is_soccer && !m_is_cutscene)
|
||||
loadDriveGraph(mode_id, reverse_track);
|
||||
else if ((m_is_arena || m_is_soccer) && !m_is_cutscene && m_has_navmesh)
|
||||
@ -2422,7 +2441,7 @@ void Track::handleSky(const XMLNode &xml_node, const std::string &filename)
|
||||
} // handleSky
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void Track::flagCommand(const XMLNode *node)
|
||||
Vec3 Track::flagCommand(const XMLNode *node)
|
||||
{
|
||||
Vec3 xyz;
|
||||
// Set some kind of default in case Y is not defined in the file
|
||||
@ -2431,6 +2450,9 @@ void Track::flagCommand(const XMLNode *node)
|
||||
xyz.setY(1000);
|
||||
node->getXYZ(&xyz);
|
||||
|
||||
if (!m_track_mesh)
|
||||
return xyz;
|
||||
|
||||
Vec3 loc(xyz);
|
||||
|
||||
// Test if the item lies on a 3d node, if so adjust the normal
|
||||
@ -2480,6 +2502,7 @@ void Track::flagCommand(const XMLNode *node)
|
||||
m_blue_flag = btTransform(shortestArcQuat(Vec3(0, 1, 0), normal),
|
||||
hit_point);
|
||||
}
|
||||
return hit_point;
|
||||
} // flagCommand
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -430,7 +430,7 @@ public:
|
||||
void update(int ticks);
|
||||
void reset();
|
||||
void itemCommand(const XMLNode *node);
|
||||
void flagCommand(const XMLNode *node);
|
||||
Vec3 flagCommand(const XMLNode *node);
|
||||
core::stringw getName() const;
|
||||
core::stringw getSortName() const;
|
||||
bool isInGroup(const std::string &group_name);
|
||||
|
Loading…
Reference in New Issue
Block a user