少年修仙传客户端代码仓库
hch
2025-07-24 50e53441950268933694eeb5aad36147bbe1014d
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
using vnxbqy.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
 
class MatGridBehaviour
{
 
    public Transform transform;
    ItemCell itemCell;
    Text countText;
    int itemID;
 
    public void BindController(Transform target)
    {
        this.transform = target;
        this.itemCell = this.transform.FindComponentEx<ItemCell>("ItemCell");
        this.countText = this.transform.FindComponentEx<Text>("Text_Count");
        this.itemCell.button.SetListener(() =>
        {
            ItemTipUtility.Show(this.itemID);
        });
    }
 
    public void Init()
    {
        this.transform.SetActiveIL(false);
    }
 
    public void Init(Int2 upCostItem, int remainCount)
    {
        if (upCostItem == null)
        {
            this.transform.SetActiveIL(false);
            return;
        }
        this.transform.SetActiveIL(true);
        this.itemID = upCostItem.x;
        this.itemCell.Init(new ItemCellModel(upCostItem.x));
        var remainCountStr = "";
        TextColType colorType;
        if (remainCount < upCostItem.y)
        {
            colorType = TextColType.Red;
            remainCountStr = UIHelper.AppendColor(colorType, remainCount.ToString());
        }
        else
        {
            colorType = TextColType.Green;
            remainCountStr = UIHelper.AppendColor(colorType, remainCount.ToString(), true);
        }
        this.countText.text = StringUtility.Contact(remainCountStr, "/", upCostItem.y);
    }
 
}