c1_lua/lua/app/ui/battle/cell/grid_cell.lua
xiekaidong 76ace3a065 棋盘
2023-04-07 11:24:27 +08:00

23 lines
935 B
Lua

local GridCell = class("GridCell", BaseCell)
function GridCell:refresh(gridEntity, curElement)
local atlas, icon = ModuleManager.BattleManager:getElementIcon(gridEntity:getElementType())
local uiMap = self:getUIMap()
if self.lastIcon ~= icon then
self.lastIcon = icon
uiMap["grid_cell.touch_node.ani_node.middle_bg"]:setSprite(atlas, icon)
end
uiMap["grid_cell.touch_node.ani_node.mask"]:setVisible(curElement and curElement ~= gridEntity:getElementType())
uiMap["grid_cell.touch_node.ani_node.obstacle"]:setVisible(gridEntity:isCantFallType())
--- 测试代码
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