| 
									
										
										
										
											2022-02-09 11:36:47 +00:00
										 |  |  |  | using System; | 
					
						
							|  |  |  |  | using System.Collections; | 
					
						
							|  |  |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  |  | using UnityEngine; | 
					
						
							|  |  |  |  | using UnityEngine.UI; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | public class PanelResult : BasePanel | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     public Action DelAgain; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     [SerializeField] Text mTxtEndingName; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     [SerializeField] GameObject mGobWinTitle; | 
					
						
							|  |  |  |  |     [SerializeField] GameObject mGobLoseTitle; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     [SerializeField] GameObject mGobWinFace; | 
					
						
							|  |  |  |  |     [SerializeField] GameObject mGobLoseFace; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     [SerializeField] GameObject mGobWinBtns; | 
					
						
							|  |  |  |  |     [SerializeField] GameObject mGobOtherBtns; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-10 10:17:22 +00:00
										 |  |  |  |     [SerializeField] GameObject mGobFx; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-09 11:36:47 +00:00
										 |  |  |  |     [SerializeField] Button mBtnAgain1; | 
					
						
							|  |  |  |  |     [SerializeField] Button mBtnAgain2; | 
					
						
							|  |  |  |  |     [SerializeField] Button mBtnNext; | 
					
						
							|  |  |  |  |     [SerializeField] Button mBtnChoose; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     [SerializeField] ButtonEndings mBtnEndings; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-16 11:41:50 +00:00
										 |  |  |  |     private bool mReviewShowed = false; | 
					
						
							|  |  |  |  |     private const int REVIEW_LEVEL = 1; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-09 11:36:47 +00:00
										 |  |  |  |     private void Awake() | 
					
						
							|  |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-02-16 09:00:22 +00:00
										 |  |  |  |         UIUtils.BindBtn(mBtnAgain1, OnClickAgain, AudioClipType.Click_Normal); | 
					
						
							|  |  |  |  |         UIUtils.BindBtn(mBtnAgain2, OnClickAgain, AudioClipType.Click_Normal); | 
					
						
							|  |  |  |  |         UIUtils.BindBtn(mBtnNext, OnClickNext, AudioClipType.Click_Normal); | 
					
						
							|  |  |  |  |         UIUtils.BindBtn(mBtnChoose, OnClickChoose, AudioClipType.Click_Normal); | 
					
						
							| 
									
										
										
										
											2022-02-09 11:36:47 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         mBtnEndings.DelClick = OnClickEndings; | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-10 10:17:22 +00:00
										 |  |  |  |     public override void OnFocus(bool pFocus) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         base.OnFocus(pFocus); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         mGobFx.SetActive(pFocus); | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-14 10:38:47 +00:00
										 |  |  |  |     public void Init(int pLevelID, string pEndingName, bool pIsWin, bool pNextLevelClear, bool pHasNew = false, bool pHasComplete = false) | 
					
						
							| 
									
										
										
										
											2022-02-09 11:36:47 +00:00
										 |  |  |  |     { | 
					
						
							|  |  |  |  |         mTxtEndingName.text = pEndingName; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         mGobWinTitle.SetActive(pIsWin); | 
					
						
							|  |  |  |  |         mGobLoseTitle.SetActive(!pIsWin); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         mGobWinFace.SetActive(pIsWin); | 
					
						
							|  |  |  |  |         mGobLoseFace.SetActive(!pIsWin); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-11 13:04:38 +00:00
										 |  |  |  |         mGobWinBtns.SetActive(!pNextLevelClear && pIsWin); | 
					
						
							|  |  |  |  |         mGobOtherBtns.SetActive(pNextLevelClear || !pIsWin); | 
					
						
							| 
									
										
										
										
											2022-02-09 12:07:40 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         LevelData tLvData = GameConfig.Instance.GetLevelData(pLevelID); | 
					
						
							|  |  |  |  |         mBtnEndings.Init(pLevelID, PlayerData.Instance.EndingCountOfLevel(pLevelID), tLvData.Endings.Count); | 
					
						
							| 
									
										
										
										
											2022-02-14 10:38:47 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         if (pHasNew) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (pHasComplete) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 TimerManager.Instance.Schedule(() => mBtnEndings.ShowComplete(true), 0.7f); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 TimerManager.Instance.Schedule(() => mBtnEndings.ShowNew(true), 0.7f); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         else | 
					
						
							|  |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-02-14 11:17:52 +00:00
										 |  |  |  |             mBtnEndings.ShowTip(!pIsWin && !pHasComplete); | 
					
						
							| 
									
										
										
										
											2022-02-14 10:38:47 +00:00
										 |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2022-02-16 11:41:50 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         if (!PlayerData.Instance.HasShowedReview && PlayerData.Instance.CurrentLevel == REVIEW_LEVEL) | 
					
						
							|  |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-02-16 12:09:52 +00:00
										 |  |  |  |             PlayerData.Instance.MarkReviewShowed(); | 
					
						
							| 
									
										
										
										
											2022-02-16 11:41:50 +00:00
										 |  |  |  |             ToukaUtils.OpenSystemReviewPop(); | 
					
						
							|  |  |  |  |             mReviewShowed = true; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         else | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             mReviewShowed = false; | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2022-02-09 11:36:47 +00:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     private void OnClickAgain() | 
					
						
							|  |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-02-16 11:41:50 +00:00
										 |  |  |  |         ToukaSDKManager.Instance.LogEventByUmeng(Const.AdsEvent.EndRetry, Const.AdsEvtID.Level, PlayerData.Instance.CurrentLevel.ToString()); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-09 11:36:47 +00:00
										 |  |  |  |         DelAgain?.Invoke(); | 
					
						
							| 
									
										
										
										
											2022-02-16 11:41:50 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         if (!mReviewShowed) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             ToukaSDKManager.Instance.PlayInterstitialAd(Const.AdsEvtValue.EndRetry); | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2022-02-09 11:36:47 +00:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     private void OnClickNext() | 
					
						
							|  |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-02-16 11:41:50 +00:00
										 |  |  |  |         ToukaSDKManager.Instance.LogEventByUmeng(Const.AdsEvent.EndNext, Const.AdsEvtID.Level, PlayerData.Instance.CurrentLevel.ToString()); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-09 12:28:20 +00:00
										 |  |  |  |         GameManager.Instance.NextLevel(); | 
					
						
							| 
									
										
										
										
											2022-02-15 10:59:36 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-16 11:41:50 +00:00
										 |  |  |  |         if (!mReviewShowed) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             ToukaSDKManager.Instance.PlayInterstitialAd(Const.AdsEvtValue.EndNext); | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2022-02-09 11:36:47 +00:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     private void OnClickChoose() | 
					
						
							|  |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-02-16 11:41:50 +00:00
										 |  |  |  |         ToukaSDKManager.Instance.LogEventByUmeng(Const.AdsEvent.EndSelect, Const.AdsEvtID.Level, PlayerData.Instance.CurrentLevel.ToString()); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-10 09:21:59 +00:00
										 |  |  |  |         PanelLevel tUILevel = UIManager.Instance.OpenUI<PanelLevel>(); | 
					
						
							|  |  |  |  |         tUILevel.Init(true); | 
					
						
							| 
									
										
										
										
											2022-02-15 10:59:36 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-16 11:41:50 +00:00
										 |  |  |  |         if (!mReviewShowed) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             ToukaSDKManager.Instance.PlayInterstitialAd(Const.AdsEvtValue.EndSelect); | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2022-02-09 11:36:47 +00:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     private void OnClickEndings() | 
					
						
							|  |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-02-10 04:26:52 +00:00
										 |  |  |  |         PanelEndings tUIEndings = UIManager.Instance.OpenUI<PanelEndings>(); | 
					
						
							|  |  |  |  |         tUIEndings.Init(PlayerData.Instance.CurrentLevelID); | 
					
						
							| 
									
										
										
										
											2022-02-09 11:36:47 +00:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  | } |