DO-91-일환-주석-디버그-로그-삭제
This commit is contained in:
parent
8758f3cd1f
commit
76aeacecbd
@ -8,10 +8,10 @@ public class AudioManager : Singleton<AudioManager>
|
||||
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<AudioManager>
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake(); // 부모 클래스의 Awake 호출
|
||||
base.Awake();
|
||||
|
||||
// BGM과 SFX를 위한 별도의 AudioSource 생성
|
||||
|
||||
bgmAudioSource = gameObject.AddComponent<AudioSource>();
|
||||
sfxAudioSource = gameObject.AddComponent<AudioSource>();
|
||||
|
||||
//Sounds폴더 내의 모든 오디오클립 로드
|
||||
|
||||
AudioClip[] clips = Resources.LoadAll<AudioClip>("Sounds");
|
||||
|
||||
foreach (AudioClip clip in clips)
|
||||
@ -35,8 +35,6 @@ public class AudioManager : Singleton<AudioManager>
|
||||
audioClips[clip.name] = clip;
|
||||
}
|
||||
|
||||
Debug.Log($"총 {audioClips.Count}개의 오디오클립이 로드됨.");
|
||||
|
||||
}
|
||||
|
||||
public AudioClip GetAudioClip(string clipName)
|
||||
@ -45,14 +43,10 @@ public class AudioManager : Singleton<AudioManager>
|
||||
{
|
||||
return clip;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError($"패널 '{clipName}'을 찾을 수 없습니다.");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// 시작 시 BGM을 자동으로 재생
|
||||
|
||||
private void Start()
|
||||
{
|
||||
isPlayBGM = UserManager.IsPlayBGM;
|
||||
@ -61,7 +55,7 @@ public class AudioManager : Singleton<AudioManager>
|
||||
PlayBGM();
|
||||
}
|
||||
|
||||
// 메인 BGM을 재생하는 함수
|
||||
|
||||
public void PlayMainBGM()
|
||||
{
|
||||
mainBgm = GetAudioClip("MainBGM");
|
||||
@ -69,9 +63,9 @@ public class AudioManager : Singleton<AudioManager>
|
||||
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<AudioManager>
|
||||
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<AudioManager>
|
||||
{
|
||||
if (bgmAudioSource != null && bgmAudioSource.isPlaying)
|
||||
{
|
||||
bgmAudioSource.Stop(); // 게임용 BGM을 멈춤
|
||||
bgmAudioSource.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
// 씬이 로드될 때마다 호출되는 OnSceneLoaded 메서드
|
||||
|
||||
protected override void OnSceneLoaded(Scene scene, LoadSceneMode mode)
|
||||
{
|
||||
PlayBGM();
|
||||
|
@ -25,7 +25,7 @@ public class ScoreCellController : MonoBehaviour
|
||||
|
||||
if (profileImage != null)
|
||||
{
|
||||
profileImage.sprite = profileSprites[item.imageIndex]; // 프로필 이미지 (Sprite 할당)
|
||||
profileImage.sprite = profileSprites[item.imageIndex];
|
||||
}
|
||||
}
|
||||
}
|
@ -7,5 +7,5 @@ using UnityEngine.Serialization;
|
||||
[Serializable]
|
||||
public class ScoreListWrapper
|
||||
{
|
||||
public List<ScoreInfo> leaderboardDatas; // 여러 개의 ScoreInfo를 담을 리스트
|
||||
public List<ScoreInfo> leaderboardDatas;
|
||||
}
|
@ -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<ScoreInfo> 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<ScoreCellController>();
|
||||
|
||||
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<ScoreInfo> LoadOfflineLeaderboard()
|
||||
{
|
||||
List<ScoreInfo> leaderboard = new List<ScoreInfo>();
|
||||
|
||||
// 오프라인 데이터 로딩 (PlayerPrefs 사용 예시)
|
||||
|
||||
string savedData = PlayerPrefs.GetString("OfflineLeaderboard", string.Empty);
|
||||
|
||||
if (!string.IsNullOrEmpty(savedData))
|
||||
{
|
||||
// 저장된 JSON 데이터를 파싱하여 리더보드 리스트로 변환
|
||||
leaderboard = JsonUtility.FromJson<ScoreListWrapper>(savedData).leaderboardDatas;
|
||||
}
|
||||
|
||||
@ -95,6 +90,6 @@ public class LeaderBoardController : MonoBehaviour
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
Destroy(gameObject); // 자기 자신을 삭제
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
@ -11,11 +11,11 @@ public class SettingsPanelController : PanelController
|
||||
|
||||
void Start()
|
||||
{
|
||||
// 스위치 컨트롤러 상태 변경 이벤트 연결
|
||||
|
||||
sfxSwitch.GetComponent<SwitchController>().OnSwitchChanged += OnSFXToggleValueChanged;
|
||||
bgmSwitch.GetComponent<SwitchController>().OnSwitchChanged += OnBGMToggleValueChanged;
|
||||
|
||||
// 현재 저장된 설정 값을 UI에 반영
|
||||
|
||||
sfxSwitch.GetComponent<SwitchController>().SetSwitch(UserManager.IsPlaySFX);
|
||||
bgmSwitch.GetComponent<SwitchController>().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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user