hch
1 天以前 89fa96e505af9fe7baf676591222bfdb23b48262
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
using UnityEngine;
using UnityEngine.UI;
 
public class PhantasmPavilionUnlockButton : MonoBehaviour
{
    [SerializeField] ButtonEx btnUnlock;
    [SerializeField] ImageEx imgItem;
    [SerializeField] TextEx txtCount;
    [SerializeField] Image imgRed;
    PhantasmPavilionType type;
    int id;
    int unlockWay;
    int unlockValue;
    PhantasmPavilionManager manager { get { return PhantasmPavilionManager.Instance; } }
    public void Display(int id)
    {
        type = manager.nowType;
        this.id = id;
        btnUnlock.SetListener(() =>
        {
            if (unlockWay == 2)
            {
                var hasCnt = PackManager.Instance.GetItemCountByID(PackType.Item, unlockValue);
                int useCnt = manager.GetUnlockNeedCnt(type, id);
                if (useCnt > hasCnt)
                {
                    if (!ItemConfig.HasKey(unlockValue))
                        return;
                    string name = ItemConfig.Get(unlockValue).ItemName;
                    SysNotifyMgr.Instance.ShowTip("UnLockFail2", name);
                    return;
                }
            }
            else if (unlockWay == 3)
            {
                bool hasHero = HeroManager.Instance.HasHero(unlockValue);
                if (!hasHero)
                {
                    SysNotifyMgr.Instance.ShowTip("UnLockFail1");
                    return;
                }
            }
            manager.SendOPPack(type, PhantasmPavilionOperation.Activate, (uint)id);
            SysNotifyMgr.Instance.ShowTip("UnLockSuccess");
        });
 
        unlockWay = manager.GetUnlockWay(type, id);
        unlockValue = manager.GetUnlockValue(type, id);
 
        txtCount.SetActive(unlockWay == 2);
        imgRed.SetActive(false);
        if (unlockWay == 2)
        {
 
            if (!ItemConfig.HasKey(unlockValue))
                return;
            imgItem.SetItemSprite(unlockValue);
 
            var hasCnt = PackManager.Instance.GetItemCountByID(PackType.Item, unlockValue);
            int useCnt = manager.GetUnlockNeedCnt(type, id);
            txtCount.text = UIHelper.AppendColor(useCnt <= hasCnt ? TextColType.Green : TextColType.Red, Language.Get("BoneField09", hasCnt, useCnt));
            imgRed.SetActive(useCnt <= hasCnt);
        }
    }
 
}