Exemple #1
0
void CPowerUp::Respawn()
{
	int x, y;

	CRenderer *pRenderer = CRenderer::Instance();
	CUniverse* universe = CODEManager::Instance()->m_pUniverse;
	
	do
	{
		x = rand()%((int) universe->m_fWidth*2)  - (int) universe->m_fWidth;
		y = rand()%((int) universe->m_fHeight*2) - (int) universe->m_fHeight;
	} while ( pRenderer->ObjectsInRange( x, y, 100 ) );

	Vector v = Vector( (float)x, (float)y, 0.0f );
	SetPosition( v );
	Vector n;
	Vector vel((float) (rand() % 10), (float) (rand() % 10), 0);
	m_oPhysicsData.m_pOwner->SetLinVelocity(vel);
	SetForce(n);
	this->m_bIsGrabable = true;
	this->m_oPhysicsData.m_bHasCollision = true;

	CSound *pSound = (CSound *)CResourceManager::Instance()->GetResource("media/sounds/powerup_spawn.wav", RT_SOUND);
	if ( pSound )
		pSound->Play();
}
void CResourceManager::PlayASound(int soundID)
{
	if (CResourceManager::IsPlaySound)
	{
		map<int, CSound*>::iterator it = CResourceManager::_instance->_lstSound.find(soundID);
		if (it != CResourceManager::_instance->_lstSound.end())
		{
			CSound* sound = it->second;

			if (sound->loop)
			{
				sound->Play(0, 1);
				CResourceManager::_instance->_idSoundBGDefault = it->first;
			}
			else if (!sound->IsSoundPlaying())
				sound->Play();
		}
	}
}
void ManageAudio::playSound(TypeAudio _type)
{
	this->stopSound(_type);
	std::hash_map<int, CSound*>::iterator it = this->listAudio.find((int)_type);
	if (it != this->listAudio.end())
	{
		CSound* sound = it->second;

		if (sound->loop)
		{
			   sound->Reset();
			   sound->Play(0, DSBPLAY_LOOPING);
			//sound->Play(0, DSSCL_PRIORITY);
		}
		else
		{
			sound->Reset();
			sound->Play();
		}
	}
}
void CResourceManager::ReplaySound()
{
	for (map<int, CSound*>::iterator it = CResourceManager::_instance->_lstSound.begin(); it != CResourceManager::_instance->_lstSound.end(); it++)
	{
		CSound* sound = it->second;
		if (it->first == CResourceManager::_instance->_idSoundBGDefault)
		{
			sound->Play(0, 1);
			IsPlaySound = true;
			break;
		}
	}

}
Exemple #5
0
void CEnemyBase::Damaged()
{
	// 残り耐久度を1減らす
	hardness--;
	if(hardness == 0){
		CSound *se = new CSound(*(CSound*)FindItemBox("explode1"));
		se->EnableDeleteByEnd();
		se->Play();

		// 爆発処理を追加
		AppendObject(new CExplosion(x, y), EXPLOSION_PRIORITY, true);
		// 自身を削除
		RemoveObject(this);
	}
}
Exemple #6
0
BOOL cDxSound::playSound(char *filename)
{
	if(!_pSoundManager) return FALSE;

	CSound *pSound = NULL;
	long hashValue = hash(filename);
	if(!_sounds.Lookup(hashValue, pSound))
	{	// A new sound, so we have to load it in first
		if(FAILED(_pSoundManager->Create(&pSound, filename, 0, GUID_NULL, 5)))
		{
			return FALSE;
		}
		_sounds.SetAt(hashValue, pSound);
	}
	pSound->Play();
	return TRUE;
}
Exemple #7
0
void CEnemy3::Damaged()
{
	hardness--;
	if(hardness == 0){
		// 10個の爆炎をランダムで拡散させる
		for(int i = 0; i < 10; i++){
			float angle = d2r((float)(36 * i));
			float size = 0.5f + 2.0f * (float)rand() / (float)(RAND_MAX + 1);
			float speed = 1.0f + 5.0f * (float)rand() / (float)(RAND_MAX + 1);
			AppendObject(new CExplosion(x, y, size, angle, speed),
				EXPLOSION_PRIORITY, true);
		}

		CSound *se = new CSound(*(CSound*)FindItemBox("explode2"));
		se->EnableDeleteByEnd();
		se->Play();

		AppendObject(new CPowerupItem(x, y), PLAYER_PRIORITY, true);
		RemoveObject(this);
	}
}
Exemple #8
0
bool CBoss::ActionDestroy()
{
	frame++;
	if(frame < 500){
		// 500フレーム目まではボス周辺でランダムに爆炎を発生させる
		if(frame % 5 == 0){
			float xx = x + (float)(rand() % 500 - 250);
			float yy = y + (float)(rand() % 300 - 150);
			float sz = 1.0f + 2.0f * (float)rand() / (float)RAND_MAX;
			AppendObject(new CExplosion(xx, yy, sz, 0.0f, 0.0f),
				EXPLOSION_PRIORITY, true);
		}

		y += 0.2f;

		if(frame % 15 == 0){
			((CSound*)FindItemBox("explode1"))->Play();
		}

		return false;
	}else{
		// 500フレーム目で大爆発を起こす
		float xx, yy, a, s, z;
		for(int i = 0; i < 50; i++){
			xx = x + (float)(rand() % 100 - 50);
			yy = y + (float)(rand() % 100 - 50);
			a = atan2f(x - xx, yy - y);
			s = 5.0f + 10.0f * (float)rand() / (float)RAND_MAX;
			z = 3.0f + 8.0f * (float)rand() / (float)RAND_MAX;
			AppendObject(new CExplosion(xx, yy,
				2.0f, a, s), EXPLOSION_PRIORITY, true);
		}

        CSound *se = new CSound(*(CSound*)FindItemBox("explode3"));
        se->EnableDeleteByEnd();
        se->Play();

		return true;
	}
}
void CFreezePowerUp::CollideWith(CBaseObject* pOther, Vector &pos)
{
	if(pOther->getType() == SHIP && this->m_bIsGrabable)
	{
		std::vector<PhysicsData*>& players = CODEManager::Instance()->m_vPlayers;
		std::vector<PhysicsData*>::iterator it = players.begin();
		for(it; it != players.end(); it++){
			if((*it)->m_pOwner != pOther){
				CPlayerObject* other = dynamic_cast<CPlayerObject*>((*it)->m_pOwner);
				if(other->m_fPUJellyTime > 0.001){
					other->m_fPUJellyTime = 0;
				} else {
					other->AffectedByFreezePU();
				}
			}
		}

		CSound *pSound = (CSound *)CResourceManager::Instance()->GetResource("media/sounds/freeze_object.wav", RT_SOUND);
		if ( pSound )
			pSound->Play();
	}

	CPowerUp::CollideWith(pOther, Vector(pos));
}
Exemple #10
0
//=============================================================================
// キーボードでの選択
//=============================================================================
void CStageSelect::SelectByButton(void)
{

	// Wiiコンの取得
	WiiRemote* pTmpPad = CManager::GetWii(1);

	//サウンド取得の作成
	CSound *pSound;
	pSound = CManager::GetSound();

	//キーボードインプットの受け取り
	CInputKeyboard *pInputKeyboard;
	pInputKeyboard = CManager::GetInputKeyboard();

	float fTmpRad = (D3DX_PI * 2.0f) / MAX_STAGE;
	float tmpRot((D3DX_PI * 2.0f));

	//エンターキーが押された場合
	if (pInputKeyboard->GetKeyTrigger(DIK_RETURN) || pTmpPad->GetKeyTrigger(WII_BUTTOM_A))
	{

		// 遷移処理
		pSound->Play(SOUND_LABEL_SE_SELECT002);
		m_nState = STATE::CHANGE_SCENE;

		// 選択したマップを保存
		CManager::SetSelectMap(m_playerData[0].nSelectNum);

		m_pFade->StartFade(FADE_IN, 100, D3DXCOLOR(1.0f, 1.0f, 1.0f, 0.0f), CManager::GetSelectChar(0));
		//pSound->PlayVoice(m_playerData[0].nSelectNum,VOICE_LABEL_SE_START);

	}
	else if (pInputKeyboard->GetKeyTrigger(DIK_A) || pInputKeyboard->GetKeyTrigger(DIK_LEFT) || pTmpPad->GetKeyTrigger(WII_BUTTOM_LEFT))
	{

		//pSound->Play(SOUND_LABEL_SE_SELECT000);
		selectStageOld = m_playerData[0].nSelectNum;

		m_playerData[0].nSelectNum--;
		NomalizeSelectObject(m_playerData[0].nSelectNum);

		for (int i = 0; i < MAX_STAGE; i++)
		{
			m_Obj[i].nDestCnt--;
			NomalizeSelectObject(m_Obj[i].nDestCnt);

			if (m_Obj[i].fLenCoff <= 0.0f)
			{
				m_Obj[i].fLenCoff = tmpRot;
			}
		}
		m_fTime = 0.0f;

		m_nState = STATE::SATELLITE_ORBIT;

	}
	else if (pInputKeyboard->GetKeyTrigger(DIK_D) || pInputKeyboard->GetKeyTrigger(DIK_RIGHT) || pTmpPad->GetKeyTrigger(WII_BUTTOM_RIGHT))
	{
		//pSound->Play(SOUND_LABEL_SE_SELECT000);
		selectStageOld = m_playerData[0].nSelectNum;

		m_playerData[0].nSelectNum++;
		NomalizeSelectObject(m_playerData[0].nSelectNum);

		for (int i = 0; i < MAX_STAGE; i++)
		{
			m_Obj[i].nDestCnt++;
			NomalizeSelectObject(m_Obj[i].nDestCnt);

			if (m_Obj[i].fLenCoff >= tmpRot - fTmpRad)
			{
				m_Obj[i].fLenCoff = 0.0f - fTmpRad;
			}


		}
		m_fTime = 0.0f;

		m_nState = STATE::SATELLITE_ORBIT;

	}

}