diff --git a/Assets/Resources/Game bgm2.mp3 b/Assets/Resources/Game bgm2.mp3 new file mode 100644 index 0000000..6e753a4 Binary files /dev/null and b/Assets/Resources/Game bgm2.mp3 differ diff --git a/Assets/Resources/Game bgm2.mp3.meta b/Assets/Resources/Game bgm2.mp3.meta new file mode 100644 index 0000000..15e5280 --- /dev/null +++ b/Assets/Resources/Game bgm2.mp3.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: 576c895328ccd5f4a91364f7fa42bea8 +AudioImporter: + externalObjects: {} + serializedVersion: 7 + defaultSettings: + serializedVersion: 2 + loadType: 0 + sampleRateSetting: 0 + sampleRateOverride: 44100 + compressionFormat: 1 + quality: 1 + conversionMode: 0 + preloadAudioData: 0 + platformSettingOverrides: {} + forceToMono: 0 + normalize: 1 + loadInBackground: 0 + ambisonic: 0 + 3D: 1 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/Prefabs/Audio Manager.prefab b/Assets/Resources/Prefabs/Audio Manager.prefab index 1fa43b9..47f54b7 100644 --- a/Assets/Resources/Prefabs/Audio Manager.prefab +++ b/Assets/Resources/Prefabs/Audio Manager.prefab @@ -10,7 +10,6 @@ GameObject: m_Component: - component: {fileID: 2402232447803946232} - component: {fileID: 3667565604047053759} - - component: {fileID: 841089304725320238} m_Layer: 0 m_Name: Audio Manager m_TagString: Untagged @@ -46,103 +45,16 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: mainBgm: {fileID: 8300000, guid: 1d9c7fb20aa822c48933d00b6bd6a757, type: 3} - gameBgm: {fileID: 8300000, guid: 6d4eda23943dd0b4099b86b28fa0840c, type: 3} + gameBgm: {fileID: 8300000, guid: 576c895328ccd5f4a91364f7fa42bea8, type: 3} clickSound: {fileID: 8300000, guid: cff2e6cf7f46a074d86955b3b6fd499a, type: 3} closeSound: {fileID: 8300000, guid: e7c0f32158a3e5b46bc3b59035aba898, type: 3} - sfxVolume: 0 ---- !u!82 &841089304725320238 -AudioSource: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2946408323859178723} - m_Enabled: 1 - serializedVersion: 4 - OutputAudioMixerGroup: {fileID: 0} - m_audioClip: {fileID: 0} - m_PlayOnAwake: 1 - m_Volume: 1 - m_Pitch: 1 - Loop: 0 - Mute: 0 - Spatialize: 0 - SpatializePostEffects: 0 - Priority: 128 - DopplerLevel: 1 - MinDistance: 1 - MaxDistance: 500 - Pan2D: 0 - rolloffMode: 0 - BypassEffects: 0 - BypassListenerEffects: 0 - BypassReverbZones: 0 - rolloffCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 1 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - - serializedVersion: 3 - time: 1 - value: 0 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - panLevelCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 0 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - spreadCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 0 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - reverbZoneMixCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 1 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 + coinsAddSound: {fileID: 8300000, guid: 1ec44182fa76a4b3eb1459c0a6d9a8ab, type: 3} + coinsEmptySound: {fileID: 8300000, guid: 908a78cb991984977bea42916bed8684, type: 3} + coinsRemoveSound: {fileID: 8300000, guid: 585a9de0fb7ee4163af5c559ba5b2364, type: 3} + winSound: {fileID: 8300000, guid: 1613a4bf934e4d043b4e50b1b74c16b5, type: 3} + loseSound: {fileID: 8300000, guid: 2a467daa72a01214384d2fa5677f668a, type: 3} + stoneSound: {fileID: 8300000, guid: 829ae38dccffa8f4ebf5829b8963ad31, type: 3} + bgmAudioSource: {fileID: 0} + sfxVolume: 1 + isPlayBGM: 0 + isPlaySFX: 0 diff --git a/Assets/Resources/Prefabs/Panels/Coins Panel.prefab b/Assets/Resources/Prefabs/Panels/Coins Panel.prefab index 93b08f8..7596238 100644 --- a/Assets/Resources/Prefabs/Panels/Coins Panel.prefab +++ b/Assets/Resources/Prefabs/Panels/Coins Panel.prefab @@ -10,7 +10,6 @@ GameObject: m_Component: - component: {fileID: 1769668775421633028} - component: {fileID: 4222531876603999234} - - component: {fileID: 5499754916380040505} m_Layer: 5 m_Name: Coins Panel m_TagString: Untagged @@ -53,106 +52,6 @@ MonoBehaviour: m_EditorClassIdentifier: coinsRemoveImageObject: {fileID: 4198953742281733827} coinsCountText: {fileID: 2892066450466788586} - coinsRemoveAudioClip: {fileID: 8300000, guid: 585a9de0fb7ee4163af5c559ba5b2364, type: 3} - coinsAddAudioClip: {fileID: 8300000, guid: 1ec44182fa76a4b3eb1459c0a6d9a8ab, type: 3} - coinsEmptyAudioClip: {fileID: 8300000, guid: 908a78cb991984977bea42916bed8684, type: 3} - ShopPanel: {fileID: 8190964574954487140, guid: eb257b0a685b2254f860f294ce8cba54, type: 3} ---- !u!82 &5499754916380040505 -AudioSource: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 646100354038727038} - m_Enabled: 1 - serializedVersion: 4 - OutputAudioMixerGroup: {fileID: 0} - m_audioClip: {fileID: 0} - m_PlayOnAwake: 1 - m_Volume: 1 - m_Pitch: 1 - Loop: 0 - Mute: 0 - Spatialize: 0 - SpatializePostEffects: 0 - Priority: 128 - DopplerLevel: 1 - MinDistance: 1 - MaxDistance: 500 - Pan2D: 0 - rolloffMode: 0 - BypassEffects: 0 - BypassListenerEffects: 0 - BypassReverbZones: 0 - rolloffCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 1 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - - serializedVersion: 3 - time: 1 - value: 0 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - panLevelCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 0 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - spreadCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 0 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - reverbZoneMixCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 1 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 --- !u!1 &4198953742281733827 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Resources/Prefabs/Panels/Setting Panel.prefab b/Assets/Resources/Prefabs/Panels/Setting Panel.prefab index 61d981c..0b9d12b 100644 --- a/Assets/Resources/Prefabs/Panels/Setting Panel.prefab +++ b/Assets/Resources/Prefabs/Panels/Setting Panel.prefab @@ -13,7 +13,6 @@ GameObject: - component: {fileID: 5762671619601460934} - component: {fileID: 6789969287113785900} - component: {fileID: 413977444317235173} - - component: {fileID: 6428684691423417346} m_Layer: 5 m_Name: Switch m_TagString: Untagged @@ -148,103 +147,6 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: handleImage: {fileID: 6756679498073114696} - clickSound: {fileID: 8300000, guid: cff2e6cf7f46a074d86955b3b6fd499a, type: 3} ---- !u!82 &6428684691423417346 -AudioSource: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 212417647848747046} - m_Enabled: 1 - serializedVersion: 4 - OutputAudioMixerGroup: {fileID: 0} - m_audioClip: {fileID: 0} - m_PlayOnAwake: 1 - m_Volume: 1 - m_Pitch: 1 - Loop: 0 - Mute: 0 - Spatialize: 0 - SpatializePostEffects: 0 - Priority: 128 - DopplerLevel: 1 - MinDistance: 1 - MaxDistance: 500 - Pan2D: 0 - rolloffMode: 0 - BypassEffects: 0 - BypassListenerEffects: 0 - BypassReverbZones: 0 - rolloffCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 1 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - - serializedVersion: 3 - time: 1 - value: 0 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - panLevelCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 0 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - spreadCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 0 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - reverbZoneMixCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 1 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 --- !u!1 &1754413034098038561 GameObject: m_ObjectHideFlags: 0 @@ -859,7 +761,6 @@ GameObject: - component: {fileID: 2622934673103949083} - component: {fileID: 3464089222698319368} - component: {fileID: 8434701791193156984} - - component: {fileID: 9145795730378986889} m_Layer: 5 m_Name: Switch m_TagString: Untagged @@ -994,103 +895,6 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: handleImage: {fileID: 1822478720763898751} - clickSound: {fileID: 8300000, guid: cff2e6cf7f46a074d86955b3b6fd499a, type: 3} ---- !u!82 &9145795730378986889 -AudioSource: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5387157431517620447} - m_Enabled: 1 - serializedVersion: 4 - OutputAudioMixerGroup: {fileID: 0} - m_audioClip: {fileID: 0} - m_PlayOnAwake: 1 - m_Volume: 1 - m_Pitch: 1 - Loop: 0 - Mute: 0 - Spatialize: 0 - SpatializePostEffects: 0 - Priority: 128 - DopplerLevel: 1 - MinDistance: 1 - MaxDistance: 500 - Pan2D: 0 - rolloffMode: 0 - BypassEffects: 0 - BypassListenerEffects: 0 - BypassReverbZones: 0 - rolloffCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 1 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - - serializedVersion: 3 - time: 1 - value: 0 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - panLevelCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 0 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - spreadCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 0 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - reverbZoneMixCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 1 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 --- !u!1 &7654744771681034987 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Resources/win sound.mp3 b/Assets/Resources/win sound.mp3 new file mode 100644 index 0000000..6c1153f Binary files /dev/null and b/Assets/Resources/win sound.mp3 differ diff --git a/Assets/Resources/win sound.mp3.meta b/Assets/Resources/win sound.mp3.meta new file mode 100644 index 0000000..fb95f3c --- /dev/null +++ b/Assets/Resources/win sound.mp3.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: 1613a4bf934e4d043b4e50b1b74c16b5 +AudioImporter: + externalObjects: {} + serializedVersion: 7 + defaultSettings: + serializedVersion: 2 + loadType: 0 + sampleRateSetting: 0 + sampleRateOverride: 44100 + compressionFormat: 1 + quality: 1 + conversionMode: 0 + preloadAudioData: 0 + platformSettingOverrides: {} + forceToMono: 0 + normalize: 1 + loadInBackground: 0 + ambisonic: 0 + 3D: 1 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Script/Common/AudioManager.cs b/Assets/Script/Common/AudioManager.cs index fcb7ff3..9e8c51c 100644 --- a/Assets/Script/Common/AudioManager.cs +++ b/Assets/Script/Common/AudioManager.cs @@ -1,5 +1,6 @@ using UnityEngine; using UnityEngine.SceneManagement; +using UnityEngine.Timeline; public class AudioManager : Singleton { @@ -9,11 +10,20 @@ public class AudioManager : Singleton [Header("SFX")] [SerializeField] private AudioClip clickSound; [SerializeField] private AudioClip closeSound; + [SerializeField] private AudioClip coinsAddSound; + [SerializeField] private AudioClip coinsEmptySound; + [SerializeField] private AudioClip coinsRemoveSound; + [SerializeField] private AudioClip winSound; + [SerializeField] private AudioClip loseSound; + [SerializeField] private AudioClip stoneSound; - private AudioSource bgmAudioSource; // BGM을 위한 AudioSource + [HideInInspector] public AudioSource bgmAudioSource; // BGM을 위한 AudioSource private AudioSource sfxAudioSource; // SFX를 위한 AudioSource - [HideInInspector] public float sfxVolume = 1.0f; // SFX 볼륨 (기본값 1) + public float sfxVolume = 1.0f; // SFX 볼륨 (기본값 1) + + [HideInInspector]public bool isPlayBGM; + [HideInInspector]public bool isPlaySFX; private void Awake() { @@ -27,10 +37,9 @@ public class AudioManager : Singleton // 시작 시 BGM을 자동으로 재생 private void Start() { - if (UserManager.IsPlayBGM) // UserManager의 BGM 설정값에 따라 BGM을 재생 - { - PlayMainBGM(); // 기본 BGM을 재생 - } + isPlayBGM = UserManager.IsPlayBGM; + isPlaySFX = UserManager.IsPlaySFX; + PlayBGM(); } // 메인 BGM을 재생하는 함수 @@ -44,15 +53,6 @@ public class AudioManager : Singleton bgmAudioSource.Play(); // BGM 재생 } } - - // BGM을 멈추는 함수 - public void StopMainBGM() - { - if (bgmAudioSource != null && bgmAudioSource.isPlaying) - { - bgmAudioSource.Stop(); // BGM을 멈춤 - } - } public void PlayGameBGM() { @@ -64,18 +64,44 @@ public class AudioManager : Singleton bgmAudioSource.Play(); // 게임 BGM 재생 } } + + public void PlayBGM() + { + if (isPlayBGM) + { + Scene currentScene = SceneManager.GetActiveScene(); + + if (currentScene.name == "Main") + { + StopBGM(); + PlayMainBGM(); + } + else if (currentScene.name == "Game") + { + StopBGM(); + PlayGameBGM(); + } + } + } - public void StopGameBGM() + public void StopBGM() { if (bgmAudioSource != null && bgmAudioSource.isPlaying) { bgmAudioSource.Stop(); // 게임용 BGM을 멈춤 } } + + // 씬이 로드될 때마다 호출되는 OnSceneLoaded 메서드 + protected override void OnSceneLoaded(Scene scene, LoadSceneMode mode) + { + PlayBGM(); + } // 클릭 사운드(SFX) 재생 public void PlayClickSound() { + if (sfxAudioSource != null) { sfxAudioSource.PlayOneShot(clickSound, sfxVolume); @@ -91,26 +117,51 @@ public class AudioManager : Singleton } } - // 씬이 로드될 때마다 호출되는 OnSceneLoaded 메서드 - protected override void OnSceneLoaded(Scene scene, LoadSceneMode mode) + public void PlayCoinsAddSound() { - if (scene.name == "Main") + if (isPlaySFX && sfxAudioSource!=null) { - StopGameBGM(); - - if (UserManager.IsPlayBGM) // BGM 설정값에 따라 메인 BGM을 재생 - { - PlayMainBGM(); - } + sfxAudioSource.PlayOneShot(coinsAddSound, sfxVolume); } - else if (scene.name == "Game") + } + + public void PlayCoinsEmptySound() + { + if (isPlaySFX && sfxAudioSource!=null) { - StopMainBGM(); - - if (UserManager.IsPlayBGM) // BGM 설정값에 따라 게임 BGM을 재생 - { - PlayGameBGM(); - } + sfxAudioSource.PlayOneShot(coinsEmptySound, sfxVolume); + } + } + + public void PlayCoinsRemoveSound() + { + if (isPlaySFX && sfxAudioSource!=null) + { + sfxAudioSource.PlayOneShot(coinsRemoveSound, sfxVolume); + } + } + + public void PlayLoseSound() + { + if (isPlaySFX && sfxAudioSource!=null) + { + sfxAudioSource.PlayOneShot(loseSound, sfxVolume); + } + } + + public void PlayWinSound() + { + if (isPlaySFX && sfxAudioSource!=null) + { + sfxAudioSource.PlayOneShot(winSound, sfxVolume); + } + } + + public void PlayStoneSound() + { + if (isPlaySFX && sfxAudioSource!=null) + { + sfxAudioSource.PlayOneShot(stoneSound, sfxVolume); } } } \ No newline at end of file diff --git a/Assets/Script/Common/CoinsPanelController.cs b/Assets/Script/Common/CoinsPanelController.cs index a51c973..7d3c38e 100644 --- a/Assets/Script/Common/CoinsPanelController.cs +++ b/Assets/Script/Common/CoinsPanelController.cs @@ -6,16 +6,11 @@ using UnityEngine.EventSystems; using UnityEngine.Serialization; using UnityEngine.UI; -[RequireComponent(typeof(AudioSource))] public class CoinsPanelController : MonoBehaviour { [SerializeField] private GameObject coinsRemoveImageObject; [SerializeField] private TMP_Text coinsCountText; - [SerializeField] private AudioClip coinsRemoveAudioClip; - [SerializeField] private AudioClip coinsAddAudioClip; - [SerializeField] private AudioClip coinsEmptyAudioClip; - private Color _coinsColor; private AudioSource _audioSource; private int _coinsCount; @@ -110,19 +105,17 @@ public class CoinsPanelController : MonoBehaviour { ChangeTextAnimation(true, ()=> { - // TODO : 코인 수량 업데이트 + _coinsCount += 500; action?.Invoke(); }); // 효과음 재생 - // TODO : if (UserInformation.IsPlaySFX) - _audioSource.PlayOneShot(coinsAddAudioClip); + AudioManager.Instance.PlayCoinsAddSound(); }); sequence.AppendInterval(0.5f); } sequence.OnComplete(() => { - _coinsCount += coinsCount; //추가된 코인 적용 _canvasGroup.blocksRaycasts = true; //구매 후 클릭 활성화 }); } @@ -130,8 +123,7 @@ public class CoinsPanelController : MonoBehaviour public void EmptyCoins() { // 효과음 재생 - // TODO: if (UserInformation.IsPlaySFX) - _audioSource.PlayOneShot(coinsEmptyAudioClip); + AudioManager.Instance.PlayCoinsEmptySound(); GetComponent().DOPunchPosition(new Vector3(20f, 0, 0), 1f, 7); } @@ -151,8 +143,7 @@ public class CoinsPanelController : MonoBehaviour } // 효과음 재생 - // TODO: if (UserInformation.IsPlaySFX) - _audioSource.PlayOneShot(coinsRemoveAudioClip); + AudioManager.Instance.PlayCoinsRemoveSound(); // 코인 사라지는 연출 coinsRemoveImageObject.SetActive(true); diff --git a/Assets/Script/Main/UserManager.cs b/Assets/Script/Main/UserManager.cs index c9f99e9..16d9d03 100644 --- a/Assets/Script/Main/UserManager.cs +++ b/Assets/Script/Main/UserManager.cs @@ -87,14 +87,22 @@ public class UserManager : Singleton public static bool IsPlaySFX { get { return PlayerPrefs.GetInt("IsPlaySFX", 1) == 1; } - set { PlayerPrefs.SetInt("IsPlaySFX", value ? 1 : 0); } + set + { + PlayerPrefs.SetInt("IsPlaySFX", value ? 1 : 0); + AudioManager.Instance.isPlaySFX = value; + } } // 배경음악 재생 여부 public static bool IsPlayBGM { get { return PlayerPrefs.GetInt("IsPlayBGM", 1) == 1; } - set { PlayerPrefs.SetInt("IsPlayBGM", value ? 1 : 0); } + set + { + PlayerPrefs.SetInt("IsPlayBGM", value ? 1 : 0); + AudioManager.Instance.isPlayBGM = value; + } } protected override void OnSceneLoaded(Scene scene, LoadSceneMode mode) diff --git a/Assets/Script/UI/PanelChildController/SwitchController.cs b/Assets/Script/UI/PanelChildController/SwitchController.cs index 6045071..8df8317 100644 --- a/Assets/Script/UI/PanelChildController/SwitchController.cs +++ b/Assets/Script/UI/PanelChildController/SwitchController.cs @@ -6,11 +6,9 @@ using UnityEngine.UI; using DG.Tweening; [RequireComponent(typeof(Image))] -[RequireComponent(typeof(AudioSource))] public class SwitchController : MonoBehaviour { [SerializeField] private Image handleImage; - [SerializeField] private AudioClip clickSound; //스위치에 상태 변경 시 호출할 콜백 함수 public delegate void OnSwitchChangedDelegate(bool isOn); @@ -56,8 +54,7 @@ public class SwitchController : MonoBehaviour } // 효과음 재생 - if (clickSound != null) - _audioSource.PlayOneShot(clickSound); + AudioManager.Instance.PlayClickSound(); //이벤트 호출 OnSwitchChanged?.Invoke(isOn); diff --git a/Assets/Script/UI/PanelController/SettingPanelController.cs b/Assets/Script/UI/PanelController/SettingPanelController.cs index ba9efb3..d568e8b 100644 --- a/Assets/Script/UI/PanelController/SettingPanelController.cs +++ b/Assets/Script/UI/PanelController/SettingPanelController.cs @@ -33,15 +33,15 @@ public class SettingsPanelController : PanelController // BGM을 끄는 경우 if (!value) { - GameManager.Instance.audioManager.StopMainBGM(); // BGM을 끄기 + AudioManager.Instance.StopBGM(); // BGM을 끄기 } // BGM을 켜는 경우 else { // 이미 BGM이 재생 중인 경우 새로 시작하지 않도록 체크 - if (!GameManager.Instance.audioManager.GetComponent().isPlaying) + if (!AudioManager.Instance.bgmAudioSource.isPlaying) { - GameManager.Instance.audioManager.PlayMainBGM(); // BGM을 켜기 + AudioManager.Instance.PlayBGM(); // BGM을 켜기 } } }