战斗续关

This commit is contained in:
xiekaidong 2023-07-31 16:22:05 +08:00
parent 9c04ce2fe0
commit caf1fd0af9
11 changed files with 461 additions and 24 deletions

View File

@ -37,6 +37,7 @@ local LOCAL_DATA_KEY = {
LINK_TOUCH_CANCEL_COUNT = "LINK_TOUCH_CANCEL_COUNT",
ARENA_TODAY_BATTLE_COUNT = "ARENA_TODAY_BATTLE_COUNT",
TRIAL_HERO = "TRIAL_HERO",
BATTLE_SNAPSHOT = "BATTLE_SNAPSHOT",
}
LocalData.KEYS = LOCAL_DATA_KEY
@ -430,4 +431,19 @@ function LocalData:GetMarktrailHero()
return self:getInt(LocalData:getRoleKey(LOCAL_DATA_KEY.TRIAL_HERO), 0)
end
function LocalData:saveBattleSnapshot(snapshot)
self:setString(LocalData:getRoleKey(LOCAL_DATA_KEY.BATTLE_SNAPSHOT), json.encode(snapshot))
if EDITOR_MODE then
Logger.logHighlight(json.encode(snapshot))
end
end
function LocalData:getBattleSnapshot()
local dealedSnapshot = self:getString(LocalData:getRoleKey(LOCAL_DATA_KEY.BATTLE_SNAPSHOT), "{}")
if EDITOR_MODE then
Logger.logHighlight(json.decode(dealedSnapshot))
end
return json.decode(dealedSnapshot)
end
return LocalData

View File

@ -91,7 +91,7 @@ function BattleManager:isInBattle()
end
-- params = {atkFormation= {elementType = heroEntity}, defFormation= ?}
function BattleManager:playBattle(battleType, params, returnFunc)
function BattleManager:playBattle(battleType, params, returnFunc, snapshot)
UIManager:showLoading(UIManager.LOADING_TYPE.CLOUD, function()
params = params or {}
if self.battleController then -- 同一时间只能有一场战斗
@ -99,11 +99,11 @@ function BattleManager:playBattle(battleType, params, returnFunc)
end
self.returnFunc = returnFunc
UIManager:stopCurrentBGM()
self:_play(battleType, params)
self:_play(battleType, params, snapshot)
end)
end
function BattleManager:_play(battleType, params)
function BattleManager:_play(battleType, params, snapshot)
params.battleType = battleType
if not params.atkFormation then
params.atkFormation = {}
@ -117,7 +117,7 @@ function BattleManager:_play(battleType, params)
end
local controllerPath = BATTLE_CONTROLLER[battleType] or BATTLE_CONTROLLER_BASE
self.battleController = require(controllerPath):create()
self.battleController:init(params)
self.battleController:init(params, snapshot)
end
function BattleManager:onSelectSkill(skillId, value, pos)

View File

