39 lines
1.2 KiB
Lua
39 lines
1.2 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) and not table.containValue(GConst.MATCH_ALL_HPP_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 |