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) { 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); }); } }