123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534 |
- ---@class KLShapeShiftCardInlayPanel:UIKmlLuaPanelBase
- ---@field view KLShapeShiftCardInlayPanelView
- local KLShapeShiftCardInlayPanel = class(UIKmlLuaPanelBase)
- local this =KLShapeShiftCardInlayPanel
- ---@class EquipPartCardInfo
- ---@field luck number
- ---@field unlock boolean
- ---@field card number
- ---卡牌装备部位
- local EquipParts = {1,2,3,4,5,6,7,8,9,10,11,12,13}
- ---卡牌装备部位坐标
- local PartsPos = {
- [1] = {-340, 51},
- [2] = {-340, -52},
- [3] = {-340, 51},
- [4] = {-443, 149},
- [6] = {-443, 51},
- [7] = {-443, -52},
- [8] = {-443, -150},
- [5] = {329, 50},
- [9] = {330, -51},
- [10] = {429, 151},
- [11] = {429, 50},
- [12] = {429, -52},
- [13] = {429, -151},
- }
- function this:AsyncLoadUI()
- end
- ---创建时调用一次
- function this:Init()
- GUI:OSAScrollView_Initialized(self.view.osa_card_list, self.CardItemGetFun, self.CardItemUpdateFun, self)
- GUI:OSAScrollView_Initialized(self.view.osa_card_house_list, self.CardItemGetFun_2,self.CardItemUpdateFun_2, self)
- GUI:OSAScrollView_Initialized(self.view.osa_attr_list_left, nil,self.CardAttrLeftUpdateFun, self)
- GUI:OSAScrollView_Initialized(self.view.osa_attr_list_right, nil,self.CardAttrRightUpdateFun, self)
- end
- function this:CardItemGetFun()
- return GUI:UIPanel_Open("dev/outui/ShapeShiftCard/Item/KLShapeShiftCard/KLShapeShiftCardItem", nil, self, { type = E_ShapeShiftCardFuncType.UnInlay }, true)
- end
- ---@param item KLShapeShiftCardItem
- ---@param index number
- function this:CardItemUpdateFun(item,index)
- local partInfo = self.allPartsInfo[self.part]
- local cardInfo = partInfo[index + 1]
- item:RefreshUnInlayItem(cardInfo, index + 1, self.part, partInfo)
- end
- function this:CardItemGetFun_2()
- return GUI:UIPanel_Open("dev/outui/ShapeShiftCard/Item/KLShapeShiftCard/KLShapeShiftCardItem", nil, self, { type = E_ShapeShiftCardFuncType.Inlay }, true)
- end
- ---@param item KLShapeShiftCardItem
- ---@param index number
- function this:CardItemUpdateFun_2(item,index)
- item:RefreshBagItem(self.selectPartCardInfo[index + 1])
- end
- function this:CardAttrLeftUpdateFun(item, index)
- local text_attr_name = GUI:GetChildById(item, "text_attr_name")
- local text_attr_value = GUI:GetChildById(item, "text_attr_value")
- local info = self.allAttrTbl[index + 1]
- ---@type cfg_att_info_column
- local tbl = SL:GetConfig("cfg_att_info", info.attr)
- local name = tbl.name
- if info.value2 then
- name = "攻击力"
- end
- if info.active then
- GUI:Text_setString(text_attr_name, name .. ":")
- GUI:Text_setTextColor(text_attr_name, "#DCE1E5")
- GUI:Text_setTextColor(text_attr_value, "#DCE1E5")
- else
- GUI:Text_setString(text_attr_name, name .. ":(未激活)")
- GUI:Text_setTextColor(text_attr_name, "#999999")
- GUI:Text_setTextColor(text_attr_value, "#999999")
- end
- if info.value2 then
- if info.value2 > info.value then
- GUI:Text_setString(text_attr_value, info.value .. "~" .. info.value2)
- else
- GUI:Text_setString(text_attr_value, info.value2 .. "~" .. info.value)
- end
- else
- if tbl.remarks == 1 then
- GUI:Text_setString(text_attr_value, tostring(info.value))
- else
- local value = info.value / 100
- GUI:Text_setString(text_attr_value, value .. "%")
- end
- end
- end
- function this:CardAttrRightUpdateFun(item, index)
- local text_skill_name = GUI:GetChildById(item, "text_skill_name")
- local info = self.allSkillTbl[index + 1]
- local text = "Lv." .. info.level .. " " .. info.name
- if info.active then
- GUI:Text_setString(text_skill_name, text)
- if info.quality == 1 then
- GUI:Text_setTextColor(text_skill_name, "#4CC5FE")
- elseif info.quality == 2 then
- GUI:Text_setTextColor(text_skill_name, "#E6E600")
- elseif info.quality == 3 then
- GUI:Text_setTextColor(text_skill_name, "#FF2323")
- end
- else
- GUI:Text_setString(text_skill_name, text .. "(未激活)")
- GUI:Text_setTextColor(text_skill_name, "#999999")
- end
- end
- ---注册UI事件和服务器消息
- function this:RegistEvents()
- for _, v in pairs(EquipParts) do
- local partBtn = self.view["equip_part_" .. v]
- GUI:AddOnClickEvent(partBtn, self, self.OnClickEquipPart, v)
- end
- GUI:AddOnClickEvent(self.view.btn_card_close, self, self.CloseCardHouse)
- GUI:AddOnClickEvent(self.view.btn_go, self, self.SwitchCardShop)
- GUI:AddOnClickEvent(self.view.btn_tips, self, self.FuncTips)
- GUI:AddOnClickEvent(self.view.btn_tips_2, self, self.FuncTips_2)
-
- --SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_TRANSFER_CARD_PART_INFO, self.RES_TRANSFER_CARD_PART_INFO, self)
- SL:RegisterLUAEvent(LUA_SHAPE_CARD_BAG_CHANGE, self.RES_TRANSFER_CARD_BAG, self)
- SL:RegisterLUAEvent(LUA_SHAPE_CARD_PART_INFO_CHANGE, self.RES_TRANSFER_CARD_PART_INFO, self)
- --SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_TRANSFER_CARD_BAG, self.RES_TRANSFER_CARD_BAG, self)
- end
- ---刷新卡牌镶嵌栏
- function this:OnClickEquipPart(_,part)
- self.part = part
- GUI:setPosition(self.view.img_equip_part_select, PartsPos[part][1], PartsPos[part][2])
- if self.equip and self.equip[1] and self.equip[1][part] then
- GUI:setVisible(self.view.panel_lapse, false)
- else
- GUI:setVisible(self.view.panel_lapse, true)
- end
- ---刷新默认镶嵌槽位
- self.selectIndex = 0
- for i, v in pairs(self.allPartsInfo[self.part]) do
- if v.unlock and (not v.card or v.card == 0) then
- self.selectIndex = i
- break
- end
- end
- self:CloseCardHouse()
- self:RefreshCardHouseList()
- end
- ---界面显示时调用一次
- function this:Show()
-
- end
- ---创建或者刷新界面数据时调用
- function this:Refresh()
- ---@type BagShapeShiftCard[]
- self.allCardInfo = InfoManager.shapeShiftCardInfo.allCardInfo
- ---@type ShapeShiftMessage[]
- self.allPartsInfo = InfoManager.shapeShiftCardInfo.allPartsInfo
- self:RefreshRoleEquip()
- ---当职业为弓箭手或使用双手武器时,使用双手武器槽位
- if SL:GetMetaValue(EMetaVarGetKey.JOB) == 3 or (self.equip and self.equip[1] and self.equip[1][3]) then
- GUI:setVisible(self.view.equip_part_1, false)
- GUI:setVisible(self.view.equip_part_3, true)
- self:OnClickEquipPart(nil, 3)
- else
- GUI:setVisible(self.view.equip_part_1, true)
- GUI:setVisible(self.view.equip_part_3, false)
- self:OnClickEquipPart(nil, 1)
- end
- self:RefreshAllPartRedPointInfo()
- self:RefreshAllPartAttrInfo()
- end
- ---刷新装备栏装备
- function this:RefreshRoleEquip()
- self.equip = SL:GetTotalWearEquips()
- if self.equip[1] then
- for _, v in pairs(EquipParts) do
- local tbl = SL:GetConfig("cfg_card_inlay", v)
- GUI:Image_loadTexture(self.view["item_equip_type_" ..v], "icon_type_" .. tbl.type, "Atlas/KLShapeShiftCard.spriteatlas")
- if self.equip[1][v] then
- GUI:setVisible(self.view["item_equip_" .. v], true)
- GUI:Item_setItemId(self.view["item_equip_" .. v], self.equip[1][v].cfgId)
- else
- GUI:setVisible(self.view["item_equip_" .. v], false)
- end
- end
- end
- end
- function this:OpenCardHouse(index)
- self:RefreshSelectIndex(index)
- GUI:setVisible(self.view.panel_cards, true)
- GUI:setVisible(self.view.layout_all_attr, false)
- end
- ---当前选中卡牌下标
- function this:RefreshSelectIndex(index)
- self.selectIndex = index
- end
- function this:CloseCardHouse()
- GUI:setVisible(self.view.panel_cards, false)
- GUI:setVisible(self.view.layout_all_attr, true)
- end
- ---当前部位卡牌参数变化刷新
- function this:RES_TRANSFER_CARD_PART_INFO(_, eventData)
- self:OnClickEquipPart(_, eventData)
- self:RefreshAllPartAttrInfo()
- self:RefreshAllPartRedPointInfo()
- end
- function this:SwitchCardShop()
- local ui = GUI:GetUI("dev/outui/ShapeShiftCard/Panel/KLShapeShiftCardMain/KLShapeShiftCardMainPanel")
- if ui then
- GUI:Toggle_setIsOn(ui.view.toggle_shop, true)
- end
- end
- function this:FuncTips()
- local helpCfg = SL:GetConfig("cfg_rule_text", 101)
- if helpCfg then
- SL:CommonStrTipsMessage({ title = helpCfg.menutxt, str = helpCfg.location })
- end
- end
- function this:FuncTips_2()
- local helpCfg = SL:GetConfig("cfg_rule_text", 104)
- if helpCfg then
- SL:CommonStrTipsMessage({ title = helpCfg.menutxt, str = helpCfg.location })
- end
- end
- ---刷新卡牌属性
- function this:RefreshAllPartAttrInfo()
- self.allAttrTbl = {}
- local lockSkillTbl = {}
- local unlockSkillTbl = {}
- for i, v in pairs(self.allPartsInfo) do
- ---@param k ShapeShiftCardMessage
- for _, k in ipairs(v) do
- if k.card and table.count(k.card) > 0 then
- local active
- if self.equip and self.equip[1] and self.equip[1][i] then
- active = true
- else
- active = false
- end
- local tbl_attr = {}
- ---左侧属性list
- ---@type cfg_card_shapeshift_column
- local tbl = SL:GetConfig("cfg_card_shapeshift", k.card.cfgid)
- for _, vv in pairs(tbl.attribute) do
- tbl_attr[#tbl_attr + 1] = { vv[1], vv[2] }
- end
- for _, vv in pairs(k.card.entry) do
- tbl_attr[#tbl_attr + 1] = { vv.attrid, vv.attrvalue }
- end
- for _, n2 in pairs(tbl_attr) do
- local set = false
- for _, n in pairs(self.allAttrTbl) do
- if n2[1] == n.attr and active == n.active then
- n.value = n.value + n2[2]
- set = true
- end
- end
- if not set then
- ---@type cfg_att_info_column
- local attTbl = SL:GetConfig("cfg_att_info", n2[1])
- local info = {}
- info.attr = n2[1]
- info.value = n2[2]
- info.active = active
- info.sort = attTbl.sort
- self.allAttrTbl[#self.allAttrTbl + 1] = info
- end
- end
- ---右侧技能list
- if #tbl.skill > 0 then
- if active then
- if unlockSkillTbl[tbl.group] then
- if unlockSkillTbl[tbl.group].level < tbl.level then
- unlockSkillTbl[tbl.group].level = tbl.level
- unlockSkillTbl[tbl.group].id = tbl.id
- unlockSkillTbl[tbl.group].quality = tbl.quality
- end
- else
- local info = {}
- info.id = tbl.id
- info.name = tbl.name
- info.level = tbl.level
- info.quality = tbl.quality
- unlockSkillTbl[tbl.group] = info
- end
- else
- if lockSkillTbl[tbl.group] then
- if lockSkillTbl[tbl.group].level < tbl.level then
- lockSkillTbl[tbl.group].level = tbl.level
- lockSkillTbl[tbl.group].id = tbl.id
- lockSkillTbl[tbl.group].quality = tbl.quality
- end
- else
- local info = {}
- info.id = tbl.id
- info.name = tbl.name
- info.level = tbl.level
- info.quality = tbl.quality
- lockSkillTbl[tbl.group] = info
- end
- end
- end
- end
- end
- end
- table.sort(self.allAttrTbl, function(a, b)
- if a.active == b.active then
- return a.sort < b.sort
- else
- return a.active
- end
- end)
- ---攻击力属性合并
- local indexActive, specialAttrActive, index, specialAttr
- for i, v in pairs(self.allAttrTbl) do
- if v.attr == 201021 then
- if v.active then
- if not specialAttrActive then
- specialAttrActive = v.value
- indexActive = i
- else
- v.value2 = specialAttrActive
- end
- else
- if not specialAttr then
- specialAttr = v.value
- index = i
- else
- v.value2 = specialAttr
- end
- end
- elseif v.attr == 201011 then
- if v.active then
- if not specialAttrActive then
- specialAttrActive = v.value
- indexActive = i
- else
- v.value2 = specialAttrActive
- end
- else
- if not specialAttr then
- specialAttr = v.value
- index = i
- else
- v.value2 = specialAttr
- end
- end
- end
- end
- if indexActive then
- table.remove(self.allAttrTbl, indexActive)
- end
- if index then
- if indexActive then
- table.remove(self.allAttrTbl, index - 1)
- else
- table.remove(self.allAttrTbl, index)
- end
- end
- if #self.allAttrTbl > 0 then
- GUI:setVisible(self.view.img_left_tips, false)
- else
- GUI:setVisible(self.view.img_left_tips, true)
- end
- GUI:OSAScrollView_RefreshList(self.view.osa_attr_list_left, #self.allAttrTbl)
- for i, v in pairs(unlockSkillTbl) do
- local info = lockSkillTbl[i]
- if info and info.level <= v.level then
- lockSkillTbl[i] = nil
- end
- end
- self.allSkillTbl = {}
- for _, v in pairs(unlockSkillTbl) do
- v.active = true
- self.allSkillTbl[#self.allSkillTbl + 1] = v
- end
- for _, v in pairs(lockSkillTbl) do
- v.active = false
- self.allSkillTbl[#self.allSkillTbl + 1] = v
- end
-
- table.sort(self.allSkillTbl, function(a, b)
- if a.active == b.active then
- return a.quality > b.quality
- else
- return a.active
- end
- end)
- if #self.allSkillTbl > 0 then
- GUI:setVisible(self.view.img_right_tips, false)
- else
- GUI:setVisible(self.view.img_right_tips, true)
- end
- GUI:OSAScrollView_RefreshList(self.view.osa_attr_list_right, #self.allSkillTbl)
- end
- ---把后端传过来的表key转换成number格式
- function this:RefreshCardPartKeyToNumber(message)
- if message and next(message) then
- local tbl = {}
- for i, v in pairs(message) do
- local tbl_1 = {}
- for j, k in pairs(v) do
- tbl_1[tonumber(j)] = k
- end
- tbl[tonumber(i)] = tbl_1
- end
- return tbl
- end
- end
- function this:RES_TRANSFER_CARD_BAG()
- ---@type BagShapeShiftCard[]
- self.allCardInfo = InfoManager.shapeShiftCardInfo.allCardInfo
- self:RefreshCardHouseList(true)
- self:RefreshAllPartRedPointInfo()
- end
- ---刷新镶嵌槽位与镶嵌牌库
- function this:RefreshCardHouseList()
- ---@type cfg_card_inlay_column
- local inlayCfg = SL:GetConfig("cfg_card_inlay", self.part)
- GUI:OSAScrollView_RefreshList(self.view.osa_card_list, inlayCfg.holeAmount)
- ---当背包变化或卡牌种类不同才刷新
- self.currPartType = inlayCfg.type
- self.selectPartCardInfo = {}
- if inlayCfg.type == 1 then
- local partInfo = self.allPartsInfo[self.part]
- local limitList = {}
- for _, v in pairs(partInfo) do
- if v.card and table.count(v.card) > 0 then
- local tbl = SL:GetConfig("cfg_card_shapeshift", v.card.cfgid)
- limitList[tbl.group] = true
- end
- end
- for _, v in ipairs(self.allCardInfo) do
- if inlayCfg.type == v.type and not limitList[v.group] then
- self.selectPartCardInfo[#self.selectPartCardInfo + 1] = v
- end
- end
- else
- for _, v in ipairs(self.allCardInfo) do
- if inlayCfg.type == v.type then
- self.selectPartCardInfo[#self.selectPartCardInfo + 1] = v
- end
- end
- end
-
- GUI:OSAScrollView_RefreshList(self.view.osa_card_house_list, #self.selectPartCardInfo)
- if #self.selectPartCardInfo > 0 then
- GUI:setVisible(self.view.panel_no_card, false)
- else
- GUI:setVisible(self.view.panel_no_card, true)
- end
- end
- ---刷新镶嵌红点
- function this:RefreshAllPartRedPointInfo()
- if self.allPartsInfo then
- for i, v in pairs(self.allPartsInfo) do
- local state = self:GetEachPartRedPointState(i, v)
- GUI:setVisible(self.view["item_equip_redPoint_" .. i], state)
- end
- end
- end
- ---各部位红点
- function this:GetEachPartRedPointState(part, partInfo)
- ---@type cfg_card_inlay_column
- local inlay = SL:GetConfig("cfg_card_inlay", tonumber(part))
- for j, k in pairs(partInfo) do
- if k.unlock then
- ---有卡牌可镶嵌
- if not k.card or table.count(k.card) == 0 then
- if InfoManager.shapeShiftCardInfo:GetPartHaveCardCheck(part) then
- return true
- end
- end
- else
- if inlay.holeAmount == #inlay.unlockFree then
- local rank = InfoManager.shapeShiftCardInfo:GetEquipRankByPart(part)
- for _, v in pairs(inlay.unlockParameter) do
- if j == v[1] then
- if rank >= v[2] then
- return true
- end
- end
- end
- else
- ---道具够解锁
- if inlay.unlockNormal then
- for _, vv in ipairs(inlay.unlockNormal) do
- if vv[1] == tonumber(j) then
- if SL:GetBagItemCount(vv[2]) >= vv[3] then
- return true
- end
- end
- end
- end
- end
- end
- end
- return false
- end
- function this:Close()
- self.selectPartCardInfo = nil
- self.allSkillTbl = nil
- self.allAttrTbl = nil
- self.allPartsInfo = nil
- self.equip = nil
- end
- return this
|