66 lines
2.3 KiB
Lua
66 lines
2.3 KiB
Lua
local SkillNodeCell = class("SkillNodeCell", BaseCell)
|
|
|
|
function SkillNodeCell:refresh(skillEntity, elementMap, showSfx)
|
|
local elementType = skillEntity:getPosition()
|
|
local add = 0
|
|
if elementMap and elementMap[elementType] then
|
|
add = elementMap[elementType]
|
|
end
|
|
|
|
local uiMap = self:getUIMap()
|
|
local mask2 = uiMap["skill_node_cell.icon_node.mask_2"]
|
|
if showSfx and add <= 0 then
|
|
mask2:setVisible(true)
|
|
else
|
|
mask2:setVisible(false)
|
|
end
|
|
local iconNode = uiMap["skill_node_cell.icon_node"]
|
|
if not skillEntity:getUnlocked() then
|
|
iconNode:setVisible(false)
|
|
return
|
|
else
|
|
iconNode:setVisible(true)
|
|
end
|
|
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()
|
|
local value = curEnergy / needEnergy
|
|
self.imgComp.fillAmount = value
|
|
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
|
|
|
|
local effect = uiMap["skill_node_cell.icon_node.vfx_ui_battle_skill_full_b01"]
|
|
if not self.lastValue then
|
|
self.lastValue = 0
|
|
end
|
|
if add > 0 and value == 1 and showSfx and self.lastValue < value then
|
|
effect:setVisible(true)
|
|
effect:stopAndClear()
|
|
effect:play()
|
|
else
|
|
if not showSfx then
|
|
effect:setVisible(false)
|
|
end
|
|
end
|
|
self.lastValue = value
|
|
end
|
|
|
|
function SkillNodeCell:addClickListener(func)
|
|
local uiMap = self:getUIMap()
|
|
local iconNode = uiMap["skill_node_cell.icon_node"]
|
|
iconNode:addClickListener(func)
|
|
end
|
|
|
|
return SkillNodeCell |