c1_lua/lua/app/ui/battle/cell/skill_node_cell.lua
2023-04-14 22:19:22 +08:00

31 lines
1.3 KiB
Lua

local SkillNodeCell = class("SkillNodeCell", BaseCell)
function SkillNodeCell:refresh(skillEntity, elementMap)
local elementType = skillEntity:getPosition()
local add = 0
if elementMap and elementMap[elementType] then
add = elementMap[elementType]
end
local uiMap = self:getUIMap()
if not self.imgComp then
self.imgComp = uiMap["skill_node_cell.energy_bg"]:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_IMAGE)
end
local curEnergy = skillEntity:getEnergy() + add
local needEnergy = skillEntity:getNeedEnergy()
self.imgComp.fillAmount = curEnergy / needEnergy
if self.lastSkillIcon ~= skillEntity:getBattleIcon() then
self.lastSkillIcon = skillEntity:getBattleIcon()
uiMap["skill_node_cell.skill_icon"]:setSprite(GConst.ATLAS_PATH.ICON_SKILL, self.lastSkillIcon)
end
if self.lastNeedEnergy ~= needEnergy then
self.lastNeedEnergy = needEnergy
uiMap["skill_node_cell.mask"]:setSprite(GConst.ATLAS_PATH.BATTLE, "battle_skill_line_" .. needEnergy)
end
if self.lastElementType ~= elementType then
self.lastElementType = elementType
uiMap["skill_node_cell.match_bg"]:setSprite(GConst.ATLAS_PATH.BATTLE, GConst.BattleConst.SKILL_ELEMENT_BG[elementType])
end
end
return SkillNodeCell