c1_lua/lua/app/userdata/battle/battle_grid_entity.lua
2023-04-06 18:32:04 +08:00

88 lines
1.9 KiB
Lua

local BattleGridEntity = class("BattleGridEntity", BaseData)
function BattleGridEntity:ctor(data)
self.posId = data.posId or 0
self.gridType = data.gridType or GConst.BattleConst.GRID_TYPE.EMPTY
self.elementType = data.elementType or GConst.BattleConst.ELEMENT_TYPE.RED
self.eliminationCount = data.eliminationCount or 0 -- 周围消除次数
self.isIdle = false
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 self.gridType == GConst.BattleConst.GRID_TYPE.OBSTACLE
end
function BattleGridEntity:getEliminationCount()
return self.eliminationCount
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
end
function BattleGridEntity:canLink()
if self:isCantFallType() then
return false
end
-- 其他类型的一些判定
return true
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
end
function BattleGridEntity:setElementType(elementType)
self.elementType = elementType
end
return BattleGridEntity