hch
20 分钟以前 39e8090ed6471b2f95743681d89fb524eea8e00a
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
//--------------------------------------------------------
//    [Author]:           玩个游戏
//    [  Date ]:           Wednesday, September 26, 2018
//--------------------------------------------------------
using UnityEngine;
using System.Collections.Generic;
 
 
 
public class CustomizedGiftChooseCell : CellView
{
    [SerializeField] List<ItemCell> itemCells;
    [SerializeField] List<ImageEx> images;
 
 
    public void Display(int index)
    {
        var selectItemInfo = CTGConfig.Get(CustomizedRechargeModel.Instance.chooseCTGID).SelectItemInfo;
        int chooseCount = selectItemInfo.Length;
 
        for (int i = 0; i < itemCells.Count; i++)
        {
            int itemIndex = index * 7 + i;
            if (itemIndex < selectItemInfo[CustomizedRechargeModel.Instance.chooseWinIndex].Length)
            {
                int selectID = selectItemInfo[CustomizedRechargeModel.Instance.chooseWinIndex][itemIndex];
                int itemId = CTGSelectItemConfig.Get(selectID).ItemID;
                int count = CTGSelectItemConfig.Get(selectID).ItemCount;
                var itemData = new ItemCellModel((int)itemId, false, (ulong)count);
                images[i].SetActive(CustomizedRechargeModel.Instance.GetChooseSubIndex(CustomizedRechargeModel.Instance.chooseWinIndex) - 1 == i);
                itemCells[i].SetActive(true);
                itemCells[i].Init(itemData);
                itemCells[i].button.SetListener(() =>
                {
                    CustomizedRechargeModel.Instance.chooseIndexDict[CustomizedRechargeModel.Instance.chooseWinIndex] = itemIndex + 1;
                    //选中后跳下一个
                    if (CustomizedRechargeModel.Instance.chooseWinIndex + 1 < chooseCount)
                    {
                        CustomizedRechargeModel.Instance.chooseWinIndex += 1;
                    }
                    else
                    {
                        CustomizedRechargeModel.Instance.chooseWinIndex = 0;
                    }
 
                    CustomizedRechargeModel.Instance.UpdateWin?.Invoke();
                });
            }
            else
            {
                images[i].SetActive(false);
                itemCells[i].SetActive(false);
            }
        }
    }
}