| //-------------------------------------------------------- | 
| //    [Author]:           玩个游戏 | 
| //    [  Date ]:           Thursday, April 18, 2019 | 
| //-------------------------------------------------------- | 
|   | 
| using UnityEngine; | 
| using UnityEngine.UI; | 
|   | 
|   | 
| public class CustomizedGiftWin : UIBase | 
| { | 
|     [SerializeField] ScrollerController m_Controller; | 
|     [SerializeField] Button CloseBtn; | 
|     [SerializeField] TextEx actTime; | 
|   | 
|     protected override void InitComponent() | 
|     { | 
|         CloseBtn.SetListener(CloseWindow); | 
|     } | 
|   | 
|     protected override void OnPreOpen() | 
|     { | 
|         m_Controller.OnRefreshCell += OnRefreshCell; | 
|         RechargeManager.Instance.rechargeCountEvent += VipModel_rechargeCountEvent; | 
|         CustomizedGiftModel.Instance.UpdateRechargeGiftActEvent += OnUpdateRechargeGiftActEvent; | 
|         GlobalTimeEvent.Instance.secondEvent += secondEvent; | 
|         secondEvent(); | 
|         DisplayScroll(); | 
|     } | 
|   | 
|     void VipModel_rechargeCountEvent(int obj) | 
|     { | 
|         m_Controller.m_Scorller.RefreshActiveCellViews(); | 
|     } | 
|   | 
|   | 
|     protected override void OnPreClose() | 
|     { | 
|         m_Controller.OnRefreshCell -= OnRefreshCell; | 
|         RechargeManager.Instance.rechargeCountEvent -= VipModel_rechargeCountEvent; | 
|         CustomizedGiftModel.Instance.UpdateRechargeGiftActEvent -= OnUpdateRechargeGiftActEvent; | 
|         GlobalTimeEvent.Instance.secondEvent -= secondEvent; | 
|     } | 
|     void secondEvent() | 
|     { | 
|         OperationBase holiday; | 
|         if (!OperationTimeHepler.Instance.TryGetOperation(CustomizedGiftModel.operaType, out holiday)) | 
|         { | 
|             return; | 
|         } | 
|         actTime.text = Language.Get("BossFHLanguage2", TimeUtility.SecondsToHMS(holiday.GetResetSurplusTime())); | 
|     } | 
|   | 
|     void OnUpdateRechargeGiftActEvent() | 
|     { | 
|         m_Controller.m_Scorller.RefreshActiveCellViews(); | 
|     } | 
|   | 
|     void DisplayScroll() | 
|     { | 
|         m_Controller.Refresh(); | 
|         OperationRechargeGiftAct act; | 
|         OperationTimeHepler.Instance.TryGetOperation(CustomizedGiftModel.operaType, out act); | 
|   | 
|         for (int i = 0; i <= act.ctgIDs.Count; i++) | 
|         { | 
|             m_Controller.AddCell(ScrollerDataType.Header, i); | 
|         } | 
|         m_Controller.Restart(); | 
|   | 
|     } | 
|   | 
|     private void OnRefreshCell(ScrollerDataType type, CellView cell) | 
|     { | 
|         var _cell = cell as CustomizedGiftCell; | 
|         _cell.Display(_cell.index); | 
|     } | 
| } |