local UIUnlockAssistanceHeroPanel = UIViewClass() --------------------------------- 系统函数 ----------------------------------- function UIUnlockAssistanceHeroPanel:OnOpened(context) UIUtils.SetLabelText(self.UICommonPopUp.txt_Title, Const_IDS["IDS_AssistanceFight_UnlockTitle1"]) self:RegistSystemEvent(EventID.UI_AssistanceFight_RefreshUnlockPanel, self.RefreshPanel) self:RegistSystemEvent(EventID.BagItem_Update, self.RefreshPanel) self.slotInfo = context self:RefreshPanel() end function UIUnlockAssistanceHeroPanel:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUp.btn_Close) end function UIUnlockAssistanceHeroPanel:OnButtonClicked(comp) if comp == self.btn_OneKey then local triggerIsUnlock, itemIsUnlock = CTL.AssistanceFight.CheckSlotUnlockState(self.slotInfo) if triggerIsUnlock and itemIsUnlock then MDL.AssistanceFight.RequestUnlockSlot(self.slotInfo.data.slotId) self:CloseView() else if not triggerIsUnlock then -- 条件不满足 CTL.Tips.AddTipsMsg(Const_IDS.IDS_AssistanceFight_UnlockHint1) elseif not itemIsUnlock 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.slotInfo.config.UnlockItem_Table[i].UnlockItemID) return end end end end ------------------------------------------------------------------------------ function UIUnlockAssistanceHeroPanel:RefreshPanel() local triggerIsUnlock, itemIsUnlock = CTL.AssistanceFight.CheckSlotUnlockState(self.slotInfo) local configData = self.slotInfo.config local triggerData = DataSheetManager.TriggerID:GetDataByID(configData.UnlockTriggerID) self.btn_OneKey:SetGray(not triggerIsUnlock or not itemIsUnlock, true) if triggerData and triggerData.Unlock_Table and #triggerData.Unlock_Table > 0 then for i = 1, 2 do if triggerData.Unlock_Table[i] then local isTrigger = MDL.Unlock.IsTriggerComplete(triggerData.Unlock_Table[i].UnlockCondition, nil, triggerData.Unlock_Table[i].UnlockConditionParamA) local triggerStr = isTrigger == false and MDL.Unlock.GetDesByTriggerID(triggerData.Unlock_Table[i], isTrigger) or MDL.Unlock.GetDesByTriggerID(triggerData.Unlock_Table[i]) if i == 1 then UIUtils.SetLabel(self.txt_UnlockConditions, triggerStr) else UIUtils.SetLabel(self.txt_UnlockConditions2, triggerStr) end end end end local needCount = configData.UnlockItem_Table[1].UnlockItemNum local itemCountStr = itemIsUnlock and needCount or UTL.Color.FormatRedColor(tostring(needCount)) UTL.Item.SetItemCell(self.get_Item[1], configData.UnlockItem_Table[1].UnlockItemID, itemCountStr) end return UIUnlockAssistanceHeroPanel