113 lines
2.8 KiB
Lua
113 lines
2.8 KiB
Lua
local BattleGridEntity = class("BattleGridEntity", BaseData)
|
|
local BattleConst = GConst.BattleConst
|
|
|
|
function BattleGridEntity:ctor(data)
|
|
self.posId = data.posId or 0
|
|
self.gridType = data.gridType or BattleConst.GRID_TYPE.EMPTY
|
|
self.elementType = data.elementType or BattleConst.ELEMENT_TYPE.RED
|
|
self.aroundEliminationCount = data.aroundEliminationCount or 0 -- 周围消除次数
|
|
self.isIdle = false
|
|
self.data.isDirty = false
|
|
end
|
|
|
|
function BattleGridEntity:setDirty()
|
|
self.data.isDirty = not self.data.isDirty
|
|
end
|
|
|
|
function BattleGridEntity:getPosId()
|
|
return self.posId
|
|
end
|
|
|
|
function BattleGridEntity:setPosId(posId)
|
|
self.posId = posId
|
|
end
|
|
|
|
function BattleGridEntity:getGridType()
|
|
return self.gridType
|
|
end
|
|
|
|
function BattleGridEntity:getElementType()
|
|
return self.elementType
|
|
end
|
|
|
|
function BattleGridEntity:isCantFallType()
|
|
return BattleConst.CANT_FALL_GRID_TYPE[self.gridType] or false
|
|
end
|
|
|
|
function BattleGridEntity:isObstacleType()
|
|
return self.gridType == BattleConst.GRID_TYPE.OBSTACLE
|
|
end
|
|
|
|
function BattleGridEntity:getAroundEliminationCount()
|
|
return self.aroundEliminationCount
|
|
end
|
|
|
|
function BattleGridEntity:addAroundEliminationCount(count)
|
|
count = count or 1
|
|
self.aroundEliminationCount = self.aroundEliminationCount + count
|
|
local gridTypeList = BattleConst.AROUND_ELIMINATION_TO_TYPE_COUNT[self.gridType]
|
|
if gridTypeList and gridTypeList[self.aroundEliminationCount] then
|
|
local gridType = gridTypeList[self.aroundEliminationCount]
|
|
self:setGridType(gridType)
|
|
if gridType == BattleConst.GRID_TYPE.EMPTY then
|
|
self:setIsIdle(true)
|
|
end
|
|
end
|
|
self:setDirty()
|
|
end
|
|
|
|
function BattleGridEntity:getPos()
|
|
return ModuleManager.BattleManager:getPosInfo(self.posId)
|
|
end
|
|
|
|
function BattleGridEntity:setCell(cell)
|
|
self.gridCell = cell
|
|
end
|
|
|
|
function BattleGridEntity:getCell()
|
|
return self.gridCell
|
|
end
|
|
|
|
function BattleGridEntity:getIsIdle()
|
|
return self.isIdle
|
|
end
|
|
|
|
function BattleGridEntity:setIsIdle(isIdle)
|
|
self.isIdle = isIdle == true
|
|
if self.isIdle then
|
|
self.aroundEliminationCount = 0
|
|
end
|
|
end
|
|
|
|
function BattleGridEntity:canLink()
|
|
return not BattleConst.CANT_LINK_GRID_TYPE[self.gridType]
|
|
end
|
|
|
|
function BattleGridEntity:addPath(singlePath)
|
|
self:getPath()
|
|
table.insert(self.pathList, singlePath)
|
|
end
|
|
|
|
function BattleGridEntity:getPath()
|
|
if not self.pathList then
|
|
self.pathList = {}
|
|
end
|
|
return self.pathList
|
|
end
|
|
|
|
function BattleGridEntity:clearPath()
|
|
self.pathList = {}
|
|
end
|
|
|
|
function BattleGridEntity:setGridType(gridType)
|
|
self.gridType = gridType
|
|
self.aroundEliminationCount = 0
|
|
self:setDirty()
|
|
end
|
|
|
|
function BattleGridEntity:setElementType(elementType)
|
|
self.elementType = elementType
|
|
self:setDirty()
|
|
end
|
|
|
|
return BattleGridEntity |