200 lines
6.3 KiB
C#
200 lines
6.3 KiB
C#
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class SettingPopup : PopupBase
|
|
{
|
|
[SerializeField] public GameObject[] gos_music_onoff; // 0 on, 1 off
|
|
[SerializeField] public GameObject[] gos_sfx_onoff; // 0 on, 1 off
|
|
[SerializeField] public Slider slider_speed;
|
|
[SerializeField] public TextMeshProUGUI t_speed;
|
|
[Header("Game Speed")]
|
|
[SerializeField] private Image[] UploadButton;
|
|
[SerializeField] private RectTransform DownloadButton;
|
|
[Header("Account")]
|
|
[SerializeField] private TextMeshProUGUI AccountStateText;
|
|
[SerializeField] private GameObject SignoutButton;
|
|
|
|
protected override void Awake()
|
|
{
|
|
base.Awake();
|
|
|
|
GameManager.Account.OnAccountSignIn.AddListener(OnAccountSignIn);
|
|
GameManager.Account.OnAccountSignOut.AddListener(OnAccountSignOut);
|
|
GameManager.Account.OnUploadSaveData.AddListener(OnUploadSaveData);
|
|
GameManager.Account.OnDownloadSaveData.AddListener(OnDownloadSaveData);
|
|
GameManager.Account.OnOverWriteSaveData.AddListener(OnOverWriteSaveData);
|
|
|
|
//SignoutButton.gameObject.SetActive(GameManager.Account.IsUserLogin);
|
|
}
|
|
|
|
public override void ShowPopup(int drawOrder)
|
|
{
|
|
base.ShowPopup(drawOrder);
|
|
this.UpdateMusicUI();
|
|
this.UpdateSFXUI();
|
|
|
|
slider_speed.value = GameManager.DB.GameSpeed;
|
|
}
|
|
|
|
public override void HidePopup()
|
|
{
|
|
GameManager.Account.OnAccountSignIn.RemoveListener(OnAccountSignIn);
|
|
GameManager.Account.OnAccountSignOut.RemoveListener(OnAccountSignOut);
|
|
GameManager.Account.OnUploadSaveData.RemoveListener(OnUploadSaveData);
|
|
GameManager.Account.OnDownloadSaveData.RemoveListener(OnDownloadSaveData);
|
|
GameManager.Account.OnOverWriteSaveData.RemoveListener(OnOverWriteSaveData);
|
|
|
|
base.HidePopup();
|
|
|
|
GameManager.DB.GameSpeed = GamePanel.GameSpeed = slider_speed.value;
|
|
GameManager.DB.SaveDatas();
|
|
}
|
|
|
|
public void ClickCloseButton()
|
|
{
|
|
if (GameManager.UI.IsOpendPopup(EPopupType.SettingPopup))
|
|
GameManager.UI.HideTopPopup();
|
|
GameManager.Sound.PlaySFX(ESFXType.Button_Hit);
|
|
}
|
|
|
|
public void ClickMusicToggle()
|
|
{
|
|
GameManager.DB.BGMMute = !GameManager.DB.BGMMute;
|
|
GameManager.Sound.BGMMute(GameManager.DB.BGMMute);
|
|
this.UpdateMusicUI();
|
|
GameManager.DB.SaveDatas();
|
|
GameManager.Sound.PlaySFX(ESFXType.Button_Hit);
|
|
}
|
|
|
|
private void UpdateMusicUI()
|
|
{
|
|
DSUtil.InActivateGameObjects(gos_music_onoff, GameManager.DB.BGMMute ? 1 : 0);
|
|
}
|
|
|
|
public void ClickSFXToggle()
|
|
{
|
|
GameManager.DB.SFXMute = !GameManager.DB.SFXMute;
|
|
GameManager.Sound.SFXMute(GameManager.DB.SFXMute);
|
|
this.UpdateSFXUI();
|
|
GameManager.DB.SaveDatas();
|
|
GameManager.Sound.PlaySFX(ESFXType.Button_Hit);
|
|
}
|
|
|
|
public void OnChange_Speed()
|
|
{
|
|
t_speed.text = $"x{slider_speed.value.ToString("N1")}";
|
|
}
|
|
|
|
private void UpdateSFXUI()
|
|
{
|
|
DSUtil.InActivateGameObjects(gos_sfx_onoff, GameManager.DB.SFXMute ? 1 : 0);
|
|
}
|
|
|
|
private void OnAccountSignIn(bool isSuccessed)
|
|
{
|
|
SignoutButton.gameObject.SetActive(isSuccessed);
|
|
if (isSuccessed == true)
|
|
{
|
|
AccountStateText.text = "로그인에 성공하였습니다.";
|
|
}
|
|
else
|
|
{
|
|
AccountStateText.text = "로그인에 실패하였습니다. 인터넷을 확인해 주시기를 바랍니다.";
|
|
}
|
|
|
|
}
|
|
private void OnAccountSignOut(bool isSuccessed)
|
|
{
|
|
SignoutButton.gameObject.SetActive(!isSuccessed);
|
|
if (isSuccessed == true)
|
|
{
|
|
AccountStateText.text = "로그아웃에 성공하였습니다.";
|
|
}
|
|
else
|
|
{
|
|
AccountStateText.text = "로그아웃에 실패하였습니다.";
|
|
}
|
|
}
|
|
|
|
private void OnUploadSaveData(bool isSuccessed)
|
|
{
|
|
if (isSuccessed == true)
|
|
{
|
|
AccountStateText.text = "서버에 저장파일 업로드를 성공하였습니다.";
|
|
}
|
|
else
|
|
{
|
|
AccountStateText.text = "업로드에 실패하였습니다. 인터넷을 확인해 주시기 바랍니다.";
|
|
}
|
|
}
|
|
|
|
private void OnDownloadSaveData(bool isSuccessed)
|
|
{
|
|
if (isSuccessed == true)
|
|
{
|
|
AccountStateText.text = "서버에 있는 저장파일 다운로드를 성공하였습니다.";
|
|
}
|
|
else
|
|
{
|
|
AccountStateText.text = "다운로드에 실패하였습니다. 인터넷을 확인해 주시기 바랍니다.";
|
|
}
|
|
}
|
|
|
|
private void OnOverWriteSaveData()
|
|
{
|
|
AccountStateText.text = "서버에 이미 저장파일이 존재합니다.";
|
|
}
|
|
|
|
public void ClickSaveButton()
|
|
{
|
|
GameManager.Sound.PlaySFX(ESFXType.Button_Hit);
|
|
GameManager.UI.ShowNStackPopup(EPopupType.CloudSavePopup);
|
|
|
|
//if (GameManager.Account.IsUserLogin == false)
|
|
//{
|
|
// AgreeConditionsPopup popup = GameManager.UI.ShowNStackPopup<AgreeConditionsPopup>(EPopupType.AgreeConditionsPopup);
|
|
// if (popup != null)
|
|
// {
|
|
// popup.InitAgreeConditionsPopup(AgreeConditionsPopup.EAgreeConditionsPopupType.Upload);
|
|
// }
|
|
//}
|
|
//else
|
|
//{
|
|
// GameManager.Account.SignInWithUploadSaveData(true);
|
|
//}
|
|
}
|
|
|
|
public void ClickDataLoadButton()
|
|
{
|
|
GameManager.Sound.PlaySFX(ESFXType.Button_Hit);
|
|
GameManager.UI.ShowNStackPopup(EPopupType.CloudLoadPopup);
|
|
|
|
//if (GameManager.Account.IsUserLogin == false)
|
|
//{
|
|
// AgreeConditionsPopup popup = GameManager.UI.ShowNStackPopup<AgreeConditionsPopup>(EPopupType.AgreeConditionsPopup);
|
|
// if (popup != null)
|
|
// {
|
|
// popup.InitAgreeConditionsPopup(AgreeConditionsPopup.EAgreeConditionsPopupType.Download);
|
|
// }
|
|
//}
|
|
//else
|
|
//{
|
|
// GameManager.Account.SignInWithDownloadSaveData();
|
|
//}
|
|
}
|
|
|
|
public void ClickPrivacyPolicyButton()
|
|
{
|
|
GameManager.Sound.PlaySFX(ESFXType.Button_Hit);
|
|
// 개인정보 정책 팝업 출력
|
|
GameManager.UI.ShowNStackPopup(EPopupType.PrivacyPoilcyPopup);
|
|
}
|
|
|
|
public void ClickSignOutButton()
|
|
{
|
|
GameManager.Sound.PlaySFX(ESFXType.Button_Hit);
|
|
GameManager.Account.SignOut();
|
|
}
|
|
}
|