lcy
21 小时以前 b97ca7fc69d2cddeaf1af2d4e59ba4b413034784
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
 
 
using System;
using UnityEngine;
using UnityEngine.UI;
 
//批量使用物品
public class ItemBatchUseWin : UIBase
{
    [SerializeField] ItemCell itemCell;
    [SerializeField] Text nameText;
    [SerializeField] Text countText;
    [SerializeField] Text descText;
    [SerializeField] SliderPanel sliderPanel;
    [SerializeField] Text tipText;
    [SerializeField] Button okBtn;
    [SerializeField] Text btnNameText;
    [SerializeField] Text titleText;
 
    public static Func<long, string> ShowTextEvent;
    public static int itemID;
    public static string btnName;
 
 
    int useCnt;
    long maxCnt;
    protected override void InitComponent()
    {
        okBtn.AddListener(OnOK);
    }
 
 
 
    protected override void OnPreOpen()
    {
        useCnt = 1;
        Display();
    }
 
    void Display()
    {
 
        var key = "UseItemTitle_" + itemID;
        if (LanguageConfig.HasKey(key))
        {
            titleText.text = Language.Get(key);
        }
        else
        {
            titleText.text = Language.Get("UseItemDefault");
        }
        maxCnt = PackManager.Instance.GetItemCountByID(PackType.Item, itemID);
        useCnt = maxCnt > 0 ? 1 : 0;
        itemCell.Init(new ItemCellModel(itemID, false, useCnt));
        itemCell.button.AddListener(() =>
        {
            ItemTipUtility.Show(itemID);
        });
 
 
        var itemConfig = ItemConfig.Get(itemID);
        nameText.text = itemConfig.ItemName;
        countText.text = Language.Get("storename12", maxCnt);
        descText.text = itemConfig.Description;
 
 
 
        OnSliderChange(useCnt);
        sliderPanel.Init((value) => { OnSliderChange(value); }, (int)maxCnt);
 
        btnNameText.text = btnName;
    }
 
    void OnSliderChange(int value)
    {
        useCnt = value;
        itemCell.countText.text = UIHelper.ReplaceLargeNum(useCnt);
 
        if (ShowTextEvent != null)
        {
            tipText.text = ShowTextEvent(useCnt);
        }
        else
        {
            tipText.text = "";
        }
 
    }
 
 
    void OnOK()
    {
        CloseWindow();
        if (useCnt == 0)
        {
            SysNotifyMgr.Instance.ShowTip("UseItem1");
            return;
        }
        if (ItemLogicUtility.CheckItemCount(PackType.Item, itemID, useCnt, 1))
        {
            ItemLogicUtility.Instance.UseItem(PackManager.Instance.GetItemGUIDByID(itemID), useCnt);
        }
 
        SysNotifyMgr.Instance.ShowTip("UseOK");
    }
}