c1_lua/lua/app/ui/common/cell/hero_cell.lua
2023-04-11 18:23:25 +08:00

47 lines
1.3 KiB
Lua

local HeroCell = class("HeroCell", BaseCell)
function HeroCell:init()
local uiMap = self.baseObject:genAllChildren()
self.icon = uiMap["hero_cell.hero_bg.icon"]
self.heroBg = uiMap["hero_cell.hero_bg"]
self.check = uiMap["hero_cell.hero_bg.mask"]
self.matchImg = uiMap["hero_cell.hero_bg.match_img"]
self.isGray = false
end
function HeroCell:refresh(heroEntity, isGray)
local heroInfo = heroEntity:getConfig()
self:_refresh(heroInfo, isGray)
end
function HeroCell:refreshWithCfgId(id, isGray)
local heroInfo = ConfigManager:getConfig("hero")[id]
self:_refresh(heroInfo, isGray)
end
function HeroCell:_refresh(heroInfo, isGray)
if isGray then
self.heroBg:setSprite(GConst.ATLAS_PATH.ICON_HERO, GConst.HERO_FRAME_GRAY_QLT[heroInfo.qlt])
else
self.heroBg:setSprite(GConst.ATLAS_PATH.ICON_HERO, GConst.HERO_FRAME_QLT[heroInfo.qlt])
end
self.icon:setSprite(GConst.ATLAS_PATH.ICON_HERO, tostring(heroInfo.icon))
self.matchImg:setSprite(GConst.ATLAS_PATH.ICON_HERO, GConst.HeroConst.MATCH_ICON_NAME[heroInfo.position])
self.check:setVisible(false)
self:setGray(isGray)
end
function HeroCell:setVisible(visible)
self.baseObject:setVisible(visible)
end
function HeroCell:setGray(isGray)
if self.isGray == isGray then
return
end
self.icon:setImageGray(isGray)
self.matchImg:setImageGray(isGray)
end
return HeroCell