| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- namespace DuckHunter
- {
- public class AudioManager : MonoBehaviour
- {
- private static AudioManager _Instance;
- public static AudioManager Instance
- {
- get
- {
- if (!_Instance) new GameObject(typeof(AudioManager).Name).AddComponent<AudioManager>();
- return _Instance;
- }
- }
- void Awake()
- {
- _Instance = this;
- }
- void OnDestroy()
- {
- if (_Instance == this) _Instance = null;
- }
- public void PlayGunShoot(GameObject target)
- {
- PlayAudio("Audios/gun_shoot", GetAudioSource(target));
- }
- public void PlayShoot(GameObject target)
- {
- PlayAudio("DuckHunter/Audios/Shoot", GetAudioSource(target));
- }
- public void PlayDuckHit(GameObject target)
- {
- PlayAudio("DuckHunter/Audios/DuckHit", GetAudioSource(target));
- }
- public void PlayDogTaunt(GameObject target)
- {
- PlayAudio("DuckHunter/Audios/DogTaunt", GetAudioSource(target));
- }
- public void PlayDogHappy(GameObject target)
- {
- PlayAudio("DuckHunter/Audios/DogHappy", GetAudioSource(target));
- }
- public void PlayGameStart()
- {
- PlayAudio("DuckHunter/Audios/GameStart", null);
- }
- public void PlayGameOver()
- {
- PlayAudio("DuckHunter/Audios/GameOver", null);
- }
- public void PlayGamePass()
- {
- PlayAudio("DuckHunter/Audios/GamePass", null);
- }
- public void PlayFullScore()
- {
- PlayAudio("DuckHunter/Audios/FullScore", null);
- }
- public void PlayBtn()
- {
- AudioMgr.ins.PlayBtn();
- }
- private void PlayAudio(string audioPath, AudioSource audioSource)
- {
- AudioMgr.ins.Play(audioPath, audioSource);
- }
- private AudioSource GetAudioSource(GameObject target)
- {
- if (target == null) return null;
- return AudioMgr.GetAudioSource(target);
- }
- }
- }
|