--[[ 宠物助阵位解锁 ]]-- local UIPetUnlockAssistancePanel = UIViewClass() function UIPetUnlockAssistancePanel:OnOpened(context) UIUtils.SetLabelText(self.UICommonPopUp.txt_Title, Const_IDS["IDS_AssistanceFight_UnlockTitle1"]) self:RegistSystemEvent(EventID.BagItem_Update, self.RefreshPanel) self.slotConfig = context self:RefreshPanel() end function UIPetUnlockAssistancePanel:RefreshPanel() local triggerData = DataSheetManager.TriggerID:GetDataByID(self.slotConfig.TriggerID) self.isTriggerUnlock = MDL.Unlock.IsTriggerIdComplete(self.slotConfig.TriggerID) if self.isTriggerUnlock == false then UIUtils.SetLabel(self.txt_UnlockConditions, MDL.Unlock.GetDesByTriggerID(triggerData.Unlock_Table[1], false)) else UIUtils.SetLabel(self.txt_UnlockConditions, MDL.Unlock.GetDesByTriggerID(triggerData.Unlock_Table[1])) end local needCount = self.slotConfig.item[2] self.isItemEnough = MDL.Currency.IsMoneyEnough(self.slotConfig.item[1], needCount) local itemCountStr = self.isItemEnough and needCount or UTL.Color.FormatRedColor(tostring(needCount)) UTL.Item.SetItemCell(self.get_Item[1], self.slotConfig.item[1], itemCountStr) self.btn_OneKey:SetGray(not self.isTriggerUnlock or not self.isItemEnough, true) end function UIPetUnlockAssistancePanel:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUp.btn_Close) end function UIPetUnlockAssistancePanel:OnButtonClicked(comp) if comp == self.btn_OneKey then if self.isTriggerUnlock and self.isItemEnough then MDL.Pet.PetAssistanceUnlockReq(self.slotConfig.ID / 2) CTL.Sound.PlayGameSound("UI_breakout_02") else if not self.isTriggerUnlock then -- 条件不满足 CTL.Tips.AddTipsMsg(Const_IDS.IDS_AssistanceFight_UnlockHint1) elseif not self.isItemEnough then -- 道具不足 CTL.Tips.AddTipsMsg(Const_IDS.IDS_AssistanceFight_UnlockHint2) end end elseif comp == self.UICommonPopUp.btn_Close or comp == self.img_Bottom then self:CloseView() else for i, v in ipairs(self.get_Item) do if comp == v.event_Click then UTL.ItemTips.ShowCommonTipsById(self.slotConfig.item[1]) return end end end end return UIPetUnlockAssistancePanel