| //--------------------------------------------------------  | 
| //    [Author]:           第二世界  | 
| //    [  Date ]:           Tuesday, September 12, 2017  | 
| //--------------------------------------------------------  | 
| using UnityEngine;  | 
| using System.Collections;  | 
| using UnityEngine.UI;  | 
|   | 
| using System;  | 
|   | 
| namespace vnxbqy.UI  | 
| {  | 
|   | 
|     public class DungeonEnterInfo : MonoBehaviour  | 
|     {  | 
|         [SerializeField]  | 
|         Text surplusTimeText;  | 
|         [SerializeField]  | 
|         Button clearBtn;  | 
|   | 
|         DungeonModel m_Model;  | 
|         DungeonModel model {  | 
|             get {  | 
|                 return m_Model ?? (m_Model = ModelCenter.Instance.GetModel<DungeonModel>());  | 
|             }  | 
|         }  | 
|   | 
|         DungeonEnterCoolDown dungeonEnter;  | 
|   | 
|         public event Action OnCoolDowndComplete;  | 
|   | 
|         private void Awake()  | 
|         {  | 
|             if (clearBtn != null)  | 
|             {  | 
|                 clearBtn.onClick.AddListener(OnClearBtn);  | 
|             }  | 
|         }  | 
|   | 
|         private void OnClearBtn()  | 
|         {  | 
|             ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), UIHelper.ReplaceNewLine(Language.Get("FairyLand_Func11", dungeonEnter.clearCoolDownCost)), (bool isOk) =>  | 
|             {  | 
|                 if (isOk)  | 
|                 {  | 
|                     if ( PlayerDatas.Instance.baseData.diamond >= dungeonEnter.clearCoolDownCost)  | 
|                     {  | 
|                         model.RequestClearEnterCD(dungeonEnter.mapId);  | 
|                     }  | 
|                     else  | 
|                     {  | 
|                         if (VersionConfig.Get().isBanShu)  | 
|                         {  | 
|                             SysNotifyMgr.Instance.ShowTip("GoldErr");  | 
|                             return;  | 
|                         }  | 
|                         WindowCenter.Instance.Open<RechargeTipWin>();  | 
|                     }  | 
|                 }  | 
|             });  | 
|         }  | 
|   | 
|         private void OnEnable()  | 
|         {  | 
|             var dungeonId = model.GetDungeonId(model.currentDungeon);  | 
|             var dungeonConfig = DungeonConfig.Get(dungeonId);  | 
|             dungeonEnter = model.GetEnterCoolDown(dungeonConfig.DataMapID);  | 
|   | 
|             model.dungeonEnterCoolDownUpdate += UpdateDungeonEnterCD;  | 
|         }  | 
|   | 
|         private void UpdateDungeonEnterCD()  | 
|         {  | 
|             if (dungeonEnter != null && dungeonEnter.suplursSeconds == 0)  | 
|             {  | 
|                 gameObject.SetActive(false);  | 
|             }  | 
|         }  | 
|   | 
|         private void OnDisable()  | 
|         {  | 
|             model.dungeonEnterCoolDownUpdate -= UpdateDungeonEnterCD;  | 
|         }  | 
|   | 
|         private void LateUpdate()  | 
|         {  | 
|             TimeSpan timeSpan = dungeonEnter.endCoolDownTime - TimeUtility.ServerNow;  | 
|             surplusTimeText.text = StringUtility.Contact(Language.Get("FairyLand_Func12"), timeSpan.Minutes.ToString("D2"), ":",  | 
|                 Mathf.Max(0, timeSpan.Seconds).ToString("D2"));  | 
|             if (timeSpan.Minutes <= 0 && timeSpan.Seconds <= 0)  | 
|             {  | 
|                 gameObject.SetActive(false);  | 
|                 if (OnCoolDowndComplete != null)  | 
|                 {  | 
|                     OnCoolDowndComplete();  | 
|                 }  | 
|             }  | 
|         }  | 
|     }  | 
|   | 
| }  | 
|   | 
|   | 
|   |