Playing sound on EGameStart. Menu sounds.

This commit is contained in:
Stiffly
2015-10-19 13:53:42 +02:00
parent 0180b29544
commit dc2ec46cfa
3 changed files with 28 additions and 23 deletions
-4
View File
@@ -1,7 +1,3 @@
//
// Created by Adam on 2015-09-25.
//
#ifndef EVENTS_EGAMESTART_H__
#define EVENTS_EGAMESTART_H__
+4
View File
@@ -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<SoundSystem, dd::Events::MasterVolume> m_EMasterVolume;
bool OnMasterVolume(const dd::Events::MasterVolume &event);
dd::EventRelay<SoundSystem, dd::Events::GameStart> m_EGameStart;
bool OnGameStart(const dd::Events::GameStart &event);
ALuint CreateSource();
};
+24 -19
View File
@@ -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<ConfigFile>("Config.ini")->GetValue<float>("Audio.SFXVolume", 1.f);
m_BGMMasterVolume = ResourceManager::Load<ConfigFile>("Config.ini")->GetValue<float>("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;
}