本文整理汇总了C++中IEntitySoundProxy::PlaySound方法的典型用法代码示例。如果您正苦于以下问题:C++ IEntitySoundProxy::PlaySound方法的具体用法?C++ IEntitySoundProxy::PlaySound怎么用?C++ IEntitySoundProxy::PlaySound使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEntitySoundProxy
的用法示例。
在下文中一共展示了IEntitySoundProxy::PlaySound方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Activate
//------------------------------------------------------------------------
void SSoundEffect::Activate(EntityId targetId, EntityId ownerId, EntityId weaponId, const char *effect, const char *defaultEffect)
{
// TODO: make work in MP...
IEntity* pEntity = gEnv->pEntitySystem->GetEntity(targetId);
IEntity* pOwnerEntity = gEnv->pEntitySystem->GetEntity(ownerId);
if(pEntity && gEnv->pSoundSystem && pOwnerEntity)
{
int soundFlag = FLAG_SOUND_3D;
bool repeating = false;
bool force3DSound = true;
IEntitySoundProxy* pSoundProxy = (IEntitySoundProxy*)pOwnerEntity->GetProxy(ENTITY_PROXY_SOUND);
if(pSoundProxy)
{
//Execute sound at entity position
GameWarning("Sound effect: %s (Entity)", defaultEffect);
pSoundProxy->PlaySound(defaultEffect, pEntity->GetWorldPos()-pOwnerEntity->GetWorldPos(),FORWARD_DIRECTION, FLAG_SOUND_DEFAULT_3D);
// Notify AI system (TODO: Parametrize radius)
gEnv->pAISystem->SoundEvent(pEntity->GetWorldPos(), 100.0f, AISE_GENERIC, NULL);
//gEnv->pRenderer->GetIRenderAuxGeom()->DrawSphere(pEntity->GetWorldPos(),0.5f,ColorB(255,0,0));
}
}
}
示例2: PlaySound
void CBoidObject::PlaySound( int nIndex )
{
if (nIndex >= 0 && nIndex < (int)m_flock->m_bc.sounds.size())
{
IEntity *pEntity = gEnv->pEntitySystem->GetEntity(m_entity);
if (pEntity)
{
IEntitySoundProxy* pSndProxy = (IEntitySoundProxy*)pEntity->CreateProxy(ENTITY_PROXY_SOUND);
Vec3 ofs(0,0,0),dir(FORWARD_DIRECTION);
pSndProxy->PlaySound( m_flock->m_bc.sounds[nIndex],ofs,dir,FLAG_SOUND_DEFAULT_3D, 0, eSoundSemantic_Living_Entity );
}
}
}
示例3: PickUp
//------------------------------------------------------------------------
void CAmmoPickup::PickUp(EntityId pickerId, bool sound, bool select, bool keepHistory)
{
if(!CheckAmmoRestrictions(pickerId))
return;
SetOwnerId(pickerId);
CActor *pActor=GetActor(pickerId);
if (!pActor)
return;
IInventory *pInventory = GetActorInventory(pActor);
if (!pInventory)
return;
if (IsServer())
{
// bonus ammo is always put in the actor's inv
if (!m_bonusammo.empty())
{
for (TAmmoMap::iterator it=m_bonusammo.begin(); it!=m_bonusammo.end(); ++it)
{
int count=it->second;
SetInventoryAmmoCount(it->first, GetInventoryAmmoCount(it->first)+count);
if(pActor->IsPlayer())
{
ShouldSwitchGrenade(it->first);
OnIncendiaryAmmoPickedUp(it->first,count);
}
}
m_bonusammo.clear();
}
for (TAmmoMap::iterator it=m_ammo.begin(); it!=m_ammo.end(); ++it)
{
int count=it->second;
SetInventoryAmmoCount(it->first, GetInventoryAmmoCount(it->first)+count);
if(pActor->IsPlayer())
{
ShouldSwitchGrenade(it->first);
OnIncendiaryAmmoPickedUp(it->first,count);
}
}
if (!m_ammoName.empty() && m_ammoCount)
{
IEntityClass* pClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass(m_ammoName.c_str());
SetInventoryAmmoCount(pClass, GetInventoryAmmoCount(pClass)+m_ammoCount);
if(pActor->IsPlayer())
{
ShouldSwitchGrenade(pClass);
OnIncendiaryAmmoPickedUp(pClass,m_ammoCount);
}
}
TriggerRespawn();
}
//Play sound
if(!m_pickup_sound.empty())
{
IEntity *pPicker = m_pEntitySystem->GetEntity(pickerId);
if(pPicker)
{
IEntitySoundProxy* pSoundProxy = (IEntitySoundProxy*)pPicker->GetProxy(ENTITY_PROXY_SOUND);
if(pSoundProxy)
{
//Execute sound at picker position
pSoundProxy->PlaySound(m_pickup_sound, pPicker->GetWorldPos(),FORWARD_DIRECTION, FLAG_SOUND_DEFAULT_3D, eSoundSemantic_Weapon);
}
}
}
RemoveEntity();
}
示例4: PlaySound
// add enum of sound you want to play, and add command to game code at appropiate spot
void CGameAudio::PlaySound(EGameAudioSounds eSound, IEntity *pEntity, float param, bool stopSound)
{
int soundFlag = 0; //localActor will get 2D sounds
ESoundSemantic eSemantic = eSoundSemantic_None;
ISound *pSound = NULL;
bool setParam = false;
static string soundName;
soundName.resize(0);
switch(eSound)
{
case EGameAudioSound_NOSOUND:
break;
case EGameAudioSound_LAST:
break;
default:
break;
}
//if(!force3DSound && m_pOwner == m_pGameFramework->GetClientActor() && !m_pOwner->IsThirdPerson() && soundName.size())
//{
// if (bAppendPostfix)
// soundName.append("_fp");
//}
IEntitySoundProxy *pSoundProxy = pEntity ? (IEntitySoundProxy *)pEntity->CreateProxy(ENTITY_PROXY_SOUND) : NULL;
if(soundName.size() && eSound < EGameAudioSound_LAST) //get / create or stop sound
{
if(m_sounds[eSound].ID != INVALID_SOUNDID)
{
if(pSoundProxy)
pSound = pSoundProxy->GetSound(m_sounds[eSound].ID);
else
pSound = gEnv->pSoundSystem->GetSound(m_sounds[eSound].ID);
if(stopSound)
{
if(pSound)
pSound->Stop();
m_sounds[eSound].ID = INVALID_SOUNDID;
return;
}
}
if(!pSound && !stopSound)
{
pSound = gEnv->pSoundSystem->CreateSound(soundName, soundFlag);
if(pSound)
{
pSound->SetSemantic(eSemantic);
//float fTemp = 0.0f;
m_sounds[eSound].ID = pSound->GetId();
m_sounds[eSound].bLooping = (pSound->GetFlags() & FLAG_SOUND_LOOP) != 0;
m_sounds[eSound].b3D = (pSound->GetFlags() & FLAG_SOUND_3D) != 0;
//m_sounds[eSound].nMassIndex = pSound->GetParam("mass", &fTemp, false);
//m_sounds[eSound].nSpeedIndex = pSound->GetParam("speed", &fTemp, false);
//m_sounds[eSound].nStrengthIndex = pSound->GetParam("strength", &fTemp, false);
}
}
}
if(pSound) //set params and play
{
//pSound->SetPosition(m_pOwner->GetEntity()->GetWorldPos());
if(setParam)
{
//if (m_sounds[eSound].nMassIndex != -1)
// pSound->SetParam(m_sounds[sound].nMassIndex, param);
//if (m_sounds[eSound].nSpeedIndex != -1)
// pSound->SetParam(m_sounds[sound].nSpeedIndex, param);
//if (m_sounds[eSound].nStrengthIndex != -1)
// pSound->SetParam(m_sounds[sound].nStrengthIndex, param);
}
if(!(m_sounds[eSound].bLooping && pSound->IsPlaying()))
{
if(pSoundProxy)
pSoundProxy->PlaySound(pSound);
else
pSound->Play();
}
}
}