//------------------------------------------------------------------------------------ // 이펙트 모델 선택 void CUIPetStashSelectEffect::SelectModel() { PetStash* pPetStash = GameDataManager::getSingleton()->GetStashData(); int nSelectIndex = -1; if (pPetStash) nSelectIndex = pPetStash->GetEffectModelNo(); if (m_aniMid->GetRenderIdx() == nSelectIndex) { m_bSelect = TRUE; } else { m_nCurFrame = m_nCurFrame % m_nMaxFrame; m_aniLeft->SetRenderIdx( m_nCurFrame ); m_aniMid->SetRenderIdx( m_nCurFrame + 1 ); m_aniRight->SetRenderIdx( m_nCurFrame + 2 ); m_dwDelayTime += m_dwDelay; m_nCurFrame++; _PlaySound(SOUND_TYPE_MOVE); } }
void CUIPetStashSelectEffect::UpdateAni() { DWORD nCurrent = timeGetTime(); if ( nCurrent < m_dwAniStartTime + m_dwAniMaitionTime ) { if (nCurrent > m_dwDelayTime) { m_nCurFrame = m_nCurFrame % m_nMaxFrame; m_aniLeft->SetRenderIdx( m_nCurFrame ); m_aniMid->SetRenderIdx( m_nCurFrame + 1 ); m_aniRight->SetRenderIdx( m_nCurFrame + 2 ); m_dwDelayTime = nCurrent + m_dwDelay; m_dwDelay += m_dwSlowTime; m_nCurFrame++; _PlaySound(SOUND_TYPE_MOVE); } } else { if ( m_bSelect == TRUE) EndAni(); else { if ( nCurrent > m_dwDelayTime) { SelectModel(); } } } }
void CUIPetStashSelectEffect::EndAni() { PetStash* pPetStash = GameDataManager::getSingleton()->GetStashData(); int nSelectIndex = -1; if (pPetStash) { nSelectIndex = pPetStash->GetEffectModelNo(); pPetStash->SetEffectModelNo(nSelectIndex); pPetStash->SendEffectReq(nSelectIndex); } _PlaySound(SOUND_TYPE_SELECT); m_bAni = FALSE; m_imgSelect->Hide(FALSE); m_pbtnOk->SetEnable(TRUE); m_pbtnOk->SetBtnState(UBS_IDLE); }
bool SoundEditDialog::frameStarted(const Ogre::FrameEvent& evt) { if (!mPlaySound) return true; if (/*mPlaySoundInGame*/0) { Ogre::Camera* camera = mSceneManipulator->getCamera(); const Ogre::Vector3& camPos = camera->getPosition(); Fairy::TerrainData* terrainData = mSceneManipulator->getTerrainData(); std::pair<int, int> camGrid = terrainData->getGrid(camPos.x, camPos.z); for (size_t i=0; i<mSoundItems.size(); ++i) { SoundItem* workingItem = mSoundItems[i]; if (workingItem->mRepeatTime != 0) { FLOAT deltaTime = evt.timeSinceLastFrame * 1000; // 如果当前的播放次数已达到重复播放次数,就累加时间,直到达到下次播放的时间,就播放 if (workingItem->mCurrentRepeatTime == workingItem->mRepeatTime) { workingItem->mCurrentPlayIntervalTime += (INT)deltaTime; if (workingItem->mCurrentPlayIntervalTime >= workingItem->mNextRepeatTime) { workingItem->mCurrentRepeatTime = 0; workingItem->mCurrentPlayIntervalTime = 0; SoundNames::iterator it = mSoundNames.find(workingItem->mSoundID); if (it != mSoundNames.end()) { workingItem->mSoundHandle = _PlaySound(it->second, workingItem->mSoundHandle, false); } ++workingItem->mCurrentRepeatTime; } } else { // 累加重复播放之间的间隔时间 workingItem->mCurrentRepeatIntervalTime += (INT)deltaTime; if (workingItem->mCurrentRepeatIntervalTime >= workingItem->mRepeatIntervalTime) { workingItem->mCurrentRepeatIntervalTime = 0; SoundNames::iterator it = mSoundNames.find(workingItem->mSoundID); if (it != mSoundNames.end()) { workingItem->mSoundHandle = _PlaySound(it->second, workingItem->mSoundHandle, false); } ++workingItem->mCurrentRepeatTime; } } } else { if (workingItem->mSoundHandle == -1) { SoundNames::iterator it = mSoundNames.find(workingItem->mSoundID); if (it != mSoundNames.end()) { workingItem->mSoundHandle = _PlaySound(it->second, workingItem->mSoundHandle, false); } workingItem->mSoundHandle = _PlaySound(it->second, workingItem->mSoundHandle, true); } } if (workingItem->mRadius > 0) { float dis = Ogre::Math::Sqrt( (camGrid.first - workingItem->mXPos) * (camGrid.first - workingItem->mXPos) + (camGrid.second - workingItem->mZPos) * (camGrid.second - workingItem->mZPos) ); float volume = 0; if(dis <= workingItem->mRadius) volume = 1.0f-(dis/workingItem->mRadius); _SetSoundVolume(workingItem->mSoundHandle, volume); } } } else { if (mPlaySound && mCurrentSoundItem && mCurrentSoundItem->mRepeatTime != 0) { FLOAT deltaTime = evt.timeSinceLastFrame * 1000; // 如果当前的播放次数已达到重复播放次数,就累加时间,直到达到下次播放的时间,就播放 if (mCurrentRepeatTime == mCurrentSoundItem->mRepeatTime) { mCurrentPlayIntervalTime += (INT)deltaTime; if (mCurrentPlayIntervalTime >= mCurrentSoundItem->mNextRepeatTime) { mCurrentRepeatTime = 0; mCurrentPlayIntervalTime = 0; SoundNames::iterator it = mSoundNames.find(mCurrentSoundItem->mSoundID); if (it != mSoundNames.end()) { mCurrentSoundHandle = _PlaySound(it->second, mCurrentSoundHandle, false); } ++mCurrentRepeatTime; } } else { // 累加重复播放之间的间隔时间 mCurrentRepeatIntervalTime += (INT)deltaTime; if (mCurrentRepeatIntervalTime >= mCurrentSoundItem->mRepeatIntervalTime) { mCurrentRepeatIntervalTime = 0; SoundNames::iterator it = mSoundNames.find(mCurrentSoundItem->mSoundID); if (it != mSoundNames.end()) { mCurrentSoundHandle = _PlaySound(it->second, mCurrentSoundHandle, false); } ++mCurrentRepeatTime; } } } } return true; }
void SoundEditDialog::OnListBoxSoundItemDoubleClick( wxCommandEvent &event ) { _StopAllSounds(); mPlaySoundInGame = false; int index = event.GetInt(); if (index < (int)(mSoundItems.size())) { mWorkingSoundIndex = index; SoundItem* soundItem = mSoundItems[event.GetInt()]; if (mSoundNameComboBox->IsEmpty()) _FillSoundNameComboBox(); SoundNames::iterator it = mSoundNames.find(soundItem->mSoundID); if (it != mSoundNames.end()) { const Ogre::String& soundName = it->second; if (mSoundNameComboBox->FindString(soundName)) mSoundNameComboBox->SetValue(soundName); else mSoundNameComboBox->SetSelection(0); mCurrentSoundHandle = _PlaySound(it->second, mCurrentSoundHandle, soundItem->mRepeatTime == 0); } else { mSoundNameComboBox->SetSelection(0); } mRadiusTextCtrl->SetValue( Ogre::StringConverter::toString(soundItem->mRadius) ); mXPosTextCtrl->SetValue( Ogre::StringConverter::toString(soundItem->mXPos) ); mZPosTextCtrl->SetValue( Ogre::StringConverter::toString(soundItem->mZPos) ); mRepeatTimeTextCtrl->SetValue( Ogre::StringConverter::toString(soundItem->mRepeatTime) ); mRepeatIntervalTimeTextCtrl->SetValue( Ogre::StringConverter::toString(soundItem->mRepeatIntervalTime) ); mNextRepeatTimeTextCtrl->SetValue( Ogre::StringConverter::toString(soundItem->mNextRepeatTime) ); mSoundIDText->SetLabel( Ogre::StringConverter::toString(soundItem->mSoundID) ); mCurrentSoundItem = soundItem; mCurrentRepeatTime = 0; mCurrentRepeatIntervalTime = 0; mCurrentPlayIntervalTime = 0; Ogre::Camera* camera = mSceneManipulator->getCamera(); Fairy::TerrainData* terrainData = mSceneManipulator->getTerrainData(); std::pair<float, float> worldPos = terrainData->gridToWorld(soundItem->mXPos, soundItem->mZPos); float worldHeight = terrainData->getHeightAt(worldPos.first, worldPos.second); Ogre::Vector3 direction = camera->getDirection(); float v = Ogre::Math::Sin(Ogre::Math::DegreesToRadians(89.9f)); float s = Ogre::Math::Sqrt((direction.x*direction.x + direction.z*direction.z) / (1-v*v)); direction.x /= s; direction.z /= s; direction.y = -v; camera->setDirection(direction); camera->setPosition(worldPos.first, worldHeight + 2750.0f, worldPos.second); Fairy::Action* action = mSceneManipulator->_getAction("SoundEditAction"); action->setParameter("ShowRadiusEntity", Ogre::StringConverter::toString(worldPos.first) + " " + Ogre::StringConverter::toString(worldHeight) + " " + Ogre::StringConverter::toString(worldPos.second) + " " + Ogre::StringConverter::toString(soundItem->mRadius)); } }