diff --git a/include/Game/EGameStart.h b/include/Game/EGameStart.h index bfee0fd..faf89a2 100644 --- a/include/Game/EGameStart.h +++ b/include/Game/EGameStart.h @@ -1,7 +1,3 @@ -// -// Created by Adam on 2015-09-25. -// - #ifndef EVENTS_EGAMESTART_H__ #define EVENTS_EGAMESTART_H__ diff --git a/include/Sound/SoundSystem.h b/include/Sound/SoundSystem.h index 3d02ef2..5349258 100644 --- a/include/Sound/SoundSystem.h +++ b/include/Sound/SoundSystem.h @@ -19,6 +19,7 @@ #include "Sound/EMasterVolume.h" #include "Physics/ECreateParticleSequence.h" #include "Physics/EContact.h" +#include "Game/EGameStart.h" namespace dd @@ -54,6 +55,9 @@ private: bool OnStopSound(const dd::Events::StopSound &event); dd::EventRelay m_EMasterVolume; bool OnMasterVolume(const dd::Events::MasterVolume &event); + dd::EventRelay m_EGameStart; + bool OnGameStart(const dd::Events::GameStart &event); + ALuint CreateSource(); }; diff --git a/src/game/Sound/SoundSystem.cpp b/src/game/Sound/SoundSystem.cpp index 78def4e..7580b99 100644 --- a/src/game/Sound/SoundSystem.cpp +++ b/src/game/Sound/SoundSystem.cpp @@ -39,24 +39,10 @@ void dd::Systems::SoundSystem::Initialize() EVENT_SUBSCRIBE_MEMBER(m_EPlaySFX, &SoundSystem::OnPlaySound); EVENT_SUBSCRIBE_MEMBER(m_EStopSound, &SoundSystem::OnStopSound); EVENT_SUBSCRIBE_MEMBER(m_EMasterVolume, &SoundSystem::OnMasterVolume); + EVENT_SUBSCRIBE_MEMBER(m_EGameStart, &SoundSystem::OnGameStart); m_SFXMasterVolume = ResourceManager::Load("Config.ini")->GetValue("Audio.SFXVolume", 1.f); m_BGMMasterVolume = ResourceManager::Load("Config.ini")->GetValue("Audio.BGMVolume", 1.f); - -// //Todo: Move this -// { -// dd::Events::PlaySound e; -// e.FilePath = "Sounds/BGM/under-the-sea-instrumental.wav"; -// e.IsAmbient = true; -// EventBroker->Publish(e); -// } -// { -// dd::Events::PlaySound e; -// e.FilePath = "Sounds/BGM/water-flowing.wav"; -// e.Gain = 0.3f; -// e.IsAmbient = true; -// EventBroker->Publish(e); -// } } void dd::Systems::SoundSystem::Update(double dt) @@ -182,14 +168,33 @@ bool dd::Systems::SoundSystem::OnContact(const dd::Events::Contact &event) //Send play-sound event { -// dd::Events::PlaySound e; -// e.FilePath = collisionSound->FilePath; -// e.IsAmbient = false; -// EventBroker->Publish(e); + dd::Events::PlaySound e; + e.FilePath = collisionSound->FilePath; + e.IsAmbient = false; + e.Gain = 0.8f; + EventBroker->Publish(e); } return true; } +bool dd::Systems::SoundSystem::OnGameStart(const dd::Events::GameStart &event) +{ + { + dd::Events::PlaySound e; + e.FilePath = "Sounds/BGM/under-the-sea-instrumental.wav"; + e.IsAmbient = true; + EventBroker->Publish(e); + } + { + dd::Events::PlaySound e; + e.FilePath = "Sounds/BGM/water-flowing.wav"; + e.Gain = 0.3f; + e.IsAmbient = true; + EventBroker->Publish(e); + } + return true; +} +