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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
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);
 
        // 内部读取货币招募开关状态
        bool isMoneyToggleOn = false;
        var act = manager.GetOperationHeroAppearInfo();
        if (act != null)
        {
            var config = ActHeroAppearConfig.Get(act.CfgID);
            if (config != null)
            {
                isMoneyToggleOn = manager.LoadCallMoneyToggleData(config.CfgID, act.startDate, act.endDate);
            }
        }
 
        if (isMoneyToggleOn)
        {
            // 勾选:货币优先,没超次数就用货币
            if (nowMoneyCnt + treasureCnt <= dailyMaxCountMoney)
            {
                DisplayByMoney(treasureSetConfig.CostMoneyType, needCostMoneyCnt, moneyCount);
            }
            else
            {
                DisplayByItem(treasureSetConfig.CostItemID, treasureCnt);
            }
        }
        else
        {
            // 没勾选:保持原逻辑
            if (hasItemCnt < needCostItemCnt &&
                nowMoneyCnt + treasureCnt <= dailyMaxCountMoney)
            {
                DisplayByMoney(treasureSetConfig.CostMoneyType, needCostMoneyCnt, moneyCount);
                return;
            }
            DisplayByItem(treasureSetConfig.CostItemID, treasureCnt);
        }
    }
 
    void DisplayByMoney(int moneyType, long needCostMoneyCnt, long moneyCount)
    {
 
        bool isEnough = moneyCount >= needCostMoneyCnt;
        needText.text = Language.Get("L1100", RichTextMsgReplaceConfig.GetRichReplace("MONEY", moneyType), UIHelper.AppendColor(!isEnough ? TextColType.Red : TextColType.LightGreen, needCostMoneyCnt.ToString()));
        needImage.SetIconWithMoneyType(moneyType);
 
        clickButton.SetListener(() =>
        {
            if (!isEnough)
            {
                ItemTipUtility.ShowMoneyTip(moneyType, true);
                return;
            }
            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);
        });
 
    }
 
}