少年修仙传客户端代码仓库
hch
2 天以前 600733c8f592cb9e65f2b7a3e110ac1d686e6bfe
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
79
80
81
82
83
84
85
86
87
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System;
using vnxbqy.UI;
 
public class ILDayOnlineCell : ILBehaviour
{
    Text m_TimeInfo;
    List<ItemCell> m_Items = new List<ItemCell>();
    Image m_StateImg;
    ButtonEx m_GetBtn;
    UIEffect m_GetEffect;
 
    ILDayOnlineModel model = ILDayOnlineModel.Instance;
 
    protected override void Awake()
    {
        m_TimeInfo = proxy.GetWidgtEx<Text>("time");
        m_StateImg = proxy.GetWidgtEx<Image>("Img_State");
        m_GetBtn = proxy.GetWidgtEx<ButtonEx>("Btn_Get");
        m_GetEffect = proxy.GetWidgtEx<UIEffect>("Effect_Get");
        m_Items.Add(proxy.GetWidgtEx<ItemCell>("0"));
        m_Items.Add(proxy.GetWidgtEx<ItemCell>("1"));
        m_Items.Add(proxy.GetWidgtEx<ItemCell>("2"));
        m_Items.Add(proxy.GetWidgtEx<ItemCell>("3"));
        m_Items.Add(proxy.GetWidgtEx<ItemCell>("4"));
    }
 
    public void Display(int index)
    {
        //原索引对应的物品奖励;index是排序后的索引
        int realIndex = Array.IndexOf(model.timeArr, model.indexSort[index]) + 1;
 
        for (int i = 0; i < m_Items.Count; i++)
        {
            if (model.awards.ContainsKey(realIndex) && i < model.awards[realIndex].Count)
            {
                m_Items[i].SetActiveIL(true);
                var itemID = model.awards[realIndex][i][0];
                var itemCount = model.awards[realIndex][i][1];
 
                var Item = ItemConfig.Get(itemID);
                ItemCellModel cellModel = new ItemCellModel(itemID, true, (ulong)itemCount);
                m_Items[i].Init(cellModel);
                m_Items[i].button.SetListener(() =>
                {
                    ItemTipUtility.Show(itemID);
                });
 
            }
            else
            {
                m_Items[i].SetActiveIL(false);
            }
        }
 
        m_TimeInfo.text = Language.Get("dayOnline_2", model.indexSort[index]);
        m_GetEffect.SetActiveIL(false);
        m_GetEffect.Stop();
        var state = model.GetAwardState(realIndex - 1);
        if (state == 2)
        {
            m_StateImg.SetActiveIL(true);
            m_GetBtn.SetActiveIL(false);
        }
        else
        {
            m_StateImg.SetActiveIL(false);
            m_GetBtn.SetActiveIL(true);
            if (state == 0)
            { 
                m_GetEffect.SetActiveIL(true);
                m_GetEffect.Play();
            }
            m_GetBtn.SetColorful(null, state == 0);
 
            m_GetBtn.SetListener(() => {
                CA506_tagCMGetOnlinePrize pack = new CA506_tagCMGetOnlinePrize();
                pack.Index = (byte)realIndex;
                pack.IsDaily = 1;
                GameNetSystem.Instance.SendInfo(pack);
            });
        }
    }
}