74 lines
2.9 KiB
Lua
74 lines
2.9 KiB
Lua
local GridCell = class("GridCell", BaseCell)
|
|
|
|
function GridCell:refresh(gridEntity, curElement)
|
|
local uiMap = self:getUIMap()
|
|
local elementType = gridEntity:getElementType()
|
|
local elementIcon = uiMap["grid_cell.touch_node.ani_node.middle_bg"]
|
|
local highLightIcon = uiMap["grid_cell.touch_node.ani_node.middle_bg.high_light_icon"]
|
|
if self.lastElementType ~= elementType then
|
|
self.lastElementType = elementType
|
|
local atlas, icon = ModuleManager.BattleManager:getElementIcon(elementType)
|
|
elementIcon:setSprite(atlas, icon)
|
|
highLightIcon:setSprite(atlas, icon .. "_1")
|
|
end
|
|
elementIcon:setVisible(true)
|
|
|
|
local showMask = false
|
|
if curElement and (curElement ~= elementType or not gridEntity:canLink()) then
|
|
showMask = true
|
|
end
|
|
self.curElement = curElement
|
|
uiMap["grid_cell.touch_node.ani_node.mask"]:setVisible(showMask)
|
|
|
|
uiMap["grid_cell.touch_node.ani_node.obstacle"]:setVisible(gridEntity:isObstacleType())
|
|
|
|
if self.lastGridType ~= gridEntity:getGridType() then
|
|
self.lastGridType = gridEntity:getGridType()
|
|
local atlas, icon = ModuleManager.BattleManager:getGridTypeIcon(self.lastGridType)
|
|
uiMap["grid_cell.touch_node.ani_node.up_bg"]:setSprite(atlas, icon)
|
|
end
|
|
|
|
local skillIcon = uiMap["grid_cell.touch_node.ani_node.skill_icon"]
|
|
local skillHighLightIcon = uiMap["grid_cell.touch_node.ani_node.skill_icon.high_light_icon"]
|
|
local skillId = gridEntity:getSkillId()
|
|
if skillId then
|
|
elementIcon:setVisible(false)
|
|
skillIcon:setVisible(true)
|
|
|
|
if self.lastSkillId ~= skillId then
|
|
self.lastSkillId = skillId
|
|
local cfg = ModuleManager.BattleManager.SKILL_HERO_CFG[skillId]
|
|
if cfg then
|
|
skillIcon:setSprite(GConst.ATLAS_PATH.ICON_SKILL, tostring(cfg.battle_icon))
|
|
skillHighLightIcon:setSprite(GConst.ATLAS_PATH.ICON_SKILL, tostring(cfg.battle_icon) .. "_1")
|
|
end
|
|
end
|
|
else
|
|
skillIcon:setVisible(false)
|
|
end
|
|
|
|
self:showCircle(false)
|
|
self:showHighLight(false)
|
|
--- 测试代码
|
|
uiMap["grid_cell.touch_node.ani_node.count"]:setText(gridEntity:getAroundEliminationCount())
|
|
end
|
|
|
|
function GridCell:addTouchListener(func)
|
|
local uiMap = self:getUIMap()
|
|
uiMap["grid_cell.touch_node"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_ELIMINATION_TOUCH_EVENT):AddTouchEventListener(func)
|
|
end
|
|
|
|
function GridCell:showCircle(show)
|
|
local uiMap = self:getUIMap()
|
|
uiMap["grid_cell.touch_node.ani_node.circle"]:setVisible(show)
|
|
end
|
|
|
|
function GridCell:showHighLight(show)
|
|
local uiMap = self:getUIMap()
|
|
local highLightIcon = uiMap["grid_cell.touch_node.ani_node.middle_bg.high_light_icon"]
|
|
local skillHighLightIcon = uiMap["grid_cell.touch_node.ani_node.skill_icon.high_light_icon"]
|
|
highLightIcon:setVisible(show)
|
|
skillHighLightIcon:setVisible(show)
|
|
end
|
|
|
|
return GridCell |