lcy
6 天以前 2b60f3b22b916327f678388c8d5832d2bdabb49d
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
using UnityEngine;
 
public class HeroDebutCallButton : MonoBehaviour
{
    [SerializeField] ButtonEx clickButton;
    [SerializeField] TextEx callText;
    [SerializeField] TextEx needText;
    [SerializeField] ImageEx needImage;
    HeroDebutManager manager => HeroDebutManager.Instance;
    HappyXBModel xbManager => HappyXBModel.Instance;
    int index;
    int type;
    int needCostItemCnt;
    long hasItemCnt;
    int needCostMoneyCnt;
    long moneyCount;
    public void Display(int treasureType, int index)
    {
        this.index = index;
        type = treasureType;
        var treasureSetConfig = TreasureSetConfig.Get(treasureType);
        if (treasureSetConfig == null) return;
        if (treasureSetConfig.TreasureCountList == null || treasureSetConfig.TreasureCountList.Length <= index) return;
        if (treasureSetConfig.CostItemCountList == null || treasureSetConfig.CostItemCountList.Length <= index) return;
        if (treasureSetConfig.CostMoneyList == null || treasureSetConfig.CostMoneyList.Length <= index) return;
 
        XBTypeInfo info = xbManager.GetXBInfoByType(treasureType);
        if (info == null) return;
 
        int treasureCnt = treasureSetConfig.TreasureCountList[index];
 
        callText.text = Language.Get("HeroDebut23", treasureCnt);
 
        int dailyMaxCountMoney = treasureSetConfig.DailyMaxCountMoney;
        int nowMoneyCnt = info.treasureCountTodayGold;
 
        needCostMoneyCnt = treasureSetConfig.CostMoneyList[index];
        moneyCount = UIHelper.GetMoneyCnt(treasureSetConfig.CostMoneyType);
 
        needCostItemCnt = treasureSetConfig.CostItemCountList[index];
        hasItemCnt = PackManager.Instance.GetItemCountByID(PackType.Item, treasureSetConfig.CostItemID);
 
        // 物品不足 && 没超货币招募次数上限 &&  货币足够
        if (hasItemCnt < needCostItemCnt &&
            nowMoneyCnt + treasureCnt <= dailyMaxCountMoney &&
            moneyCount >= needCostMoneyCnt)
        {
            DisplayByMoney(treasureSetConfig.CostMoneyType, needCostMoneyCnt);
            return;
        }
        DisplayByItem(treasureSetConfig.CostItemID, treasureCnt);
    }
 
    void DisplayByMoney(int moneyType, long moneyCnt)
    {
        needText.text = Language.Get("L1100", RichTextMsgReplaceConfig.GetRichReplace("MONEY", moneyType), UIHelper.AppendColor(moneyCount < moneyCnt ? TextColType.Red : TextColType.LightGreen, moneyCnt.ToString()));
        needImage.SetIconWithMoneyType(moneyType);
 
        clickButton.SetListener(() =>
        {
            HeroUIManager.Instance.selectCallType = (HappXBTitle)type;
            HeroUIManager.Instance.selectCallIndex = index;
            HappyXBModel.Instance.SendXBQuest(type, index, 0);
        });
    }
 
    void DisplayByItem(int itemID, int count)
    {
        ItemConfig itemConfig = ItemConfig.Get(itemID);
        if (itemConfig == null) return;
        bool isEnough = hasItemCnt >= needCostItemCnt;
        needText.text = Language.Get("L1100", itemConfig.ItemName, UIHelper.AppendColor(!isEnough ? TextColType.Red : TextColType.LightGreen, count.ToString()));
        needImage.SetItemSprite(itemID);
 
        clickButton.SetListener(() =>
        {
            if (!isEnough)
            {
                ItemTipUtility.Show(itemID, true);
                return;
            }
            HeroUIManager.Instance.selectCallType = (HappXBTitle)type;
            HeroUIManager.Instance.selectCallIndex = index;
            HappyXBModel.Instance.SendXBQuest(type, index, 2);
        });
 
    }
 
}