c1_lua/lua/app/ui/talent/cell/talent_cell.lua
2025-08-28 19:39:12 +08:00

38 lines
1.1 KiB
Lua

local TalentCell = class("TalentCell", BaseCell)
function TalentCell:init()
local uiMap = self:getUIMap()
self.animator = self.baseObject:getComponent(GConst.TYPEOF_UNITY_CLASS.ANIMATOR)
self.bg1 = uiMap["talent_cell.bg1"]
self.bg = uiMap["talent_cell.bg"]
self.descTx1 = uiMap["talent_cell.desc_tx_1"]
self.descTx2 = uiMap["talent_cell.desc_tx_2"]
self.animator.enabled = false
self.baseObject:addClickListener(function()
local parmas = {}
parmas.id = self.idx
ModuleManager.TalentManager:showInfoUI(parmas)
end)
end
function TalentCell:refresh(idx, cfg, showAni)
self.idx = idx
local cfg = DataManager.TalentData:getCfgList()[idx]
self.bg1:setSprite(GConst.ATLAS_PATH.ICON_TALENT, "talent_b_" .. cfg.qlt)
self.bg:setSprite(GConst.ATLAS_PATH.ICON_TALENT, "talent_" .. idx)
self.descTx1:setText(I18N:getText("talent", idx, "name"))
local lv = DataManager.TalentData:getLevels(idx)
self.descTx2:setText("Lv." .. lv)
if showAni then
self.animator.enabled = true
self.animator:SetTrigger("t_open")
end
end
function TalentCell:setActive(active)
self.baseObject:setActive(active)
end
return TalentCell