Exemple #1
0
void Audio::PlaySound(const String& filename, const Position& position, float minDistance,
                             float attenuation /*= 0.5f*/)
{
    Sound* sound = CreateSound(filename, position);
    sound->SetMinDistance(minDistance);
    sound->Play();
    mImmediateSounds.push_back(sound);
}
Exemple #2
0
//-----------------------------------------------------------------
// Opens a door
void CSegment::OpenDoor (int nSide)
{
CWall* wallP;
if (!(wallP = Wall (nSide)))
	return;

CActiveDoor* doorP;
if (!(doorP = wallP->OpenDoor ()))
	return;

	short			nConnSide, nConnWall = NO_WALL;
	CSegment		*connSegP;
// So that door can't be shot while opening
if (m_children [nSide] < 0) {
	if (gameOpts->legacy.bWalls)
		Warning (TXT_OPEN_SINGLE, this - SEGMENTS, nSide, WallNum (nSide));
	connSegP = NULL;
	nConnSide = -1;
	nConnWall = NO_WALL;
	}
else {
	connSegP = SEGMENTS + m_children [nSide];
	nConnSide = ConnectedSide (connSegP);
	if (nConnSide >= 0) {
		CWall* wallP = connSegP->Wall (nConnSide);
		if (wallP)
			wallP->state = WALL_DOOR_OPENING;
		}
	}

//KillStuckObjects(WallNumP (connSegP, nConnSide));
doorP->nFrontWall [0] = WallNum (nSide);
doorP->nBackWall [0] = nConnWall;
Assert(SEG_IDX (this) != -1);
if (gameData.demo.nState == ND_STATE_RECORDING)
	NDRecordDoorOpening (SEG_IDX (this), nSide);
if (IS_WALL (wallP->nLinkedWall) && IS_WALL (nConnWall) && (wallP->nLinkedWall == nConnWall)) {
	CWall *linkedWallP = WALLS + wallP->nLinkedWall;
	CSegment *linkedSegP = SEGMENTS + linkedWallP->nSegment;
	linkedWallP->state = WALL_DOOR_OPENING;
	connSegP = SEGMENTS + linkedSegP->m_children [linkedWallP->nSide];
	if (IS_WALL (nConnWall))
		WALLS [nConnWall].state = WALL_DOOR_OPENING;
	doorP->nPartCount = 2;
	doorP->nFrontWall [1] = wallP->nLinkedWall;
	doorP->nBackWall [1] = linkedSegP->ConnectedSide (connSegP);
	}
else
	doorP->nPartCount = 1;
if (gameData.demo.nState != ND_STATE_PLAYBACK) {
	if (gameData.walls.animP [wallP->nClip].openSound > -1)
		CreateSound (gameData.walls.animP [wallP->nClip].openSound, nSide);
	}
}
void SoundMgr::PlaySound( const std::string& sSoundPath, float volume /*= 100*/ )
{
	int id = CreateSound( sSoundPath );
	object_t* objContainer = IObjectManager::GetById( id );

	if( objContainer )
	{
		objContainer->GetData()->m_isDestroyWhenFinished = true;
		objContainer->GetData()->GetSound()->SetLoop( false );
		objContainer->GetData()->GetSound()->Play();
		objContainer->GetData()->GetSound()->SetVolume( volume );
		objContainer->GetData()->GetSound()->SetRelativeToListener(true);
	}
}
Exemple #4
0
// start the transition from closed -> open CWall
void CSegment::StartCloak (int nSide)
{
if (gameData.demo.nState == ND_STATE_PLAYBACK)
	return;

CWall* wallP = Wall (nSide);
if (!wallP)
	return;

if (wallP->nType == WALL_OPEN || wallP->state == WALL_DOOR_CLOAKING)		//already open or cloaking
	return;

	CCloakingWall*	cloakWallP;
	CSegment*		connSegP;
	short				nConnSide;
	int				i;
	short				nConnWall;


connSegP = SEGMENTS + m_children [nSide];
nConnSide = ConnectedSide (connSegP);

if (!(cloakWallP = wallP->StartCloak ())) {
	wallP->nType = WALL_OPEN;
	if ((wallP = connSegP->Wall (nConnSide)))
		wallP->nType = WALL_OPEN;
	return;
	}

nConnWall = connSegP->WallNum (nConnSide);
if (IS_WALL (nConnWall))
	WALLS [nConnWall].state = WALL_DOOR_CLOAKING;
cloakWallP->nFrontWall = WallNum (nSide);
cloakWallP->nBackWall = nConnWall;
Assert(SEG_IDX (this) != -1);
//Assert(!IS_WALL (wallP->nLinkedWall));
if (gameData.demo.nState != ND_STATE_PLAYBACK) {
	CreateSound (SOUND_WALL_CLOAK_ON, nSide);
	}
for (i = 0; i < 4; i++) {
	cloakWallP->front_ls [i] = m_sides [nSide].m_uvls [i].l;
	if (IS_WALL (nConnWall))
		cloakWallP->back_ls [i] = connSegP->m_sides [nConnSide].m_uvls [i].l;
	}
}
Exemple #5
0
//-----------------------------------------------------------------
// Closes a door
void CSegment::CloseDoor (int nSide)
{
	CWall*	wallP;

if (!(wallP = Wall (nSide)))
	return;
if ((wallP->state == WALL_DOOR_CLOSING) ||		//already closing
	 (wallP->state == WALL_DOOR_WAITING) ||		//open, waiting to close
	 (wallP->state == WALL_DOOR_CLOSED))			//closed
	return;
if (DoorIsBlocked (nSide))
	return;

	CActiveDoor*	doorP;

if (!(doorP = wallP->CloseDoor ()))
	return;

	CSegment*		connSegP;
	short				nConnSide, nConnWall;

connSegP = SEGMENTS + m_children [nSide];
nConnSide = ConnectedSide (connSegP);
nConnWall = connSegP->WallNum (nConnSide);
if (IS_WALL (nConnWall))
	WALLS [nConnWall].state = WALL_DOOR_CLOSING;
doorP->nFrontWall [0] = WallNum (nSide);
doorP->nBackWall [0] = nConnWall;
Assert(SEG_IDX (this) != -1);
if (gameData.demo.nState == ND_STATE_RECORDING)
	NDRecordDoorOpening (SEG_IDX (this), nSide);
if (IS_WALL (wallP->nLinkedWall))
	Int3();		//don't think we ever used linked walls
else
	doorP->nPartCount = 1;
if (gameData.demo.nState != ND_STATE_PLAYBACK) {
	if (gameData.walls.animP [wallP->nClip].openSound > -1)
		CreateSound (gameData.walls.animP [wallP->nClip].openSound, nSide);
	}
}
Exemple #6
0
MOint
moSoundManager::GetSoundId( moText p_name, bool create ) {

	MOint i,idnuevo;

	for( i=0; i<(int)m_sounds_array.Count(); i++ ) {
		if(!stricmp( m_sounds_array[i]->GetName(), p_name )) {
			return(i);
			break;
		}
	}

  if (!create) return -1;

	moSoundType stype = GetTypeForFile(p_name);
	if (!m_pResourceManager) return MO_SOUNDERROR;

	moText namefull = m_pResourceManager->GetDataMan()->GetDataPath();
	namefull +=  moSlash + (const moText)p_name;

	moFile fileSound(namefull);
	namefull = fileSound.GetCompletePath();

	moSoundParam sparam = MODefSoundParams ;
	moSound* pSound = CreateSound( p_name );

	if (pSound) {

		pSound->LoadFromFile( namefull );

		m_sounds_array.Add( pSound );

		idnuevo = m_sounds_array.Count() - 1;
	} else {
	  idnuevo = -1;
	}
	//si es superior a 65535 es un error
	stype = MO_SOUNDTYPE_UNDEFINED;
	return(idnuevo);
}
Exemple #7
0
//-----------------------------------------------------------------
// start the transition from open -> closed CWall
void CSegment::StartDecloak (int nSide)
{
if (gameData.demo.nState == ND_STATE_PLAYBACK)
	return;
	CWall				*wallP;

if (!(wallP = Wall (nSide)))
	return;
if (wallP->nType == WALL_CLOSED || wallP->state == WALL_DOOR_DECLOAKING)		//already closed or decloaking
	return;

	CCloakingWall	*cloakWallP;
	short				nConnSide;
	CSegment			*connSegP;
	int				i;

connSegP = SEGMENTS + m_children [nSide];
nConnSide = ConnectedSide (connSegP);
if (!(cloakWallP = wallP->StartDecloak ())) {
	wallP->state = WALL_CLOSED;
	if ((wallP = connSegP->Wall (nConnSide)))
		wallP->state = WALL_CLOSED;
	return;
	}
// So that door can't be shot while opening
if ((wallP = connSegP->Wall (nConnSide)))
	wallP->state = WALL_DOOR_DECLOAKING;
cloakWallP->nFrontWall = WallNum (nSide);
cloakWallP->nBackWall = connSegP->WallNum (nConnSide);
if (gameData.demo.nState != ND_STATE_PLAYBACK) {
	CreateSound (SOUND_WALL_CLOAK_OFF, nSide);
	}
for (i = 0; i < 4; i++) {
	cloakWallP->front_ls [i] = m_sides [nSide].m_uvls [i].l;
	if (wallP)
		cloakWallP->back_ls [i] = connSegP->m_sides [nConnSide].m_uvls [i].l;
	}
}
int SoundManager::CreateLoopedStream(String &fileName)
{
	return CreateSound(fileName, SOUND_TYPE_2D_SOUND_LOOPED);
}
int SoundManager::CreateSound(String &fileName)
{
	return CreateSound(fileName, SOUND_TYPE_3D_SOUND);
}
Exemple #10
0
	int SoundManager::CreateLoopedSound(std::string &fileName)
	{
		return CreateSound(fileName, SOUND_TYPE_3D_SOUND_LOOPED);
	}
