| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  | using System.Collections; | 
					
						
							|  |  |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  |  | using UnityEngine; | 
					
						
							|  |  |  |  | using UnityEngine.UI; | 
					
						
							|  |  |  |  | using DG.Tweening; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | public class PanelSettings : BasePanel | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     [SerializeField] CanvasGroup mCvsBg; | 
					
						
							|  |  |  |  |     [SerializeField] RectTransform mRctBg; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     [SerializeField] Button mBtnMask; | 
					
						
							|  |  |  |  |     [SerializeField] Button mBtnClose; | 
					
						
							|  |  |  |  |     [SerializeField] UIToggleSwap mTglSound; | 
					
						
							|  |  |  |  |     [SerializeField] UIToggleSwap mTglVibrate; | 
					
						
							|  |  |  |  |     [SerializeField] Button mBtnRestore; | 
					
						
							|  |  |  |  |     [SerializeField] Button mBtnPrivacy; | 
					
						
							|  |  |  |  |     [SerializeField] Button mBtnPolicy; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     [SerializeField] Text mTxtRestore; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     private void Awake() | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         UIUtils.BindBtn(mBtnMask, OnClickClose); | 
					
						
							|  |  |  |  |         UIUtils.BindBtn(mBtnClose, OnClickClose); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         UIUtils.BindBtn(mBtnRestore, OnClickRestore); | 
					
						
							|  |  |  |  |         UIUtils.BindBtn(mBtnPrivacy, OnClickPrivacy); | 
					
						
							|  |  |  |  |         UIUtils.BindBtn(mBtnPolicy, OnClickPolicy); | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     public override void OnOpen() | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         base.OnOpen(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | #if USE_IAP | 
					
						
							|  |  |  |  |         IAPTool.Instance.OnRestoreDone += SetRestoring; | 
					
						
							|  |  |  |  | #endif | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         mTglSound.OnSwitch += SwitchSound; | 
					
						
							|  |  |  |  |         mTglVibrate.OnSwitch += SwitchVibrate; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         mTglSound.IsOn = SettingData.Instance.IsSoundOn; | 
					
						
							|  |  |  |  |         mTglVibrate.IsOn = SettingData.Instance.IsVibrateOn; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         mCvsBg.alpha = 0; | 
					
						
							|  |  |  |  |         mRctBg.anchoredPosition = new Vector2(0, -160); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         mCvsBg.DOFade(1, 0.3f); | 
					
						
							|  |  |  |  |         mRctBg.DOAnchorPosY(100, 0.3f); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         SetRestoring(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-08 13:23:44 +00:00
										 |  |  |  | #if USE_IAP | 
					
						
							|  |  |  |  | #if ANDROID_GP | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  |         mBtnRestore.transform.parent.gameObject.SetActive(false); | 
					
						
							|  |  |  |  |         mBtnPolicy.gameObject.SetActive(false); | 
					
						
							|  |  |  |  | #else | 
					
						
							|  |  |  |  |         mBtnRestore.transform.parent.gameObject.SetActive(true); | 
					
						
							|  |  |  |  |         mBtnPolicy.gameObject.SetActive(false); | 
					
						
							| 
									
										
										
										
											2022-06-08 13:23:44 +00:00
										 |  |  |  | #endif | 
					
						
							|  |  |  |  | #else | 
					
						
							|  |  |  |  |         mBtnRestore.transform.parent.gameObject.SetActive(false); | 
					
						
							|  |  |  |  |         mBtnPolicy.gameObject.SetActive(true); | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  | #endif | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     public override void OnClose() | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         base.OnClose(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | #if USE_IAP | 
					
						
							|  |  |  |  |         IAPTool.Instance.OnRestoreDone -= SetRestoring; | 
					
						
							|  |  |  |  | #endif | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         mTglSound.OnSwitch -= SwitchSound; | 
					
						
							|  |  |  |  |         mTglVibrate.OnSwitch -= SwitchVibrate; | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     private void SwitchSound(bool pIsOn) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         SettingData.Instance.IsSoundOn = pIsOn; | 
					
						
							|  |  |  |  |         AudioManager.Instance.SetSoundOn(pIsOn); | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     private void SwitchVibrate(bool pIsOn) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         SettingData.Instance.IsVibrateOn = pIsOn; | 
					
						
							|  |  |  |  |         VibrateManager.Instance.SetVibrateOn(pIsOn); | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     private void SetRestoring(bool pResult = false) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  | #if USE_IAP | 
					
						
							|  |  |  |  |         mTxtRestore.text = LanguageConfig.Instance.GetText(IAPTool.Instance.IsRestoring ? "Restoring" : "Restore"); | 
					
						
							|  |  |  |  | #endif | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     private void OnClickClose() | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         mCvsBg.DOFade(0, 0.3f); | 
					
						
							|  |  |  |  |         mRctBg.DOAnchorPosY(-160, 0.3f).onComplete = Close; | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     private void OnClickRestore() | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  | #if USE_IAP | 
					
						
							|  |  |  |  |         if (IAPTool.Instance.IsRestoring) | 
					
						
							|  |  |  |  |             return; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         IAPTool.Instance.RestorePurchases(); | 
					
						
							|  |  |  |  |         SetRestoring(); | 
					
						
							|  |  |  |  | #endif | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     private void OnClickPrivacy() | 
					
						
							|  |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-08-30 02:21:29 +00:00
										 |  |  |  |         TKGSDKManager.Instance.OpenPolicyPop(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     private void OnClickPolicy() | 
					
						
							|  |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-08-30 02:21:29 +00:00
										 |  |  |  |         TKGSDKManager.Instance.OpenPolicyPop(); | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  | } |