c1_lua/lua/app/ui/hero/cell/star_cell.lua
2025-05-28 00:19:06 +08:00

40 lines
1.1 KiB
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 <= idx then
v:setActive(true)
else
v:setActive(false)
end
end
if idx <= star then
self.baseObject:setSprite(GConst.ATLAS_PATH.COMMON, "common_board_quality_3")
else
self.baseObject:setSprite(GConst.ATLAS_PATH.COMMON, "common_board_quality_2")
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