| 
									
										
										
										
											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 PanelResult : BasePanel | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     [SerializeField] GameObject mGobWin; | 
					
						
							|  |  |  |  |     [SerializeField] GameObject mGobLose; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |  |     [SerializeField] Text mTxtDiamond; | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  |     [SerializeField] Text mTxtCoin; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |  |     [SerializeField] Button mBtnContinueOnly; | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |  |     [SerializeField] GameObject mBtnNormalGroup; | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  |     [SerializeField] Button mBtnAdCoin; | 
					
						
							|  |  |  |  |     [SerializeField] Button mBtnContinue; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-08 13:23:44 +00:00
										 |  |  |  |     [SerializeField] GameObject mGobNative; | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |  |     [SerializeField] RectTransform mRctNative; | 
					
						
							| 
									
										
										
										
											2022-06-08 13:23:44 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |  |     [SerializeField] MultipleRoller mRoller; | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |  |     private int mBaseDiamond = 0; | 
					
						
							|  |  |  |  |     private int mBaseCoin = 0; | 
					
						
							|  |  |  |  |     private float mMultiple = 1; | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |  |     private int mCurLevel; | 
					
						
							| 
									
										
										
										
											2022-06-08 13:23:44 +00:00
										 |  |  |  |     private bool mWin; | 
					
						
							|  |  |  |  |     private bool mHasClickedAdCoin; | 
					
						
							|  |  |  |  |     private bool mHasShowedNoAds = false; | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  |     private AudioSource mWheelAS; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     private void Awake() | 
					
						
							|  |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |  |         UIUtils.BindBtn(mBtnContinueOnly, OnClickContinue); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  |         UIUtils.BindBtn(mBtnAdCoin, OnClickAdCoin); | 
					
						
							|  |  |  |  |         UIUtils.BindBtn(mBtnContinue, OnClickContinue); | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         mRoller.DelRolling = SetMultiple; | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-08 13:23:44 +00:00
										 |  |  |  |     public void InitResult(bool pWin, int pTotalHurt, bool pShowNative) | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |  |         mCurLevel = PlayerData.Instance.CurrentLevel; | 
					
						
							| 
									
										
										
										
											2022-06-08 13:23:44 +00:00
										 |  |  |  |         mWin = pWin; | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-08 13:23:44 +00:00
										 |  |  |  |         mGobWin.SetActive(mWin); | 
					
						
							|  |  |  |  |         mGobLose.SetActive(!mWin); | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |  |         mBaseDiamond = MMOModule.Instance.GetRewardDiamondOfLevel(PlayerData.Instance.Diamond, mCurLevel); | 
					
						
							|  |  |  |  |         mBaseDiamond = mWin ? mBaseDiamond : (mCurLevel > 3 ? (mBaseDiamond / 3) : 0); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-08 13:23:44 +00:00
										 |  |  |  |         if (GameConfig.Instance.IsAutoLevel) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             mBaseCoin = mWin ? PlayerData.Instance.CurrentWinCoin : PlayerData.Instance.CurrentLoseCoin; | 
					
						
							|  |  |  |  |             mBaseCoin = Mathf.Max(100, mBaseCoin); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         else | 
					
						
							|  |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |  |             float tLevelFactor = ((mCurLevel - 1) / 20) * 0.5f + 1; | 
					
						
							|  |  |  |  |             mBaseCoin = (int)(pTotalHurt * 10 * tLevelFactor * (mWin ? 1f : GameConfig.Instance.FailRewardRatio)); | 
					
						
							| 
									
										
										
										
											2022-06-08 13:23:44 +00:00
										 |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |  |         PlayerData.Instance.Diamond += mBaseDiamond; | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  |         PlayerData.Instance.Coin += mBaseCoin; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |  |         //int tCoin = 0; | 
					
						
							|  |  |  |  |         //DOTween.To(() => tCoin, (tVal) => tCoin = tVal, mBaseCoin, 1).SetEase(Ease.Linear).onUpdate = () => | 
					
						
							|  |  |  |  |         //{ | 
					
						
							|  |  |  |  |         //    mTxtCoin.text = "+" + UIUtils.NumForShort(tCoin); | 
					
						
							|  |  |  |  |         //}; | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |  |         mTxtDiamond.text = "+" + UIUtils.NumForShort(mBaseDiamond); | 
					
						
							|  |  |  |  |         mTxtCoin.text = "+" + UIUtils.NumForShort(mBaseCoin); | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |  |         Utils.DelayShowGameObject(mBtnContinue.gameObject, 1.5f); | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         TKGSDKManager.Instance.LogRewardAdBtnShow(Const.AdsValue.GetCoin); | 
					
						
							| 
									
										
										
										
											2022-06-08 13:23:44 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         Debug.Log("TKG Native switch:" + TKGSDKManager.Instance.GetConfigBool(TKGParamKey.NativeSwitch.ToString())); | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |  |         Debug.Log("TKG Native ready:" + TKGSDKManager.Instance.IsNativeReady()); | 
					
						
							| 
									
										
										
										
											2022-06-08 13:23:44 +00:00
										 |  |  |  |         if (pShowNative) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             ShowNative(true); | 
					
						
							|  |  |  |  |             TKGSDKManager.Instance.HideBanner(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         else | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             ShowNative(false); | 
					
						
							|  |  |  |  |             TKGSDKManager.Instance.ShowBanner(2); | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |  |         if (mCurLevel > 3) | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |  |             mWheelAS = AudioManager.Instance.PlaySoundLoop(AudioClipType.PrizeWheel, 0.6f); | 
					
						
							|  |  |  |  |             mRoller.IsRolling = true; | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         mBtnContinueOnly.gameObject.SetActive(mCurLevel <= 3); | 
					
						
							|  |  |  |  |         mBtnNormalGroup.gameObject.SetActive(mCurLevel > 3); | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-08 13:23:44 +00:00
										 |  |  |  |     private void OnDestroy() | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         ShowNative(false); | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |  |         AudioManager.Instance.StopSoundLoop(mWheelAS); | 
					
						
							| 
									
										
										
										
											2022-06-08 13:23:44 +00:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     private void ShowNative(bool pShow) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         mGobNative.SetActive(pShow); | 
					
						
							|  |  |  |  |         if (pShow) | 
					
						
							|  |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |  |             TKGSDKManager.Instance.ShowNative(mRctNative, mWin ? Const.AdsValue.GameSuccess : Const.AdsValue.GameFailure); | 
					
						
							| 
									
										
										
										
											2022-06-08 13:23:44 +00:00
										 |  |  |  |         } | 
					
						
							|  |  |  |  |         else | 
					
						
							|  |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |  |             TKGSDKManager.Instance.HideNative(); | 
					
						
							| 
									
										
										
										
											2022-06-08 13:23:44 +00:00
										 |  |  |  |         } | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |  |     private void SetMultiple(float pMultiple) | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |  |         mMultiple = pMultiple; | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |  |         mTxtDiamond.text = "+" + ((int)(mBaseDiamond * mMultiple)).ToString(); | 
					
						
							|  |  |  |  |         mTxtCoin.text = "+" + UIUtils.NumForShort((int)(mBaseCoin * mMultiple)); | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |  |     private void OnClickAdCoin() | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |  |         if (mCurLevel > 3) | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |  |             AudioManager.Instance.StopSoundLoop(mWheelAS); | 
					
						
							|  |  |  |  |             mRoller.IsRolling = false; | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         AdsUtils.PlayReward(Const.AdsValue.GetCoin, () => | 
					
						
							|  |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |  |             PlayerData.Instance.Diamond += (int)(mBaseDiamond * (mMultiple - 1)); | 
					
						
							|  |  |  |  |             UIUtils.FlyDiamond(mTxtDiamond.transform.position, (int)(mBaseDiamond * mMultiple)); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  |             PlayerData.Instance.Coin += (int)(mBaseCoin * (mMultiple - 1)); | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |  |             UIUtils.FlyCoin(mTxtCoin.transform.position, (int)(mBaseCoin * mMultiple)); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  |             AudioManager.Instance.PlaySound(AudioClipType.GetCoin); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-08 13:23:44 +00:00
										 |  |  |  |             mHasClickedAdCoin = true; | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  |             WaitForLoad(1.5f); | 
					
						
							|  |  |  |  |         }); | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     private void OnClickContinue() | 
					
						
							|  |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |  |         if (mCurLevel > 3) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             AudioManager.Instance.StopSoundLoop(mWheelAS); | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |  |         UIUtils.FlyDiamond(mTxtDiamond.transform.position, mBaseDiamond); | 
					
						
							|  |  |  |  |         UIUtils.FlyCoin(mTxtCoin.transform.position, mBaseCoin); | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  |         AudioManager.Instance.PlaySound(AudioClipType.GetCoin); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-08 13:23:44 +00:00
										 |  |  |  |         mHasClickedAdCoin = false; | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  |         WaitForLoad(1.5f); | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     private void WaitForLoad(float pWaitSeconds) | 
					
						
							|  |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-07-04 11:17:39 +00:00
										 |  |  |  |         mBtnContinueOnly.gameObject.SetActive(false); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  |         mBtnAdCoin.gameObject.SetActive(false); | 
					
						
							|  |  |  |  |         mBtnContinue.gameObject.SetActive(false); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-08 13:56:34 +00:00
										 |  |  |  |         TimerManager.Instance.Schedule(GameManager.Instance.LoadGame, pWaitSeconds); | 
					
						
							| 
									
										
										
										
											2022-06-08 13:23:44 +00:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     private void LoadGame() | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         if(mHasClickedAdCoin) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             GameManager.Instance.LoadGame(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         else | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             mHasShowedNoAds = AdsUtils.PlayInterstitial(mWin ? Const.AdsValue.GameSuccess : Const.AdsValue.GameFailure, mWin, () => | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 if (mHasShowedNoAds) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     GameManager.Instance.LoadGame(); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             }); | 
					
						
							|  |  |  |  |             if (!mHasShowedNoAds) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 GameManager.Instance.LoadGame(); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  | } |