---@class KLShapeShiftCardItem:UIKmlLuaPanelBase ---@field view KLShapeShiftCardItemView local KLShapeShiftCardItem = class(UIKmlLuaPanelBase) local this = KLShapeShiftCardItem ---创建时调用一次 function this:Init() if self.args.type == E_ShapeShiftCardFuncType.ExSynthesis then GUI:setVisible(self.view.btn_card_func, true) GUI:Button_setTitleText(self.view.btn_card_func, "合成") elseif self.args.type == E_ShapeShiftCardFuncType.ExBreak then GUI:setVisible(self.view.btn_card_func, true) GUI:Button_setTitleText(self.view.btn_card_func, "突破") else GUI:setVisible(self.view.btn_card_func, false) end end ---注册UI事件和服务器消息 function this:RegistEvents() GUI:AddOnClickEvent(self.view.img_empty_bg, self, self.ClickSelf) GUI:AddOnClickEvent(self.view.img_card_bg, self, self.ClickSelf) GUI:AddOnClickEvent(self.view.btn_card_func, self, self.ClickUpgradeFunc) end ---界面显示时调用一次 function this:Show() end ---创建或者刷新界面数据时调用 function this:Refresh() --GUI:setContentSize(self.view.KLShapeShiftCardItem, 164, 255) end ---在镶嵌-上 ---@param data EquipPartCardInfo function this:RefreshUnInlayItem(data, index, part, partInfo) if data.unlock then ---解锁 if data.card and data.card.cfgid > 0 then ---有卡 GUI:setVisible(self.view.panel_empty, false) GUI:setVisible(self.view.panel_card, true) self:RefreshCardInfo(data.card.cfgid) GUI:setVisible(self.view.item_equip_redPoint, false) else ---无卡 GUI:setVisible(self.view.panel_card, false) GUI:setVisible(self.view.panel_empty, true) GUI:setVisible(self.view.img_empty_lock, false) GUI:setVisible(self.view.img_empty_add, true) GUI:setVisible(self.view.item_equip_redPoint, InfoManager.shapeShiftCardInfo:GetPartHaveCardCheck(part)) end else ---未解锁 GUI:setVisible(self.view.panel_empty, true) GUI:setVisible(self.view.panel_card, false) GUI:setVisible(self.view.img_empty_lock, true) GUI:setVisible(self.view.img_empty_add, false) ---@type cfg_card_inlay_column local tbl = SL:GetConfig("cfg_card_inlay", part) local rank = InfoManager.shapeShiftCardInfo:GetEquipRankByPart(part) for _, v in ipairs(tbl.unlockParameter) do if index == v[1] then GUI:setVisible(self.view.item_equip_redPoint, rank >= v[2]) end end --for i, v in pairs(tbl.unlockNormal) do -- if v[1] == index then -- if SL:GetBagItemCount(v[2]) >= v[3] then -- GUI:setVisible(self.view.item_equip_redPoint, true) -- else -- GUI:setVisible(self.view.item_equip_redPoint, false) -- end -- end --end end GUI:setPosition(self.view.item_equip_redPoint, 5, 5) self.partInfo = partInfo self.cardInfo = data self.index = index self.part = part end ---在(镶嵌-下)牌库 function this:RefreshBagItem(card, cardTblIndex) GUI:setVisible(self.view.panel_empty, false) GUI:setVisible(self.view.panel_card, true) self:RefreshCardInfo(card.cfgid) self.isSelect = card.select GUI:setVisible(self.view.img_select, self.isSelect) self.cardTblIndex = cardTblIndex GUI:setVisible(self.view.item_equip_redPoint, false) self.cardInfo = card end function this:RefreshAwardItem(card) GUI:setVisible(self.view.panel_empty, false) GUI:setVisible(self.view.panel_card, true) self:RefreshCardInfo(card.cfgid) self.cardInfo = card end ---在合成 function this:RefreshSynthesis(card) GUI:setVisible(self.view.panel_empty, false) GUI:setVisible(self.view.panel_card, true) if self.args.type == E_ShapeShiftCardFuncType.Synthesis then self.isSelect = card.select GUI:setVisible(self.view.img_select, self.isSelect) self:RefreshCardInfo(card.cfgid) elseif self.args.type == E_ShapeShiftCardFuncType.ExSynthesis then self:RefreshCardInfo(card.cfgid, #card.count) elseif self.args.type == E_ShapeShiftCardFuncType.UnSynthesis then if not card then GUI:setVisible(self.view.panel_card, false) GUI:setVisible(self.view.panel_empty, true) GUI:setVisible(self.view.img_empty_lock, false) GUI:setVisible(self.view.img_empty_add, false) else self:RefreshCardInfo(card.cfgid) end end self.cardInfo = card end ---在突破 function this:RefreshBreak(card) GUI:setVisible(self.view.panel_empty, false) GUI:setVisible(self.view.panel_card, true) if self.args.type == E_ShapeShiftCardFuncType.Break then self.isSelect = card.select GUI:setVisible(self.view.img_select, self.isSelect) self:RefreshCardInfo(card.cfgid) elseif self.args.type == E_ShapeShiftCardFuncType.ExBreak then self:RefreshCardInfo(card.cfgid, #card.count) elseif self.args.type == E_ShapeShiftCardFuncType.UnBreak then if not card then GUI:setVisible(self.view.panel_card, false) GUI:setVisible(self.view.panel_empty, true) GUI:setVisible(self.view.img_empty_lock, false) GUI:setVisible(self.view.img_empty_add, false) else self:RefreshCardInfo(card.cfgid) end end self.cardInfo = card end function this:RefreshCardInfo(id, count) ---@type cfg_card_shapeshift_column local tbl = SL:GetConfig("cfg_card_shapeshift", id) ---@type cfg_item_column local item_tbl = SL:GetConfig("cfg_item", id) GUI:Image_loadTexture(self.view.img_card_bg, "card_quality_" .. tbl.quality, "Atlas/KLShapeShiftCard.spriteatlas") GUI:Image_loadTexture(self.view.img_card_icon, tbl.img, "Atlas/KLShapeShiftCard.spriteatlas") if #tbl.position > 0 then GUI:setPosition(self.view.img_card_icon, tbl.position[1], tbl.position[2]) else GUI:setPosition(self.view.img_card_icon, 0, 0) end if tbl.scale ~= 0 then GUI:setScale(self.view.img_card_icon, tbl.scale) else GUI:setScale(self.view.img_card_icon, 1) end GUI:Image_loadTexture(self.view.img_card_level, "num_quality_" .. tbl.quality .. "_" .. tbl.level, "Atlas/KLShapeShiftCard.spriteatlas") GUI:Text_setString(self.view.text_card_name, item_tbl.name) GUI:Text_setTextColor(self.view.text_card_name, tostring(item_tbl.color)) GUI:setVisible(self.view.text_card_count, false) GUI:setPosition(self.view.item_equip_redPoint, 5, 5) local upgradeCount if self.args.type == E_ShapeShiftCardFuncType.ExSynthesis or self.args.type == E_ShapeShiftCardFuncType.Synthesis or self.args.type == E_ShapeShiftCardFuncType.UnSynthesis then upgradeCount = tbl.upAmount elseif self.args.type == E_ShapeShiftCardFuncType.ExBreak or self.args.type == E_ShapeShiftCardFuncType.Break or self.args.type == E_ShapeShiftCardFuncType.UnBreak then ---@type cfg_card_breakthrough_column local break_tbl = SL:GetConfig("cfg_card_breakthrough", id) upgradeCount = break_tbl.expend end if self.args.type == E_ShapeShiftCardFuncType.ExSynthesis or self.args.type == E_ShapeShiftCardFuncType.ExBreak then if count then self.canUpgrade = false if upgradeCount > 0 then if count >= upgradeCount then self.canUpgrade = true GUI:Text_setString(self.view.text_card_count, "" .. count .. "/" .. upgradeCount) GUI:setVisible(self.view.item_equip_redPoint, true) GUI:setPosition(self.view.item_equip_redPoint, 0, -182) else GUI:Text_setString(self.view.text_card_count, "" .. count .. "/" .. upgradeCount) GUI:setVisible(self.view.item_equip_redPoint, false) end GUI:setVisible(self.view.text_card_count, true) end end end if self.args.type == E_ShapeShiftCardFuncType.Synthesis or self.args.type == E_ShapeShiftCardFuncType.Break then local cardCount = InfoManager.shapeShiftCardInfo:GetBagCardCountByCfgId(id) if cardCount >= upgradeCount then GUI:setVisible(self.view.item_equip_redPoint, true) else GUI:setVisible(self.view.item_equip_redPoint, false) end end self.cardId = id end function this:ClickSelf() if not self.cardInfo then return end ---@type KLShapeShiftCardInlayPanel local ui = GUI:GetUI("dev/outui/ShapeShiftCard/Panel/KLShapeShiftCardInlay/KLShapeShiftCardInlayPanel") if self.args.type == E_ShapeShiftCardFuncType.UnInlay then if self.cardInfo.unlock then ---解锁 if self.cardInfo.card and self.cardInfo.card.cfgid > 0 then ---打开卡牌tips,卸下卡牌 GUI:UIPanel_Open("dev/outui/ShapeShiftCard/Panel/KLShapeShiftCardTips/KLShapeShiftCardTipsPanel", nil, nil, { cardInfo = self.cardInfo.card, part = self.part, index = self.index, type = self.args.type }) if ui then ui:RefreshSelectIndex(self.index) end else ---打开牌库 if ui then ui:OpenCardHouse(self.index) return end end else local _, isNone = InfoManager.shapeShiftCardInfo:GetEquipRankByPart(self.part) if not self.partInfo[self.index - 1] or self.partInfo[self.index - 1].unlock and not isNone then GUI:UIPanel_Open("dev/outui/ShapeShiftCard/Panel/KLShapeShiftCardUnLock/KLShapeShiftCardUnLockPanel", nil, nil, { index = self.index, part = self.part, info = self.cardInfo }) else SL:TipMessage(SL:GetConfig('cfg_string', 20001).text, 1, NoticeType.NoticeMid) end end if ui then ui:CloseCardHouse() end else if self.args.type == E_ShapeShiftCardFuncType.House then ---@type KLShapeShiftCardHousePanel local houseUI = GUI:GetUI("dev/outui/ShapeShiftCard/Panel/KLShapeShiftCardHouse/KLShapeShiftCardHousePanel") if houseUI then if houseUI.recoveryIsShow then self.isSelect = not self.isSelect houseUI:SetRecoveryInfo(self.cardInfo, self.isSelect, self.cardTblIndex) GUI:setVisible(self.view.img_select, self.isSelect) return end end end --if self.args.type == E_ShapeShiftCardFuncType.Synthesis then -- ---@type KLShapeShiftCardSynthesisPanel -- local panel = GUI:GetUI("dev/outui/ShapeShiftCard/Panel/KLShapeShiftCardSynthesis/KLShapeShiftCardSynthesisPanel") -- if panel then -- if panel.synthesisIsShow then -- if not self.isSelect then -- local result = panel:SetSynthesisInfo(self.cardInfo, true) -- if result then -- SL:TipMessage( SL:GetConfig('cfg_string',20007).text, 1, NoticeType.NoticeMid ) --"卡牌数量不足" -- end -- else -- panel:SetSynthesisInfo(self.cardInfo, false) -- end -- return -- end -- end --end --if self.args.type == E_ShapeShiftCardFuncType.UnSynthesis then -- if self.cardInfo then -- ---@type KLShapeShiftCardSynthesisPanel -- local panel = GUI:GetUI("dev/outui/ShapeShiftCard/Panel/KLShapeShiftCardSynthesis/KLShapeShiftCardSynthesisPanel") -- if panel then -- if panel.synthesisIsShow then -- panel:SetSynthesisInfo(self.cardInfo, false) -- return -- end -- end -- else -- return -- end --end local partValue, indexValue if ui then partValue = ui.part indexValue = ui.selectIndex end GUI:UIPanel_Open("dev/outui/ShapeShiftCard/Panel/KLShapeShiftCardTips/KLShapeShiftCardTipsPanel", _, _, { cardInfo = self.cardInfo, type = self.args.type, index = indexValue, part = partValue, select = self.isSelect }) end end function this:ClickUpgradeFunc() local stringId, msgId if self.args.type == E_ShapeShiftCardFuncType.ExSynthesis or self.args.type == E_ShapeShiftCardFuncType.ExBreak then local upgradeCount if self.args.type == E_ShapeShiftCardFuncType.ExSynthesis then upgradeCount = self.cardInfo.tbl.upAmount stringId = 20006 msgId = LuaMessageIdToSever.REQ_TRANSFER_CARD_SYNTHESIS elseif self.args.type == E_ShapeShiftCardFuncType.ExBreak then upgradeCount = self.cardInfo.breakTbl.expend stringId = 20008 msgId = LuaMessageIdToSever.REQ_BREAKTHROUGH_CARD end if self.canUpgrade then SL:CommonTipsMessage({ stringTblID = stringId, ui = self, callback = function() local card = {} local mainCard = self.cardInfo.count[1] for i = 2, upgradeCount do card[i - 1] = self.cardInfo.count[i] end SL:SendLuaNetMsg(msgId, { mainCard, card }) end }) else SL:TipMessage(SL:GetConfig('cfg_string', 20004).text, 1, NoticeType.NoticeMid) --"卡牌数量不足" end end end function this:ShowSelectShow(id, isShow) if self.cardInfo and id == self.cardInfo.id then GUI:setVisible(self.view.img_select, isShow) self.isSelect = isShow return true end return false end function this:Close() end return this