[add] Load BroomRace Bubble
[add] Sound tool 추가 [add] Sound Event 분리
This commit is contained in:
@@ -1032,10 +1032,34 @@ HRESULT CGameInstance::Load_Sound(SOUND::SD_KIND eKind, const _tchar* wstrSoundF
|
||||
{
|
||||
return m_pSound_Manager->Load_Sound(eKind, wstrSoundFilePath, eSoundMode);
|
||||
}
|
||||
SOUND::SD_KIND CGameInstance::Find_Sound(const _wstring wstrFilePath)
|
||||
{
|
||||
return m_pSound_Manager->Find_Sound(wstrFilePath);
|
||||
}
|
||||
void CGameInstance::Sound_Play(SOUND::SD_KIND eSoundKind, SD_CHANNEL_GROUP eSoundChannel, _bool bRepeat, _float fVolume)
|
||||
{
|
||||
m_pSound_Manager->Sound_Play(eSoundKind, eSoundChannel, bRepeat, fVolume);
|
||||
}
|
||||
void CGameInstance::Sound_Play_3DPos(SOUND::SD_KIND eSoundKind, SD_CHANNEL_GROUP eSoundChannel, _float3& refSpeaker, _float fMin, _float fMax, _bool bRepeat)
|
||||
{
|
||||
m_pSound_Manager->Sound_Play_3DPos(eSoundKind, eSoundChannel, refSpeaker, fMin, fMax, bRepeat);
|
||||
}
|
||||
void CGameInstance::Sound_Pause_Channel(SD_CHANNEL_GROUP eSoundChannel, bool bPause)
|
||||
{
|
||||
m_pSound_Manager->Sound_Pause_Channel(eSoundChannel, bPause);
|
||||
}
|
||||
void CGameInstance::Sound_Set3DListenerPos(CTransform* pTransform)
|
||||
{
|
||||
m_pSound_Manager->Sound_Set3DListenerPos(pTransform);
|
||||
}
|
||||
void CGameInstance::Sound_StopChannel(SD_CHANNEL_GROUP eSoundChannel)
|
||||
{
|
||||
m_pSound_Manager->Sound_StopChannel(eSoundChannel);
|
||||
}
|
||||
void CGameInstance::Sound_Stop(SOUND::SD_KIND eSoundKind, SD_CHANNEL_GROUP eSoundChannel)
|
||||
{
|
||||
m_pSound_Manager->Sound_Stop(eSoundKind, eSoundChannel);
|
||||
}
|
||||
void CGameInstance::Sound_StopAll()
|
||||
{
|
||||
m_pSound_Manager->Sound_StopAll();
|
||||
|
||||
@@ -7,7 +7,7 @@ System* CSound_Manager::s_pSystem = { nullptr };
|
||||
_string CSound_Manager::s_ArrChannelName[ENUM_CLASS(SD_CHANNEL_GROUP::END)] = { "BGM", "ENVIRONMENT", "EFFECT", "VOICE" };
|
||||
list<Channel*> CSound_Manager::s_listChannel[ENUM_CLASS(SD_CHANNEL_GROUP::END)] = {};
|
||||
Sound* CSound_Manager::s_ArrSounds[ENUM_CLASS(SOUND::SD_KIND::END)] = {};
|
||||
|
||||
map<_wstring, SOUND::SD_KIND > CSound_Manager::s_SoundMap = {};
|
||||
|
||||
CSound_Manager::CSound_Manager(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
|
||||
: m_pDevice(pDevice),
|
||||
@@ -38,7 +38,6 @@ HRESULT CSound_Manager::Update()
|
||||
}
|
||||
}
|
||||
}
|
||||
Sound_Test();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
@@ -204,45 +203,8 @@ void CSound_Manager::Sound_SetVolume(SD_CHANNEL_GROUP eSoundChannel, float fVolu
|
||||
}
|
||||
}
|
||||
|
||||
void CSound_Manager::Sound_Test()
|
||||
{
|
||||
//GUI::Begin("Music_Player");
|
||||
//static int item_selected_CHANNEL = 0;
|
||||
//static int item_selected_SD_KIND = 0;
|
||||
|
||||
//GUI::BeginChild("##ITEMs", ImVec2(350.f, 175.f), true, ImGuiWindowFlags_HorizontalScrollbar);
|
||||
//for (int iIndex = 0; iIndex < SOUND::SD_KIND::END; ++iIndex) {
|
||||
// if (GUI::Button(CMyTools::ToString(SOUND::SD_PATH::SD_KIND_STRING[iIndex]).c_str())) {
|
||||
// item_selected_SD_KIND = iIndex;
|
||||
// }
|
||||
//}
|
||||
//GUI::EndChild();
|
||||
//GUI::BeginChild("##Channels", ImVec2(350.f, 175.f), true, ImGuiWindowFlags_HorizontalScrollbar);
|
||||
//for (int iIndex = 0; iIndex < ENUM_CLASS(SD_CHANNEL_GROUP::END); ++iIndex) {
|
||||
// if (GUI::Button(s_ArrChannelName[iIndex].c_str())) {
|
||||
// item_selected_CHANNEL = iIndex;
|
||||
// }
|
||||
//}
|
||||
//GUI::EndChild();
|
||||
|
||||
//if (GUI::Button("Play_Sound", { 50, 50 })) {
|
||||
// Sound_Play(static_cast<SOUND::SD_KIND>(item_selected_SD_KIND), static_cast<SD_CHANNEL_GROUP>(item_selected_CHANNEL), false, false, 1.f);
|
||||
//} GUI::SameLine();
|
||||
//if (GUI::Button("Sound_STOP", { 50, 50 })) {
|
||||
// Sound_StopAll();
|
||||
//}
|
||||
//GUI::End();
|
||||
}
|
||||
|
||||
HRESULT CSound_Manager::Load_Sound(SOUND::SD_KIND eKind, const _tchar* wstrSoundFilePath, FMOD_MODE eSoundMode)
|
||||
{
|
||||
//const _tchar* pSoundFilePath = TEXT("../Bin/Resources/Sounds/");
|
||||
//for (int iIndex = 0; iIndex < ENUM_CLASS(SOUND::SD_KIND::END); ++iIndex) {
|
||||
// if (FAILED(m_pGameInstance->Load_Sound((SOUND::SD_KIND)iIndex, (_wstring(pSoundFilePath) + SOUND::SD_PATH::SD_KIND_STRING[iIndex]).c_str()))) {
|
||||
// return E_FAIL;
|
||||
// }
|
||||
//}
|
||||
|
||||
//// 사운드 생성, 파일 불러오기
|
||||
FMOD_RESULT fr = CSound_Manager::s_pSystem->createSound(
|
||||
CMyTools::ToString(wstrSoundFilePath).c_str(), // 대상 경로
|
||||
@@ -255,6 +217,16 @@ HRESULT CSound_Manager::Load_Sound(SOUND::SD_KIND eKind, const _tchar* wstrSound
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
SOUND::SD_KIND CSound_Manager::Find_Sound(const _wstring wstrFilePath)
|
||||
{
|
||||
auto iter = s_SoundMap.find(wstrFilePath);
|
||||
|
||||
if (iter == s_SoundMap.end())
|
||||
return SOUND::SD_KIND::END;
|
||||
|
||||
return iter->second;
|
||||
}
|
||||
|
||||
HRESULT CSound_Manager::Initialize()
|
||||
{
|
||||
FMOD_RESULT r = System_Create(&s_pSystem);
|
||||
@@ -275,9 +247,22 @@ HRESULT CSound_Manager::Initialize()
|
||||
s_pSystem->init(512, FMOD_INIT_NORMAL, nullptr);
|
||||
}
|
||||
|
||||
Ready_SoundMap();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void CSound_Manager::Ready_SoundMap()
|
||||
{
|
||||
_uint iNumSound = ENUM_CLASS(SOUND::SD_KIND::END);
|
||||
for (_uint i = 0; i < iNumSound; ++i)
|
||||
{
|
||||
s_SoundMap.emplace(SOUND::SD_PATH::SD_KIND_PATHS[i], static_cast<SOUND::SD_KIND>(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
CSound_Manager* CSound_Manager::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
|
||||
{
|
||||
CSound_Manager* pInstance = new CSound_Manager(pDevice, pContext);
|
||||
|
||||
@@ -186,6 +186,37 @@ void CUnit::Play_Event()
|
||||
|
||||
++iter;
|
||||
}
|
||||
|
||||
/* Sound */
|
||||
for (auto iter = m_SoundEvents.begin(); iter != m_SoundEvents.end(); )
|
||||
{
|
||||
_float ratio = m_pModelCom->Get_CurrentTrackProgressRatio();
|
||||
_uint curAnim = m_pModelCom->Get_AnimIndex();
|
||||
|
||||
_float prevRatio = iter->PrevRatio;
|
||||
|
||||
if (curAnim == iter->AnimIndex)
|
||||
{
|
||||
if (prevRatio <= iter->fRatio && ratio >= iter->fRatio)
|
||||
{
|
||||
iter->Callback();
|
||||
|
||||
if (!iter->bKeep)
|
||||
{
|
||||
iter = m_SoundEvents.erase(iter);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
iter->PrevRatio = ratio;
|
||||
}
|
||||
else
|
||||
{
|
||||
iter->PrevRatio = 0.f;
|
||||
}
|
||||
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
|
||||
void CUnit::Add_Event(_uint AnimIndex, function<void()> Callback, _float fRatio,_bool bKeep)
|
||||
@@ -198,6 +229,21 @@ void CUnit::Add_Event(_uint AnimIndex, function<void()> Callback, _float fRatio,
|
||||
m_PendingEvents.push_back(Desc);
|
||||
}
|
||||
|
||||
void CUnit::Add_Sound_Event(_uint AnimIndex, function<void()> Callback, _float fRatio, _bool bKeep)
|
||||
{
|
||||
PendingEvent Desc;
|
||||
Desc.AnimIndex = AnimIndex;
|
||||
Desc.fRatio = fRatio;
|
||||
Desc.Callback = Callback;
|
||||
Desc.bKeep = bKeep;
|
||||
m_SoundEvents.push_back(Desc);
|
||||
}
|
||||
|
||||
void CUnit::Reset_SoundEvent()
|
||||
{
|
||||
m_SoundEvents.clear();
|
||||
}
|
||||
|
||||
void CUnit::Reset_Event()
|
||||
{
|
||||
m_PendingEvents.clear();
|
||||
@@ -584,6 +630,48 @@ STATEANIM::ESTATE CUnit::StringToStateAnim(const string& s)
|
||||
return it->second;
|
||||
}
|
||||
|
||||
HRESULT CUnit::Ready_Sound_Events(const _char* pFilePath)
|
||||
{
|
||||
tinyxml2::XMLDocument xmlDoc;
|
||||
|
||||
if ((tinyxml2::XML_SUCCESS != xmlDoc.LoadFile(pFilePath)))
|
||||
return E_FAIL;
|
||||
|
||||
tinyxml2::XMLElement* root = xmlDoc.FirstChildElement("KeyFrames");
|
||||
|
||||
if (nullptr == root)
|
||||
{
|
||||
MSG_BOX("Failed to Find root");
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
for (auto* Animation = root->FirstChildElement("Animation"); Animation; Animation = Animation->NextSiblingElement("Animation"))
|
||||
{
|
||||
_uint iAnimationIndex = {};
|
||||
|
||||
Animation->QueryUnsignedAttribute("Index", &iAnimationIndex);
|
||||
|
||||
|
||||
for (auto* KeyFrame = Animation->FirstChildElement("KeyFrame"); KeyFrame; KeyFrame = KeyFrame->NextSiblingElement("KeyFrame"))
|
||||
{
|
||||
_float fVolume = {};
|
||||
_float fRatio = {};
|
||||
const _char* pPath = {};
|
||||
|
||||
KeyFrame->QueryStringAttribute("Event", &pPath);
|
||||
KeyFrame->QueryFloatAttribute("Ratio", &fRatio);
|
||||
KeyFrame->QueryFloatAttribute("Volume", &fVolume);
|
||||
|
||||
SOUND::SD_KIND eSoundKind = m_pGameInstance->Find_Sound(CMyTools::ToWstring(pPath));
|
||||
|
||||
Add_Sound_Event(iAnimationIndex,
|
||||
[this, eSoundKind, fVolume]() { m_pGameInstance->Sound_Play(eSoundKind, SD_CHANNEL_GROUP::EFFECT, false, fVolume); },
|
||||
fRatio, true);
|
||||
}
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void CUnit::Free()
|
||||
{
|
||||
|
||||
@@ -211,8 +211,14 @@ class ENGINE_DLL CGameInstance final : public CBase
|
||||
#pragma endregion
|
||||
#pragma region SOUND_MANAGER
|
||||
HRESULT Load_Sound(SOUND::SD_KIND eKind, const _tchar* wstrSoundFilePath, FMOD_MODE eSoundMode);
|
||||
SOUND::SD_KIND Find_Sound(const _wstring wstrFilePath);
|
||||
void Sound_Play(SOUND::SD_KIND eSoundKind, SD_CHANNEL_GROUP eSoundChannel, _bool bRepeat, _float fVolume);
|
||||
void Sound_StopAll(); // 전체 정지
|
||||
void Sound_Play_3DPos(SOUND::SD_KIND eSoundKind, SD_CHANNEL_GROUP eSoundChannel, _float3& refSpeaker, _float fMin = 3.f, _float fMax = 20.f, _bool bRepeat = false);
|
||||
void Sound_Pause_Channel(SD_CHANNEL_GROUP eSoundChannel, bool bPause);
|
||||
void Sound_Set3DListenerPos(class CTransform* pTransform);
|
||||
void Sound_StopChannel(SD_CHANNEL_GROUP eSoundChannel);
|
||||
void Sound_Stop(SOUND::SD_KIND eSoundKind, SD_CHANNEL_GROUP eSoundChannel);
|
||||
void Sound_StopAll();
|
||||
#pragma endregion
|
||||
|
||||
#pragma region PICKING
|
||||
|
||||
@@ -11,6 +11,7 @@ class CSound_Manager final :
|
||||
static _string s_ArrChannelName[ENUM_CLASS(SD_CHANNEL_GROUP::END)];
|
||||
static list<Channel*> s_listChannel[ENUM_CLASS(SD_CHANNEL_GROUP::END)];
|
||||
static Sound* s_ArrSounds[ENUM_CLASS(SOUND::SD_KIND::END)];
|
||||
static map<_wstring, SOUND::SD_KIND> s_SoundMap;
|
||||
|
||||
private:
|
||||
CSound_Manager(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
|
||||
@@ -29,9 +30,9 @@ class CSound_Manager final :
|
||||
void Sound_Stop(SOUND::SD_KIND eSoundKind, SD_CHANNEL_GROUP eSoundChannel); // 특정 사운드 정지
|
||||
void Sound_StopAll(); // 전체 정지
|
||||
void Sound_SetVolume(SD_CHANNEL_GROUP eSoundChannel, float fVolume);
|
||||
void Sound_Test();
|
||||
|
||||
HRESULT Load_Sound(SOUND::SD_KIND eKind, const _tchar* wstrSoundFilePath, FMOD_MODE eSoundMode);
|
||||
SOUND::SD_KIND Find_Sound(const _wstring wstrFilePath);
|
||||
|
||||
private:
|
||||
ID3D11Device* m_pDevice = { nullptr };
|
||||
@@ -41,6 +42,7 @@ class CSound_Manager final :
|
||||
|
||||
private:
|
||||
HRESULT Initialize();
|
||||
void Ready_SoundMap();
|
||||
|
||||
public:
|
||||
static CSound_Manager* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
|
||||
|
||||
@@ -36,6 +36,9 @@ class ENGINE_DLL CUnit abstract : public CContainerObject
|
||||
_wstring& Get_PrototypeTag() { return m_strModelPrototypeTag; }
|
||||
_bool IsAI() { return m_bAI; }
|
||||
|
||||
HRESULT Ready_Sound_Events(const _char* pFilePath);
|
||||
void Add_Sound_Event(_uint AnimIndex, function<void()> Callback, _float fRatio = 0.f, _bool bKeep = false);
|
||||
void Reset_SoundEvent();
|
||||
#ifdef _DEBUG
|
||||
void Load_KeyFrame();
|
||||
#endif // _DEBUG
|
||||
@@ -89,6 +92,7 @@ class ENGINE_DLL CUnit abstract : public CContainerObject
|
||||
_float m_fHitRadius = {};
|
||||
|
||||
vector<PendingEvent> m_PendingEvents;
|
||||
vector<PendingEvent> m_SoundEvents = {};
|
||||
|
||||
_float m_fHitDegree = {};
|
||||
_float m_fHitCross = {};
|
||||
@@ -105,12 +109,17 @@ class ENGINE_DLL CUnit abstract : public CContainerObject
|
||||
|
||||
protected:
|
||||
HRESULT Ready_Components(void*pArg);
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
#endif // _DEBUG
|
||||
void Play_Event();
|
||||
protected:
|
||||
void Add_Event(_uint AnimIndex, function<void()> Callback, _float fRatio = 0.f, _bool bKeep = false);
|
||||
void Reset_Event();
|
||||
void Check_HitAngle(_vector ProjectileDir);
|
||||
virtual void Load_AnimXML(const string& path);
|
||||
STATEANIM::ESTATE StringToStateAnim(const string& s);
|
||||
|
||||
public:
|
||||
virtual CGameObject* Clone(void* pArg, CGameObject* pOwner = nullptr)PURE;
|
||||
virtual void Free() override;
|
||||
|
||||
Reference in New Issue
Block a user