Exemple #11
0
	int SoundManager::CreateStream(std::string &filename)
	{
		return CreateSound(filename, SOUND_TYPE_2D_SOUND);
	}
Exemple #12
0
void Audio::PlaySound(const String& filename)
{
    Sound* sound = CreateSound(filename);
    sound->Play();
    mImmediateSounds.push_back(sound);
}
Exemple #13
0
bool STGResources::LoadSounds()
{
	auto audio = Audio::GetInstance();

	soundShoot1 = audio->CreateSound("sound/se_tan00.wav");
	if (soundShoot1 == nullptr)
	{
		return false;
	}

	soundShoot2 = audio->CreateSound("sound/se_tan01.wav");
	if (soundShoot2 == nullptr)
	{
		return false;
	}

	soundShoot3 = audio->CreateSound("sound/se_tan02.wav");
	if (soundShoot3 == nullptr)
	{
		return false;
	}

	soundBiu = audio->CreateSound("sound/se_pldead00.wav");
	if (soundBiu == nullptr)
	{
		return false;
	}

	soundMenuOK = audio->CreateSound("sound/se_ok00.wav");
	if (soundMenuOK == nullptr)
	{
		return false;
	}

	soundMenuSelect = audio->CreateSound("sound/se_select00.wav");
	if (soundMenuSelect == nullptr)
	{
		return false;
	}

	soundItem = audio->CreateSound("sound/se_item00.wav");
	if (soundItem == nullptr)
	{
		return false;
	}

	soundDamage00 = audio->CreateSound("sound/se_damage00.wav");
	if (soundDamage00 == nullptr)
	{
		return false;
	}

	soundDamage01 = audio->CreateSound("sound/se_damage01.wav");
	if (soundDamage01 == nullptr)
	{
		return false;
	}

	soundEnemyDie00 = audio->CreateSound("sound/se_enep00.wav");
	if (soundEnemyDie00 == nullptr)
	{
		return false;
	}

	soundEnemyDie01 = audio->CreateSound("sound/se_enep01.wav");
	if (soundEnemyDie01 == nullptr)
	{
		return false;
	}

	soundPlayerShoot = audio->CreateSound("sound/se_plst00.wav");
	if (soundPlayerShoot == nullptr)
	{
		return false;
	}

	soundBomb = audio->CreateSound("sound/se_nep00.wav");
	if (soundBomb == nullptr)
	{
		return false;
	}

	soundExplode = audio->CreateSound("sound/se_cat00.wav");
	if (soundExplode == nullptr)
	{
		return false;
	}

	return true;
}