c1_lua/lua/app/ui/hero/cell/attr_node_cell.lua
2023-08-15 12:20:17 +08:00

41 lines
1.6 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))
end
self.attrCount = 0
for index, attr in ipairs(node) do
if node ~= GConst.HeroConst.ATTR_SHOW_SKIN or DataManager.SkinData:hasAttr(heroEntity, attr[heroEntity:getMatchType()]) 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:getShowAttrCount()
return self.attrCount
end
return AttrNodeCell