少年修仙传客户端代码仓库
lcy
2024-12-16 a39c35fc6449430cd02bccb681c4a0a880e46cd9
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
using vnxbqy.UI;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine;
 
public class GarbageGirdCell : ILBehaviour
{
    ItemCell itemCell;
    UIDragDropBehaviour dragDrop;
    Image imgSelect;
 
    int objIndex = 0;
    protected override void Awake() 
    {
        itemCell = proxy.GetWidgtEx<ItemCell>("ItemCell");
        imgSelect = proxy.GetWidgtEx<Image>("SelectImage");
        dragDrop = proxy.GetWidgtEx<UIDragDropBehaviour>("dragItem");
 
    }
 
 
    //index档位字典的数组索引
    public void Display(int index)
    {
        objIndex = index;
        var item = HolidayRefuseClassificationModel.Instance.packModel.GetItemByIndex(index);
        if (item == null)
        {
            itemCell.SetActiveIL(false);
            imgSelect.SetActiveIL(false);
            dragDrop.SetActiveIL(false);
            return;
        }
 
        itemCell.SetActiveIL(true);
        imgSelect.SetActiveIL(HolidayRefuseClassificationModel.Instance.selectIndex == index);
        dragDrop.SetActiveIL(true);
 
        dragDrop.Init(objIndex);
        dragDrop.onClick -= OnClick;
        dragDrop.onClick += OnClick;
 
        var model = new ItemCellModel(item.itemId, false, (ulong)item.count);
        itemCell.Init(model);
        itemCell.auctionIcon.SetActiveIL(item.isAuction);
    }
 
    void OnClick(int index)
    {
        //在UIDragDropBehaviour的draging超过0.2秒 不触发onclick
        HolidayRefuseClassificationModel.Instance.selectIndex = index;
        //脱离物品时触发主动设置数据
        UIDragDropBehaviour.draging = true;
        UIDragDropBehaviour.dragData = objIndex;
    }
}