35 lines
925 B
Lua
35 lines
925 B
Lua
local StarCell = class("StarCell", BaseCell)
|
|
|
|
function StarCell:init()
|
|
local uiMap = self:getUIMap()
|
|
self.starBg = uiMap["cell.star_bg"]
|
|
self.descTx = uiMap["cell.desc_tx"]
|
|
self.starImgs = {}
|
|
for i = 1, 5 do
|
|
self.starImgs[i] = uiMap["cell.star_bg.star_img_" .. i]
|
|
end
|
|
|
|
-- self:addClickListener(function()
|
|
-- EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.SKIN_SELECT, self.skinId)
|
|
-- end)
|
|
end
|
|
|
|
function StarCell:refresh(heroEntity, idx)
|
|
self.heroEntity = heroEntity
|
|
if not self.heroEntity then
|
|
return
|
|
end
|
|
|
|
local star = self.heroEntity:getStar()
|
|
for i, v in ipairs(self.starImgs) do
|
|
if i <= star then
|
|
v:setActive(true)
|
|
else
|
|
v:setActive(false)
|
|
end
|
|
end
|
|
self.starBg:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_HORIZONTAL_OR_VERTICAL_LAYOUT):RefreshLayout()
|
|
self.descTx:setText(I18N:getGlobalText(I18N.GlobalConst["HERO_STAR_DESC_" .. idx]) .. self.heroEntity:getCfgId())
|
|
end
|
|
|
|
return StarCell |