diff --git a/lua/app/config/skill_hero.lua b/lua/app/config/skill_hero.lua index 505206f6..1adfcb3c 100644 --- a/lua/app/config/skill_hero.lua +++ b/lua/app/config/skill_hero.lua @@ -1,6 +1,6 @@ local skill_hero = { [10]={ - ["energy"]=10, + ["energy"]=3, ["position"]=3, ["method"]=2, ["skill_type"]=1, @@ -14,10 +14,11 @@ local skill_hero = { ["range"]=1 } }, - ["icon"]=10 + ["icon"]=10, + ["battle_icon"]=1 }, [20]={ - ["energy"]=10, + ["energy"]=3, ["position"]=2, ["method"]=2, ["skill_type"]=0, @@ -30,12 +31,13 @@ local skill_hero = { } }, ["obj"]=2, - ["icon"]=20 + ["icon"]=20, + ["battle_icon"]=2 }, [21]={ - ["energy"]=10, + ["energy"]=3, ["position"]=2, - ["method"]=2, + ["method"]=1, ["skill_type"]=2, ["skill_type_parameter"]=2, ["boardrange"]={ @@ -64,10 +66,11 @@ local skill_hero = { ["round"]=0 } }, - ["icon"]=20 + ["icon"]=20, + ["battle_icon"]=2 }, [30]={ - ["energy"]=10, + ["energy"]=3, ["position"]=4, ["method"]=2, ["skill_type"]=1, @@ -77,10 +80,11 @@ local skill_hero = { ["range"]=2 } }, - ["icon"]=30 + ["icon"]=30, + ["battle_icon"]=3 }, [40]={ - ["energy"]=10, + ["energy"]=3, ["position"]=5, ["method"]=2, ["skill_type"]=0, @@ -93,10 +97,11 @@ local skill_hero = { } }, ["obj"]=1, - ["icon"]=40 + ["icon"]=40, + ["battle_icon"]=4 }, [50]={ - ["energy"]=10, + ["energy"]=3, ["position"]=1, ["method"]=2, ["skill_type"]=1, @@ -110,10 +115,11 @@ local skill_hero = { ["range"]=2 } }, - ["icon"]=50 + ["icon"]=50, + ["battle_icon"]=5 }, [60]={ - ["energy"]=10, + ["energy"]=3, ["position"]=3, ["method"]=2, ["skill_type"]=0, @@ -126,10 +132,11 @@ local skill_hero = { } }, ["obj"]=1, - ["icon"]=60 + ["icon"]=60, + ["battle_icon"]=6 }, [70]={ - ["energy"]=10, + ["energy"]=3, ["position"]=2, ["method"]=2, ["skill_type"]=0, @@ -142,10 +149,11 @@ local skill_hero = { } }, ["obj"]=1, - ["icon"]=70 + ["icon"]=70, + ["battle_icon"]=7 }, [71]={ - ["energy"]=10, + ["energy"]=3, ["position"]=2, ["method"]=1, ["skill_type"]=2, @@ -177,10 +185,11 @@ local skill_hero = { } }, ["obj"]=1, - ["icon"]=70 + ["icon"]=70, + ["battle_icon"]=7 }, [72]={ - ["energy"]=10, + ["energy"]=3, ["position"]=2, ["method"]=1, ["skill_type"]=2, @@ -219,10 +228,11 @@ local skill_hero = { ["range"]=1 } }, - ["icon"]=70 + ["icon"]=70, + ["battle_icon"]=7 }, [80]={ - ["energy"]=10, + ["energy"]=3, ["position"]=4, ["method"]=2, ["skill_type"]=0, @@ -240,10 +250,11 @@ local skill_hero = { ["round"]=1 } }, - ["icon"]=80 + ["icon"]=80, + ["battle_icon"]=8 }, [81]={ - ["energy"]=10, + ["energy"]=3, ["position"]=4, ["method"]=2, ["skill_type"]=1, @@ -279,7 +290,8 @@ local skill_hero = { ["round"]=1 } }, - ["icon"]=80 + ["icon"]=80, + ["battle_icon"]=8 } } local config = { diff --git a/lua/app/global/global_const.lua b/lua/app/global/global_const.lua index 0b01624c..e19e1ff3 100644 --- a/lua/app/global/global_const.lua +++ b/lua/app/global/global_const.lua @@ -168,6 +168,7 @@ GConst.ATLAS_PATH = { BATTLE = "assets/arts/atlas/ui/battle.asset", ICON_ITEM = "assets/arts/atlas/icon/item.asset", UI_LOGIN = "assets/arts/atlas/ui/login.asset", + ICON_SKILL = "assets/arts/atlas/icon/skill.asset", } GConst.TOUCH_EVENT = { diff --git a/lua/app/module/battle/battle_const.lua b/lua/app/module/battle/battle_const.lua index 48b5702b..d2f92e8a 100644 --- a/lua/app/module/battle/battle_const.lua +++ b/lua/app/module/battle/battle_const.lua @@ -252,4 +252,9 @@ BattleConst.SKILL_TYPE = { CHANGE_AROUND = 2, } +BattleConst.SKILL_METHOD_TYPE = { + ON_ENTER = 1, + ON_FINAL = 2, +} + return BattleConst \ No newline at end of file diff --git a/lua/app/module/battle/battle_manager.lua b/lua/app/module/battle/battle_manager.lua index d195f061..5c755b36 100644 --- a/lua/app/module/battle/battle_manager.lua +++ b/lua/app/module/battle/battle_manager.lua @@ -2,6 +2,8 @@ local BattleManager = class("BattleManager", BaseModule) local BattleConst = GConst.BattleConst +BattleManager.SKILL_HERO_CFG = ConfigManager:getConfig("skill_hero") + local BATTLE_CONTROLLER_BASE = "app/module/battle/controller/battle_controller" local BATTLE_CONTROLLER = { diff --git a/lua/app/module/battle/controller/battle_controller.lua b/lua/app/module/battle/controller/battle_controller.lua index 42820502..01b66cc1 100644 --- a/lua/app/module/battle/controller/battle_controller.lua +++ b/lua/app/module/battle/controller/battle_controller.lua @@ -1,5 +1,7 @@ local BattleController = class("BattleController") +local BATTLE_BOARD_SKILL_HANDLE = require "app/module/battle/skill/battle_board_skill_handle" + local ELIMINATION_TOUCH_EVENT = GConst.ELIMINATION_TOUCH_EVENT local BattleConst = GConst.BattleConst @@ -26,20 +28,33 @@ function BattleController:initOther() end function BattleController:onLinkChange() + for posId, entity in pairs(DataManager.BattleData:getGridEnties()) do + if entity:getCell() then + entity:getCell():showHighLight(false) + end + end + local sequence = DataManager.BattleData:getGridSequence() local elementTypeMap = {} for _, info in ipairs(sequence) do local entity = DataManager.BattleData:getGridEntity(info.posId) + if not entity:getSkillId() then local elementType = entity:getElementType() elementTypeMap[elementType] = (elementTypeMap[elementType] or 0) + 1 end + + if entity:getCell() then + entity:getCell():showHighLight(true) + end end + + self.battleUI:refreshSkill(elementTypeMap) Logger.logHighlight("---------onLinkChange--------------") Logger.printTable(elementTypeMap) end --- *************各个子模块的战斗需要重写的方法 START************* +-- *************各个子模块的战斗需要重写的方法 END************* function BattleController:ctor() @@ -68,8 +83,8 @@ function BattleController:onTouchEvent(eventType, posId) end DataManager.BattleData:insertGridSequence(posId, self:snapshotBoard()) self.battleUI:showBoardMask(entity:getElementType()) - self:onLinkChange() self:findSkillInfluenceGrids() + self:onLinkChange() elseif eventType == ELIMINATION_TOUCH_EVENT.ENTER then local sequence = DataManager.BattleData:getGridSequence() local info = sequence[#sequence] @@ -106,8 +121,8 @@ function BattleController:onTouchEvent(eventType, posId) end else DataManager.BattleData:insertGridSequence(posId, self:snapshotBoard()) - self:onLinkChange() self:findSkillInfluenceGrids() + self:onLinkChange() end elseif eventType == ELIMINATION_TOUCH_EVENT.EXIT then @@ -127,14 +142,23 @@ function BattleController:onTouchEvent(eventType, posId) end DataManager.BattleData:clearGridSequence() + self:onLinkChange() return end local cellList = {} + local elementTypeMap = {} for _, info in ipairs(sequence) do local entity = DataManager.BattleData:getGridEntity(info.posId) table.insert(cellList, entity:getCell()) + if not entity:getSkillId() then + local elementType = entity:getElementType() + elementTypeMap[elementType] = (elementTypeMap[elementType] or 0) + 1 + end end + + DataManager.BattleData:addSkillEnergy(elementTypeMap) + self.battleUI:disableUITouch() self.battleUI:eliminationAni(cellList, function() self:onEliminationAniOver() @@ -216,10 +240,36 @@ function BattleController:fillBoard() end self.battleUI:fallGrid(pathMap, function() + self:onFillBoardOver() self.battleUI:enableUITouch() end) end +function BattleController:onFillBoardOver() + local map = {} + for _, skillEntity in pairs(DataManager.BattleData:getSkillEntities()) do + if skillEntity:getEnergyEnough() then + map[skillEntity:getPosition()] = skillEntity:getSkillId() + end + end + + Logger.logHighlight("------onFillBoardOver-------") + Logger.printTable(map) + for elementType, skillId in pairs(map) do + local list = DataManager.BattleData:getSameElementList(elementType, 1, true) + Logger.printTable(list) + for _, posId in ipairs(list) do + local entity = DataManager.BattleData:getGridEntity(posId) + if entity then + entity:setSkilId(skillId) + if entity:getElementType() ~= elementType then + entity:setElementType(elementType) + end + end + end + end +end + ---- 从一个点直接遍历所有相关的路径 function BattleController:fillThisPos(posId, columnCount) local entity = DataManager.BattleData:getGridEntity(posId) @@ -322,37 +372,9 @@ function BattleController:findSkillInfluenceGrids(isFinal) local entity = DataManager.BattleData:getGridEntity(info.posId) local skillId = entity:getSkillId() if skillId then - self:activeBoardSkill(info.posId, skillId, isFinal) - end - end -end - -function BattleController:activeBoardSkill(posId, skillId, isFinal) - local skillCard = ConfigManager:getConfig("skill_hero")[skillId] - if not skillCard then - return - end - - if isFinal then - if skillCard.method == 2 then - if skillCard.boardrange then - -- body - end - end - else - if skillCard.method == 1 then - if skillCard.boardrange then - local cludePosIdsMap = {} - for posId, entity in pairs(DataManager.BattleData:getGridEnties()) do - if entity:canLink() then - cludePosIdsMap[posId] = true - end - end - local ids = ModuleManager.BattleManager:getAroundPosIdsByList(posId, skillCard.boardrange, cludePosIdsMap) - for _, posId in ipairs(ids) do - local entity = DataManager.BattleData:getGridEntity(posId) - entity:setElementType(skillCard.skill_type_parameter) - end + local skillEntity = DataManager.BattleData:getSkillEntityByElement(entity:getElementType()) + if skillEntity then + BATTLE_BOARD_SKILL_HANDLE.activeBoardSkill(info.posId, skillEntity, DataManager.BattleData:getGridEnties(), isFinal) end end end diff --git a/lua/app/module/battle/skill.meta b/lua/app/module/battle/skill.meta new file mode 100644 index 00000000..0b9098c5 --- /dev/null +++ b/lua/app/module/battle/skill.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0c2881479b6fcea41b5b168d0779f096 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/lua/app/module/battle/skill/battle_board_skill_handle.lua b/lua/app/module/battle/skill/battle_board_skill_handle.lua new file mode 100644 index 00000000..1a18cde5 --- /dev/null +++ b/lua/app/module/battle/skill/battle_board_skill_handle.lua @@ -0,0 +1,70 @@ +local BattleConst = require "app/module/battle/battle_const" + +local BattleBoardSkillHandle = {} + +local SKILL_TYPE = BattleConst.SKILL_TYPE +local SKILL_METHOD_TYPE = BattleConst.SKILL_METHOD_TYPE + +local function _takeElimination(posId, skillEntity, gridEntities) + local boardrange = skillEntity:getBoardRange() + if boardrange then + local cludePosIdsMap = {} + for posId, entity in pairs(gridEntities) do + cludePosIdsMap[posId] = true + end + local ids = ModuleManager.BattleManager:getAroundPosIdsByList(posId, boardrange, cludePosIdsMap) + cludePosIdsMap = {} + for _, posId in ipairs(ids) do + cludePosIdsMap[posId] = true + end + DataManager.BattleData:cacheSkillInfluenceGrids(cludePosIdsMap) + end +end + +local function _takeChangeAround(posId, skillEntity, gridEntities) + local boardrange = skillEntity:getBoardRange() + if boardrange then + local cludePosIdsMap = {} + for posId, entity in pairs(gridEntities) do + if entity:canChangeInfo() then + cludePosIdsMap[posId] = true + end + end + local ids = ModuleManager.BattleManager:getAroundPosIdsByList(posId, boardrange, cludePosIdsMap) + for _, posId in ipairs(ids) do + local entity = gridEntities[posId] + if entity then + entity:setElementType(skillEntity:getSkillTypeParameter()) + end + end + end +end + +BattleBoardSkillHandle._activeBoardSkill = { + [SKILL_TYPE.ELIMINATION] = _takeElimination, + [SKILL_TYPE.CHANGE_AROUND] = _takeChangeAround, +} + +function BattleBoardSkillHandle.activeBoardSkill(posId, skillEntity, gridEntities, isFinal) + if not skillEntity then + return + end + + if isFinal then + if skillEntity:getMethond() == SKILL_METHOD_TYPE.ON_FINAL then + local func = BattleBoardSkillHandle._activeBoardSkill[skillEntity:getSkillType()] + if func then + func(posId, skillEntity, gridEntities) + end + end + else + if skillEntity:getMethond() == SKILL_METHOD_TYPE.ON_ENTER then + local func = BattleBoardSkillHandle._activeBoardSkill[skillEntity:getSkillType()] + if func then + func(posId, skillEntity, gridEntities) + end + end + end +end + +return BattleBoardSkillHandle \ No newline at end of file diff --git a/lua/app/userdata/battle/skill/battle_card_skill_entity.lua.meta b/lua/app/module/battle/skill/battle_board_skill_handle.lua.meta similarity index 86% rename from lua/app/userdata/battle/skill/battle_card_skill_entity.lua.meta rename to lua/app/module/battle/skill/battle_board_skill_handle.lua.meta index 3586abe5..186d9232 100644 --- a/lua/app/userdata/battle/skill/battle_card_skill_entity.lua.meta +++ b/lua/app/module/battle/skill/battle_board_skill_handle.lua.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 14a09e5699837c548b5878119e718c87 +guid: 08753749ebd71ea46a0a94518c022fa6 ScriptedImporter: internalIDToNameTable: [] externalObjects: {} diff --git a/lua/app/ui/battle/battle_ui.lua b/lua/app/ui/battle/battle_ui.lua index 58660650..4c1bd93f 100644 --- a/lua/app/ui/battle/battle_ui.lua +++ b/lua/app/ui/battle/battle_ui.lua @@ -16,6 +16,7 @@ end function BattleUI:_display() local uiMap = self.root:genAllChildren() self:initGridCell() + self:initSkill() end function BattleUI:_addListeners() @@ -25,7 +26,52 @@ function BattleUI:_addListeners() end) end +function BattleUI:initSkill() + if self.skillObjs then + return + end + self.skillObjs = {} + + local uiMap = self.root:genAllChildren() + for elementType, skillEntity in pairs(DataManager.BattleData:getSkillEntities()) do + if not self.skillObjs[elementType] then + local prefix = "battle_ui.bg_2.skill_node_" .. elementType + self.skillObjs[elementType] = { + icon = uiMap[prefix], + mask = uiMap[prefix .. ".mask"], + } + self.skillObjs[elementType].imgComp = self.skillObjs[elementType].mask:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_IMAGE) + self.skillObjs[elementType].icon:setSprite(GConst.ATLAS_PATH.ICON_SKILL, skillEntity:getBattleIcon()) + self.skillObjs[elementType].mask:setSprite(GConst.ATLAS_PATH.ICON_SKILL, skillEntity:getBattleIcon()) + end + end +end + +function BattleUI:refreshSkill(elementMap) + if not self.skillObjs then + return + end + + for elementType, skillEntity in pairs(DataManager.BattleData:getSkillEntities()) do + if not self.skillObjs[elementType] then + return + end + local add = 0 + if elementMap and elementMap[elementType] then + add = elementMap[elementType] + end + local curEnergy = skillEntity:getEnergy() + add + local needEnergy = skillEntity:getNeedEnergy() + self.skillObjs[elementType].imgComp.fillAmount = (needEnergy - curEnergy) / needEnergy + end +end + function BattleUI:initGridCell() + if self.root.gridCells then + self.gridCells = self.root.gridCells + self.gridInitOver = true + end + if self.gridCells and self.gridInitOver then self:onInitGridCellOver() return @@ -49,6 +95,7 @@ function BattleUI:initGridCell() if self.cellLoadRemianCount <= 0 then self.gridInitOver = true self:onInitGridCellOver() + self.root.gridCells = self.gridCells end end) end @@ -112,6 +159,8 @@ function BattleUI:eliminationAni(cellList, callback) callback() end, 1) end + + self:refreshSkill() end function BattleUI:fallGrid(listInfo, callback) diff --git a/lua/app/ui/battle/cell/grid_cell.lua b/lua/app/ui/battle/cell/grid_cell.lua index bfa76cc0..801afa5a 100644 --- a/lua/app/ui/battle/cell/grid_cell.lua +++ b/lua/app/ui/battle/cell/grid_cell.lua @@ -3,11 +3,15 @@ local GridCell = class("GridCell", BaseCell) function GridCell:refresh(gridEntity, curElement) local uiMap = self:getUIMap() local elementType = gridEntity:getElementType() + local elementIcon = uiMap["grid_cell.touch_node.ani_node.middle_bg"] + local highLightIcon = uiMap["grid_cell.touch_node.ani_node.middle_bg.high_light_icon"] 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) + elementIcon:setSprite(atlas, icon) + highLightIcon:setSprite(atlas, icon .. "_1") end + elementIcon:setVisible(true) local showMask = false if curElement and (curElement ~= elementType or not gridEntity:canLink()) then @@ -24,6 +28,27 @@ function GridCell:refresh(gridEntity, curElement) uiMap["grid_cell.touch_node.ani_node.up_bg"]:setSprite(atlas, icon) end + local skillIcon = uiMap["grid_cell.touch_node.ani_node.skill_icon"] + local skillHighLightIcon = uiMap["grid_cell.touch_node.ani_node.skill_icon.high_light_icon"] + local skillId = gridEntity:getSkillId() + if skillId then + elementIcon:setVisible(false) + skillIcon:setVisible(true) + + if self.lastSkillId ~= skillId then + self.lastSkillId = skillId + local cfg = ModuleManager.BattleManager.SKILL_HERO_CFG[skillId] + if cfg then + skillIcon:setSprite(GConst.ATLAS_PATH.ICON_SKILL, tostring(cfg.battle_icon)) + skillHighLightIcon:setSprite(GConst.ATLAS_PATH.ICON_SKILL, tostring(cfg.battle_icon) .. "_1") + end + end + else + skillIcon:setVisible(false) + end + + self:showCircle(false) + self:showHighLight(false) --- 测试代码 uiMap["grid_cell.touch_node.ani_node.count"]:setText(gridEntity:getAroundEliminationCount()) end @@ -33,4 +58,17 @@ function GridCell:addTouchListener(func) uiMap["grid_cell.touch_node"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_ELIMINATION_TOUCH_EVENT):AddTouchEventListener(func) end +function GridCell:showCircle(show) + local uiMap = self:getUIMap() + uiMap["grid_cell.touch_node.ani_node.circle"]:setVisible(show) +end + +function GridCell:showHighLight(show) + local uiMap = self:getUIMap() + local highLightIcon = uiMap["grid_cell.touch_node.ani_node.middle_bg.high_light_icon"] + local skillHighLightIcon = uiMap["grid_cell.touch_node.ani_node.skill_icon.high_light_icon"] + highLightIcon:setVisible(show) + skillHighLightIcon:setVisible(show) +end + return GridCell \ No newline at end of file diff --git a/lua/app/userdata/battle/battle_data.lua b/lua/app/userdata/battle/battle_data.lua index 8d433cc7..82435bd7 100644 --- a/lua/app/userdata/battle/battle_data.lua +++ b/lua/app/userdata/battle/battle_data.lua @@ -1,10 +1,11 @@ local BattleData = class("BattleData", BaseData) +local SKILL_HERO_CFG = ConfigManager:getConfig("skill_hero") local BattleConst = GConst.BattleConst local BATTLE_GRID_ENTITY = require "app/userdata/battle/battle_grid_entity" -local BATTLE_CARD_SKILL_ENTITY = require "app/userdata/battle/skill/battle_card_skill_entity" +local BATTLE_BOARD_SKILL_ENTITY = require "app/userdata/battle/skill/battle_borad_skill_entity" -function BattleData:init(board) +function BattleData:init(board, skillIds) self:clear() for i, info in ipairs(board) do @@ -31,6 +32,15 @@ function BattleData:init(board) self.elementTypeMap[data.elementType] = (self.elementTypeMap[data.elementType] or 0) + 1 end end + + --- todo + skillIds = { + 10, 21, 30, 40, 50 + } + for _, skillId in ipairs(skillIds) do + local cfg = SKILL_HERO_CFG[skillId] + self.skillMap[cfg.position] = BATTLE_BOARD_SKILL_ENTITY:create(skillId) + end end function BattleData:clear() @@ -38,6 +48,7 @@ function BattleData:clear() self.gridEntities = {} self.elementTypeMap = {} -- 同元素得格子数量 + self.skillMap = {} end function BattleData:getElementTypeMap() @@ -80,16 +91,22 @@ function BattleData:removeGridSequence(posId) end function BattleData:cacheSkillInfluenceGrids(grids) - self.skillInfluenceGrids = grids + if not self.skillInfluenceGrids then + self.skillInfluenceGrids = {} + end + for posId, status in pairs(grids) do + self.skillInfluenceGrids[posId] = true + end end function BattleData:getSkillInfluenceGrids() - return self.skillInfluenceGrids + return self.skillInfluenceGrids or {} end function BattleData:clearGridSequence() self.gridSequence = {} -- 格子队列 self.gridSequenceMap = {} -- 格子队列对应的map,方面查找 + self.skillInfluenceGrids = {} -- 技能影响的格子 end function BattleData:getGridEnties() @@ -134,6 +151,68 @@ function BattleData:setGridInfo(posId, gridInfo) self.elementTypeMap[gridInfo.elementType] = (self.elementTypeMap[gridInfo.elementType] or 0) + 1 end end + + entity:setSkilId() -- 清除skillId +end + +function BattleData:getSameElementList(elementType, count, useAlternate) + local result = {} + if not self.gridEntities then + return result + end + + local sameElementList = {} + local alternateList = {} + for posId, entity in pairs(self.gridEntities) do + if entity:canChangeInfo() then + if entity:getElementType() == elementType then + table.insert(sameElementList, posId) + else + table.insert(alternateList, posId) + end + end + end + + local addCount = 0 + for i = 1, count do + if not sameElementList[i] then + break + end + table.insert(result, table.remove(sameElementList, math.random(1, #sameElementList))) + addCount = addCount + 1 + end + + if addCount < count and useAlternate then + for i = 1, count - addCount do + if not alternateList[1] then + break + end + table.insert(result, table.remove(alternateList, math.random(1, #alternateList))) + end + end + + return result +end + +function BattleData:getSkillEntities() + return self.skillMap +end + +function BattleData:getSkillEntityByElement(elementType) + if not self.skillMap then + return + end + return self.skillMap[elementType] +end + +function BattleData:addSkillEnergy(elementMap) + if not self.skillMap then + return + end + + for elementType, entity in pairs(self.skillMap) do + entity:addEnergy(elementMap[elementType] or 0) + end end return BattleData \ No newline at end of file diff --git a/lua/app/userdata/battle/battle_grid_entity.lua b/lua/app/userdata/battle/battle_grid_entity.lua index eb6736cf..43ef9b37 100644 --- a/lua/app/userdata/battle/battle_grid_entity.lua +++ b/lua/app/userdata/battle/battle_grid_entity.lua @@ -102,6 +102,9 @@ function BattleGridEntity:setIsIdle(isIdle) end function BattleGridEntity:canLink() + if self:getIsIdle() then + return false + end return not BattleConst.CANT_LINK_GRID_TYPE[self.gridType] end @@ -139,4 +142,16 @@ function BattleGridEntity:getSkillId() return self.skillId end +function BattleGridEntity:setSkilId(skillId) + self.skillId = skillId + self:setDirty() +end + +function BattleGridEntity:canChangeInfo() + if self:canLink() and not self:getSkillId() then + return true + end + return false +end + return BattleGridEntity \ No newline at end of file diff --git a/lua/app/userdata/battle/skill/battle_borad_skill_entity.lua b/lua/app/userdata/battle/skill/battle_borad_skill_entity.lua new file mode 100644 index 00000000..ca8bf3c2 --- /dev/null +++ b/lua/app/userdata/battle/skill/battle_borad_skill_entity.lua @@ -0,0 +1,114 @@ +local BattleBoardSkillEnity = class("BattleBoardSkillEnity", BaseData) + +function BattleBoardSkillEnity:ctor(skillId) + self:refreshSkillId(skillId) + self.curEnergy = 0 +end + +function BattleBoardSkillEnity:refreshSkillId(skillId) + self.skillId = skillId + self.config = ConfigManager:getConfig("skill_hero")[skillId] +end + +function BattleBoardSkillEnity:getSkillId() + return self.skillId +end + +function BattleBoardSkillEnity:getNeedEnergy() + if not self.config then + return 1 + end + return self.config.energy +end + +function BattleBoardSkillEnity:getPosition() + if not self.config then + return 1 + end + return self.config.position +end + +function BattleBoardSkillEnity:getMethond() + if not self.config then + return + end + return self.config.method +end + +function BattleBoardSkillEnity:getSkillType() + if not self.config then + return + end + return self.config.skill_type +end + +function BattleBoardSkillEnity:getSkillTypeParameter() + if not self.config then + return + end + return self.config.skill_type_parameter +end + +function BattleBoardSkillEnity:getBoardRange() + if not self.config then + return + end + return self.config.boardrange +end + +function BattleBoardSkillEnity:getEffect() + if not self.config then + return + end + return self.config.effect +end + +function BattleBoardSkillEnity:getTartget() + if not self.config then + return + end + return self.config.obj +end + +function BattleBoardSkillEnity:getIcon() + if not self.config then + return + end + return self.config.icon +end + +function BattleBoardSkillEnity:getBattleIcon() + if not self.config then + return + end + return tostring(self.config.battle_icon) +end + +function BattleBoardSkillEnity:getNameAct() + if not self.config then + return + end + return self.config.name_act +end + +function BattleBoardSkillEnity:getEnergy() + return self.curEnergy +end + +function BattleBoardSkillEnity:getEnergyEnough(onlyGetBool) + local enough = self.curEnergy >= self:getNeedEnergy() + if enough and not onlyGetBool then + self:clearEnergy() + end + return enough +end + +function BattleBoardSkillEnity:addEnergy(count) + self.curEnergy = self.curEnergy + count +end + +function BattleBoardSkillEnity:clearEnergy() + self.curEnergy = 0 +end + +return BattleBoardSkillEnity \ No newline at end of file diff --git a/lua/app/userdata/battle/skill/battle_borad_skill_entity.lua.meta b/lua/app/userdata/battle/skill/battle_borad_skill_entity.lua.meta new file mode 100644 index 00000000..12be0efd --- /dev/null +++ b/lua/app/userdata/battle/skill/battle_borad_skill_entity.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 02d214b08c9e8e249af651ea321569bd +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/userdata/battle/skill/battle_card_skill_entity.lua b/lua/app/userdata/battle/skill/battle_card_skill_entity.lua deleted file mode 100644 index c09052eb..00000000 --- a/lua/app/userdata/battle/skill/battle_card_skill_entity.lua +++ /dev/null @@ -1,87 +0,0 @@ -local BattleCardSkillEnity = class("BattleCardSkillEnity", BaseData) - -function BattleCardSkillEnity:ctor(skillId) - self:refreshSkillId(skillId) - -end - -function BattleCardSkillEnity:refreshSkillId(skillId) - self.skillId = skillId - self.config = ConfigManager:getConfig("skill_hero")[skillId] -end - -function BattleCardSkillEnity:getSkillId() - return self.skillId -end - -function BattleCardSkillEnity:getMethond() - if not self.config then - return - end - return self.config.method -end - -function BattleCardSkillEnity:getSkillType() - if not self.config then - return - end - return self.config.skill_type -end - -function BattleCardSkillEnity:getSkillTypeParameter() - if not self.config then - return - end - return self.config.skill_type_parameter -end - -function BattleCardSkillEnity:getBoardRange() - if not self.config then - return - end - return self.config.boardrange -end - -function BattleCardSkillEnity:getEffect() - if not self.config then - return - end - return self.config.effect -end - -function BattleCardSkillEnity:getTartget() - if not self.config then - return - end - return self.config.obj -end - -function BattleCardSkillEnity:getTartget() - if not self.config then - return - end - return self.config.obj -end - -function BattleCardSkillEnity:getIcon() - if not self.config then - return - end - return self.config.icon -end - -function BattleCardSkillEnity:getBattleIcon() - if not self.config then - return - end - return self.config.battle_icon -end - -function BattleCardSkillEnity:getNameAct() - if not self.config then - return - end - return self.config.name_act -end - -return BattleCardSkillEnity \ No newline at end of file