@ -10,6 +10,7 @@ local BATTLE_GRID_EFFECT_HANDLE = require "app/module/battle/skill/battle_grid_e
local BATTLE_INSTRUCTIONS_HELPER = require "app/module/battle/helper/battle_instructions_helper"
local BattleBoardTouchHelper = require "app/module/battle/helper/battle_board_touch_helper"
local BattleBuffHandle = require "app/module/battle/helper/battle_buff_handle"
local BATTLE_SNAPSHOT_HELPER = require "app/module/battle/helper/battle_snapshot_helper"
local BattleBaseController = class("BattleBaseController")
local BattleConst = GConst.BattleConst
local BUFF_NAME_TO_ATTR = BattleConst.BUFF_NAME_TO_ATTR
@ -423,8 +424,9 @@ function BattleBaseController:ctor()
self.battleData = DataManager.BattleData
end
function BattleBaseController:init(params)
function BattleBaseController:init(params, snapshot)
params = params or {}
self.snapshot = snapshot
self.params = params
self.battleType = params.battleType or GConst.BattleConst.BATTLE_TYPE.STAGE
self.waveDurationTime = 0
@ -454,7 +456,12 @@ function BattleBaseController:init(params)
self.delayEffectTextList = {}
self.delayEffectTextCount = 0
self.time = 0
if snapshot then -- 处理战斗快照
self:dealSnapshotBattleBaseInfo(snapshot)
self.battleData:init(params, snapshot.battledataShopInfo)
else
self.battleData:init(params)
end
BattleScheduler:init()
BattlePool:init()
BattleHelper:init()
@ -466,6 +473,18 @@ function BattleBaseController:init(params)
self:prepareFight()
end
function BattleBaseController:dealSnapshotBattleExtraInfo(snapshot)
BATTLE_SNAPSHOT_HELPER:dealSnapshotBattleExtraInfo(self, snapshot)
end
function BattleBaseController:dealSnapshotBattleBaseInfo(snapInfo)
BATTLE_SNAPSHOT_HELPER:dealSnapshotBattleBaseInfo(self, snapInfo)
end
function BattleBaseController:snapshotBattleInfo()
BATTLE_SNAPSHOT_HELPER:snapshotBattleInfo(self)
end
function BattleBaseController:bindData()
self.battleData:bind("timeSpeed", ModuleManager.BattleManager, function()
self:setTimeScale( self.battleData:getTimeScale())
@ -635,7 +654,11 @@ end
function BattleBaseController:initDefUnits(callback)
local config = self:getChapterConfig()[self.chapterId]
local unitEntity = self.battleData:addMonster(config.monster[1], nil, self)
local initIndex = self.waveIndex
if self.waveIndex <= 0 then
initIndex = 1
end
local unitEntity = self.battleData:addMonster(config.monster[initIndex], nil, self)
local modelId = unitEntity:getModelId()
BattleHelper:loadBattleHeroModel(modelId, self.battleUI:getBattleNode(), function(spineObject)
local monsterComp = spineObject:addLuaComponent(BattleConst.TYPEOF_LUA_COMP.BATTLE_MONSTER_COMPONENT)
@ -723,6 +746,9 @@ end
function BattleBaseController:onLoadComplete()
UIManager:closeLoading()
self:handleBuffs()
if self.snapshot then
self:dealSnapshotBattleExtraInfo(self.snapshot)
end
self:battleStart()
end
@ -733,7 +759,12 @@ function BattleBaseController:battleStart()
self.tickSid = BattleScheduler:scheduleGlobal(function(dt, originDt)
self:_tick(dt, originDt)
end, 0)
if self.snapshot then
self:enterNextWaveBySnapshot(self.snapshot)
else
self:enterNextWave()
end
end
function BattleBaseController:addTimeSpeed()
@ -824,6 +855,36 @@ function BattleBaseController:enterNextWave()
self.waveDurationTime = 0
self.eliminateCount = 0
self:snapshotBattleInfo()
self.isBossWave = self.defTeam:getMainUnit().unitEntity:getIsBoss()
self:postFightStart()
if not self.needWaitingBoardOver then
self:enterRoundBegin()
end
if not self.isBossWave then
self.battleUI:hideBuffTips()
end
end
function BattleBaseController:enterNextWaveBySnapshot(snapShot)
local atkTeam = self.battleData:getAtkTeam()
if not atkTeam or atkTeam:getIsDead() then
self.victory = false
self:battleEnd()
return
end
self.curWaveMonsterDead = false
self:refreshWave(self.waveIndex)
self.needWaitingBoardOver = true
self:generateBoard(true, snapShot.boardSnapInfo)
self.waveDurationTime = 0
self.eliminateCount = 0
self:snapshotBattleInfo()
self.isBossWave = self.defTeam:getMainUnit().unitEntity:getIsBoss()
self:postFightStart()
if not self.needWaitingBoardOver then
@ -1487,7 +1548,7 @@ function BattleBaseController:getIsLastInstruction()
return false
end
function BattleBaseController:generateBoard(isFirst)
function BattleBaseController:generateBoard(isFirst, snapshot)
local boardList, _, mysteryBoxIndexMap = self:getInitBoard()
if self.curBoardIndex and self.curBoardIndex >= #boardList then
if isFirst then
@ -1516,7 +1577,7 @@ function BattleBaseController:generateBoard(isFirst)
board = mysteryBoard
end
self.battleUI:switchBoard(function()
self.battleData:refreshBoard(board, self:getBlockIcon())
self.battleData:refreshBoard(board, self:getBlockIcon(), snapshot)
self.battleUI:initGridCell(function()
if isFirst then
self.needWaitingBoardOver = false
@ -2047,10 +2108,10 @@ function BattleBaseController:getRandomSkillList(getCount, onlyCommonSkill, excl
return result
end
function BattleBaseController:dealSelectSkill(skillId, value, side)
function BattleBaseController:dealSelectSkill(skillId, value, side, isSnapshot)
side = side or self:getCurActionSide()
self.battleData:addSkillCount(skillId, value, side)
BATTLE_ROGUE_SKILL_HANDLE.takeEffect(skillId, self.battleData, self, value, side)
BATTLE_ROGUE_SKILL_HANDLE.takeEffect(skillId, self.battleData, self, value, side, isSnapshot)
local skillEntities = self:getSkillEntities(side)
for _, entity in pairs(skillEntities) do
@ -2814,6 +2875,7 @@ function BattleBaseController:clear()
end
function BattleBaseController:endBattleAndExit()
BATTLE_SNAPSHOT_HELPER:clearSnap(self)
ModuleManager.BattleManager:exitBattle()
end

View File

@ -0,0 +1,262 @@
local BattleConst = GConst.BattleConst
local SIDE_ATK = GConst.BattleConst.SIDE_ATK
local BATTLE_ROGUE_SKILL_HANDLE = require "app/module/battle/skill/battle_rogue_skill_handle"
local BattleSnapshotHelper = {}
local NEED_SAVE_SNAPSHOT_BATTLE_TYPE = {
[BattleConst.BATTLE_TYPE.STAGE] = true,
[BattleConst.BATTLE_TYPE.DAILY_CHALLENGE] = true,
}
function BattleSnapshotHelper:clearSnap(battleBaseController)
if not NEED_SAVE_SNAPSHOT_BATTLE_TYPE[battleBaseController.battleType] then
return
end
LocalData:saveBattleSnapshot({})
end
function BattleSnapshotHelper:snapshotBattleInfo(battleBaseController)
-- 每一波开始时记录, 此时怪物为正常状态
if not NEED_SAVE_SNAPSHOT_BATTLE_TYPE[battleBaseController.battleType] then
return
end
battleBaseController.snapShotInfo = table.clearOrCreate(battleBaseController.snapShotInfo)
-- 战斗
battleBaseController.snapShotInfo.params = table.clearOrCreate(battleBaseController.snapShotInfo.params) -- 战斗参数
if battleBaseController.params then
if battleBaseController.params.atkFormation then
local formation = battleBaseController.params.atkFormation
battleBaseController.snapShotInfo.params.atkFormation = table.clearOrCreate(battleBaseController.snapShotInfo.params.atkFormation)
for matchType, heroEntity in pairs(formation) do
battleBaseController.snapShotInfo.params.atkFormation[tostring(matchType)] = heroEntity:getCfgId()
end
end
if battleBaseController.snapShotInfo.params.defFormation then
battleBaseController.snapShotInfo.params.defFormation = nil
end
end
battleBaseController.snapShotInfo.battleType = battleBaseController.battleType -- 战斗类型
battleBaseController.snapShotInfo.totalDurationTime = battleBaseController.totalDurationTime -- 总时间
battleBaseController.snapShotInfo.eliminateTotalCount = battleBaseController.eliminateTotalCount -- 消除个数
battleBaseController.snapShotInfo.maxLinkCount = battleBaseController.maxLinkCount -- 最长链接数
battleBaseController.snapShotInfo.realTime = battleBaseController.realTime -- 真实时间
battleBaseController.snapShotInfo.taskProgress = battleBaseController.taskProgress -- 战斗任务数据
battleBaseController.snapShotInfo.waveRoundCount = table.clearOrCreate(battleBaseController.snapShotInfo.waveRoundCount) -- 波次的回合数
for k, v in pairs(battleBaseController.waveRoundCount) do
battleBaseController.snapShotInfo.waveRoundCount[tostring(k)] = v
end
battleBaseController.snapShotInfo.lastRoundBreakedGridType = table.clearOrCreate(battleBaseController.snapShotInfo.lastRoundBreakedGridType) -- 上一回合破碎的格子类型
for k, v in pairs(battleBaseController.lastRoundBreakedGridType) do
battleBaseController.snapShotInfo.lastRoundBreakedGridType[tostring(k)] = v
end
battleBaseController.snapShotInfo.chapterId = battleBaseController.chapterId -- 当前战斗关卡
battleBaseController.snapShotInfo.waveIndex = battleBaseController.waveIndex -- 当前波次
battleBaseController.snapShotInfo.gotMysteryBoxIndexs = table.clearOrCreate(battleBaseController.snapShotInfo.gotMysteryBoxIndexs) -- 神秘宝箱索引
for k, v in pairs(battleBaseController.gotMysteryBoxIndexs) do
battleBaseController.snapShotInfo.gotMysteryBoxIndexs[tostring(k)] = v
end
battleBaseController.snapShotInfo.time = battleBaseController.time -- 未暂停的战斗时间
-- 棋盘
local board = battleBaseController:snapshotBoard()
battleBaseController.snapShotInfo.boardSnapInfo = {}
for posId, info in pairs(board) do
battleBaseController.snapShotInfo.boardSnapInfo[tostring(posId)] = info
end
-- 血量
battleBaseController.snapShotInfo.hpPercent = battleBaseController.battleData.atkTeam:getHpPercent()
-- 技能
battleBaseController.snapShotInfo.atkSkillMap = table.clearOrCreate(battleBaseController.snapShotInfo.atkSkillMap)
for skillId, info in pairs(battleBaseController.battleData:getSelectSkillMap(SIDE_ATK)) do
battleBaseController.snapShotInfo.atkSkillMap[tostring(skillId)] = info
end
-- BattleBaseData
battleBaseController.snapShotInfo.battledataShopInfo = battleBaseController.battleData:getSnapshoptInfo()
-- buff
battleBaseController.snapShotInfo.atkBuff = table.clearOrCreate(battleBaseController.snapShotInfo.atkBuff)
local buffList = battleBaseController.atkTeam:getBuffList()
for index, buffEffect in pairs(buffList) do
local buffEntity = buffEffect.buff
if buffEntity and buffEntity:getNeedSave() then
local saveBuffEffect = {
type = buffEntity:getName(),
num = buffEntity:getEffectNum(),
round = buffEffect.round or 1,
ratio = 10000,
}
table.insert(battleBaseController.snapShotInfo.atkBuff, saveBuffEffect)
end
end
-- 战斗数据
battleBaseController.snapShotInfo.heroReport = {}
local members = battleBaseController.battleData:getAtkTeam():getAllMembers()
for k, v in pairs(members) do
local matchTypeStr = tostring(v:getMatchType())
battleBaseController.snapShotInfo.heroReport[matchTypeStr] = {
skill_cast = v:getActiveSkillReleaseCount(),
damage = v:getDamageCount(),
}
end
-- 快照时间
battleBaseController.snapShotInfo.snapShotTime = Time:getServerTime()
battleBaseController.snapShotInfo.currentVersion = Platform:getClientVersion()
LocalData:saveBattleSnapshot(battleBaseController.snapShotInfo)
end
function BattleSnapshotHelper:dealSnapshotBattleBaseInfo(battleBaseController, snapInfo)
if not snapInfo then
return
end
if not NEED_SAVE_SNAPSHOT_BATTLE_TYPE[snapInfo.battleType] then
return
end
local atkFormation = snapInfo.params.atkFormation
snapInfo.params.atkFormation = {}
for matchTypeStr, heroId in ipairs(atkFormation) do
local matchType = tonumber(matchTypeStr)
local heroEntity = DataManager.HeroData:getHeroById(heroId)
if matchType and heroEntity then
snapInfo.params.atkFormation[matchType] = heroEntity
end
end
battleBaseController.params = snapInfo.params
battleBaseController.battleType = snapInfo.battleType or GConst.BattleConst.BATTLE_TYPE.STAGE
battleBaseController.totalDurationTime = snapInfo.totalDurationTime
battleBaseController.eliminateTotalCount = snapInfo.eliminateTotalCount
battleBaseController.maxLinkCount = snapInfo.maxLinkCount
battleBaseController.realTime = snapInfo.realTime
battleBaseController.taskProgress = snapInfo.taskProgress
if snapInfo.waveRoundCount then
for waveIndexStr, round in pairs(snapInfo.waveRoundCount) do
local waveIndex = tonumber(waveIndexStr)
if waveIndex then
battleBaseController.waveRoundCount[waveIndex] = round
end
end
end
if snapInfo.lastRoundBreakedGridType then
for gridtypeStr, v in pairs(snapInfo.lastRoundBreakedGridType) do
local gridtype = tonumber(gridtypeStr)
if gridtype then
battleBaseController.lastRoundBreakedGridType[gridtype] = v
end
end
end
battleBaseController.chapterId = snapInfo.chapterId
battleBaseController.waveIndex = snapInfo.waveIndex
if snapInfo.gotMysteryBoxIndexs then
for indexStr, v in pairs(snapInfo.gotMysteryBoxIndexs) do
local index = tonumber(indexStr)
if index then
battleBaseController.gotMysteryBoxIndexs[index] = v
end
end
end
end
function BattleSnapshotHelper:dealSnapshotBattleExtraInfo(battleBaseController, snapshot)
if not snapshot then
return
end
if not NEED_SAVE_SNAPSHOT_BATTLE_TYPE[snapshot.battleType] then
return
end
local atkSelecetSkillMap = snapshot.atkSkillMap
if atkSelecetSkillMap then
local skillPool = battleBaseController.battleData:getSkillPool(SIDE_ATK)
if skillPool then
for elementType, list in pairs(skillPool) do -- 先遍历一下未解锁的技能
if not battleBaseController.battleData:isUnlockedSkillElementType(elementType, SIDE_ATK) then
local skillEntity = battleBaseController.battleData:getSkillEntityByElement(elementType, SIDE_ATK)
if skillEntity then
local skillId = skillEntity:getUnlockId()
local skillIdStr = tostring(skillId)
if skillId and atkSelecetSkillMap[skillIdStr] then
atkSelecetSkillMap[skillIdStr] = nil
battleBaseController:dealSelectSkill(skillId, nil, SIDE_ATK, true)
end
end
end
end
end
for skillIdStr, info in pairs(atkSelecetSkillMap) do
local skillId = tonumber(skillIdStr)
if skillId then
if info.value and info.value > 0 then
battleBaseController.battleData:setSkillCount(skillId, info.value, SIDE_ATK, info.count)
BATTLE_ROGUE_SKILL_HANDLE.takeEffect(skillId, battleBaseController.battleData, battleBaseController, info.value, SIDE_ATK)
local skillEntities = battleBaseController:getSkillEntities(SIDE_ATK)
for _, entity in pairs(skillEntities) do
entity:gotUpSKill(skillId)
end
else
if info.count then
for i = 1, info.count do
battleBaseController:dealSelectSkill(skillId, info.value, SIDE_ATK, true)
end
end
end
end
end
if battleBaseController.battleUI then
battleBaseController.battleUI:refreshSkill(nil, nil, SIDE_ATK)
end
end
-- buff
local atkBuff = snapshot.atkBuff
if atkBuff then
local atkMainUnit = battleBaseController.atkTeam:getMainUnit()
for _, saveBuffEffect in ipairs(atkBuff) do
local BattleBuffEntity = require "app/userdata/battle/skill/battle_buff_entity"
local buffEntity = BattleBuffEntity:create()
buffEntity:init(saveBuffEffect, atkMainUnit.unitEntity)
buffEntity:setTargetSide(atkMainUnit)
buffEntity:setNeedSave(true)
atkMainUnit:takeEffect(buffEntity, atkMainUnit)
end
end
if snapshot.hpPercent then
local atkTeamEntity = battleBaseController.battleData.atkTeam
local hp = atkTeamEntity:getHp() * snapshot.hpPercent
hp = math.floor(hp + 0.00000000001)
if hp < 1 then
hp = 1
end
atkTeamEntity:setAttrValue(BattleConst.ATTR_NAME.HP, hp)
if battleBaseController.battleUI then
battleBaseController.battleUI:refreshAtkHp(atkTeamEntity:getHp(), atkTeamEntity:getHpPercent())
end
end
if snapshot.heroReport then
local members = battleBaseController.battleData:getAtkTeam():getAllMembers()
for matchTypeStr, v in pairs(snapshot.heroReport) do
local matchType = tonumber(matchTypeStr)
if members[matchType] then
members[matchType]:setDamageCount(v.damage)
members[matchType]:setActiveSkillReleaseCount(v.skill_cast)
end
end
end
end
return BattleSnapshotHelper

View File

@ -88,7 +88,11 @@ local _addLinkAtkp = function(skillId, skillInfo, battleBaseData, battleControll
end
end
local _changeElementType = function(skillId, skillInfo, battleBaseData, battleController, value, side)
local _changeElementType = function(skillId, skillInfo, battleBaseData, battleController, value, side, isSnapshot)
if isSnapshot then
return
end
if not skillInfo.boardrange or not skillInfo.parameter then
return
end
@ -436,7 +440,7 @@ BattleRogueSkillHandle._effectOn = {
[16] = _addSkillRatio, -- 增加技能效果概率
}
function BattleRogueSkillHandle.takeEffect(skillId, battleData, battleController, value, side)
function BattleRogueSkillHandle.takeEffect(skillId, battleData, battleController, value, side, isSnapshot)
local cfg = SKILL_ROGUE_CFG[skillId]
if not cfg or not cfg.type then
return
@ -455,7 +459,7 @@ function BattleRogueSkillHandle.takeEffect(skillId, battleData, battleController
local func = BattleRogueSkillHandle._effectOn[cfg.type]
if func then
func(skillId, cfg, battleData, battleController, value, side)
func(skillId, cfg, battleData, battleController, value, side, isSnapshot)
end
end

View File

@ -77,8 +77,10 @@ function ChapterManager:endFight(id, combatReport, gotMysteryBoxIndexs, taskProg
if gotMysteryBoxIndexs and cfg.mystery_box then
local indexMap = {}
for index, wave in ipairs(cfg.mystery_box) do
if not DataManager.ChapterData:getChapterMysteryBoxIsGot(id, index) then -- 容错一下
indexMap[wave] = index
end
end
for boardIndex, _ in pairs(gotMysteryBoxIndexs) do
if indexMap[boardIndex] then
table.insert(mystery_box_idx, indexMap[boardIndex])

View File

@ -2286,6 +2286,9 @@ function BattleBaseUI:clear()
if self.battleNode then
self.battleNode:removeAllChildren()
end
if self.maxLayerNode then
self.maxLayerNode:removeAllChildren()
end
if self.fxNode then
self.fxNode:removeAllChildren()
end

View File

@ -960,6 +960,28 @@ function MainCityUI:checkMainPop()
return
end
-- 续关
if self.isFirstEnter then
local battleSnapshot = LocalData:getBattleSnapshot()
LocalData:saveBattleSnapshot({})
if battleSnapshot.battleType then
if battleSnapshot.currentVersion == Platform:getClientVersion() then
local snapshotTime = battleSnapshot.snapShotTime
if snapshotTime and Time:getOverOfServerToday(snapshotTime) >= Time:getOverOfServerToday() then
local params = {
content = I18N:getGlobalText(I18N.GlobalConst.BATTLE_DESC_14),
okFunc = function()
ModuleManager.BattleManager:playBattle(battleSnapshot.battleType, battleSnapshot.parmas, nil, battleSnapshot)
end,
boxType = GConst.MESSAGE_BOX_TYPE.MB_OK_CANCEL,
}
GFunc.showMessageBox(params)
return
end
end
end
end
-- 检查是否升级
if DataManager.PlayerData:getIfCanLevelUp() then
ModuleManager.PlayerManager:levelUp()

View File

@ -27,19 +27,19 @@ function BattleBaseData:getTimeScaleBase()
end
---------------------------------end按需重写的方法-------------------------------
function BattleBaseData:init(params)
function BattleBaseData:init(params, snapInfo)
self:clear()
self.battleLv = 1
self.curBattleExp = 0
self.battleLv = snapInfo and snapInfo.battleLv or 1
self.curBattleExp = snapInfo and snapInfo.curBattleExp or 0
self.needBattleExp = self:getLvNeedExp()
self.addLvCount = 0
self.commonSelectSkillCount = 0
self.addLvCount = snapInfo and snapInfo.addLvCount or 0
self.commonSelectSkillCount = snapInfo and snapInfo.commonSelectSkillCount or 0
self.timeScale = BattleConst.TIME_SCALE.LEVEL_1 * self:getTimeScaleBase()
self.lockElementMap = {}
self.data.timeSpeed = 1
self.data.lvDirty = false
self.adRefreshSkillCount = 0
self.refreshSkillCount = 0
self.adRefreshSkillCount = snapInfo and snapInfo.adRefreshSkillCount or 0
self.refreshSkillCount = snapInfo and snapInfo.refreshSkillCount or 0
BattleSkillEntity.sid = 0
self.atkTeam = self:initTeam(SIDE_ATK, params.atkFormation)
self.defTeam = self:initTeam(SIDE_DEF, params.defFormation)
@ -47,6 +47,25 @@ function BattleBaseData:init(params)
self:initRogueSkills(SIDE_DEF, params.defFormation)
self.atkFormation = params.atkFormation or {}
self.defFormation = params.defFormation or {}
if snapInfo then
if snapInfo.cacheSkillList then
self.cacheSkillList = snapInfo.cacheSkillList
self.cacheSkillCount = #self.cacheSkillList
end
end
end
function BattleBaseData:getSnapshoptInfo()
return {
battleLv = self.battleLv,
curBattleExp = self.curBattleExp,
addLvCount = self.addLvCount,
commonSelectSkillCount = self.commonSelectSkillCount,
adRefreshSkillCount = self.adRefreshSkillCount,
refreshSkillCount = self.refreshSkillCount,
cacheSkillList = self.cacheSkillList,
}
end
function BattleBaseData:getTimeScale()
@ -151,7 +170,7 @@ function BattleBaseData:initRogueSkills(side, formation)
end
end
function BattleBaseData:refreshBoard(board, blockIcon)
function BattleBaseData:refreshBoard(board, blockIcon, snapshot)
local r = 1
local c = 1
@ -181,6 +200,15 @@ function BattleBaseData:refreshBoard(board, blockIcon)
self.gridEntities[data.posId]:setObstacleIcon(blockIcon)
c = c + 1
end
if snapshot then
for posIdStr, snap in pairs(snapshot) do
local posId = tonumber(posIdStr)
if self.gridEntities[posId] and snap then
self.gridEntities[posId]:setInfoBySnapshop(snap)
end
end
end
end
function BattleBaseData:getNewGridEntity(posId, gridType, elementType)
@ -483,6 +511,26 @@ function BattleBaseData:addSkillCount(skillId, value, side)
end
end
function BattleBaseData:setSkillCount(skillId, value, side, count)
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 = count
if value then
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

View File

@ -20,6 +20,8 @@ function BattleBuffEntity:init(effectParams, owner, hostSkill)
self.notShowIcon = false
self.showNameStr = nil
self.showNameRedColor = nil
self.needSave = self.hostSkill ~= nil
end
function BattleBuffEntity:setOwner(owner)
@ -151,4 +153,12 @@ function BattleBuffEntity:setNotShowIcon(notShow)
self.notShowIcon = notShow
end
function BattleBuffEntity:setNeedSave(needSave)
self.needSave = needSave
end
function BattleBuffEntity:getNeedSave()
return self.needSave
end
return BattleBuffEntity

View File

@ -249,6 +249,10 @@ function BattleUnitEntity:getDamageCount()
return self.damageCount
end
function BattleUnitEntity:setDamageCount(damageCount)
self.damageCount = damageCount or 0
end
-- 伤害统计
function BattleUnitEntity:addDamageCount(num)
if num > 0 then -- 加血统计
@ -262,6 +266,10 @@ function BattleUnitEntity:getActiveSkillReleaseCount()
return self.activeSkillReleaseCount
end
function BattleUnitEntity:setActiveSkillReleaseCount(count)
self.activeSkillReleaseCount = count or 0
end
-- 主动技能释放次数统计
function BattleUnitEntity:addActiveSkillReleaseCount(num)
self.activeSkillReleaseCount = self.activeSkillReleaseCount + num