c1_lua/lua/app/ui/hero/cell/attr_node_cell.lua
2023-09-12 10:35:46 +08:00

55 lines
2.0 KiB
Lua

local AttrNodeCell = class("AttrNodeCell", BaseCell)
local ATTR_CELL = "app/ui/hero/cell/attr_cell"
local ATTR_CELL_PATH = "assets/prefabs/ui/hero/cell/attr_cell.prefab"
function AttrNodeCell:init()
local uiMap = self:getUIMap()
self.txTitle = uiMap["total_node.tx_title"]
self.itemsRoot = uiMap["total_node.items"]
end
function AttrNodeCell:refresh(heroEntity, node)
if node == GConst.HeroConst.ATTR_SHOW_TOTAL then
self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_13))
elseif node == GConst.HeroConst.ATTR_SHOW_BASE then
self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_14))
elseif node == GConst.HeroConst.ATTR_SHOW_WEAPON then
self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_15))
elseif node == GConst.HeroConst.ATTR_SHOW_ARMOR then
self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_16))
elseif node == GConst.HeroConst.ATTR_SHOW_SKIN then
self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_17))
elseif node == GConst.HeroConst.ATTR_SHOW_RUNES then
self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.RUNES_DESC_22))
end
self.attrCount = 0
for index, attr in ipairs(node) do
if self:isShowAttr(heroEntity, node, attr) then
self.attrCount = self.attrCount + 1
CellManager:loadCellAsync(ATTR_CELL_PATH, ATTR_CELL, self.itemsRoot, function(cell)
cell:refresh(heroEntity, node, attr)
end)
end
end
end
-- 是否显示属性项
function AttrNodeCell:isShowAttr(heroEntity, node, attr)
if node == GConst.HeroConst.ATTR_SHOW_SKIN then
return DataManager.SkinData:hasAttr(heroEntity, attr[heroEntity:getMatchType()])
end
if node == GConst.HeroConst.ATTR_SHOW_RUNES then
return heroEntity:getRunes():hasAttr(attr[heroEntity:getMatchType()])
end
return true
end
--获取节点显示属性个数
function AttrNodeCell:getShowAttrCount()
return self.attrCount
end
return AttrNodeCell