pvp战斗概念引入
This commit is contained in:
parent
eb7d04a5dc
commit
a623c25f6f
@ -13,6 +13,7 @@ function DataManager:init()
|
|||||||
self:initManager("HeroData", "app/userdata/hero/hero_data")
|
self:initManager("HeroData", "app/userdata/hero/hero_data")
|
||||||
self:initManager("BagData", "app/userdata/bag/bag_data")
|
self:initManager("BagData", "app/userdata/bag/bag_data")
|
||||||
self:initManager("BattleData", "app/userdata/battle/battle_data")
|
self:initManager("BattleData", "app/userdata/battle/battle_data")
|
||||||
|
self:initManager("BattlePVPData", "app/userdata/battle/battle_pvp_data")
|
||||||
self:initManager("FormationData", "app/userdata/formation/formation_data")
|
self:initManager("FormationData", "app/userdata/formation/formation_data")
|
||||||
self:initManager("TutorialData", "app/userdata/tutorial/tutorial_data")
|
self:initManager("TutorialData", "app/userdata/tutorial/tutorial_data")
|
||||||
self:initManager("MailData", "app/userdata/mail/mail_data")
|
self:initManager("MailData", "app/userdata/mail/mail_data")
|
||||||
@ -33,7 +34,7 @@ function DataManager:initManager(name, path)
|
|||||||
self._cacheManager[name] = self[name]
|
self._cacheManager[name] = self[name]
|
||||||
end
|
end
|
||||||
|
|
||||||
if name == "BattleData" and self._cacheManager[name] then
|
if (name == "BattleData" or name == "BattlePVPData") and self._cacheManager[name] then
|
||||||
else
|
else
|
||||||
self[name] = require(path):create()
|
self[name] = require(path):create()
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
local BattleConst = {}
|
local BattleConst = {}
|
||||||
|
|
||||||
BattleConst.ROW_COUNT = 7
|
BattleConst.ROW_COUNT = 7
|
||||||
|
BattleConst.PVP_ROW_COUNT = 10
|
||||||
BattleConst.COLUMN_COUNT = 7
|
BattleConst.COLUMN_COUNT = 7
|
||||||
BattleConst.PVP_COLUMN_COUNT = 10
|
|
||||||
BattleConst.HALF_ROW_COUNT = 4 -- 计算偏移 math.ceil(ROW_COUNT / 2)
|
BattleConst.HALF_ROW_COUNT = 4 -- 计算偏移 math.ceil(ROW_COUNT / 2)
|
||||||
BattleConst.HALF_COLUMN_COUNT = 4 -- 计算偏移 math.ceil(COLUMN_COUNT / 2)
|
BattleConst.HALF_COLUMN_COUNT = 4 -- 计算偏移 math.ceil(COLUMN_COUNT / 2)
|
||||||
BattleConst.GRID_STEP_H = 94
|
BattleConst.GRID_STEP_H = 94
|
||||||
|
|||||||
@ -47,6 +47,7 @@ function BattleManager:isInBattle()
|
|||||||
return self.battleController ~= nil
|
return self.battleController ~= nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- params = {atkFormation= {elementType = heroEntity}, defFormation= ?}
|
||||||
function BattleManager:playBattle(battleType, params, returnFunc)
|
function BattleManager:playBattle(battleType, params, returnFunc)
|
||||||
UIManager:showLoading(UIManager.LOADING_TYPE.CLOUD, function()
|
UIManager:showLoading(UIManager.LOADING_TYPE.CLOUD, function()
|
||||||
params = params or {}
|
params = params or {}
|
||||||
@ -61,6 +62,16 @@ end
|
|||||||
|
|
||||||
function BattleManager:_play(battleType, params)
|
function BattleManager:_play(battleType, params)
|
||||||
params.battleType = battleType
|
params.battleType = battleType
|
||||||
|
if not params.atkFormation then
|
||||||
|
params.atkFormation = {}
|
||||||
|
local formation = DataManager.FormationData:getStageFormation()
|
||||||
|
for elementType, heroId in pairs(formation) do
|
||||||
|
local heroEntity = DataManager.HeroData:getHeroById(heroId)
|
||||||
|
if heroEntity then
|
||||||
|
params.atkFormation[elementType] = heroEntity
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
local controllerPath = BATTLE_CONTROLLER[battleType] or BATTLE_CONTROLLER_BASE
|
local controllerPath = BATTLE_CONTROLLER[battleType] or BATTLE_CONTROLLER_BASE
|
||||||
self.battleController = require(controllerPath):create()
|
self.battleController = require(controllerPath):create()
|
||||||
self.battleController:init(params)
|
self.battleController:init(params)
|
||||||
|
|||||||
2873
lua/app/module/battle/controller/battle_base_controller.lua
Normal file
2873
lua/app/module/battle/controller/battle_base_controller.lua
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 06696c742e709a642ba2189a9c75b45a
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||||
@ -418,7 +418,7 @@ function BattleController:init(params)
|
|||||||
self.delayEffectTextList = {}
|
self.delayEffectTextList = {}
|
||||||
self.delayEffectTextCount = 0
|
self.delayEffectTextCount = 0
|
||||||
self.time = 0
|
self.time = 0
|
||||||
self.battleData:init()
|
self.battleData:init(params)
|
||||||
BattleScheduler:init()
|
BattleScheduler:init()
|
||||||
BattlePool:init()
|
BattlePool:init()
|
||||||
BattleHelper:init()
|
BattleHelper:init()
|
||||||
@ -2034,7 +2034,7 @@ end
|
|||||||
|
|
||||||
function BattleController:onSelectSkill(skillId, value, pos)
|
function BattleController:onSelectSkill(skillId, value, pos)
|
||||||
self.battleData:addSkillCount(skillId, value)
|
self.battleData:addSkillCount(skillId, value)
|
||||||
BATTLE_ROGUE_SKILL_HANDLE.takeEffect(skillId, self.battleData, self, value)
|
BATTLE_ROGUE_SKILL_HANDLE.takeEffect(skillId, self.battleData, self, value, BattleConst.SIDE_ATK)
|
||||||
|
|
||||||
local skillEntities = self.battleData:getSkillEntities()
|
local skillEntities = self.battleData:getSkillEntities()
|
||||||
for _, entity in pairs(skillEntities) do
|
for _, entity in pairs(skillEntities) do
|
||||||
|
|||||||
173
lua/app/module/battle/controller/battle_controller_pvp.lua
Normal file
173
lua/app/module/battle/controller/battle_controller_pvp.lua
Normal file
@ -0,0 +1,173 @@
|
|||||||
|
local BattleHelper = require "app/module/battle/helper/battle_helper"
|
||||||
|
local BattleBaseController = require "app/module/battle/controller/battle_base_controller"
|
||||||
|
local BattleControllerPVP = class("BattleControllerPVP", BattleBaseController)
|
||||||
|
local BattleConst = GConst.BattleConst
|
||||||
|
|
||||||
|
-- *************各个子模块的战斗需要重写的方法 START*************
|
||||||
|
function BattleControllerPVP:getBoardConfig()
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleControllerPVP:getChapterConfig()
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleControllerPVP:getChapterId()
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleControllerPVP:getBuffs()
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 战斗对应的ui
|
||||||
|
function BattleControllerPVP:getBattleUIPath()
|
||||||
|
return "app/ui/battle/battle_ui_pvp"
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 战斗结束
|
||||||
|
function BattleControllerPVP:controllBattleEnd()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 一共有多少波
|
||||||
|
function BattleControllerPVP:getMaxWave()
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleControllerPVP:findNextDefUnit()
|
||||||
|
self:enterRoundEnd(true)
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleControllerPVP:onLinkChange()
|
||||||
|
self.battleUI:hideAllSfxLine()
|
||||||
|
self.linkChangeNeedFalsePosMap = table.clearOrCreate(self.linkChangeNeedFalsePosMap)
|
||||||
|
for posId, entity in pairs(self.battleData:getGridEnties()) do
|
||||||
|
if entity:getCell() then
|
||||||
|
self.linkChangeNeedFalsePosMap[posId] = entity:getCell()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local sequence = self.battleData:getGridSequence()
|
||||||
|
local mainElementType
|
||||||
|
|
||||||
|
for index, info in ipairs(sequence) do
|
||||||
|
local entity = self.battleData:getGridEntity(info.posId)
|
||||||
|
if not mainElementType then
|
||||||
|
local skillId = entity:getSkillId()
|
||||||
|
if not skillId then
|
||||||
|
mainElementType = entity:getElementType()
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local count = #sequence
|
||||||
|
|
||||||
|
for index, info in ipairs(sequence) do
|
||||||
|
local entity = self.battleData:getGridEntity(info.posId)
|
||||||
|
if entity:getCell() then
|
||||||
|
entity:getCell():showHighLight(true, mainElementType, self.battleUI)
|
||||||
|
end
|
||||||
|
if self.linkChangeNeedFalsePosMap[info.posId] then
|
||||||
|
self.linkChangeNeedFalsePosMap[info.posId] = nil
|
||||||
|
end
|
||||||
|
if index < count then
|
||||||
|
local nextPosId = sequence[index + 1].posId
|
||||||
|
self.battleUI:getSfxLine(index, function(obj)
|
||||||
|
local curPos = ModuleManager.BattleManager:getPosInfo(info.posId)
|
||||||
|
local nextPos = ModuleManager.BattleManager:getPosInfo(nextPosId)
|
||||||
|
local pos, z = ModuleManager.BattleManager:getPosCenterAndDir(curPos, nextPos)
|
||||||
|
obj:setLocalScale(25, 25, 25)
|
||||||
|
obj:setLocalPosition(pos.x, pos.y, 0)
|
||||||
|
obj:setEulerAngles(0, 0, z)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
if index == count then
|
||||||
|
if entity:getCell() then
|
||||||
|
entity:getCell():showAni()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for posId, cell in pairs(self.linkChangeNeedFalsePosMap) do
|
||||||
|
cell:showHighLight(false)
|
||||||
|
end
|
||||||
|
|
||||||
|
for posId, info in pairs(self.battleData:getSkillInfluenceGrids()) do
|
||||||
|
local entity = self.battleData:getGridEntity(posId)
|
||||||
|
if info.direction ~= BattleConst.BOARD_RANGE_TYPE.RANDOM then
|
||||||
|
if entity:getCell() then
|
||||||
|
entity:getCell():showCircle(true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if not self.atkTeam:getMainUnit().unitEntity:getActiveSkillLimit() then
|
||||||
|
local aniSequence, influenceElementType, lineCount, elementTypeMap, linkElementType = self:calculateCurElimination(true)
|
||||||
|
self.battleUI:refreshSkill(elementTypeMap, count > 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
if mainElementType then
|
||||||
|
self.atkTeam:changeMainUnit(mainElementType)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleControllerPVP:postWaveOver(atkDead, isQuit)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleControllerPVP:postFightStart()
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleControllerPVP:onEliminationBegin()
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleControllerPVP:refreshWave()
|
||||||
|
if not self.battleUI then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
self.battleUI:refreshWave(self.waveIndex)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- *************各个子模块的战斗需要重写的方法 END*************
|
||||||
|
|
||||||
|
function BattleControllerPVP:ctor()
|
||||||
|
self.battleData = DataManager.BattlePVPData
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleControllerPVP:initDefUnits(callback)
|
||||||
|
local defTeamEntity = self.battleData:getDefTeam()
|
||||||
|
local count = 0
|
||||||
|
local totalCount = defTeamEntity:getMembersCount()
|
||||||
|
local function onloadFinished()
|
||||||
|
count = count + 1
|
||||||
|
if count == totalCount then
|
||||||
|
self.battleUI:refreshAtkHp(defTeamEntity:getHp(), defTeamEntity:getHpPercent())
|
||||||
|
callback()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local members = defTeamEntity:getAllMembers()
|
||||||
|
for k, v in pairs(members) do
|
||||||
|
local modelId = v:getModelId()
|
||||||
|
BattleHelper:loadBattleHeroModel(modelId, self.battleUI:getBattleNode(), function(spineObject)
|
||||||
|
local heroComp = spineObject:addLuaComponent(BattleConst.TYPEOF_LUA_COMP.BATTLE_HERO_COMPONENT)
|
||||||
|
heroComp:initWithEntity(modelId, v, self)
|
||||||
|
if v:getIsMainUnit() then
|
||||||
|
self.defTeam:addUnit(heroComp, true)
|
||||||
|
else
|
||||||
|
self.defTeam:addUnit(heroComp)
|
||||||
|
heroComp:hideOutsideScreen()
|
||||||
|
end
|
||||||
|
onloadFinished()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
if totalCount == 0 then
|
||||||
|
callback()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return BattleControllerPVP
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: cf144ebf0bb8b7b46b1341ca0f899c3e
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||||
@ -4,7 +4,7 @@ local BattleBuffEntity = require "app/userdata/battle/skill/battle_buff_entity"
|
|||||||
|
|
||||||
local BattleRogueSkillHandle = {}
|
local BattleRogueSkillHandle = {}
|
||||||
|
|
||||||
local _changeBaseSkill = function(skillId, skillInfo, battleData, battleController)
|
local _changeBaseSkill = function(skillId, skillInfo, battleBaseData, battleController, value, side)
|
||||||
local elementType = skillInfo.skill_position
|
local elementType = skillInfo.skill_position
|
||||||
if not elementType or not skillInfo.parameter then
|
if not elementType or not skillInfo.parameter then
|
||||||
return
|
return
|
||||||
@ -14,14 +14,14 @@ local _changeBaseSkill = function(skillId, skillInfo, battleData, battleControll
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local skillEntity = battleData:getSkillEntityByElement(elementType)
|
local skillEntity = battleBaseData:getSkillEntityByElement(elementType, side)
|
||||||
if skillEntity then
|
if skillEntity then
|
||||||
local skillId = skillEntity:getSkillId()
|
local skillId = skillEntity:getSkillId()
|
||||||
battleData:changeSkillId(elementType, newSkillId)
|
battleBaseData:changeSkillId(elementType, newSkillId, side)
|
||||||
if not battleData.atkTeam then
|
if not battleBaseData.atkTeam then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local unitEntity = battleData.atkTeam:getAllMembers()[elementType]
|
local unitEntity = battleBaseData.atkTeam:getAllMembers()[elementType]
|
||||||
if unitEntity then
|
if unitEntity then
|
||||||
unitEntity:changeSkillId(skillId, newSkillId)
|
unitEntity:changeSkillId(skillId, newSkillId)
|
||||||
for effectType, effect in pairs(skillEntity:getSkillRoundAdd()) do -- 技能回合数
|
for effectType, effect in pairs(skillEntity:getSkillRoundAdd()) do -- 技能回合数
|
||||||
@ -39,54 +39,54 @@ local _changeBaseSkill = function(skillId, skillInfo, battleData, battleControll
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local _addEliminationRange = function(skillId, skillInfo, battleData, battleController)
|
local _addEliminationRange = function(skillId, skillInfo, battleData, battleController, value, side)
|
||||||
local elementType = skillInfo.skill_position
|
local elementType = skillInfo.skill_position
|
||||||
if not elementType or not skillInfo.boardrange then
|
if not elementType or not skillInfo.boardrange then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local entity = battleData:getSkillEntityByElement(elementType)
|
local entity = battleData:getSkillEntityByElement(elementType, side)
|
||||||
if entity then
|
if entity then
|
||||||
entity:addBoardRange(skillInfo.boardrange)
|
entity:addBoardRange(skillInfo.boardrange)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local _canLinkAnyElement = function(skillId, skillInfo, battleData, battleController)
|
local _canLinkAnyElement = function(skillId, skillInfo, battleData, battleController, value, side)
|
||||||
local elementType = skillInfo.skill_position
|
local elementType = skillInfo.skill_position
|
||||||
if not elementType then
|
if not elementType then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local entity = battleData:getSkillEntityByElement(elementType)
|
local entity = battleData:getSkillEntityByElement(elementType, side)
|
||||||
if entity then
|
if entity then
|
||||||
entity:setIgnoreElementType(true)
|
entity:setIgnoreElementType(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local _addLinkAtkp = function(skillId, skillInfo, battleData, battleController)
|
local _addLinkAtkp = function(skillId, skillInfo, battleData, battleController, value, side)
|
||||||
local elementType = skillInfo.skill_position
|
local elementType = skillInfo.skill_position
|
||||||
if not elementType or not skillInfo.effect then
|
if not elementType or not skillInfo.effect then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if not battleController.battleData or not battleController.battleData.atkTeam then
|
if not battleData.atkTeam then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local unitEntity = battleController.battleData.atkTeam:getAllMembers()[elementType]
|
local unitEntity = battleData.atkTeam:getAllMembers()[elementType]
|
||||||
if not unitEntity then
|
if not unitEntity then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, effect in ipairs(skillInfo.effect) do
|
for _, effect in ipairs(skillInfo.effect) do
|
||||||
local entity = battleData:getSkillEntityByElement(elementType)
|
local entity = battleData:getSkillEntityByElement(elementType, side)
|
||||||
if entity then
|
if entity then
|
||||||
entity:addLinkEffect(effect, unitEntity, skillInfo.obj)
|
entity:addLinkEffect(effect, unitEntity, skillInfo.obj)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local _changeElementType = function(skillId, skillInfo, battleData, battleController)
|
local _changeElementType = function(skillId, skillInfo, battleData, battleController, value, side)
|
||||||
if not skillInfo.boardrange or not skillInfo.parameter then
|
if not skillInfo.boardrange or not skillInfo.parameter then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -100,7 +100,7 @@ local _changeElementType = function(skillId, skillInfo, battleData, battleContro
|
|||||||
battleController:changeElementType(count, elementType)
|
battleController:changeElementType(count, elementType)
|
||||||
end
|
end
|
||||||
|
|
||||||
local _addAttr = function(skillId, skillInfo, battleData, battleController, value)
|
local _addAttr = function(skillId, skillInfo, battleData, battleController, value, side)
|
||||||
if not skillInfo.attr then
|
if not skillInfo.attr then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -111,15 +111,15 @@ local _addAttr = function(skillId, skillInfo, battleData, battleController, valu
|
|||||||
battleController:addHeroAttr(skillInfo.attr.type, value)
|
battleController:addHeroAttr(skillInfo.attr.type, value)
|
||||||
end
|
end
|
||||||
|
|
||||||
local _unlockSkill = function(skillId, skillInfo, battleData, battleController, value)
|
local _unlockSkill = function(skillId, skillInfo, battleData, battleController, value, side)
|
||||||
if not skillInfo.skill_position then
|
if not skillInfo.skill_position then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
battleData:unlockSkillEntity(skillInfo.skill_position)
|
battleData:unlockSkillEntity(skillInfo.skill_position, side)
|
||||||
end
|
end
|
||||||
|
|
||||||
local _addSkillEffectParams = function(skillId, skillInfo, battleData, battleController)
|
local _addSkillEffectParams = function(skillId, skillInfo, battleData, battleController, value, side)
|
||||||
local elementType = skillInfo.skill_position
|
local elementType = skillInfo.skill_position
|
||||||
if not elementType or not skillInfo.parameter then
|
if not elementType or not skillInfo.parameter then
|
||||||
return
|
return
|
||||||
@ -131,7 +131,7 @@ local _addSkillEffectParams = function(skillId, skillInfo, battleData, battleCon
|
|||||||
end
|
end
|
||||||
|
|
||||||
local effect
|
local effect
|
||||||
local entity = battleData:getSkillEntityByElement(elementType)
|
local entity = battleData:getSkillEntityByElement(elementType, side)
|
||||||
if entity and entity:getEffect() then
|
if entity and entity:getEffect() then
|
||||||
local effectCfg = entity:getEffect()[index]
|
local effectCfg = entity:getEffect()[index]
|
||||||
if effectCfg then
|
if effectCfg then
|
||||||
@ -144,7 +144,7 @@ local _addSkillEffectParams = function(skillId, skillInfo, battleData, battleCon
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local skillEntity = battleData:getSkillEntityByElement(elementType)
|
local skillEntity = battleData:getSkillEntityByElement(elementType, side)
|
||||||
if skillEntity then
|
if skillEntity then
|
||||||
local skillId = skillEntity:getSkillId()
|
local skillId = skillEntity:getSkillId()
|
||||||
skillEntity:addSkillEffecuNumAdd(effect)
|
skillEntity:addSkillEffecuNumAdd(effect)
|
||||||
@ -157,7 +157,7 @@ local _addSkillEffectParams = function(skillId, skillInfo, battleData, battleCon
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local _addSkillRound = function(skillId, skillInfo, battleData, battleController)
|
local _addSkillRound = function(skillId, skillInfo, battleData, battleController, value, side)
|
||||||
local elementType = skillInfo.skill_position
|
local elementType = skillInfo.skill_position
|
||||||
if not elementType or not skillInfo.parameter then
|
if not elementType or not skillInfo.parameter then
|
||||||
return
|
return
|
||||||
@ -170,7 +170,7 @@ local _addSkillRound = function(skillId, skillInfo, battleData, battleController
|
|||||||
end
|
end
|
||||||
|
|
||||||
local effect
|
local effect
|
||||||
local entity = battleData:getSkillEntityByElement(elementType)
|
local entity = battleData:getSkillEntityByElement(elementType, side)
|
||||||
if entity and entity:getEffect() then
|
if entity and entity:getEffect() then
|
||||||
local effectCfg = entity:getEffect()[index]
|
local effectCfg = entity:getEffect()[index]
|
||||||
if effectCfg then
|
if effectCfg then
|
||||||
@ -183,7 +183,7 @@ local _addSkillRound = function(skillId, skillInfo, battleData, battleController
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local skillEntity = battleData:getSkillEntityByElement(elementType)
|
local skillEntity = battleData:getSkillEntityByElement(elementType, side)
|
||||||
if skillEntity then
|
if skillEntity then
|
||||||
local skillId = skillEntity:getSkillId()
|
local skillId = skillEntity:getSkillId()
|
||||||
skillEntity:addSkillRoundAdd(effect)
|
skillEntity:addSkillRoundAdd(effect)
|
||||||
@ -196,7 +196,7 @@ local _addSkillRound = function(skillId, skillInfo, battleData, battleController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local _addSkillEffect = function(skillId, skillInfo, battleData, battleController)
|
local _addSkillEffect = function(skillId, skillInfo, battleData, battleController, value, side)
|
||||||
if not skillInfo.effect then
|
if not skillInfo.effect then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -236,43 +236,43 @@ local _addSkillEffect = function(skillId, skillInfo, battleData, battleControlle
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local _addSkillInInfluenceAtkp = function(skillId, skillInfo, battleData, battleController)
|
local _addSkillInInfluenceAtkp = function(skillId, skillInfo, battleData, battleController, value, side)
|
||||||
local elementType = skillInfo.skill_position
|
local elementType = skillInfo.skill_position
|
||||||
if not elementType or not skillInfo.effect then
|
if not elementType or not skillInfo.effect then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if not battleController.battleData or not battleController.battleData.atkTeam then
|
if not battleData.atkTeam then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local unitEntity = battleController.battleData.atkTeam:getAllMembers()[elementType]
|
local unitEntity = battleData.atkTeam:getAllMembers()[elementType]
|
||||||
if not unitEntity then
|
if not unitEntity then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local entity = battleData:getSkillEntityByElement(elementType)
|
local entity = battleData:getSkillEntityByElement(elementType, side)
|
||||||
for _, effect in ipairs(skillInfo.effect) do
|
for _, effect in ipairs(skillInfo.effect) do
|
||||||
entity:addInInfluenceEffect(effect, unitEntity, skillInfo.obj)
|
entity:addInInfluenceEffect(effect, unitEntity, skillInfo.obj)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local _addSkillAttackBeforeEffect = function(skillId, skillInfo, battleData, battleController)
|
local _addSkillAttackBeforeEffect = function(skillId, skillInfo, battleData, battleController, value, side)
|
||||||
local elementType = skillInfo.skill_position
|
local elementType = skillInfo.skill_position
|
||||||
if not elementType or not skillInfo.effect then
|
if not elementType or not skillInfo.effect then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if not battleController.battleData or not battleController.battleData.atkTeam then
|
if not battleData.atkTeam then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local unitEntity = battleController.battleData.atkTeam:getAllMembers()[elementType]
|
local unitEntity = battleData.atkTeam:getAllMembers()[elementType]
|
||||||
if not unitEntity then
|
if not unitEntity then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local entity = battleData:getSkillEntityByElement(elementType)
|
local entity = battleData:getSkillEntityByElement(elementType, side)
|
||||||
if entity then
|
if entity then
|
||||||
if skillInfo.cover_unlock then
|
if skillInfo.cover_unlock then
|
||||||
entity:removeSkillAttackBeforeEffect(skillInfo.cover_unlock)
|
entity:removeSkillAttackBeforeEffect(skillInfo.cover_unlock)
|
||||||
@ -283,22 +283,22 @@ local _addSkillAttackBeforeEffect = function(skillId, skillInfo, battleData, bat
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local _addSkillElementCountEffect = function(skillId, skillInfo, battleData, battleController)
|
local _addSkillElementCountEffect = function(skillId, skillInfo, battleData, battleController, value, side)
|
||||||
local elementType = skillInfo.skill_position
|
local elementType = skillInfo.skill_position
|
||||||
if not elementType or not skillInfo.effect then
|
if not elementType or not skillInfo.effect then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if not battleController.battleData or not battleController.battleData.atkTeam then
|
if not battleData.atkTeam then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local unitEntity = battleController.battleData.atkTeam:getAllMembers()[elementType]
|
local unitEntity = battleData.atkTeam:getAllMembers()[elementType]
|
||||||
if not unitEntity then
|
if not unitEntity then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local entity = battleData:getSkillEntityByElement(elementType)
|
local entity = battleData:getSkillEntityByElement(elementType, side)
|
||||||
if entity then
|
if entity then
|
||||||
if skillInfo.cover_unlock then
|
if skillInfo.cover_unlock then
|
||||||
entity:removeElementCountEffect(skillInfo.cover_unlock)
|
entity:removeElementCountEffect(skillInfo.cover_unlock)
|
||||||
@ -309,22 +309,22 @@ local _addSkillElementCountEffect = function(skillId, skillInfo, battleData, bat
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local _addLinkCountMoreEffect = function(skillId, skillInfo, battleData, battleController)
|
local _addLinkCountMoreEffect = function(skillId, skillInfo, battleData, battleController, value, side)
|
||||||
local elementType = skillInfo.skill_position
|
local elementType = skillInfo.skill_position
|
||||||
if not elementType or not skillInfo.effect or not skillInfo.parameter then
|
if not elementType or not skillInfo.effect or not skillInfo.parameter then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if not battleController.battleData or not battleController.battleData.atkTeam then
|
if not battleData.atkTeam then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local unitEntity = battleController.battleData.atkTeam:getAllMembers()[elementType]
|
local unitEntity = battleData.atkTeam:getAllMembers()[elementType]
|
||||||
if not unitEntity then
|
if not unitEntity then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local entity = battleData:getSkillEntityByElement(elementType)
|
local entity = battleData:getSkillEntityByElement(elementType, side)
|
||||||
if entity then
|
if entity then
|
||||||
if skillInfo.cover_unlock then
|
if skillInfo.cover_unlock then
|
||||||
entity:removeLinkCountMoreEffects(skillInfo.cover_unlock)
|
entity:removeLinkCountMoreEffects(skillInfo.cover_unlock)
|
||||||
@ -338,22 +338,22 @@ local _addLinkCountMoreEffect = function(skillId, skillInfo, battleData, battleC
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local _addLinkCountPowerEffect = function(skillId, skillInfo, battleData, battleController)
|
local _addLinkCountPowerEffect = function(skillId, skillInfo, battleData, battleController, value, side)
|
||||||
local elementType = skillInfo.skill_position
|
local elementType = skillInfo.skill_position
|
||||||
if not elementType or not skillInfo.effect or not skillInfo.parameter then
|
if not elementType or not skillInfo.effect or not skillInfo.parameter then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if not battleController.battleData or not battleController.battleData.atkTeam then
|
if not battleData.atkTeam then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local unitEntity = battleController.battleData.atkTeam:getAllMembers()[elementType]
|
local unitEntity = battleData.atkTeam:getAllMembers()[elementType]
|
||||||
if not unitEntity then
|
if not unitEntity then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local entity = battleData:getSkillEntityByElement(elementType)
|
local entity = battleData:getSkillEntityByElement(elementType, side)
|
||||||
if entity then
|
if entity then
|
||||||
if skillInfo.cover_unlock then
|
if skillInfo.cover_unlock then
|
||||||
entity:removeLinkCountPowerEffects(skillInfo.cover_unlock)
|
entity:removeLinkCountPowerEffects(skillInfo.cover_unlock)
|
||||||
@ -367,7 +367,7 @@ local _addLinkCountPowerEffect = function(skillId, skillInfo, battleData, battle
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local _addSkillRatio = function(skillId, skillInfo, battleData, battleController)
|
local _addSkillRatio = function(skillId, skillInfo, battleData, battleController, value, side)
|
||||||
local elementType = skillInfo.skill_position
|
local elementType = skillInfo.skill_position
|
||||||
if not elementType or not skillInfo.parameter then
|
if not elementType or not skillInfo.parameter then
|
||||||
return
|
return
|
||||||
@ -380,7 +380,7 @@ local _addSkillRatio = function(skillId, skillInfo, battleData, battleController
|
|||||||
end
|
end
|
||||||
|
|
||||||
local effect
|
local effect
|
||||||
local skillEntity = battleData:getSkillEntityByElement(elementType)
|
local skillEntity = battleData:getSkillEntityByElement(elementType, side)
|
||||||
if skillEntity and skillEntity:getEffect() then
|
if skillEntity and skillEntity:getEffect() then
|
||||||
local effectCfg = skillEntity:getEffect()[index]
|
local effectCfg = skillEntity:getEffect()[index]
|
||||||
if effectCfg then
|
if effectCfg then
|
||||||
@ -424,7 +424,7 @@ BattleRogueSkillHandle._effectOn = {
|
|||||||
[16] = _addSkillRatio, -- 增加技能效果概率
|
[16] = _addSkillRatio, -- 增加技能效果概率
|
||||||
}
|
}
|
||||||
|
|
||||||
function BattleRogueSkillHandle.takeEffect(skillId, battleData, battleController, value)
|
function BattleRogueSkillHandle.takeEffect(skillId, battleData, battleController, value, side)
|
||||||
local cfg = SKILL_ROGUE_CFG[skillId]
|
local cfg = SKILL_ROGUE_CFG[skillId]
|
||||||
if not cfg or not cfg.type then
|
if not cfg or not cfg.type then
|
||||||
return
|
return
|
||||||
@ -432,7 +432,7 @@ function BattleRogueSkillHandle.takeEffect(skillId, battleData, battleController
|
|||||||
|
|
||||||
local func = BattleRogueSkillHandle._effectOn[cfg.type]
|
local func = BattleRogueSkillHandle._effectOn[cfg.type]
|
||||||
if func then
|
if func then
|
||||||
func(skillId, cfg, battleData, battleController, value)
|
func(skillId, cfg, battleData, battleController, value, side)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
2280
lua/app/ui/battle/battle_base_ui.lua
Normal file
2280
lua/app/ui/battle/battle_base_ui.lua
Normal file
File diff suppressed because it is too large
Load Diff
10
lua/app/ui/battle/battle_base_ui.lua.meta
Normal file
10
lua/app/ui/battle/battle_base_ui.lua.meta
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 700cd627202b40748b9047674c4628fa
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||||
224
lua/app/ui/battle/battle_ui_pvp.lua
Normal file
224
lua/app/ui/battle/battle_ui_pvp.lua
Normal file
@ -0,0 +1,224 @@
|
|||||||
|
local BattleBaseUI = require "app/ui/battle/battle_base_ui"
|
||||||
|
local BattleUIPVP = class("BattleUIPVP", BattleBaseUI)
|
||||||
|
|
||||||
|
local DEFAULT_X = 10000
|
||||||
|
local BOARD_POS_UP = BF.Vector2(0, 47)
|
||||||
|
local BOARD_POS_DOWN = BF.Vector2(0, -740)
|
||||||
|
|
||||||
|
---------------------------------必须重写的方法----------------------------------
|
||||||
|
function BattleBaseUI:initBaseInfo()
|
||||||
|
local uiMap = self.root:genAllChildren()
|
||||||
|
self.uiMap = uiMap
|
||||||
|
self.gridNode = uiMap["battle_ui_pvp.board_root_node.board_node_atk.grid_node"]
|
||||||
|
self.boardNode = uiMap["battle_ui_pvp.board_root_node.board_node_atk"]
|
||||||
|
self.boardNode:setAnchoredPositionX(DEFAULT_X)
|
||||||
|
self.boardMask2D = self.gridNode:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_RECT_MASK_2D)
|
||||||
|
self.boardMask = uiMap["battle_ui_pvp.board_root_node.board_node_atk.grid_node.board_mask"]
|
||||||
|
self.boardMask:setVisible(false)
|
||||||
|
self.boardCacheNode = uiMap["battle_ui.bg_2.board_cache_node"]
|
||||||
|
self.boardCacheNode:setVisible(false)
|
||||||
|
self.boardCacheBox = uiMap["battle_ui.bg_2.board_cache_node.skill_box"]
|
||||||
|
self.boardCacheBox:setAnchoredPositionX(DEFAULT_X)
|
||||||
|
self.battleRoot = uiMap["battle_ui.battle_root"]
|
||||||
|
self.maxLayerNode = uiMap["battle_ui.battle_root.battle_node.max_layer_show_node"]
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleUIPVP:initBg()
|
||||||
|
self.bg = self.uiMap["battle_ui.battle_root.bg"]
|
||||||
|
self.bg:setLocalScale(0, 0, 0)
|
||||||
|
local width = self.bg:fastGetSizeDelta()
|
||||||
|
self.bg:setAnchoredPositionX(width/4)
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleUIPVP:initSkill()
|
||||||
|
local uiMap = self.root:genAllChildren()
|
||||||
|
local atkNode = uiMap["battle_ui_pvp.bottom_node.skill_node"]
|
||||||
|
local defNode = uiMap["battle_ui_pvp.top_node.skill_node"]
|
||||||
|
local atkCellPrefix = "battle_ui_pvp.bottom_node.skill_node.skill_node_cell_"
|
||||||
|
local defCellPrefix = "battle_ui_pvp.top_node.skill_node.skill_node_cell_"
|
||||||
|
self:_initSkill(atkNode, atkCellPrefix, defNode, defCellPrefix)
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleUIPVP:initBuff()
|
||||||
|
local atkBuffPrefix = "battle_ui_pvp.bottom_node.buff.tiny_buff_cell_"
|
||||||
|
local defBuffPrefix = "battle_ui_pvp.top_node.buff.tiny_buff_cell_"
|
||||||
|
local battleBuffTipsRoot = self.uiMap["battle_ui_pvp.battle_buff_tips"]
|
||||||
|
local battleBuffTipsMask = self.uiMap["battle_ui_pvp.battle_buff_tips.mask"]
|
||||||
|
local battleBuffTipsBg = self.uiMap["battle_ui_pvp.battle_buff_tips.bg"]
|
||||||
|
local battleBuffTipsBuff = self.uiMap["battle_ui_pvp.battle_buff_tips.bg.buff"]
|
||||||
|
self:_initBuff(atkBuffPrefix, defBuffPrefix, battleBuffTipsRoot, battleBuffTipsMask, battleBuffTipsBg, battleBuffTipsBuff)
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleUIPVP:initBattlefield()
|
||||||
|
self.battleNode = self.uiMap["battle_ui.battle_root.battle_node"]
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleUIPVP:initNumberNode()
|
||||||
|
self.battleNumberNode = self.uiMap["battle_ui_pvp.battle_root.battle_number_node"]
|
||||||
|
self.battleNumberRed = self.uiMap["battle_ui_pvp.cache_node.battle_number_red"]
|
||||||
|
self.battleNumberGreen = self.uiMap["battle_ui_pvp.cache_node.battle_number_green"]
|
||||||
|
self.battleNumberBlue = self.uiMap["battle_ui_pvp.cache_node.battle_number_blue"]
|
||||||
|
self.battleNumberWhite = self.uiMap["battle_ui_pvp.cache_node.battle_number_white"]
|
||||||
|
self.battleNumberSpecial = self.uiMap["battle_ui_pvp.cache_node.battle_number_special"]
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseUI:initComboNode()
|
||||||
|
self.comboNode = self.uiMap["battle_ui_pvp.battle_root.combo"]
|
||||||
|
self.comboBg1 = self.uiMap["battle_ui_pvp.battle_root.combo.bg.bg_1"]
|
||||||
|
self.comboTx1 = self.uiMap["battle_ui_pvp.battle_root.combo.number.text.text_1"]
|
||||||
|
self.comboTx2 = self.uiMap["battle_ui_pvp.battle_root.combo.number.text.text_2"]
|
||||||
|
self.comboFx1 = self.uiMap["battle_ui_pvp.battle_root.combo.bg.vfx_ui_hit_b01"]
|
||||||
|
self.comboFx2 = self.uiMap["battle_ui_pvp.battle_root.combo.bg.vfx_ui_hit_b02"]
|
||||||
|
self.comboFx3 = self.uiMap["battle_ui_pvp.battle_root.combo.bg.vfx_ui_hit_b03"]
|
||||||
|
self:_initComboNode()
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseUI:initHpNode()
|
||||||
|
self.hpProgressLeft = self.uiMap["battle_ui_pvp.bottom_node.hp_node.hp_progress"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
|
||||||
|
self.hpProgressRight = self.uiMap["battle_ui_pvp.top_node.hp_node.hp_progress"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
|
||||||
|
self.hpTextLeft = self.uiMap["battle_ui_pvp.bottom_node.hp_node.hp"]
|
||||||
|
self.hpTextRight = self.uiMap["battle_ui_pvp.top_node.hp_node.hp"]
|
||||||
|
self.hpProgressYellowLeft = self.uiMap["battle_ui_pvp.bottom_node.hp_node.hp_progress_yellow"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
|
||||||
|
self.hpProgressYellowRight = self.uiMap["battle_ui_pvp.top_node.hp_node.hp_progress_yellow"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
|
||||||
|
self:_initHpNode()
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleUIPVP:initFxNode()
|
||||||
|
self.fxNode = self.uiMap["battle_ui.battle_root.batttle_fx_node"]
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleUIPVP:hideGenerateSkillGridCells()
|
||||||
|
local generateSkillCellPrefix = "battle_ui_pvp.board_root_node.ani_node.grid_cell_"
|
||||||
|
self:_hideGenerateSkillGridCells(generateSkillCellPrefix)
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseUI:initSkillLineSfx()
|
||||||
|
if not self.skillLineSfxs then
|
||||||
|
self.skillLineSfxs = {}
|
||||||
|
self.skillLineSfxs[13] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b01_2_1h"]
|
||||||
|
self.skillLineSfxs[11] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b01_2_1v"]
|
||||||
|
self.skillLineSfxs[15] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b01_2_1l"]
|
||||||
|
self.skillLineSfxs[17] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b01_2_1r"]
|
||||||
|
|
||||||
|
self.skillLineSfxs[23] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b01_1_2h"]
|
||||||
|
self.skillLineSfxs[21] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b01_1_2v"]
|
||||||
|
self.skillLineSfxs[25] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b01_1_2l"]
|
||||||
|
self.skillLineSfxs[27] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b01_1_2r"]
|
||||||
|
|
||||||
|
self.skillLineSfxs[33] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b01_3h"]
|
||||||
|
self.skillLineSfxs[31] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b01_3v"]
|
||||||
|
self.skillLineSfxs[35] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b01_3l"]
|
||||||
|
self.skillLineSfxs[37] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b01_3r"]
|
||||||
|
end
|
||||||
|
|
||||||
|
if not self.skillLightSfxs then
|
||||||
|
self.skillLightSfxs = {}
|
||||||
|
self.skillLightSfxs.point = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b03"]
|
||||||
|
self.skillLightSfxs[11] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b04_1"]
|
||||||
|
self.skillLightSfxs[12] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b04_2"]
|
||||||
|
self.skillLightSfxs[13] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b04_3"]
|
||||||
|
self.skillLightSfxs[14] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b04_4"]
|
||||||
|
self.skillLightSfxs[15] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b04_5"]
|
||||||
|
|
||||||
|
self.skillLightSfxs[21] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b05_1"]
|
||||||
|
self.skillLightSfxs[22] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b05_2"]
|
||||||
|
self.skillLightSfxs[23] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b05_3"]
|
||||||
|
self.skillLightSfxs[24] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b05_4"]
|
||||||
|
self.skillLightSfxs[25] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b05_5"]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleUIPVP:initGenerateSkillEffect()
|
||||||
|
local generateSkillEffecPrefix = "battle_ui_pvp.board_root_node.ani_node.grid_cell_"
|
||||||
|
self:_initGenerateSkillEffect(generateSkillEffecPrefix)
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleUIPVP:initCounterAttack()
|
||||||
|
self.counterAttackNode = self.uiMap["battle_ui_pvp.battle_root.counter_attack"]
|
||||||
|
self.counterTx = self.uiMap["battle_ui_pvp.battle_root.counter_attack.text_number"]
|
||||||
|
self.counterTxbgComp = self.uiMap["battle_ui_pvp.battle_root.counter_attack.bg"]
|
||||||
|
self.counterTxTmp = self.counterTx:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO)
|
||||||
|
self.counterAttackNode:setVisible(false)
|
||||||
|
end
|
||||||
|
|
||||||
|
--------------------------------end必须重写的方法--------------------------------
|
||||||
|
|
||||||
|
function BattleUIPVP:getPrefabPath()
|
||||||
|
return "assets/prefabs/ui/battle/battle_ui_pvp.prefab"
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleUIPVP:getBGMId()
|
||||||
|
return AudioManager.BGM_ID.BATTLE
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleUIPVP:_display()
|
||||||
|
BattleBaseUI._display(self)
|
||||||
|
self:refreshAvatar()
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleUIPVP:_addListeners()
|
||||||
|
local uiMap = self.root:genAllChildren()
|
||||||
|
uiMap["battle_ui.top_node.close_btn"]:addClickListener(function()
|
||||||
|
ModuleManager.BattleManager:showPauseUI(self.battleController.battleType)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleUIPVP:refreshAvatar()
|
||||||
|
-- 等数据
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleUIPVP:showLeftBuffTips(buffList, autoClose)
|
||||||
|
local addY = self:showBuffTips(buffList, autoClose)
|
||||||
|
self.battleBuffTipsBg:setAnchoredPosition(-175, -1018 + addY)
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleUIPVP:showRightBuffTips(buffList, autoClose)
|
||||||
|
self:showBuffTips(buffList, autoClose)
|
||||||
|
self.battleBuffTipsBg:setAnchoredPosition(175, -188)
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleUIPVP:switchBoard(downCallback, callback, isFirst)
|
||||||
|
if self.switchBoardSeq then
|
||||||
|
self.switchBoardSeq:Kill()
|
||||||
|
self.switchBoardSeq = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
if isFirst then
|
||||||
|
if downCallback then
|
||||||
|
downCallback()
|
||||||
|
end
|
||||||
|
if callback then
|
||||||
|
callback()
|
||||||
|
end
|
||||||
|
self.boardNode:setAnchoredPositionY(BOARD_POS_UP.y)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
self.switchBoardSeq = self.root:createBindTweenSequence()
|
||||||
|
self.switchBoardSeq:Append(self.boardNode:getTransform():DOAnchorPos(BOARD_POS_DOWN, 0.5))
|
||||||
|
self.switchBoardSeq:AppendCallback(function()
|
||||||
|
if downCallback then
|
||||||
|
downCallback()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
self.switchBoardSeq:Append(self.boardNode:getTransform():DOAnchorPos(BOARD_POS_UP, 0.5))
|
||||||
|
self.switchBoardSeq:AppendCallback(function()
|
||||||
|
if callback then
|
||||||
|
callback()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleUIPVP:refreshWave(wave, iconAtlas, iconName)
|
||||||
|
local uiMap = self.root:genAllChildren()
|
||||||
|
local icon = uiMap["battle_ui_pvp.bottom_node.round_icon"]
|
||||||
|
local desc = uiMap["battle_ui_pvp.bottom_node.round_text"]
|
||||||
|
desc:setText(wave)
|
||||||
|
GFunc.centerImgAndTx(icon, desc, 10)
|
||||||
|
|
||||||
|
iconAtlas = iconAtlas or GConst.ATLAS_PATH.COMMON
|
||||||
|
iconName = iconName or "common_dec_3"
|
||||||
|
icon:setSprite(iconAtlas, iconName)
|
||||||
|
end
|
||||||
|
|
||||||
|
return BattleUIPVP
|
||||||
10
lua/app/ui/battle/battle_ui_pvp.lua.meta
Normal file
10
lua/app/ui/battle/battle_ui_pvp.lua.meta
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 00c01ea12e6e5c34aa6c429a97788617
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||||
15
lua/app/ui/battle/cell/tiny_buff_cell.lua
Normal file
15
lua/app/ui/battle/cell/tiny_buff_cell.lua
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
local TinyBuffCell = class("TinyBuffCell", BaseCell)
|
||||||
|
|
||||||
|
function TinyBuffCell:refresh(buffName, round)
|
||||||
|
if round <= 1 or round > 9 then
|
||||||
|
round:setText(GConst.EMPTY_STRING)
|
||||||
|
else
|
||||||
|
round:setText(tostring(round))
|
||||||
|
end
|
||||||
|
|
||||||
|
local uiMap = self:getUIMap()
|
||||||
|
uiMap["tiny_buff_cell.buff_icon"]:setSprite(GConst.ATLAS_PATH.ICON_BUFF, buffName)
|
||||||
|
uiMap["tiny_buff_cell.round_text"]:setText(round)
|
||||||
|
end
|
||||||
|
|
||||||
|
return TinyBuffCell
|
||||||
10
lua/app/ui/battle/cell/tiny_buff_cell.lua.meta
Normal file
10
lua/app/ui/battle/cell/tiny_buff_cell.lua.meta
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1356c2d5313eee54ebd648608b523117
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||||
720
lua/app/userdata/battle/battle_base_data.lua
Normal file
720
lua/app/userdata/battle/battle_base_data.lua
Normal file
@ -0,0 +1,720 @@
|
|||||||
|
local BattleTeamEntity = require "app/userdata/battle/team/battle_team_entity"
|
||||||
|
local BattleSkillEntity = require "app/userdata/battle/skill/battle_skill_entity"
|
||||||
|
local BattleBaseData = class("BattleBaseData", BaseData)
|
||||||
|
|
||||||
|
local SKILL_CFG = ConfigManager:getConfig("skill")
|
||||||
|
local BattleConst = GConst.BattleConst
|
||||||
|
local BATTLE_GRID_ENTITY = require "app/userdata/battle/battle_grid_entity"
|
||||||
|
local BATTLE_BOARD_SKILL_ENTITY = require "app/userdata/battle/skill/battle_board_skill_entity"
|
||||||
|
|
||||||
|
local ATTR_TYPE = GConst.ATTR_TYPE
|
||||||
|
local DEFAULT_FACTOR = BattleConst.DEFAULT_FACTOR
|
||||||
|
local TIME_SPEED_LEVEL_0 = 0
|
||||||
|
local TIME_SPEED_LEVEL_1 = 1
|
||||||
|
local TIME_SPEED_LEVEL_2 = 2
|
||||||
|
local TIME_SPEED_LEVEL_3 = 3
|
||||||
|
local TIME_SPEED_LEVEL_SKILL = 100
|
||||||
|
local SIDE_ATK = BattleConst.SIDE_ATK
|
||||||
|
local SIDE_DEF = BattleConst.SIDE_DEF
|
||||||
|
|
||||||
|
----------------------------------按需重写的方法-------------------------------
|
||||||
|
function BattleBaseData:getRowCount()
|
||||||
|
return BattleConst.PVP_ROW_COUNT
|
||||||
|
end
|
||||||
|
---------------------------------end按需重写的方法-------------------------------
|
||||||
|
|
||||||
|
function BattleBaseData:init(params)
|
||||||
|
self:clear()
|
||||||
|
self.battleLv = 1
|
||||||
|
self.curBattleExp = 0
|
||||||
|
self.needBattleExp = self:getLvNeedExp()
|
||||||
|
self.addLvCount = 0
|
||||||
|
self.commonSelectSkillCount = 0
|
||||||
|
self.timeScale = BattleConst.TIME_SCALE.LEVEL_1
|
||||||
|
self.lockElementMap = {}
|
||||||
|
self.data.timeSpeed = 1
|
||||||
|
self.data.lvDirty = false
|
||||||
|
self.adRefreshSkillCount = 0
|
||||||
|
self.refreshSkillCount = 0
|
||||||
|
BattleSkillEntity.sid = 0
|
||||||
|
self.atkTeam = self:initTeam(SIDE_ATK, params.atkFormation)
|
||||||
|
self.defTeam = self:initTeam(SIDE_DEF, params.defFormation)
|
||||||
|
self:initRogueSkills(SIDE_ATK, params.atkFormation)
|
||||||
|
self:initRogueSkills(SIDE_DEF, params.defFormation)
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:getTimeScale()
|
||||||
|
return self.timeScale
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:pauseBattle()
|
||||||
|
self.cacheSpeed = self.data.timeSpeed
|
||||||
|
self.cacheTimeScale = self.timeScale
|
||||||
|
self:setTimeSpeed(TIME_SPEED_LEVEL_0)
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:resumeBattle()
|
||||||
|
if self.cacheSpeed == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if self.data.timeSpeed ~= TIME_SPEED_LEVEL_0 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
self:setTimeSpeed(self.cacheSpeed or TIME_SPEED_LEVEL_1, self.cacheTimeScale)
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:resetTimeSpeed()
|
||||||
|
if self.cacheSpeed then -- 目前处于暂停状态
|
||||||
|
self.cacheSpeed = TIME_SPEED_LEVEL_1
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if self.data.timeSpeed <= TIME_SPEED_LEVEL_1 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
self:setTimeSpeed(TIME_SPEED_LEVEL_1)
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:addTimeSpeed()
|
||||||
|
if self.data.timeSpeed >= TIME_SPEED_LEVEL_3 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if self.cacheSpeed then -- 目前处于暂停状态
|
||||||
|
if self.cacheSpeed < TIME_SPEED_LEVEL_3 then
|
||||||
|
self.cacheSpeed = self.cacheSpeed + 1
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local timeSpeed = self.data.timeSpeed + 1
|
||||||
|
self:setTimeSpeed(timeSpeed)
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:setSkillTimeSpeed(timeScale)
|
||||||
|
self:setTimeSpeed(TIME_SPEED_LEVEL_SKILL, timeScale)
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:setTimeSpeed(timeSpeed, timeScale)
|
||||||
|
if timeSpeed == self.data.timeSpeed then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if timeSpeed == TIME_SPEED_LEVEL_0 then
|
||||||
|
self.timeScale = 0
|
||||||
|
elseif timeSpeed == TIME_SPEED_LEVEL_1 then
|
||||||
|
self.timeScale = BattleConst.TIME_SCALE.LEVEL_1
|
||||||
|
elseif timeSpeed == TIME_SPEED_LEVEL_2 then
|
||||||
|
self.timeScale = BattleConst.TIME_SCALE.LEVEL_2
|
||||||
|
elseif timeSpeed == TIME_SPEED_LEVEL_3 then
|
||||||
|
self.timeScale = BattleConst.TIME_SCALE.LEVEL_3
|
||||||
|
else
|
||||||
|
self.timeScale = timeScale or BattleConst.TIME_SCALE.LEVEL_1
|
||||||
|
end
|
||||||
|
self.data.timeSpeed = timeSpeed
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:initRogueSkills(side, formation)
|
||||||
|
if not self.skillPool then
|
||||||
|
self.skillPool = {}
|
||||||
|
self.skillMap = {}
|
||||||
|
end
|
||||||
|
if not self.skillPool[side] then
|
||||||
|
self.skillPool[side] = {}
|
||||||
|
end
|
||||||
|
if not self.skillMap[side] then
|
||||||
|
self.skillMap[side] = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
if not formation then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local skillmap = {}
|
||||||
|
for matchType, heroEntity in pairs(formation) do
|
||||||
|
local skillId = heroEntity:getBaseSkill()
|
||||||
|
local cfg = SKILL_CFG[skillId]
|
||||||
|
self.skillMap[side][cfg.position] = BATTLE_BOARD_SKILL_ENTITY:create(skillId)
|
||||||
|
self.skillMap[side][cfg.position]:addUpSkills(heroEntity:getRogueSkillList())
|
||||||
|
self.skillMap[side][cfg.position]:setUnlockId(heroEntity:getUnlockRogueId())
|
||||||
|
for _, id in ipairs(heroEntity:getActiveRogueSkills()) do
|
||||||
|
if not skillmap[id] then
|
||||||
|
if not self.skillPool[side][cfg.position] then
|
||||||
|
self.skillPool[side][cfg.position] = {}
|
||||||
|
end
|
||||||
|
table.insert(self.skillPool[side][cfg.position], id)
|
||||||
|
skillmap[id] = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:refreshBoard(board, blockIcon)
|
||||||
|
local r = 1
|
||||||
|
local c = 1
|
||||||
|
|
||||||
|
for i, info in ipairs(board) do
|
||||||
|
if c > BattleConst.COLUMN_COUNT then
|
||||||
|
c = c - BattleConst.COLUMN_COUNT
|
||||||
|
r = r + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
local posId = ModuleManager.BattleManager:getPosId(r, c)
|
||||||
|
local data = {
|
||||||
|
posId = posId,
|
||||||
|
gridType = info[1] or BattleConst.GRID_TYPE.EMPTY,
|
||||||
|
elementType = info[2] or BattleConst.ELEMENT_TYPE.RED
|
||||||
|
}
|
||||||
|
if not self.gridEntities then
|
||||||
|
self.gridEntities = {}
|
||||||
|
end
|
||||||
|
if self.gridEntities[data.posId] then
|
||||||
|
self.gridEntities[data.posId]:clear()
|
||||||
|
self.gridEntities[data.posId]:setGridType(data.gridType)
|
||||||
|
self.gridEntities[data.posId]:setElementType(data.elementType)
|
||||||
|
else
|
||||||
|
self.gridEntities[data.posId] = BATTLE_GRID_ENTITY:create(data)
|
||||||
|
end
|
||||||
|
self.gridEntities[data.posId]:determineIdleStatus()
|
||||||
|
self.gridEntities[data.posId]:setObstacleIcon(blockIcon)
|
||||||
|
c = c + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:getNewGridEntity(posId, gridType, elementType)
|
||||||
|
local data = {
|
||||||
|
posId = posId or 0,
|
||||||
|
gridType = gridType or BattleConst.GRID_TYPE.EMPTY,
|
||||||
|
elementType = elementType or BattleConst.ELEMENT_TYPE.RED
|
||||||
|
}
|
||||||
|
return BATTLE_GRID_ENTITY:create(data)
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:clear()
|
||||||
|
self:clearGridSequence()
|
||||||
|
self:clearCacheBoardSkill()
|
||||||
|
|
||||||
|
self.gridEntities = {}
|
||||||
|
self.skillMap = {}
|
||||||
|
self.selectSkillMap = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:getElementTypeMap()
|
||||||
|
local elementTypeMap = {}
|
||||||
|
if self.gridEntities then
|
||||||
|
for posId, entity in pairs(self.gridEntities) do
|
||||||
|
if entity:canLink() then
|
||||||
|
local elementType = entity:getElementType()
|
||||||
|
elementTypeMap[elementType] = (elementTypeMap[elementType] or 0) + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return elementTypeMap
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:getGridSequence()
|
||||||
|
return self.gridSequence
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:alreadyInsertSequence(posId)
|
||||||
|
return self.gridSequenceMap[posId] == true
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:getIsVirtual()
|
||||||
|
return self.isVirtual
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:getSequenceHadSkill()
|
||||||
|
for _, info in ipairs(self:getGridSequence()) do
|
||||||
|
local entity = self.gridEntities[info.posId]
|
||||||
|
if entity and entity:getSkillId() then
|
||||||
|
return entity:getSkillId(), entity:getPosId()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:insertGridSequence(posId, snapshot, isVirtual)
|
||||||
|
if self:alreadyInsertSequence(posId) then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
self.gridSequenceMap[posId] = true
|
||||||
|
self.isVirtual = isVirtual
|
||||||
|
table.insert(self.gridSequence, {posId = posId, snapshot = snapshot})
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:removeGridSequence(posId)
|
||||||
|
if not self:alreadyInsertSequence(posId) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local count = #self.gridSequence
|
||||||
|
local lastPosId = self.gridSequence[count].posId
|
||||||
|
local snapshot = self.gridSequence[count].snapshot
|
||||||
|
if lastPosId ~= posId then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
table.remove(self.gridSequence, count)
|
||||||
|
self.gridSequenceMap[lastPosId] = false
|
||||||
|
return snapshot
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:getFirstSequenceSnapshot()
|
||||||
|
if not self.gridSequence[1] then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local snapshot = self.gridSequence[1].snapshot
|
||||||
|
return snapshot
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:cacheSkillInfluenceGrids(grids)
|
||||||
|
if not self.skillInfluenceGrids then
|
||||||
|
self.skillInfluenceGrids = {}
|
||||||
|
end
|
||||||
|
for posId, info in pairs(grids) do
|
||||||
|
self.skillInfluenceGrids[posId] = info
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:getSkillInfluenceGrids()
|
||||||
|
return self.skillInfluenceGrids or {}
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:clearSkillInfluenceGrids()
|
||||||
|
local grids = self:getSkillInfluenceGrids()
|
||||||
|
self.skillInfluenceGrids = {} -- 技能影响的格子
|
||||||
|
return grids
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:clearGridSequence()
|
||||||
|
self.gridSequence = {} -- 格子队列
|
||||||
|
self.gridSequenceMap = {} -- 格子队列对应的map,方面查找
|
||||||
|
self.isVirtual = nil
|
||||||
|
self:clearSkillInfluenceGrids()
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:getGridEnties()
|
||||||
|
return self.gridEntities or {}
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:getGridEntity(posId)
|
||||||
|
return self.gridEntities[posId]
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:exchangeGridEntities(posId1, posId2)
|
||||||
|
local e1 = self.gridEntities[posId1]
|
||||||
|
local e2 = self.gridEntities[posId2]
|
||||||
|
e1:setPosId(posId2)
|
||||||
|
e2:setPosId(posId1)
|
||||||
|
e2:setIsIdle(false)
|
||||||
|
self.gridEntities[posId1] = e2
|
||||||
|
self.gridEntities[posId2] = e1
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:setGridEntitiesPosId(changeInfo)
|
||||||
|
local map = {}
|
||||||
|
for posId, targetPosId in pairs(changeInfo) do
|
||||||
|
local entity = self.gridEntities[posId]
|
||||||
|
entity:setPosId(targetPosId)
|
||||||
|
map[targetPosId] = entity
|
||||||
|
end
|
||||||
|
|
||||||
|
for posId, entity in pairs(map) do
|
||||||
|
self.gridEntities[posId] = entity
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:setGridInfo(posId, gridInfo)
|
||||||
|
local entity = self.gridEntities[posId]
|
||||||
|
if not entity then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if gridInfo.gridType then
|
||||||
|
entity:setGridType(gridInfo.gridType)
|
||||||
|
end
|
||||||
|
|
||||||
|
if gridInfo.elementType then
|
||||||
|
entity:setElementType(gridInfo.elementType)
|
||||||
|
end
|
||||||
|
|
||||||
|
entity:setSkilId() -- 清除skillId
|
||||||
|
entity:determineIdleStatus()
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:setInfoBySnapshop(posId, snapInfo)
|
||||||
|
local entity = self.gridEntities[posId]
|
||||||
|
if not entity then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
entity:setInfoBySnapshop(snapInfo)
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:setGridType(posId, gridType, noDirty)
|
||||||
|
local entity = self.gridEntities[posId]
|
||||||
|
if not entity then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
entity:setGridType(gridType, noDirty)
|
||||||
|
entity:determineIdleStatus()
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:setGridDirty(posId)
|
||||||
|
local entity = self.gridEntities[posId]
|
||||||
|
if not entity then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
entity:setDirty()
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:lockAllSkillGrid(lock)
|
||||||
|
if not self.gridEntities then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
for posId, entity in pairs(self.gridEntities) do
|
||||||
|
if entity:getSkillId() then
|
||||||
|
local gridType = GConst.BattleConst.GRID_TYPE.EMPTY
|
||||||
|
if lock then
|
||||||
|
gridType = GConst.BattleConst.GRID_TYPE.LOCK
|
||||||
|
end
|
||||||
|
self:setGridType(posId, gridType)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:getSkillEntities(side)
|
||||||
|
side = side or SIDE_ATK
|
||||||
|
if self.skillMap then
|
||||||
|
return self.skillMap[side] or {}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:getSkillEntityByElement(elementType, side)
|
||||||
|
local skillMap = self:getSkillEntities(side)
|
||||||
|
if not skillMap then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
return skillMap[elementType]
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:getSkillEntityBySkillId(skillId, side)
|
||||||
|
local skillMap = self:getSkillEntities(side)
|
||||||
|
if not skillMap or not skillId then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local cfg = SKILL_CFG[skillId]
|
||||||
|
if not cfg then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
return skillMap[cfg.position]
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:unlockSkillEntity(elementType, side)
|
||||||
|
local skillMap = self:getSkillEntities(side)
|
||||||
|
if skillMap and skillMap[elementType] then
|
||||||
|
skillMap[elementType]:setUnlock()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:isUnlockedSkillElementType(elementType, side)
|
||||||
|
local skillMap = self:getSkillEntities(side)
|
||||||
|
if not skillMap or not skillMap[elementType] then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
return skillMap[elementType]:getUnlocked()
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:addSkillEnergy(elementMap, side)
|
||||||
|
local skillMap = self:getSkillEntities(side)
|
||||||
|
if not skillMap then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
for elementType, entity in pairs(skillMap) do
|
||||||
|
if entity:getUnlocked() then
|
||||||
|
entity:addEnergy(elementMap[elementType] or 0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:addSkillCount(skillId, value, side)
|
||||||
|
side = side or SIDE_ATK
|
||||||
|
if not self.selectSkillMap then
|
||||||
|
self.selectSkillMap = {}
|
||||||
|
end
|
||||||
|
if not self.selectSkillMap[side] then
|
||||||
|
self.selectSkillMap[side] = {}
|
||||||
|
end
|
||||||
|
if not self.selectSkillMap[side][skillId] then
|
||||||
|
self.selectSkillMap[side][skillId] = {
|
||||||
|
count = 0,
|
||||||
|
value = 0
|
||||||
|
}
|
||||||
|
end
|
||||||
|
self.selectSkillMap[side][skillId].count = self.selectSkillMap[side][skillId].count + 1
|
||||||
|
if value then
|
||||||
|
self.selectSkillMap[side][skillId].value = (self.selectSkillMap[side][skillId].value) + value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:getSkillCount(skillId, side)
|
||||||
|
side = side or SIDE_ATK
|
||||||
|
if self.selectSkillMap[side] and self.selectSkillMap[side][skillId] then
|
||||||
|
return self.selectSkillMap[side][skillId].count
|
||||||
|
end
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:getSelectSkillMap(side)
|
||||||
|
side = side or SIDE_ATK
|
||||||
|
return self.selectSkillMap and self.selectSkillMap[side] or {}
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:getSkillPool(side)
|
||||||
|
side = side or SIDE_ATK
|
||||||
|
return self.skillPool and self.skillPool[side] or {}
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:changeSkillId(elementType, newId, side)
|
||||||
|
if not newId then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local entity = self:getSkillEntityByElement(elementType, side)
|
||||||
|
if entity then
|
||||||
|
entity:refreshSkillId(newId)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:cacheLockElement(elementType, status)
|
||||||
|
self.lockElementMap[elementType] = status
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:getCacheLockedElement(elementType)
|
||||||
|
return self.lockElementMap[elementType]
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:cacheBoardSkill()
|
||||||
|
self.cacheSkillList = {}
|
||||||
|
self.cacheSkillCount = 0
|
||||||
|
local list
|
||||||
|
local count = 0
|
||||||
|
for posId, entity in pairs(self:getGridEnties()) do
|
||||||
|
if entity:getSkillId() then
|
||||||
|
if not list then
|
||||||
|
list = {}
|
||||||
|
end
|
||||||
|
table.insert(list, {skillId = entity:getSkillId(), posId = posId})
|
||||||
|
count = count + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if list then
|
||||||
|
if count > BattleConst.MAX_CACHE_SKILL_COUNT then
|
||||||
|
count = BattleConst.MAX_CACHE_SKILL_COUNT
|
||||||
|
end
|
||||||
|
|
||||||
|
for i = 1, count do
|
||||||
|
if not list[1] then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
local info = table.remove(list, math.random(1, #list))
|
||||||
|
table.insert(self.cacheSkillList, info)
|
||||||
|
self.cacheSkillCount = self.cacheSkillCount + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:getCacheBoardSkill()
|
||||||
|
if not self.cacheSkillList then
|
||||||
|
return self.cacheSkillList, 0
|
||||||
|
end
|
||||||
|
return self.cacheSkillList, self.cacheSkillCount
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:clearCacheBoardSkill()
|
||||||
|
self.cacheSkillList = {}
|
||||||
|
self.cacheSkillCount = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:getBattleLv()
|
||||||
|
return self.battleLv
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:getBattleExp()
|
||||||
|
return self.curBattleExp
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:getBattleNeedExp()
|
||||||
|
return self.needBattleExp
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:getLvNeedExp(lv)
|
||||||
|
lv = lv or self.battleLv
|
||||||
|
local cfg = ConfigManager:getConfig("battle_exp")
|
||||||
|
if not cfg[lv] then
|
||||||
|
return cfg[ConfigManager:getConfigNum("battle_exp")].exp
|
||||||
|
end
|
||||||
|
return cfg[lv].exp
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:addExp(exp)
|
||||||
|
self.curBattleExp = self.curBattleExp + exp
|
||||||
|
while self.curBattleExp >= self.needBattleExp do
|
||||||
|
self.curBattleExp = self.curBattleExp - self.needBattleExp
|
||||||
|
self.addLvCount = self.addLvCount + 1
|
||||||
|
self.battleLv = self.battleLv + 1
|
||||||
|
self.needBattleExp = self:getLvNeedExp()
|
||||||
|
end
|
||||||
|
self.data.lvDirty = not self.data.lvDirty
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:useAddlvCount()
|
||||||
|
if self.addLvCount <= 0 then
|
||||||
|
self.addLvCount = 0
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
self.addLvCount = self.addLvCount - 1
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:addCommonSelectSkillCount(count)
|
||||||
|
self.commonSelectSkillCount = self.commonSelectSkillCount + (count or 1)
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:useCommonSelectSkillCount()
|
||||||
|
if self.commonSelectSkillCount <= 0 then
|
||||||
|
self.commonSelectSkillCount = 0
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
self.commonSelectSkillCount = self.commonSelectSkillCount - 1
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:addRefreshSkillCount(isAd)
|
||||||
|
if isAd then
|
||||||
|
self.adRefreshSkillCount = self.adRefreshSkillCount + 1
|
||||||
|
end
|
||||||
|
self.refreshSkillCount = self.refreshSkillCount + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:getRefreshSkillCount()
|
||||||
|
return self.refreshSkillCount
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:getADRefreshSkillCount()
|
||||||
|
return self.adRefreshSkillCount
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:initTeam(side, formation)
|
||||||
|
local data = nil
|
||||||
|
data = self:initHeroData(formation)
|
||||||
|
local team = BattleTeamEntity:create()
|
||||||
|
team:init(side, data)
|
||||||
|
return team
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:getAtkTeam()
|
||||||
|
return self.atkTeam
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:getDefTeam()
|
||||||
|
return self.defTeam
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:initHeroData(formation)
|
||||||
|
local units = {}
|
||||||
|
if formation then
|
||||||
|
local skillCfg = ConfigManager:getConfig("skill")
|
||||||
|
for matchType, heroEntity in pairs(formation) do
|
||||||
|
local heroAttr = heroEntity:getAllAttr()
|
||||||
|
local skillId = heroEntity:getBaseSkill()
|
||||||
|
local hp = heroAttr[ATTR_TYPE.hp] // DEFAULT_FACTOR
|
||||||
|
local unitData = {
|
||||||
|
id = heroEntity:getCfgId(),
|
||||||
|
modelId = heroEntity:getModelId(),
|
||||||
|
matchType = matchType,
|
||||||
|
normalSkills = heroEntity:getHurtSkill(),
|
||||||
|
assistingSkill = heroEntity:getAssistingSkill(),
|
||||||
|
body = 2, -- 英雄默认是中体型
|
||||||
|
attr = {
|
||||||
|
hp = hp,
|
||||||
|
max_hp = hp,
|
||||||
|
atk = 0,
|
||||||
|
atk_red = heroAttr[ATTR_TYPE.atk_red] // DEFAULT_FACTOR,
|
||||||
|
atk_yellow = heroAttr[ATTR_TYPE.atk_yellow] // DEFAULT_FACTOR,
|
||||||
|
atk_green = heroAttr[ATTR_TYPE.atk_green] // DEFAULT_FACTOR,
|
||||||
|
atk_blue = heroAttr[ATTR_TYPE.atk_blue] // DEFAULT_FACTOR,
|
||||||
|
atk_purple = heroAttr[ATTR_TYPE.atk_purple] // DEFAULT_FACTOR,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
local skillInfo = skillCfg[skillId]
|
||||||
|
if skillInfo then
|
||||||
|
if skillInfo.effect_type == 1 then -- 主动
|
||||||
|
unitData.activeSkills = {skillId}
|
||||||
|
elseif skillInfo.effect_type == 2 then -- 被动
|
||||||
|
unitData.passiveSkills = {skillId}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
table.insert(units, unitData)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local data = {
|
||||||
|
units = units
|
||||||
|
}
|
||||||
|
return data
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:addMonster(monsterId, newTeam, battleController)
|
||||||
|
local monsterInfo = ConfigManager:getConfig("monster")[monsterId]
|
||||||
|
local hp = monsterInfo.hp // DEFAULT_FACTOR
|
||||||
|
local atk = monsterInfo.atk // DEFAULT_FACTOR
|
||||||
|
if battleController then
|
||||||
|
hp = hp * (DEFAULT_FACTOR + battleController:getMonsterHpAddition()) // DEFAULT_FACTOR
|
||||||
|
atk = atk * (DEFAULT_FACTOR + battleController:getMonsterAtkAddition()) // DEFAULT_FACTOR
|
||||||
|
end
|
||||||
|
local unitData = {
|
||||||
|
id = monsterId,
|
||||||
|
modelId = monsterInfo.model_id,
|
||||||
|
matchType = 0,
|
||||||
|
normalSkills = monsterInfo.hurt_skill,
|
||||||
|
normalSkillCount = monsterInfo.atk_times or 0,
|
||||||
|
activeSkills = monsterInfo.skill,
|
||||||
|
passiveSkills = monsterInfo.passive_skill,
|
||||||
|
assistingSkill = nil,
|
||||||
|
isBoss = monsterInfo.is_boss,
|
||||||
|
exp = monsterInfo.monster_exp or 0,
|
||||||
|
body = monsterInfo.body,
|
||||||
|
hpSkinHp = monsterInfo.monster_hp,
|
||||||
|
hpSkinSkin = monsterInfo.monster_hp_skin,
|
||||||
|
hpExp = monsterInfo.monster_hp_exp,
|
||||||
|
attr = {
|
||||||
|
hp = hp,
|
||||||
|
max_hp = hp,
|
||||||
|
atk = atk,
|
||||||
|
atk_red = 0,
|
||||||
|
atk_yellow = 0,
|
||||||
|
atk_green = 0,
|
||||||
|
atk_blue = 0,
|
||||||
|
atk_purple = 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if newTeam then
|
||||||
|
self.defTeam:init(BattleConst.SIDE_DEF)
|
||||||
|
end
|
||||||
|
return self.defTeam:addUnit(unitData)
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBaseData:getNormalAttackName(index)
|
||||||
|
if self.normalAttackName == nil then
|
||||||
|
self.normalAttackName = {}
|
||||||
|
end
|
||||||
|
local name = self.normalAttackName[index]
|
||||||
|
if name == nil then
|
||||||
|
name = string.format("attack%02d", index)
|
||||||
|
self.normalAttackName[index] = name
|
||||||
|
end
|
||||||
|
return name
|
||||||
|
end
|
||||||
|
|
||||||
|
return BattleBaseData
|
||||||
10
lua/app/userdata/battle/battle_base_data.lua.meta
Normal file
10
lua/app/userdata/battle/battle_base_data.lua.meta
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 837e21ae713803145940e1f74b06f5fd
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||||
@ -1,694 +1,10 @@
|
|||||||
local BattleTeamEntity = require "app/userdata/battle/team/battle_team_entity"
|
local BattleBaseData = require "app/userdata/battle/battle_base_data"
|
||||||
local BattleSkillEntity = require "app/userdata/battle/skill/battle_skill_entity"
|
local BattleData = class("BattleData", BattleBaseData)
|
||||||
|
|
||||||
local BattleData = class("BattleData", BaseData)
|
|
||||||
|
|
||||||
local SKILL_CFG = ConfigManager:getConfig("skill")
|
|
||||||
local BattleConst = GConst.BattleConst
|
local BattleConst = GConst.BattleConst
|
||||||
local BATTLE_GRID_ENTITY = require "app/userdata/battle/battle_grid_entity"
|
|
||||||
local BATTLE_BOARD_SKILL_ENTITY = require "app/userdata/battle/skill/battle_board_skill_entity"
|
|
||||||
|
|
||||||
local ATTR_TYPE = GConst.ATTR_TYPE
|
function BattleBaseData:getRowCount()
|
||||||
local DEFAULT_FACTOR = BattleConst.DEFAULT_FACTOR
|
return BattleConst.PVP_ROW_COUNT
|
||||||
local TIME_SPEED_LEVEL_0 = 0
|
|
||||||
local TIME_SPEED_LEVEL_1 = 1
|
|
||||||
local TIME_SPEED_LEVEL_2 = 2
|
|
||||||
local TIME_SPEED_LEVEL_3 = 3
|
|
||||||
local TIME_SPEED_LEVEL_SKILL = 100
|
|
||||||
|
|
||||||
function BattleData:init()
|
|
||||||
self:clear()
|
|
||||||
self.battleLv = 1
|
|
||||||
self.curBattleExp = 0
|
|
||||||
self.needBattleExp = self:getLvNeedExp()
|
|
||||||
self.addLvCount = 0
|
|
||||||
self.commonSelectSkillCount = 0
|
|
||||||
self.timeScale = BattleConst.TIME_SCALE.LEVEL_1
|
|
||||||
self.lockElementMap = {}
|
|
||||||
self.data.timeSpeed = 1
|
|
||||||
self.data.lvDirty = false
|
|
||||||
self.adRefreshSkillCount = 0
|
|
||||||
self.refreshSkillCount = 0
|
|
||||||
BattleSkillEntity.sid = 0
|
|
||||||
self.atkTeam = self:initTeam(BattleConst.SIDE_ATK)
|
|
||||||
self.defTeam = self:initTeam(BattleConst.SIDE_DEF)
|
|
||||||
self:initRogueSkills()
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:getTimeScale()
|
|
||||||
return self.timeScale
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:pauseBattle()
|
|
||||||
self.cacheSpeed = self.data.timeSpeed
|
|
||||||
self.cacheTimeScale = self.timeScale
|
|
||||||
self:setTimeSpeed(TIME_SPEED_LEVEL_0)
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:resumeBattle()
|
|
||||||
if self.cacheSpeed == nil then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
if self.data.timeSpeed ~= TIME_SPEED_LEVEL_0 then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
self:setTimeSpeed(self.cacheSpeed or TIME_SPEED_LEVEL_1, self.cacheTimeScale)
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:resetTimeSpeed()
|
|
||||||
if self.cacheSpeed then -- 目前处于暂停状态
|
|
||||||
self.cacheSpeed = TIME_SPEED_LEVEL_1
|
|
||||||
return
|
|
||||||
end
|
|
||||||
if self.data.timeSpeed <= TIME_SPEED_LEVEL_1 then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
self:setTimeSpeed(TIME_SPEED_LEVEL_1)
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:addTimeSpeed()
|
|
||||||
if self.data.timeSpeed >= TIME_SPEED_LEVEL_3 then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
if self.cacheSpeed then -- 目前处于暂停状态
|
|
||||||
if self.cacheSpeed < TIME_SPEED_LEVEL_3 then
|
|
||||||
self.cacheSpeed = self.cacheSpeed + 1
|
|
||||||
end
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local timeSpeed = self.data.timeSpeed + 1
|
|
||||||
self:setTimeSpeed(timeSpeed)
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:setSkillTimeSpeed(timeScale)
|
|
||||||
self:setTimeSpeed(TIME_SPEED_LEVEL_SKILL, timeScale)
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:setTimeSpeed(timeSpeed, timeScale)
|
|
||||||
if timeSpeed == self.data.timeSpeed then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
if timeSpeed == TIME_SPEED_LEVEL_0 then
|
|
||||||
self.timeScale = 0
|
|
||||||
elseif timeSpeed == TIME_SPEED_LEVEL_1 then
|
|
||||||
self.timeScale = BattleConst.TIME_SCALE.LEVEL_1
|
|
||||||
elseif timeSpeed == TIME_SPEED_LEVEL_2 then
|
|
||||||
self.timeScale = BattleConst.TIME_SCALE.LEVEL_2
|
|
||||||
elseif timeSpeed == TIME_SPEED_LEVEL_3 then
|
|
||||||
self.timeScale = BattleConst.TIME_SCALE.LEVEL_3
|
|
||||||
else
|
|
||||||
self.timeScale = timeScale or BattleConst.TIME_SCALE.LEVEL_1
|
|
||||||
end
|
|
||||||
self.data.timeSpeed = timeSpeed
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:initRogueSkills()
|
|
||||||
self.skillPool = {}
|
|
||||||
self.skillMap = {}
|
|
||||||
local skillmap = {}
|
|
||||||
local formation = DataManager.FormationData:getStageFormation()
|
|
||||||
for matchType, heroId in pairs(formation) do
|
|
||||||
if heroId > 0 then
|
|
||||||
local heroEntity = DataManager.HeroData:getHeroById(heroId)
|
|
||||||
if heroEntity then
|
|
||||||
local skillId = heroEntity:getBaseSkill()
|
|
||||||
local cfg = SKILL_CFG[skillId]
|
|
||||||
self.skillMap[cfg.position] = BATTLE_BOARD_SKILL_ENTITY:create(skillId)
|
|
||||||
self.skillMap[cfg.position]:addUpSkills(heroEntity:getRogueSkillList())
|
|
||||||
self.skillMap[cfg.position]:setUnlockId(heroEntity:getUnlockRogueId())
|
|
||||||
for _, id in ipairs(heroEntity:getActiveTogueSkills()) do
|
|
||||||
if not skillmap[id] then
|
|
||||||
if not self.skillPool[cfg.position] then
|
|
||||||
self.skillPool[cfg.position] = {}
|
|
||||||
end
|
|
||||||
table.insert(self.skillPool[cfg.position], id)
|
|
||||||
skillmap[id] = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:refreshBoard(board, blockIcon)
|
|
||||||
for i, info in ipairs(board) do
|
|
||||||
local r = 1
|
|
||||||
local c = 1
|
|
||||||
local zheng = i // BattleConst.ROW_COUNT
|
|
||||||
local yu = i % BattleConst.ROW_COUNT
|
|
||||||
if yu > 0 then
|
|
||||||
r = zheng + 1
|
|
||||||
c = yu
|
|
||||||
else
|
|
||||||
r = zheng
|
|
||||||
c = BattleConst.ROW_COUNT
|
|
||||||
end
|
|
||||||
|
|
||||||
local posId = ModuleManager.BattleManager:getPosId(r, c)
|
|
||||||
local data = {
|
|
||||||
posId = posId,
|
|
||||||
gridType = info[1] or BattleConst.GRID_TYPE.EMPTY,
|
|
||||||
elementType = info[2] or BattleConst.ELEMENT_TYPE.RED
|
|
||||||
}
|
|
||||||
if self.gridEntities[data.posId] then
|
|
||||||
self.gridEntities[data.posId]:clear()
|
|
||||||
self.gridEntities[data.posId]:setGridType(data.gridType)
|
|
||||||
self.gridEntities[data.posId]:setElementType(data.elementType)
|
|
||||||
else
|
|
||||||
self.gridEntities[data.posId] = BATTLE_GRID_ENTITY:create(data)
|
|
||||||
end
|
|
||||||
self.gridEntities[data.posId]:determineIdleStatus()
|
|
||||||
self.gridEntities[data.posId]:setObstacleIcon(blockIcon)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:getNewGridEntity(posId, gridType, elementType)
|
|
||||||
local data = {
|
|
||||||
posId = posId or 0,
|
|
||||||
gridType = gridType or BattleConst.GRID_TYPE.EMPTY,
|
|
||||||
elementType = elementType or BattleConst.ELEMENT_TYPE.RED
|
|
||||||
}
|
|
||||||
return BATTLE_GRID_ENTITY:create(data)
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:clear()
|
|
||||||
self:clearGridSequence()
|
|
||||||
self:clearCacheBoardSkill()
|
|
||||||
|
|
||||||
self.gridEntities = {}
|
|
||||||
self.skillMap = {}
|
|
||||||
self.selectSkillMap = {}
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:getElementTypeMap()
|
|
||||||
local elementTypeMap = {}
|
|
||||||
if self.gridEntities then
|
|
||||||
for posId, entity in pairs(self.gridEntities) do
|
|
||||||
if entity:canLink() then
|
|
||||||
local elementType = entity:getElementType()
|
|
||||||
elementTypeMap[elementType] = (elementTypeMap[elementType] or 0) + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return elementTypeMap
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:getGridSequence()
|
|
||||||
return self.gridSequence
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:alreadyInsertSequence(posId)
|
|
||||||
return self.gridSequenceMap[posId] == true
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:getIsVirtual()
|
|
||||||
return self.isVirtual
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:getSequenceHadSkill()
|
|
||||||
for _, info in ipairs(self:getGridSequence()) do
|
|
||||||
local entity = self.gridEntities[info.posId]
|
|
||||||
if entity and entity:getSkillId() then
|
|
||||||
return entity:getSkillId(), entity:getPosId()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:insertGridSequence(posId, snapshot, isVirtual)
|
|
||||||
if self:alreadyInsertSequence(posId) then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
self.gridSequenceMap[posId] = true
|
|
||||||
self.isVirtual = isVirtual
|
|
||||||
table.insert(self.gridSequence, {posId = posId, snapshot = snapshot})
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:removeGridSequence(posId)
|
|
||||||
if not self:alreadyInsertSequence(posId) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local count = #self.gridSequence
|
|
||||||
local lastPosId = self.gridSequence[count].posId
|
|
||||||
local snapshot = self.gridSequence[count].snapshot
|
|
||||||
if lastPosId ~= posId then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
table.remove(self.gridSequence, count)
|
|
||||||
self.gridSequenceMap[lastPosId] = false
|
|
||||||
return snapshot
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:getFirstSequenceSnapshot(posId)
|
|
||||||
if not self.gridSequence[1] then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local snapshot = self.gridSequence[1].snapshot
|
|
||||||
return snapshot
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:cacheSkillInfluenceGrids(grids)
|
|
||||||
if not self.skillInfluenceGrids then
|
|
||||||
self.skillInfluenceGrids = {}
|
|
||||||
end
|
|
||||||
for posId, info in pairs(grids) do
|
|
||||||
self.skillInfluenceGrids[posId] = info
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:getSkillInfluenceGrids()
|
|
||||||
return self.skillInfluenceGrids or {}
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:clearSkillInfluenceGrids()
|
|
||||||
local grids = self:getSkillInfluenceGrids()
|
|
||||||
self.skillInfluenceGrids = {} -- 技能影响的格子
|
|
||||||
return grids
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:clearGridSequence()
|
|
||||||
self.gridSequence = {} -- 格子队列
|
|
||||||
self.gridSequenceMap = {} -- 格子队列对应的map,方面查找
|
|
||||||
self.isVirtual = nil
|
|
||||||
self:clearSkillInfluenceGrids()
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:getGridEnties()
|
|
||||||
return self.gridEntities or {}
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:getGridEntity(posId)
|
|
||||||
return self.gridEntities[posId]
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:exchangeGridEntities(posId1, posId2)
|
|
||||||
local e1 = self.gridEntities[posId1]
|
|
||||||
local e2 = self.gridEntities[posId2]
|
|
||||||
e1:setPosId(posId2)
|
|
||||||
e2:setPosId(posId1)
|
|
||||||
e2:setIsIdle(false)
|
|
||||||
self.gridEntities[posId1] = e2
|
|
||||||
self.gridEntities[posId2] = e1
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:setGridEntitiesPosId(changeInfo)
|
|
||||||
local map = {}
|
|
||||||
for posId, targetPosId in pairs(changeInfo) do
|
|
||||||
local entity = self.gridEntities[posId]
|
|
||||||
entity:setPosId(targetPosId)
|
|
||||||
map[targetPosId] = entity
|
|
||||||
end
|
|
||||||
|
|
||||||
for posId, entity in pairs(map) do
|
|
||||||
self.gridEntities[posId] = entity
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:setGridInfo(posId, gridInfo)
|
|
||||||
local entity = self.gridEntities[posId]
|
|
||||||
if not entity then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if gridInfo.gridType then
|
|
||||||
entity:setGridType(gridInfo.gridType)
|
|
||||||
end
|
|
||||||
|
|
||||||
if gridInfo.elementType then
|
|
||||||
entity:setElementType(gridInfo.elementType)
|
|
||||||
end
|
|
||||||
|
|
||||||
entity:setSkilId() -- 清除skillId
|
|
||||||
entity:determineIdleStatus()
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:setInfoBySnapshop(posId, snapInfo)
|
|
||||||
local entity = self.gridEntities[posId]
|
|
||||||
if not entity then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
entity:setInfoBySnapshop(snapInfo)
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:setGridType(posId, gridType, noDirty)
|
|
||||||
local entity = self.gridEntities[posId]
|
|
||||||
if not entity then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
entity:setGridType(gridType, noDirty)
|
|
||||||
entity:determineIdleStatus()
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:setGridDirty(posId)
|
|
||||||
local entity = self.gridEntities[posId]
|
|
||||||
if not entity then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
entity:setDirty()
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:lockAllSkillGrid(lock)
|
|
||||||
if not self.gridEntities then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
for posId, entity in pairs(self.gridEntities) do
|
|
||||||
if entity:getSkillId() then
|
|
||||||
local gridType = GConst.BattleConst.GRID_TYPE.EMPTY
|
|
||||||
if lock then
|
|
||||||
gridType = GConst.BattleConst.GRID_TYPE.LOCK
|
|
||||||
end
|
|
||||||
self:setGridType(posId, gridType)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
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:getSkillEntityBySkillId(skillId)
|
|
||||||
if not self.skillMap or not skillId then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local cfg = SKILL_CFG[skillId]
|
|
||||||
if not cfg then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
return self.skillMap[cfg.position]
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:unlockSkillEntity(elementType)
|
|
||||||
if self.skillMap[elementType] then
|
|
||||||
self.skillMap[elementType]:setUnlock()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:isUnlockedSkillElementType(elementType)
|
|
||||||
if not self.skillMap[elementType] then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
return self.skillMap[elementType]:getUnlocked()
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:addSkillEnergy(elementMap)
|
|
||||||
if not self.skillMap then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
for elementType, entity in pairs(self.skillMap) do
|
|
||||||
if entity:getUnlocked() then
|
|
||||||
entity:addEnergy(elementMap[elementType] or 0)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:addSkillCount(skillId, value)
|
|
||||||
if not self.selectSkillMap[skillId] then
|
|
||||||
self.selectSkillMap[skillId] = {
|
|
||||||
count = 0,
|
|
||||||
value = 0
|
|
||||||
}
|
|
||||||
end
|
|
||||||
self.selectSkillMap[skillId].count = self.selectSkillMap[skillId].count + 1
|
|
||||||
if value then
|
|
||||||
self.selectSkillMap[skillId].value = (self.selectSkillMap[skillId].value) + value
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:getSkillCount(skillId)
|
|
||||||
if self.selectSkillMap[skillId] then
|
|
||||||
return self.selectSkillMap[skillId].count
|
|
||||||
end
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:getSelectSkillMap()
|
|
||||||
return self.selectSkillMap
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:getSkillPool()
|
|
||||||
return self.skillPool
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:changeSkillId(elementType, newId)
|
|
||||||
if not newId then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local entity = self:getSkillEntityByElement(elementType)
|
|
||||||
if entity then
|
|
||||||
entity:refreshSkillId(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
|
|
||||||
local list
|
|
||||||
local count = 0
|
|
||||||
for posId, entity in pairs(self:getGridEnties()) do
|
|
||||||
if entity:getSkillId() then
|
|
||||||
if not list then
|
|
||||||
list = {}
|
|
||||||
end
|
|
||||||
table.insert(list, {skillId = entity:getSkillId(), posId = posId})
|
|
||||||
count = count + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if list then
|
|
||||||
if count > BattleConst.MAX_CACHE_SKILL_COUNT then
|
|
||||||
count = BattleConst.MAX_CACHE_SKILL_COUNT
|
|
||||||
end
|
|
||||||
|
|
||||||
for i = 1, count do
|
|
||||||
if not list[1] then
|
|
||||||
break
|
|
||||||
end
|
|
||||||
local info = table.remove(list, math.random(1, #list))
|
|
||||||
table.insert(self.cacheSkillList, info)
|
|
||||||
self.cacheSkillCount = self.cacheSkillCount + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:getCacheBoardSkill()
|
|
||||||
if not self.cacheSkillList then
|
|
||||||
return self.cacheSkillList, 0
|
|
||||||
end
|
|
||||||
return self.cacheSkillList, self.cacheSkillCount
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:clearCacheBoardSkill()
|
|
||||||
self.cacheSkillList = {}
|
|
||||||
self.cacheSkillCount = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:getBattleLv()
|
|
||||||
return self.battleLv
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:getBattleExp()
|
|
||||||
return self.curBattleExp
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:getBattleNeedExp()
|
|
||||||
return self.needBattleExp
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:getLvNeedExp(lv)
|
|
||||||
lv = lv or self.battleLv
|
|
||||||
local cfg = ConfigManager:getConfig("battle_exp")
|
|
||||||
if not cfg[lv] then
|
|
||||||
return cfg[ConfigManager:getConfigNum("battle_exp")].exp
|
|
||||||
end
|
|
||||||
return cfg[lv].exp
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:addExp(exp)
|
|
||||||
self.curBattleExp = self.curBattleExp + exp
|
|
||||||
while self.curBattleExp >= self.needBattleExp do
|
|
||||||
self.curBattleExp = self.curBattleExp - self.needBattleExp
|
|
||||||
self.addLvCount = self.addLvCount + 1
|
|
||||||
self.battleLv = self.battleLv + 1
|
|
||||||
self.needBattleExp = self:getLvNeedExp()
|
|
||||||
end
|
|
||||||
self.data.lvDirty = not self.data.lvDirty
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:useAddlvCount()
|
|
||||||
if self.addLvCount <= 0 then
|
|
||||||
self.addLvCount = 0
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
self.addLvCount = self.addLvCount - 1
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:addCommonSelectSkillCount(count)
|
|
||||||
self.commonSelectSkillCount = self.commonSelectSkillCount + (count or 1)
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:useCommonSelectSkillCount()
|
|
||||||
if self.commonSelectSkillCount <= 0 then
|
|
||||||
self.commonSelectSkillCount = 0
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
self.commonSelectSkillCount = self.commonSelectSkillCount - 1
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:addRefreshSkillCount(isAd)
|
|
||||||
if isAd then
|
|
||||||
self.adRefreshSkillCount = self.adRefreshSkillCount + 1
|
|
||||||
end
|
|
||||||
self.refreshSkillCount = self.refreshSkillCount + 1
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:getRefreshSkillCount()
|
|
||||||
return self.refreshSkillCount
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:getADRefreshSkillCount()
|
|
||||||
return self.adRefreshSkillCount
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:initTeam(side)
|
|
||||||
local data = nil
|
|
||||||
if side == BattleConst.SIDE_ATK then
|
|
||||||
data = self:initHeroData()
|
|
||||||
end
|
|
||||||
local team = BattleTeamEntity:create()
|
|
||||||
team:init(side, data)
|
|
||||||
return team
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:getAtkTeam()
|
|
||||||
return self.atkTeam
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:getDefTeam()
|
|
||||||
return self.defTeam
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:initHeroData()
|
|
||||||
local units = {}
|
|
||||||
local skillCfg = ConfigManager:getConfig("skill")
|
|
||||||
local formation = DataManager.FormationData:getStageFormation()
|
|
||||||
for matchType, heroId in pairs(formation) do
|
|
||||||
if heroId > 0 then
|
|
||||||
local heroEntity = DataManager.HeroData:getHeroById(heroId)
|
|
||||||
if heroEntity then
|
|
||||||
local heroAttr = heroEntity:getAllAttr()
|
|
||||||
local skillId = heroEntity:getBaseSkill()
|
|
||||||
local hp = heroAttr[ATTR_TYPE.hp] // DEFAULT_FACTOR
|
|
||||||
local unitData = {
|
|
||||||
id = heroId,
|
|
||||||
modelId = heroEntity:getModelId(),
|
|
||||||
matchType = matchType,
|
|
||||||
normalSkills = heroEntity:getHurtSkill(),
|
|
||||||
assistingSkill = heroEntity:getAssistingSkill(),
|
|
||||||
body = 2, -- 英雄默认是中体型
|
|
||||||
attr = {
|
|
||||||
hp = hp,
|
|
||||||
max_hp = hp,
|
|
||||||
atk = 0,
|
|
||||||
atk_red = heroAttr[ATTR_TYPE.atk_red] // DEFAULT_FACTOR,
|
|
||||||
atk_yellow = heroAttr[ATTR_TYPE.atk_yellow] // DEFAULT_FACTOR,
|
|
||||||
atk_green = heroAttr[ATTR_TYPE.atk_green] // DEFAULT_FACTOR,
|
|
||||||
atk_blue = heroAttr[ATTR_TYPE.atk_blue] // DEFAULT_FACTOR,
|
|
||||||
atk_purple = heroAttr[ATTR_TYPE.atk_purple] // DEFAULT_FACTOR,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
local skillInfo = skillCfg[skillId]
|
|
||||||
if skillInfo then
|
|
||||||
if skillInfo.effect_type == 1 then -- 主动
|
|
||||||
unitData.activeSkills = {skillId}
|
|
||||||
elseif skillInfo.effect_type == 2 then -- 被动
|
|
||||||
unitData.passiveSkills = {skillId}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
table.insert(units, unitData)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local data = {
|
|
||||||
units = units
|
|
||||||
}
|
|
||||||
return data
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:addMonster(monsterId, newTeam, battleController)
|
|
||||||
local monsterInfo = ConfigManager:getConfig("monster")[monsterId]
|
|
||||||
local hp = monsterInfo.hp // DEFAULT_FACTOR
|
|
||||||
local atk = monsterInfo.atk // DEFAULT_FACTOR
|
|
||||||
if battleController then
|
|
||||||
hp = hp * (DEFAULT_FACTOR + battleController:getMonsterHpAddition()) // DEFAULT_FACTOR
|
|
||||||
atk = atk * (DEFAULT_FACTOR + battleController:getMonsterAtkAddition()) // DEFAULT_FACTOR
|
|
||||||
end
|
|
||||||
local unitData = {
|
|
||||||
id = monsterId,
|
|
||||||
modelId = monsterInfo.model_id,
|
|
||||||
matchType = 0,
|
|
||||||
normalSkills = monsterInfo.hurt_skill,
|
|
||||||
normalSkillCount = monsterInfo.atk_times or 0,
|
|
||||||
activeSkills = monsterInfo.skill,
|
|
||||||
passiveSkills = monsterInfo.passive_skill,
|
|
||||||
assistingSkill = nil,
|
|
||||||
isBoss = monsterInfo.is_boss,
|
|
||||||
exp = monsterInfo.monster_exp or 0,
|
|
||||||
body = monsterInfo.body,
|
|
||||||
hpSkinHp = monsterInfo.monster_hp,
|
|
||||||
hpSkinSkin = monsterInfo.monster_hp_skin,
|
|
||||||
hpExp = monsterInfo.monster_hp_exp,
|
|
||||||
attr = {
|
|
||||||
hp = hp,
|
|
||||||
max_hp = hp,
|
|
||||||
atk = atk,
|
|
||||||
atk_red = 0,
|
|
||||||
atk_yellow = 0,
|
|
||||||
atk_green = 0,
|
|
||||||
atk_blue = 0,
|
|
||||||
atk_purple = 0,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if newTeam then
|
|
||||||
self.defTeam:init(BattleConst.SIDE_DEF)
|
|
||||||
end
|
|
||||||
return self.defTeam:addUnit(unitData)
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleData:getNormalAttackName(index)
|
|
||||||
if self.normalAttackName == nil then
|
|
||||||
self.normalAttackName = {}
|
|
||||||
end
|
|
||||||
local name = self.normalAttackName[index]
|
|
||||||
if name == nil then
|
|
||||||
name = string.format("attack%02d", index)
|
|
||||||
self.normalAttackName[index] = name
|
|
||||||
end
|
|
||||||
return name
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return BattleData
|
return BattleData
|
||||||
9
lua/app/userdata/battle/battle_pvp_data.lua
Normal file
9
lua/app/userdata/battle/battle_pvp_data.lua
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
local BattleBaseData = require "app/userdata/battle/battle_base_data"
|
||||||
|
local BattlePVPData = class("BattlePVPData", BattleBaseData)
|
||||||
|
local BattleConst = GConst.BattleConst
|
||||||
|
|
||||||
|
function BattlePVPData:getRowCount()
|
||||||
|
return BattleConst.PVP_ROW_COUNT
|
||||||
|
end
|
||||||
|
|
||||||
|
return BattlePVPData
|
||||||
10
lua/app/userdata/battle/battle_pvp_data.lua.meta
Normal file
10
lua/app/userdata/battle/battle_pvp_data.lua.meta
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b35afc8876bdb8043912672742db5042
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||||
@ -264,7 +264,7 @@ function HeroEntity:getRogueSkillList()
|
|||||||
return self.rogueSkillList
|
return self.rogueSkillList
|
||||||
end
|
end
|
||||||
|
|
||||||
function HeroEntity:getActiveTogueSkills()
|
function HeroEntity:getActiveRogueSkills()
|
||||||
local list = {}
|
local list = {}
|
||||||
for i = 1, self:getActiveRogueCount() do
|
for i = 1, self:getActiveRogueCount() do
|
||||||
local id = self:getRogueSkillList()[i]
|
local id = self:getRogueSkillList()[i]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user