diff --git a/lua/app/module/battle/battle_const.lua b/lua/app/module/battle/battle_const.lua index c43917d0..9db3ddd0 100644 --- a/lua/app/module/battle/battle_const.lua +++ b/lua/app/module/battle/battle_const.lua @@ -255,6 +255,7 @@ local BUFF_NAME = { COUNTER_ATTACK = "counterattack", SKILL_HURT_ADD = "skill_hurt_add", DEATH_SUMMON = "death_summon", + LOCK = "lock", } BattleConst.BUFF_NAME = BUFF_NAME diff --git a/lua/app/module/battle/controller/battle_controller.lua b/lua/app/module/battle/controller/battle_controller.lua index 62e685e1..741f4c4f 100644 --- a/lua/app/module/battle/controller/battle_controller.lua +++ b/lua/app/module/battle/controller/battle_controller.lua @@ -1389,6 +1389,73 @@ function BattleController:generateGridType(skillTypeParameter, monsterPos) end end +function BattleController:lockElement(lcokElementType, isUnlock) + local elementTypeMap = {} + local list + local lockElementMap + local locked = false + for posId, entity in pairs(self.battleData:getGridEnties()) do + local elementType = entity:getElementType() + if not isUnlock then + if entity:isEmptyIdle() then + if not elementTypeMap[elementType] then + elementTypeMap[elementType] = {} + if not isUnlock then + if not list then + list = {} + end + table.insert(list, elementType) + end + end + + table.insert(elementTypeMap[elementType], posId) + end + if entity:isLock() then + locked = true + end + else + if entity:isLock() then + if not lockElementMap then + lockElementMap = {} + end + if not lockElementMap[elementType] then + lockElementMap[elementType] = {} + end + table.insert(lockElementMap[elementType], posId) + end + end + end + + if isUnlock then + if lockElementMap then + for elementType, list in pairs(lockElementMap) do + self.battleData:cacheLockElement(elementType, nil) + for _, posId in ipairs(list) do + self.battleData:setGridType(posId, BattleConst.GRID_TYPE.EMPTY) + end + end + end + else + if locked then -- 锁定过就不新锁了 + return + end + local elementType = lcokElementType + if elementType == BattleConst.ELEMENT_TYPE.NONE then + if not list or not list[1] then + return + end + elementType = list[math.random(1, #list)] + end + self.battleData:cacheLockElement(elementType, true) + local list = elementTypeMap[elementType] + if list then + for _, posId in ipairs(list) do + self.battleData:setGridType(posId, BattleConst.GRID_TYPE.LOCK) + end + end + end +end + function BattleController:getSkillElementList(elementType, count, useAlternate, excludeMap) local result = {} local gridEntities = self.battleData:getGridEnties() diff --git a/lua/app/module/battle/helper/battle_buff_special.lua b/lua/app/module/battle/helper/battle_buff_special.lua index 2aa6940e..43232ce5 100644 --- a/lua/app/module/battle/helper/battle_buff_special.lua +++ b/lua/app/module/battle/helper/battle_buff_special.lua @@ -82,6 +82,17 @@ local function _frozenOff(buffSender, target, buff, buffEffect) return 1 end +local function _lockOn(buffSender, buff, target, buffEffect) + target.battleController:lockElement(buff:getEffectNum(), false) + return 1 +end + +local function _lockOff(buffSender, target, buff, buffEffect) + target.battleController:lockElement(buff:getEffectNum(), true) + return 1 +end + + local _handleOn = { [BUFF_NAME.ADD_SKILL] = _addSkillOn, -- 添加技能 [BUFF_NAME.SKILL_FIRE_TIMES] = _skillFireTimesOn, -- 技能额外使用次数 @@ -89,6 +100,7 @@ local _handleOn = { [BUFF_NAME.UNDEAD] = _undeadOn, -- 不死 [BUFF_NAME.IMPRISON] = _imprisonOn, -- 禁锢 [BUFF_NAME.FROZEN] = _frozenOn, -- 冻结 + [BUFF_NAME.LOCK] = _lockOn, -- 锁定 } local _handleOff = { @@ -98,6 +110,7 @@ local _handleOff = { [BUFF_NAME.UNDEAD] = _undeadOff, -- 不死 [BUFF_NAME.IMPRISON] = _imprisonOff, -- 禁锢 [BUFF_NAME.FROZEN] = _frozenOff, -- 冻结 + [BUFF_NAME.LOCK] = _lockOff, -- 锁定 } local _handleWork = { diff --git a/lua/app/userdata/battle/battle_data.lua b/lua/app/userdata/battle/battle_data.lua index 2b37da9f..bcc6c4bb 100644 --- a/lua/app/userdata/battle/battle_data.lua +++ b/lua/app/userdata/battle/battle_data.lua @@ -23,6 +23,7 @@ function BattleData:init() self.needBattleExp = self:getLvNeedExp() self.addLvCount = 0 self.timeScale = BattleConst.TIME_SCALE.LEVEL_1 + self.lockElementMap = {} self.data.timeSpeed = 1 self.data.lvDirty = false BattleSkillEntity.sid = 0 @@ -330,6 +331,15 @@ function BattleData:setInfoBySnapshop(posId, snapInfo) entity:setInfoBySnapshop(snapInfo) end +function BattleData:setGridType(posId, gridType) + local entity = self.gridEntities[posId] + if not entity then + return + end + entity:setGridType(gridType) + entity:determineIdleStatus() +end + function BattleData:getSkillEntities() return self.skillMap end @@ -416,6 +426,14 @@ function BattleData:changeSkillId(elementType, newId) end end +function BattleData:cacheLockElement(elementType, status) + self.lockElementMap[elementType] = status +end + +function BattleData:getCacheLockedElement(elementType) + return self.lockElementMap[elementType] +end + function BattleData:cacheBoardSkill() self.cacheSkillList = {} self.cacheSkillCount = 0 diff --git a/lua/app/userdata/battle/battle_grid_entity.lua b/lua/app/userdata/battle/battle_grid_entity.lua index 3cb5a1e2..5f4ebffa 100644 --- a/lua/app/userdata/battle/battle_grid_entity.lua +++ b/lua/app/userdata/battle/battle_grid_entity.lua @@ -214,6 +214,9 @@ end function BattleGridEntity:setElementType(elementType) self.elementType = elementType + if DataManager.BattleData:getCacheLockedElement(self.elementType) then + self:setGridType(BattleConst.GRID_TYPE.LOCK) + end self:setDirty() end