files arranged using assembly defn
This commit is contained in:
58
Assets/DarkMatter/Code/Presentation/Audio/AudioController.cs
Normal file
58
Assets/DarkMatter/Code/Presentation/Audio/AudioController.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using Darkmatter.Core;
|
||||
using UnityEngine;
|
||||
using VContainer;
|
||||
|
||||
namespace Darkmatter.Presentation
|
||||
{
|
||||
public class AudioController : MonoBehaviour, IAudioController
|
||||
{
|
||||
[SerializeField] private AudioSource MusicSource;
|
||||
[SerializeField] private AudioSource SFXSource;
|
||||
|
||||
public AudioClip backgroundMusicClip;
|
||||
public AudioClip jumpClip;
|
||||
public AudioClip deathClip;
|
||||
public AudioClip btnPressedClip;
|
||||
public AudioClip scoredClip;
|
||||
|
||||
[Inject] private IGameSession IgameSession;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
MusicSource.clip = backgroundMusicClip;
|
||||
MusicSource.loop = true;
|
||||
MusicSource.Play();
|
||||
}
|
||||
|
||||
|
||||
public void PlaySfx(AudioClip clip)
|
||||
{
|
||||
if (!IgameSession.hasGameStarted) return;
|
||||
SFXSource.ignoreListenerPause = true;
|
||||
SFXSource.PlayOneShot(clip);
|
||||
}
|
||||
|
||||
public void PlayJumpSound()
|
||||
{
|
||||
PlaySfx(jumpClip);
|
||||
}
|
||||
|
||||
public void PlayDeathSound()
|
||||
{
|
||||
PlaySfx(deathClip);
|
||||
}
|
||||
|
||||
public void PlayBtnPressedSound()
|
||||
{
|
||||
PlaySfx(btnPressedClip);
|
||||
}
|
||||
|
||||
public void PlayScoredSound()
|
||||
{
|
||||
PlaySfx(scoredClip);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user