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 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 --- 测试代码 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