c1_lua/lua/app/ui/hero/cell/lv_cell.lua
2025-10-14 19:14:34 +08:00

39 lines
1.1 KiB
Lua

local StarCell = class("StarCell", BaseCell)
function StarCell:init()
local uiMap = self:getUIMap()
self.lvTx = uiMap["cell.lv_tx"]
self.descTx = uiMap["cell.desc_tx"]
self.lockImg = uiMap["cell.lock_img"]
end
function StarCell:refresh(heroEntity, idx)
self.heroEntity = heroEntity
if not self.heroEntity then
return
end
local lv = self.heroEntity:getLv()
local lvPoint = self.heroEntity:getLvAttrPointList()[idx]
if lvPoint <= lv then
self.baseObject:setSprite(GConst.ATLAS_PATH.COMMON, "common_bg_7")
else
self.baseObject:setSprite(GConst.ATLAS_PATH.COMMON, "common_bg_8")
end
self.lockImg:setActive(lvPoint > lv)
self.lvTx:setText(I18N:getGlobalText(I18N.GlobalConst.LV_POINT) .. lvPoint)
local attr = heroEntity:getLvAttrCfg(idx)
local attrIdx = GFunc.getAttrIdByName(attr.type)
local attrNum = GFunc.getFinalAttrValue(attr.type, attr.num)
local descTx = ""
if not table.containValue(GConst.MATCH_ALL_ATKP_NAME, attr.type) then
descTx = I18N:getText("attr", attrIdx, "desc", heroEntity:getName(), attrNum)
else
descTx = I18N:getText("attr", attrIdx, "desc", attrNum)
end
self.descTx:setText(descTx)
end
return StarCell