More sound tweaks in multiplayer
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@8593 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
a3b3fafe27
commit
41bded8917
@ -25,14 +25,17 @@
|
||||
#include "graphics/material.hpp"
|
||||
#include "graphics/material_manager.hpp"
|
||||
#include "items/projectile_manager.hpp"
|
||||
#include "race/race_manager.hpp"
|
||||
#include "utils/vec3.hpp"
|
||||
|
||||
const float burst_time = 0.1f;
|
||||
|
||||
Explosion::Explosion(const Vec3& coord, const char* explosion_sound)
|
||||
Explosion::Explosion(const Vec3& coord, const char* explosion_sound, bool player_kart_hit)
|
||||
{
|
||||
m_remaining_time = burst_time; // short emision time, explosion, not constant flame
|
||||
m_node = irr_driver->addParticleNode();
|
||||
m_player_kart_hit = player_kart_hit;
|
||||
|
||||
#ifdef DEBUG
|
||||
m_node->setName("explosion");
|
||||
#endif
|
||||
@ -89,6 +92,17 @@ Explosion::~Explosion()
|
||||
void Explosion::init(const Vec3& coord)
|
||||
{
|
||||
m_explode_sound->position(coord);
|
||||
|
||||
// in multiplayer mode, sounds are NOT positional (because we have multiple listeners)
|
||||
// so the sounds of all AIs are constantly heard. So reduce volume of sounds.
|
||||
if (race_manager->getNumLocalPlayers() > 1)
|
||||
{
|
||||
m_explode_sound->volume(m_player_kart_hit ? 1.0f : 0.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_explode_sound->volume(1.0f);
|
||||
}
|
||||
m_explode_sound->play();
|
||||
} // init
|
||||
|
||||
|
@ -38,10 +38,11 @@ class Explosion : public NoCopy
|
||||
private:
|
||||
SFXBase* m_explode_sound;
|
||||
float m_remaining_time;
|
||||
bool m_player_kart_hit;
|
||||
scene::IParticleSystemSceneNode *m_node;
|
||||
|
||||
|
||||
public:
|
||||
Explosion(const Vec3& coord, const char* explosion_sound);
|
||||
Explosion(const Vec3& coord, const char* explosion_sound, bool player_hit);
|
||||
~Explosion();
|
||||
void init (const Vec3& coord);
|
||||
void update (float delta_t);
|
||||
|
@ -126,7 +126,7 @@ void Attachment::hitBanana(Item *item, int new_attachment)
|
||||
case ATTACH_BOMB:
|
||||
{
|
||||
add_a_new_item = false;
|
||||
projectile_manager->newExplosion(m_kart->getXYZ());
|
||||
projectile_manager->newExplosion(m_kart->getXYZ(), "explosion", m_kart->getController()->isPlayerController());
|
||||
m_kart->handleExplosion(m_kart->getXYZ(), /*direct_hit*/ true);
|
||||
clear();
|
||||
if(new_attachment==-1)
|
||||
@ -235,7 +235,7 @@ void Attachment::update(float dt)
|
||||
}
|
||||
if(m_time_left<=0.0)
|
||||
{
|
||||
projectile_manager->newExplosion(m_kart->getXYZ());
|
||||
projectile_manager->newExplosion(m_kart->getXYZ(), "explosion", m_kart->getController()->isPlayerController());
|
||||
m_kart->handleExplosion(m_kart->getXYZ(),
|
||||
/*direct_hit*/ true);
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ void ProjectileManager::update(float dt)
|
||||
if(! (*p)->hasHit()) { p++; continue; }
|
||||
if((*p)->needsExplosion())
|
||||
{
|
||||
newExplosion((*p)->getXYZ(), (*p)->getExplosionSound() );
|
||||
newExplosion((*p)->getXYZ(), (*p)->getExplosionSound(), false );
|
||||
}
|
||||
Flyable *f=*p;
|
||||
Projectiles::iterator pNext=m_active_projectiles.erase(p); // returns the next element
|
||||
@ -187,9 +187,10 @@ Flyable *ProjectileManager::newProjectile(Kart *kart,
|
||||
/** See if there is an old, unused explosion object available. If so,
|
||||
* reuse this object, otherwise create a new one. */
|
||||
Explosion* ProjectileManager::newExplosion(const Vec3& coord,
|
||||
const char* explosion_sound)
|
||||
const char* explosion_sound,
|
||||
bool player_kart_hit)
|
||||
{
|
||||
Explosion *e = new Explosion(coord, explosion_sound);
|
||||
Explosion *e = new Explosion(coord, explosion_sound, player_kart_hit);
|
||||
m_active_explosions.push_back(e);
|
||||
return e;
|
||||
} // newExplosion
|
||||
|
@ -72,7 +72,8 @@ public:
|
||||
Flyable* newProjectile (Kart *kart,
|
||||
PowerupManager::PowerupType type);
|
||||
Explosion* newExplosion (const Vec3& coord,
|
||||
const char* explosion_sound="explosion");
|
||||
const char* explosion_sound="explosion",
|
||||
bool is_player_kart_hit = false);
|
||||
void Deactivate (Flyable *p) {}
|
||||
void removeTextures ();
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user