c1_lua/lua/app/ui/battle/cell/grid_cell.lua
2023-04-07 15:31:27 +08:00

35 lines
1.4 KiB
Lua

local GridCell = class("GridCell", BaseCell)
function GridCell:refresh(gridEntity, curElement)
local uiMap = self:getUIMap()
local elementType = gridEntity:getElementType()
if self.lastElementType ~= elementType then
self.lastElementType = elementType
local atlas, icon = ModuleManager.BattleManager:getElementIcon(elementType)
uiMap["grid_cell.touch_node.ani_node.middle_bg"]:setSprite(atlas, icon)
end
local showMask = false
if curElement and (curElement ~= elementType or not gridEntity:canLink()) then
showMask = true
end
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
--- 测试代码
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
return GridCell