lcy
1 天以前 761d7cf434370a72574a6809ca15dde2e7753a89
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
using UnityEngine;
using UnityEngine.UI;
 
public class PhantasmPavilionAddStarButton : MonoBehaviour
{
    [SerializeField] ButtonEx btnAddStar;
    [SerializeField] ImageEx imgAddStar;
    [SerializeField] TextEx txtAddStar;
    [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;
        btnAddStar.SetListener(() =>
        {
            if (unlockWay == 2)
            {
                var hasCnt = PackManager.Instance.GetItemCountByID(PackType.Item, unlockValue);
                int useCnt = manager.GetUpNeedCnt(type, id);
                if (useCnt > hasCnt)
                {
                    if (!ItemConfig.HasKey(unlockValue))
                        return;
                    string name = ItemConfig.Get(unlockValue).ItemName;
                    SysNotifyMgr.Instance.ShowTip("UnLockFail2", name);
                    return;
                }
            }
            manager.SendOPPack(type, PhantasmPavilionOperation.UpgradeStar, (uint)id);
        });
 
        unlockWay = manager.GetUnlockWay(type, id);
        unlockValue = manager.GetUnlockValue(type, id);
 
        bool isStarMax = manager.IsStarMax(type, id);
        txtAddStar.text = Language.Get(isStarMax ? "L1110" : "L1109");
        imgAddStar.gray = isStarMax;
        btnAddStar.interactable = !isStarMax;
        imgRed.SetActive(false);
        txtCount.SetActive(unlockWay == 2 && !isStarMax);
        if (unlockWay == 2)
        {
            if (!ItemConfig.HasKey(unlockValue))
                return;
            imgItem.SetItemSprite(unlockValue);
 
            var hasCnt = PackManager.Instance.GetItemCountByID(PackType.Item, unlockValue);
            int useCnt = manager.GetUpNeedCnt(type, id);
            txtCount.text = UIHelper.AppendColor(useCnt <= hasCnt ? TextColType.DarkGreen : TextColType.Red, Language.Get("BoneField09", hasCnt, useCnt));
            imgRed.SetActive(useCnt <= hasCnt && !isStarMax);
        }
    }
 
}