yyl
1 天以前 5d3366f2e0f687995eb7ad2107c4379fe7acd4e8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//--------------------------------------------------------
//    [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);
    }
}