From 76aeacecbd44f2f43923f4263694cb9c93698526 Mon Sep 17 00:00:00 2001 From: Parkillhwan Date: Mon, 31 Mar 2025 14:28:08 +0900 Subject: [PATCH] =?UTF-8?q?DO-91-=EC=9D=BC=ED=99=98-=EC=A3=BC=EC=84=9D-?= =?UTF-8?q?=EB=94=94=EB=B2=84=EA=B7=B8-=EB=A1=9C=EA=B7=B8-=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Script/Common/AudioManager.cs | 38 ++++++++----------- Assets/Script/Main/ScoreCellController.cs | 2 +- Assets/Script/Main/ScoreListWrapper.cs | 2 +- .../PanelController/LeaderBoardController.cs | 37 ++++++++---------- .../PanelController/SettingPanelController.cs | 22 +++++------ 5 files changed, 44 insertions(+), 57 deletions(-) diff --git a/Assets/Script/Common/AudioManager.cs b/Assets/Script/Common/AudioManager.cs index a4f9d0b..af92ce8 100644 --- a/Assets/Script/Common/AudioManager.cs +++ b/Assets/Script/Common/AudioManager.cs @@ -8,10 +8,10 @@ public class AudioManager : Singleton private AudioClip mainBgm; private AudioClip gameBgm; - [HideInInspector] public AudioSource bgmAudioSource; // BGM을 위한 AudioSource - private AudioSource sfxAudioSource; // SFX를 위한 AudioSource + [HideInInspector] public AudioSource bgmAudioSource; + private AudioSource sfxAudioSource; - public float sfxVolume = 1.0f; // SFX 볼륨 (기본값 1) + public float sfxVolume = 1.0f; [HideInInspector]public bool isPlayBGM; [HideInInspector]public bool isPlaySFX; @@ -21,13 +21,13 @@ public class AudioManager : Singleton protected override void Awake() { - base.Awake(); // 부모 클래스의 Awake 호출 + base.Awake(); - // BGM과 SFX를 위한 별도의 AudioSource 생성 + bgmAudioSource = gameObject.AddComponent(); sfxAudioSource = gameObject.AddComponent(); - //Sounds폴더 내의 모든 오디오클립 로드 + AudioClip[] clips = Resources.LoadAll("Sounds"); foreach (AudioClip clip in clips) @@ -35,8 +35,6 @@ public class AudioManager : Singleton audioClips[clip.name] = clip; } - Debug.Log($"총 {audioClips.Count}개의 오디오클립이 로드됨."); - } public AudioClip GetAudioClip(string clipName) @@ -45,14 +43,10 @@ public class AudioManager : Singleton { return clip; } - else - { - Debug.LogError($"패널 '{clipName}'을 찾을 수 없습니다."); - } return null; } - // 시작 시 BGM을 자동으로 재생 + private void Start() { isPlayBGM = UserManager.IsPlayBGM; @@ -61,7 +55,7 @@ public class AudioManager : Singleton PlayBGM(); } - // 메인 BGM을 재생하는 함수 + public void PlayMainBGM() { mainBgm = GetAudioClip("MainBGM"); @@ -69,9 +63,9 @@ public class AudioManager : Singleton if (bgmAudioSource != null && mainBgm != null && !bgmAudioSource.isPlaying) { bgmAudioSource.clip = mainBgm; - bgmAudioSource.loop = true; // BGM을 반복 재생 - bgmAudioSource.volume = 0.1f; // BGM 볼륨 설정 - bgmAudioSource.Play(); // BGM 재생 + bgmAudioSource.loop = true; + bgmAudioSource.volume = 0.1f; + bgmAudioSource.Play(); } } @@ -82,9 +76,9 @@ public class AudioManager : Singleton if (bgmAudioSource != null && gameBgm != null && !bgmAudioSource.isPlaying) { bgmAudioSource.clip = gameBgm; - bgmAudioSource.loop = true; // BGM을 반복 재생 - bgmAudioSource.volume = 0.1f; // BGM 볼륨 설정 - bgmAudioSource.Play(); // 게임 BGM 재생 + bgmAudioSource.loop = true; + bgmAudioSource.volume = 0.1f; + bgmAudioSource.Play(); } } @@ -111,11 +105,11 @@ public class AudioManager : Singleton { if (bgmAudioSource != null && bgmAudioSource.isPlaying) { - bgmAudioSource.Stop(); // 게임용 BGM을 멈춤 + bgmAudioSource.Stop(); } } - // 씬이 로드될 때마다 호출되는 OnSceneLoaded 메서드 + protected override void OnSceneLoaded(Scene scene, LoadSceneMode mode) { PlayBGM(); diff --git a/Assets/Script/Main/ScoreCellController.cs b/Assets/Script/Main/ScoreCellController.cs index 29a6526..5963b18 100644 --- a/Assets/Script/Main/ScoreCellController.cs +++ b/Assets/Script/Main/ScoreCellController.cs @@ -25,7 +25,7 @@ public class ScoreCellController : MonoBehaviour if (profileImage != null) { - profileImage.sprite = profileSprites[item.imageIndex]; // 프로필 이미지 (Sprite 할당) + profileImage.sprite = profileSprites[item.imageIndex]; } } } \ No newline at end of file diff --git a/Assets/Script/Main/ScoreListWrapper.cs b/Assets/Script/Main/ScoreListWrapper.cs index 3afdf93..01b816e 100644 --- a/Assets/Script/Main/ScoreListWrapper.cs +++ b/Assets/Script/Main/ScoreListWrapper.cs @@ -7,5 +7,5 @@ using UnityEngine.Serialization; [Serializable] public class ScoreListWrapper { - public List leaderboardDatas; // 여러 개의 ScoreInfo를 담을 리스트 + public List leaderboardDatas; } \ No newline at end of file diff --git a/Assets/Script/UI/PanelController/LeaderBoardController.cs b/Assets/Script/UI/PanelController/LeaderBoardController.cs index dd2de8f..400a975 100644 --- a/Assets/Script/UI/PanelController/LeaderBoardController.cs +++ b/Assets/Script/UI/PanelController/LeaderBoardController.cs @@ -7,11 +7,11 @@ using TMPro; public class LeaderBoardController : MonoBehaviour { - [SerializeField] private GameObject rankingPrefab; // Ranking 프리팹을 참조 (Horizontal Layout) - [SerializeField] private Transform content; // Vertical Layout Group + [SerializeField] private GameObject rankingPrefab; + [SerializeField] private Transform content; [SerializeField] private GameObject MainPanel; [SerializeField] private GameObject leaderboardPanel; - [SerializeField] private Scrollbar verticalScrollbar;// LeaderboardPanel 참조 + [SerializeField] private Scrollbar verticalScrollbar; private bool isLeaderboardLoaded = false; @@ -24,7 +24,7 @@ public class LeaderBoardController : MonoBehaviour { GameManager.Instance.audioManager.PlayClickSound(); - if (isLeaderboardLoaded) return; // 이미 리더보드가 로드되었으면 중복 호출 방지 + if (isLeaderboardLoaded) return; leaderboardPanel.SetActive(true); NetworkManager.Instance.GetLeaderboard((leaderboardItems) => @@ -36,57 +36,52 @@ public class LeaderBoardController : MonoBehaviour public void Show(List leaderboardItems) { - // 기존 셀 삭제 (리스트가 갱신될 때마다) + foreach (Transform child in content) { Destroy(child.gameObject); } - // 받은 데이터로 셀 생성 + foreach (var item in leaderboardItems) { - CreateCell(item); // 셀 생성 + CreateCell(item); } } private void CreateCell(ScoreInfo item) { - // Ranking 프리팹을 content의 자식으로 생성 + var scoreCellObj = Instantiate(rankingPrefab, content); - // Ranking 프리팹에 포함된 ScoreCellController를 찾아서 설정 + var scoreCellController = scoreCellObj.GetComponent(); if (scoreCellController != null) { - // 각 항목에 대한 UI 설정 - scoreCellController.SetCellInfo(item); // ScoreInfo로 셀 정보 설정 - } - else - { - Debug.LogError("ScoreCellController가 Ranking 프리팹에 없습니다."); + + scoreCellController.SetCellInfo(item); } } - // BackButton 클릭 시 호출되는 메소드 + public void OnBackButtonClicked() { GameManager.Instance.audioManager.PlayCloseSound(); - leaderboardPanel.SetActive(false); // LeaderboardPanel 숨기기 - MainPanel.SetActive(true); // SignInPanel 보이게 하기 + leaderboardPanel.SetActive(false); + MainPanel.SetActive(true); } private List LoadOfflineLeaderboard() { List leaderboard = new List(); - // 오프라인 데이터 로딩 (PlayerPrefs 사용 예시) + string savedData = PlayerPrefs.GetString("OfflineLeaderboard", string.Empty); if (!string.IsNullOrEmpty(savedData)) { - // 저장된 JSON 데이터를 파싱하여 리더보드 리스트로 변환 leaderboard = JsonUtility.FromJson(savedData).leaderboardDatas; } @@ -95,6 +90,6 @@ public class LeaderBoardController : MonoBehaviour private void OnDisable() { - Destroy(gameObject); // 자기 자신을 삭제 + Destroy(gameObject); } } \ No newline at end of file diff --git a/Assets/Script/UI/PanelController/SettingPanelController.cs b/Assets/Script/UI/PanelController/SettingPanelController.cs index a4047db..779bcbf 100644 --- a/Assets/Script/UI/PanelController/SettingPanelController.cs +++ b/Assets/Script/UI/PanelController/SettingPanelController.cs @@ -11,11 +11,11 @@ public class SettingsPanelController : PanelController void Start() { - // 스위치 컨트롤러 상태 변경 이벤트 연결 + sfxSwitch.GetComponent().OnSwitchChanged += OnSFXToggleValueChanged; bgmSwitch.GetComponent().OnSwitchChanged += OnBGMToggleValueChanged; - // 현재 저장된 설정 값을 UI에 반영 + sfxSwitch.GetComponent().SetSwitch(UserManager.IsPlaySFX); bgmSwitch.GetComponent().SetSwitch(UserManager.IsPlayBGM); } @@ -26,34 +26,32 @@ public class SettingsPanelController : PanelController base.Show(); } - // SFX On/Off 시 호출되는 함수 + public void OnSFXToggleValueChanged(bool value) { - UserManager.IsPlaySFX = value; // UserManager에 값 저장 + UserManager.IsPlaySFX = value; } - // BGM On/Off 시 호출되는 함수 + public void OnBGMToggleValueChanged(bool value) { - UserManager.IsPlayBGM = value; // UserManager에 값 저장 + UserManager.IsPlayBGM = value; - // BGM을 끄는 경우 + if (!value) { - AudioManager.Instance.StopBGM(); // BGM을 끄기 + AudioManager.Instance.StopBGM(); } - // BGM을 켜는 경우 else { - // 이미 BGM이 재생 중인 경우 새로 시작하지 않도록 체크 if (!AudioManager.Instance.bgmAudioSource.isPlaying) { - AudioManager.Instance.PlayBGM(); // BGM을 켜기 + AudioManager.Instance.PlayBGM(); } } } - // X 버튼 클릭시 호출되는 함수 + public void OnClickCloseButton() { Hide();