接入数据

This commit is contained in:
xiekaidong 2023-09-01 11:55:16 +08:00
parent 54c95564ba
commit fe245efaba
8 changed files with 730 additions and 78 deletions

View File

@ -136,6 +136,7 @@ function DataManager:initWithServerData(data)
if EDITOR_MODE then if EDITOR_MODE then
Logger.logHighlight("initWithServerData") Logger.logHighlight("initWithServerData")
Logger.printTable(data) Logger.printTable(data)
Logger.logHighlight("注册时间 : " .. Time:formatTimeYMDHMS(GFunc.formatTimeStep(data.stat.register_ts)))
end end
self.registerTs = data.stat and data.stat.register_ts or Time:getServerTime() self.registerTs = data.stat and data.stat.register_ts or Time:getServerTime()
self.registerTs = GFunc.formatTimeStep(self.registerTs or Time:getServerTime()) self.registerTs = GFunc.formatTimeStep(self.registerTs or Time:getServerTime())
@ -191,6 +192,7 @@ function DataManager:initWithServerData(data)
self:checkDataBind() self:checkDataBind()
ModuleManager.ArenaManager:reqArenaInfo() ModuleManager.ArenaManager:reqArenaInfo()
self:dealOpenActivity(data.activities)
-- 写在最后防止某些数据还未初始化就被bi访问报错 -- 写在最后防止某些数据还未初始化就被bi访问报错
self.initWithServer = true self.initWithServer = true
end end
@ -446,4 +448,43 @@ function DataManager:getActivityExchangeByActId(actId)
return self.activityExchangeMap[actId] return self.activityExchangeMap[actId]
end end
function DataManager:dealOpenActivity(activityInfo)
local curTime = Time:getServerTime()
if not activityInfo then
return
end
local dealTypeMap = {}
for _, info in ipairs(activityInfo) do
local startTime = GFunc.formatTimeStep(info.start_at)
if startTime <= curTime and curTime <= GFunc.formatTimeStep(info.end_at) then
local reqFunc = DataManager.activityOpenFunc[info.type]
if reqFunc and not dealTypeMap[info.type] then
dealTypeMap[info.type] = true
reqFunc(info)
end
elseif startTime > curTime then
local waitOpenFunc = DataManager.waitOpenActivity[info.type]
if waitOpenFunc and not dealTypeMap[info.type] then
dealTypeMap[info.type] = true
waitOpenFunc(info)
end
end
end
end
DataManager.activityOpenFunc = {
[2] = function(params)
ModuleManager.ActBossRushManager:reqActData()
DataManager.ActBossRushData:setActivityInfo(params)
end
}
DataManager.waitOpenActivity = {
[2] = function(params)
DataManager.ActBossRushData:init({activity_id = params.id}) -- 默认初始化
DataManager.ActBossRushData:setActivityInfo(params)
end
}
return DataManager return DataManager

View File

@ -35,7 +35,7 @@ function ActBossRushManager:reqFight()
costId = GConst.ItemConst.ITEM_ID_GEM, costId = GConst.ItemConst.ITEM_ID_GEM,
costNum = cost, costNum = cost,
okFunc = function() okFunc = function()
self:sendMessage(ProtoMsgType.FromMsgEnum., {}, {}, self.rspFight, BIReport.ITEM_GET_TYPE.ACT_BOSS_RUSH_FIGHT_START) self:sendMessage(ProtoMsgType.FromMsgEnum.BossRushStartReq, {}, {}, self.rspFight, BIReport.ITEM_GET_TYPE.ACT_BOSS_RUSH_FIGHT_START)
end, end,
} }
GFunc.showMessageBox(params) GFunc.showMessageBox(params)
@ -43,29 +43,31 @@ function ActBossRushManager:reqFight()
end end
end end
self:sendMessage(ProtoMsgType.FromMsgEnum., {}, {}, self.rspFight, BIReport.ITEM_GET_TYPE.ACT_BOSS_RUSH_FIGHT_START) self:sendMessage(ProtoMsgType.FromMsgEnum.BossRushStartReq, {}, {}, self.rspFight, BIReport.ITEM_GET_TYPE.ACT_BOSS_RUSH_FIGHT_START)
end end
function ActBossRushManager:rspFight(result) function ActBossRushManager:rspFight(result)
if result.error_code == GConst.ERROR_STR.SUCCESS then if result.error_code == GConst.ERROR_STR.SUCCESS then
DataManager.ActBossRushData:updateStageSeed(result.seed)
ModuleManager.BattleManager:playBattle(GConst.BattleConst.BATTLE_TYPE.BOSS_RUSH) ModuleManager.BattleManager:playBattle(GConst.BattleConst.BATTLE_TYPE.BOSS_RUSH)
end end
end end
function ActBossRushManager:reqEndBattle() function ActBossRushManager:reqEndBattle(chapterId, combatReport, taskProgress)
local params = { local params = {
chapterId = chapterId,
combatReport = combatReport,
task_stat = taskProgress
} }
self:sendMessage(ProtoMsgType.FromMsgEnum., params, {}, self.rspEndBattle, BIReport.ITEM_GET_TYPE.ACT_BOSS_RUSH_FIGHT) self:sendMessage(ProtoMsgType.FromMsgEnum.BossRushSettlementReq, params, {}, self.rspEndBattle, BIReport.ITEM_GET_TYPE.ACT_BOSS_RUSH_FIGHT)
end end
function ActBossRushManager:rspEndBattle(result) function ActBossRushManager:rspEndBattle(result)
if result.error_code == GConst.ERROR_STR.SUCCESS then if result.error_code == GConst.ERROR_STR.SUCCESS then
-- ModuleManager.BattleManager:showBattleResultUI(result.settlement, result.rewards, checkCount)
if result.reqData then if result.reqData then
DataManager.ActBossRushData:addWaveCount(result.reqData.task_stat.pass_wave) DataManager.ActBossRushData:addWaveCount(result.reqData.task_stat.pass_wave)
end end
ModuleManager.BattleManager:showBossRushBattleResultUI(GConst.BattleConst.BATTLE_TYPE.BOSS_RUSH, result.reqData and result.reqData.combatReport)
end end
end end
@ -79,37 +81,42 @@ function ActBossRushManager:reqFundAward(level, rewardType)
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.ACTIVITY_OVER_EDSC)) GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.ACTIVITY_OVER_EDSC))
return return
end end
-- 直接一键领取 -- -- 直接一键领取
local curLevel = DataManager.ActBossRushData:getWaveLevel() -- local curLevel = DataManager.ActBossRushData:getWaveLevel()
local idWithLv = {} -- local idWithLv = {}
for id = 1, curLevel do -- for id = 1, curLevel do
if DataManager.ActBossRushData:getFreeCanGet(id) then -- if DataManager.ActBossRushData:getFreeCanGet(id) then
table.insert(idWithLv, {id = id, grade = 0}) -- table.insert(idWithLv, {id = id, grade = 0})
end -- end
if DataManager.ActBossRushData:getProCanGet(id) then -- if DataManager.ActBossRushData:getProCanGet(id) then
table.insert(idWithLv, {id = id, grade = 1}) -- table.insert(idWithLv, {id = id, grade = 1})
end -- end
if DataManager.ActBossRushData:getUtralCanGet(id) then -- if DataManager.ActBossRushData:getUtralCanGet(id) then
table.insert(idWithLv, {id = id, grade = 2}) -- table.insert(idWithLv, {id = id, grade = 2})
end -- end
end -- end
if not idWithLv[1] then -- if not idWithLv[1] then
return -- return
end -- end
local params = { local params = {
id_with_lv = idWithLv id = level,
grade = rewardType
} }
self:sendMessage(ProtoMsgType.FromMsgEnum., params, {}, self.rspFundAward, BIReport.ITEM_GET_TYPE.ACT_BOSS_RUSH_FUND) self:sendMessage(ProtoMsgType.FromMsgEnum.BossRushBountyClaimReq, params, {}, self.rspFundAward, BIReport.ITEM_GET_TYPE.ACT_BOSS_RUSH_FUND)
end end
function ActBossRushManager:rspFundAward(result) function ActBossRushManager:rspFundAward(result)
if result.err_code == GConst.ERROR_STR.SUCCESS then if result.err_code == GConst.ERROR_STR.SUCCESS then
DataManager.ActBossRushData:gotFundReward(result.id_with_lv) if result.reqData then
if result.reqData.id ~= 0 then
DataManager.ActBossRushData:gotSingleFundReward(result.reqData.id, result.reqData.grade)
end
end
GFunc.showRewardBox(result.rewards) GFunc.showRewardBox(result.rewards)
end end
end end
@ -120,12 +127,12 @@ function ActBossRushManager:reqBuyFundLevel()
return return
end end
self:sendMessage(ProtoMsgType.FromMsgEnum., {}, {}, self.rspBuyFundLevel, BIReport.ITEM_GET_TYPE.ACT_BOSS_RUSH_BUY_FUND) self:sendMessage(ProtoMsgType.FromMsgEnum.BossRushBountyUnlockReq, {}, {}, self.rspBuyFundLevel, BIReport.ITEM_GET_TYPE.ACT_BOSS_RUSH_BUY_FUND)
end end
function ActBossRushManager:rspBuyFundLevel(result) function ActBossRushManager:rspBuyFundLevel(result)
if result.err_code == GConst.ERROR_STR.SUCCESS then if result.err_code == GConst.ERROR_STR.SUCCESS then
local addCount = result.waveCount - DataManager.ActBossRushData:getWaveCount() local addCount = result.accum_round - DataManager.ActBossRushData:getWaveCount()
if addCount > 0 then if addCount > 0 then
DataManager.ActBossRushData:addWaveCount(addCount) DataManager.ActBossRushData:addWaveCount(addCount)
end end
@ -142,7 +149,7 @@ function ActBossRushManager:reqExchange(id, count)
count = count count = count
} }
self:sendMessage(ProtoMsgType.FromMsgEnum., params, {}, self.rspExchange, BIReport.ITEM_GET_TYPE.ACT_BOSS_RUSH_SHOP) self:sendMessage(ProtoMsgType.FromMsgEnum.BossRushExchangeReq, params, {}, self.rspExchange, BIReport.ITEM_GET_TYPE.ACT_BOSS_RUSH_SHOP)
end end
function ActBossRushManager:rspExchange(result) function ActBossRushManager:rspExchange(result)
@ -155,7 +162,7 @@ function ActBossRushManager:rspExchange(result)
end end
function ActBossRushManager:reqRankReward() function ActBossRushManager:reqRankReward()
self:sendMessage(ProtoMsgType.FromMsgEnum., {}, {}, self.rspRankReward, BIReport.ITEM_GET_TYPE.ACT_BOSS_RUSH_RANK) self:sendMessage(ProtoMsgType.FromMsgEnum.BossRushRankRewardReq, {}, {}, self.rspRankReward, BIReport.ITEM_GET_TYPE.ACT_BOSS_RUSH_RANK)
end end
function ActBossRushManager:rspRankReward(result) function ActBossRushManager:rspRankReward(result)
@ -166,12 +173,12 @@ function ActBossRushManager:rspRankReward(result)
end end
function ActBossRushManager:reqActData() function ActBossRushManager:reqActData()
self:sendMessage(ProtoMsgType.FromMsgEnum., {}, {}, self.rspActData) self:sendMessage(ProtoMsgType.FromMsgEnum.BossRushInfoReq, {}, {}, self.rspActData)
end end
function ActBossRushManager:rspActData(result) function ActBossRushManager:rspActData(result)
if result.err_code == GConst.ERROR_STR.SUCCESS then if result.err_code == GConst.ERROR_STR.SUCCESS then
DataManager.ActBossRushData:init(result) DataManager.ActBossRushData:init(result.boss_rush)
end end
end end
@ -179,7 +186,7 @@ function ActBossRushManager:reqRankList()
if not DataManager.ActBossRushData:getNeedUpdateRank() then if not DataManager.ActBossRushData:getNeedUpdateRank() then
return return
end end
self:sendMessage(ProtoMsgType.FromMsgEnum., {}, {}, self.rspRankList) self:sendMessage(ProtoMsgType.FromMsgEnum.BossRushRankReq, {}, {}, self.rspRankList)
end end
function ActBossRushManager:rspRankList(result) function ActBossRushManager:rspRankList(result)
@ -192,12 +199,12 @@ function ActBossRushManager:reqTopRank()
if not DataManager.ActBossRushData:getIsOpen() then if not DataManager.ActBossRushData:getIsOpen() then
return false return false
end end
self:sendMessage(ProtoMsgType.FromMsgEnum., {}, {}, self.rspTopRank) self:sendMessage(ProtoMsgType.FromMsgEnum.BossRushTopReq, {}, {}, self.rspTopRank)
end end
function ActBossRushManager:rspTopRank(result) function ActBossRushManager:rspTopRank(result)
if result.err_code == GConst.ERROR_STR.SUCCESS then if result.err_code == GConst.ERROR_STR.SUCCESS then
DataManager.ActBossRushData:updateTopRankInfo(result) DataManager.ActBossRushData:updateTopRankInfo(result.top3)
end end
end end
@ -211,7 +218,7 @@ function ActBossRushManager:reqFormation(formation)
local params = { local params = {
heroes = heroes heroes = heroes
} }
self:sendMessage(ProtoMsgType.FromMsgEnum., params, {}, self.rspFormation) self:sendMessage(ProtoMsgType.FromMsgEnum.BossRushFormationReq, params, {}, self.rspFormation)
end end
function ActBossRushManager:rspFormation(result) function ActBossRushManager:rspFormation(result)

View File

@ -62,6 +62,13 @@ function BattleManager:showArenaBattleResultUI(settlement, rewards, checkCount)
}) })
end end
function BattleManager:showBossRushBattleResultUI(battleType, combatReport)
UIManager:showUI("app/ui/battle/battle_boss_rushresult_ui", {
battleType = battleType,
combatReport = combatReport
})
end
function BattleManager:showBoxOpenUI(rewards, callback) function BattleManager:showBoxOpenUI(rewards, callback)
UIManager:showUI("app/ui/battle/battle_box_open_ui", {rewards = rewards, callback = callback}) UIManager:showUI("app/ui/battle/battle_box_open_ui", {rewards = rewards, callback = callback})
end end

View File

@ -3078,8 +3078,9 @@ function BattleBaseController:battleEnd()
end end
-- 处理战斗任务 -- 处理战斗任务
local curWaveIndex = self:getWaveIndex()
if self.victory then if self.victory then
self:setTaskProgress(GConst.BattleConst.BATTLE_TASK_FIELD.KILLS_BOSS_TURN, self.waveRoundCount[self:getWaveIndex()]) self:setTaskProgress(GConst.BattleConst.BATTLE_TASK_FIELD.KILLS_BOSS_TURN, self.waveRoundCount[curWaveIndex])
end end
local teamEntity = self.battleData:getAtkTeam() local teamEntity = self.battleData:getAtkTeam()
@ -3088,8 +3089,14 @@ function BattleBaseController:battleEnd()
local totalRound = 0 local totalRound = 0
for wave, round in pairs(self.waveRoundCount) do for wave, round in pairs(self.waveRoundCount) do
if wave == curWaveIndex then
if self.victory then
totalRound = totalRound + round totalRound = totalRound + round
end end
else
totalRound = totalRound + round
end
end
self:setTaskProgress(GConst.BattleConst.BATTLE_TASK_FIELD.TOTAL_TURN, totalRound) self:setTaskProgress(GConst.BattleConst.BATTLE_TASK_FIELD.TOTAL_TURN, totalRound)
-- end处理战斗任务 -- end处理战斗任务

View File

@ -132,32 +132,31 @@ function BattleControllerBossRush:showBossEnterAni(bornTime, bossName, monsterCo
end end
function BattleControllerBossRush:controllBattleEnd() function BattleControllerBossRush:controllBattleEnd()
-- self.combatReport = { self.combatReport = {
-- battleType = GConst.BattleConst.BATTLE_TYPE.ACT_BOSS_RUSH, battleType = GConst.BattleConst.BATTLE_TYPE.ACT_BOSS_RUSH,
-- wave = self:getWaveIndex(), wave = self:getWaveIndex(),
-- victory = self.victory, victory = self.victory,
-- } }
-- local atkReport = {} local atkReport = {}
-- local teamEntity = self.battleData:getAtkTeam() local teamEntity = self.battleData:getAtkTeam()
-- local members = teamEntity:getAllMembers() local members = teamEntity:getAllMembers()
-- local heroInfo = {} local heroInfo = {}
-- for k, v in pairs(members) do for k, v in pairs(members) do
-- local report = { local report = {
-- heroId = v:getId(), heroId = v:getId(),
-- dmg = v:getDamageCount(), dmg = v:getDamageCount(),
-- } }
-- table.insert(atkReport, report) table.insert(atkReport, report)
-- heroInfo[v:getId()] = { heroInfo[v:getId()] = {
-- skill_cast = v:getActiveSkillReleaseCount(), skill_cast = v:getActiveSkillReleaseCount(),
-- Damage = v:getDamageCount(), Damage = v:getDamageCount(),
-- } }
-- end end
-- self.combatReport.atkReport = atkReport self.combatReport.atkReport = atkReport
-- if not self.victory then if not self.victory then
-- self.combatReport.wave = self.combatReport.wave - 1 self.combatReport.wave = self.combatReport.wave - 1
-- end end
-- local taskCurProgress = ModuleManager.DailyChallengeManager:getCurTaskProgress(self) ModuleManager.ActBossRushManager:reqEndBattle(self.chapterId, self.combatReport, self.taskProgress)
ModuleManager.ActBossRushManager:reqEndBattle(self.chapterId, self.combatReport, self.taskProgress, heroInfo, taskCurProgress)
end end
function BattleControllerBossRush:postWaveOver(atkDead, isQuit) function BattleControllerBossRush:postWaveOver(atkDead, isQuit)

View File

@ -0,0 +1,521 @@
local BattleBossRushResultUI = class("BattleBossRushResultUI", BaseUI)
local UNIT_RESULT_RERPORT_CELL = "app/ui/battle/cell/unit_result_report_cell"
local MAX_SCROLL_SHOW_COUNT = 10
local SCROLL_LINE_HEIGHT = 130
function BattleBossRushResultUI:getPrefabPath()
return "assets/prefabs/ui/battle/battle_result_ui.prefab"
end
function BattleBossRushResultUI:ctor(params)
if EDITOR_MODE then
Logger.printTable(params)
end
-- 通用
self.battleType = params.battleType
self.isWin = params.isWin
self.rewards = params.rewards
self.firstPassIdx = params.firstPassIdx or 0
self.noMergeReward = params.noMergeReward
-- pve特有
self.atkReport = params.atkReport
self.wave = params.wave
-- 主线特有
self.mysteryBoxIdx = params.mysteryBoxIdx or 0
-- 金币副本特有
self.remainRound = params.remainRound
-- 竞技场特有
self.incrScore = params.incrScore
self.arenaTotalCount = params.arenaTotalCount
self.isTryShowGoldPig = false
self.totalDmg = 0
if self.atkReport then
for _, info in ipairs(self.atkReport) do
self.totalDmg = self.totalDmg + info.dmg
end
end
if not self.noMergeReward then
local newRewards = {}
GFunc.mergeRewards2(self.rewards, newRewards)
self.rewards = newRewards
end
end
function BattleBossRushResultUI:onClose()
if self.sliderSequence then
self.sliderSequence:Kill()
end
if self.animNode then
self.animNode:Kill()
end
if self.animPig then
self.animPig:Kill()
end
if self.animRewards then
for idx, anim in pairs(self.animRewards) do
if anim then
anim:Kill()
end
end
end
if self.arenaSequence then
self.arenaSequence:Kill()
self.arenaSequence = nil
end
if self.arenaSpine then
self.arenaSpine:destroy()
self.arenaSpine = nil
end
end
function BattleBossRushResultUI:onLoadRootComplete()
local uiMap = self.root:genAllChildren()
self.continue = uiMap["battle_result_ui.continue"]
-- 胜利节点
self.victoryNode = uiMap["battle_result_ui.victory_node"]
self.victoryMask = uiMap["battle_result_ui.mask_v"]
self.victoryTxTitle = uiMap["battle_result_ui.victory_node.title_bg.desc"]
self.victorySpine = uiMap["battle_result_ui.victory_node.ui_spine_obj"]
self.victoryUnitNode = uiMap["battle_result_ui.victory_node.unit_node"]
-- 失败节点
self.defeatNode = uiMap["battle_result_ui.defeat_node"]
self.defeatMask = uiMap["battle_result_ui.mask_d"]
self.defeatTxTitle = uiMap["battle_result_ui.defeat_node.title_bg.desc"]
self.defeatSpine = uiMap["battle_result_ui.defeat_node.ui_spine_obj"]
self.defeatUnitNode = uiMap["battle_result_ui.defeat_node.unit_node"]
-- 战斗信息
self.unitNode = uiMap["battle_result_ui.unit_node"]
self.unitImgBattleIcon = uiMap["battle_result_ui.unit_node.icon"]
self.unitTxDesc1 = uiMap["battle_result_ui.unit_node.desc_1"]
self.unitTxDesc2 = uiMap["battle_result_ui.unit_node.desc_2"]
self.unitTxDesc3 = uiMap["battle_result_ui.unit_node.desc_3"]
self.unitImgReportV = uiMap["battle_result_ui.unit_node.report_img_v"]
self.unitImgReportD = uiMap["battle_result_ui.unit_node.report_img_d"]
if not self.unitResultReportCells then
self.unitResultReportCells = {}
for index = 1, 5 do
self.unitResultReportCells[index] = CellManager:addCellComp(uiMap["battle_result_ui.unit_node.unit_result_report_cell_" .. index], UNIT_RESULT_RERPORT_CELL)
end
end
-- 奖励节点
self.rewardNode = uiMap["battle_result_ui.reward_node"]
self.rewardTxTitle = uiMap["battle_result_ui.reward_node.reward_title"]
self.rewardScrollRect = uiMap["battle_result_ui.reward_node.scroll_rect"]
self.rewardScrollRectComp = self.rewardScrollRect:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
-- 金猪存钱罐
self.goldPigNode = uiMap["battle_result_ui.gold_pig"]
self.goldPigTxGem = uiMap["battle_result_ui.gold_pig.gem_bg.gem_tx"]
self.goldPigSlider = uiMap["battle_result_ui.gold_pig.slider_bg.slider"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
self.goldPigTxSlider = uiMap["battle_result_ui.gold_pig.slider_bg.text"]
self.goldPigImgGem = uiMap["battle_result_ui.gold_pig.gem_bg.gem_img"]
self.goldPigSpine = uiMap["battle_result_ui.gold_pig.spine_pig"]
self.goldPigGem = uiMap["battle_result_ui.gold_pig.gem_bg"]
self.canvasGroupPigGem = self.goldPigGem:getComponent(GConst.TYPEOF_UNITY_CLASS.CANVAS_GROUP)
-- 竞技场
self.arenaNode = uiMap["battle_result_ui.arena_node"]
self.arenaSpineRoot = uiMap["battle_result_ui.arena_node.spine_root"]
self.arenaTxGrading = uiMap["battle_result_ui.arena_node.tx_grading"]
self.arenaTxScore = uiMap["battle_result_ui.arena_node.tx_score"]
self.arenaImgProp = uiMap["battle_result_ui.arena_node.prog.img_prog"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
self.arenaTxProg = uiMap["battle_result_ui.arena_node.prog.tx_prog"]
-- 竞技场广告宝箱
self.arenaBoxNode = uiMap["battle_result_ui.arena_box_node"]
self.arenaBoxImgIcon = uiMap["battle_result_ui.arena_box_node.img_box"]
self.arenaBoxTxTitle = uiMap["battle_result_ui.arena_box_node.tx_box"]
self.arenaBoxBtnGet = uiMap["battle_result_ui.arena_box_node.btn_get"]
self.arenaBoxTxGet = uiMap["battle_result_ui.arena_box_node.btn_get.tx_get"]
self.victoryMask:addClickListener(function()
self:onClickMask()
end)
self.defeatMask:addClickListener(function()
self:onClickMask()
end)
self.arenaBoxBtnGet:addClickListener(function()
ModuleManager.ShopManager:showArenaAdBoxUI(self.isWin)
end)
self:addEventListener(EventManager.CUSTOM_EVENT.ARENA_AD_BOX_SUCCESS, function()
self.getedArenaAdBox = true
self:refreshRewards()
self:refreshArenaBoxNode()
end)
end
function BattleBossRushResultUI:onClickMask()
if self.isTryShowGoldPig then
ModuleManager.BattleManager:endBattleAndExit()
else
if not self:tryShowGoldPig() then
ModuleManager.BattleManager:endBattleAndExit()
end
end
end
function BattleBossRushResultUI:onRefresh()
if self.isWin then
self:refreshVictoryNode()
AudioManager:playEffect(AudioManager.EFFECT_ID.BATTLE_VICTORY)
else
self:refreshDefeatNode()
AudioManager:playEffect(AudioManager.EFFECT_ID.BATTLE_DEFEAT)
end
self:refreshUnitInfo()
self:refreshRewards()
self:refreshArenaNode()
self:refreshArenaBoxNode()
end
function BattleBossRushResultUI:refreshVictoryNode()
self.victoryNode:setVisible(true)
self.unitImgReportV:setVisible(true)
self.defeatNode:setVisible(false)
self.unitImgReportD:setVisible(false)
self.victoryTxTitle:setText(I18N:getGlobalText(I18N.GlobalConst.BATTLE_DESC_5))
self.victorySpine:playAnimComplete("born", false, true, function()
self.victorySpine:playAnim("idle", true, true)
end)
if self.battleType == GConst.BattleConst.BATTLE_TYPE.ARENA then
self:showNodeAnim(self.victoryUnitNode, self.arenaNode)
else
self:showNodeAnim(self.victoryUnitNode, self.unitNode)
end
end
function BattleBossRushResultUI:refreshDefeatNode()
self.victoryNode:setVisible(false)
self.unitImgReportV:setVisible(false)
self.defeatNode:setVisible(true)
self.unitImgReportD:setVisible(true)
self.defeatTxTitle:setText(I18N:getGlobalText(I18N.GlobalConst.BATTLE_DESC_6))
self.defeatSpine:playAnimComplete("born", false, true, function()
self.defeatSpine:playAnim("idle", true, true)
end)
if self.battleType == GConst.BattleConst.BATTLE_TYPE.ARENA then
self:showNodeAnim(self.defeatUnitNode, self.arenaNode)
else
self:showNodeAnim(self.defeatUnitNode, self.unitNode)
end
end
-- 播放节点动画
function BattleBossRushResultUI:showNodeAnim(parent, node)
if not parent then
node:setVisible(false)
return
else
node:setVisible(true)
end
node:setParent(parent, false)
node:setAnchoredPosition(0, 0)
local canvasNode = parent:getComponent(GConst.TYPEOF_UNITY_CLASS.CANVAS_GROUP)
self.animNode = self.root:createBindTweenSequence()
self.animNode:Insert(0, canvasNode:DOFade(0, 0))
self.animNode:Insert(0.1, canvasNode:DOFade(1, 0))
self.animNode:Insert(0, parent:getTransform():DOScale(0, 0))
self.animNode:Insert(0.1, parent:getTransform():DOScale(0.35, 0))
self.animNode:Insert(0.13, parent:getTransform():DOScale(1.1, 0.16))
self.animNode:Insert(0.26, parent:getTransform():DOScale(1, 0.14))
self.animNode:OnComplete(function()
self.animNode = nil
end)
end
function BattleBossRushResultUI:refreshArenaNode()
if self.battleType ~= GConst.BattleConst.BATTLE_TYPE.ARENA then
self.arenaNode:setVisible(false)
return
end
self.arenaNode:setVisible(true)
local totalScore = DataManager.ArenaData:getScore()
local lastScore = totalScore - self.incrScore
local curId = DataManager.ArenaData:getGradingId()
local lastId = DataManager.ArenaData:getGradingIdFromScore(lastScore)
if curId == nil or lastId == nil then
return
end
self.arenaTxGrading:setText(DataManager.ArenaData:getGradingName(lastId))
self:refreshArenaGradingSpine(lastId)
if self.arenaSequence then
self.arenaSequence:Kill()
end
self.arenaSequence = DOTweenManager:createSeqWithIntId()
local tween = DOTweenManager:createDOTweenTo(
function()
return lastScore
end,
function(value)
local maxScore = DataManager.ArenaData:getGradingScoreTotal(value)
local curScore = DataManager.ArenaData:getGradingScore(value)
if maxScore then
self.arenaImgProp.value = curScore/maxScore
self.arenaTxProg:setText(math.floor(curScore).."/"..maxScore)
else
self.arenaImgProp.value = 1
self.arenaTxProg:setText(math.floor(curScore))
end
end,
totalScore, 1.5)
self.arenaSequence:Append(tween)
self.arenaSequence:AppendCallback(function()
self.arenaTxGrading:setText(DataManager.ArenaData:getGradingName(curId))
if lastId ~= curId then
self:refreshArenaGradingSpine(curId, curId > lastId)
end
self.arenaSequence = nil
end)
if self.incrScore > 0 then
self.arenaTxScore:setText(I18N:getGlobalText(I18N.GlobalConst.ARENA_DESC_27, "+"..self.incrScore))
elseif self.incrScore == 0 then
self.arenaTxScore:setText(I18N:getGlobalText(I18N.GlobalConst.ARENA_DESC_27, "-"..self.incrScore))
else
self.arenaTxScore:setText(I18N:getGlobalText(I18N.GlobalConst.ARENA_DESC_27, self.incrScore))
end
end
function BattleBossRushResultUI:hasArenaBoxNode()
if self.battleType ~= GConst.BattleConst.BATTLE_TYPE.ARENA then
return false
end
if not DataManager.ArenaData:hasAdBox(self.isWin, self.arenaTotalCount) then
return false
end
if self.getedArenaAdBox then
return false
end
return true
end
function BattleBossRushResultUI:refreshArenaBoxNode()
self.arenaBoxNode:setVisible(false)
if not self:hasArenaBoxNode() then
return
end
self.arenaBoxNode:setVisible(true)
self.arenaBoxBtnGet:setActive(not self.getedArenaAdBox)
self.arenaBoxTxGet:setText(I18N:getGlobalText(I18N.GlobalConst.BTN_CLAIM))
if self.isWin then
-- 胜利宝箱
self.arenaBoxNode:setSprite(GConst.ATLAS_PATH.ARENA, "arena_bg_6")
self.arenaBoxImgIcon:setSprite(GConst.ATLAS_PATH.SHOP, "shop_chest_5")
self.arenaBoxTxTitle:setText(I18N:getGlobalText(I18N.GlobalConst.ARENA_DESC_33))
else
-- 鼓励宝箱
self.arenaBoxNode:setSprite(GConst.ATLAS_PATH.ARENA, "arena_bg_5")
self.arenaBoxImgIcon:setSprite(GConst.ATLAS_PATH.SHOP, "shop_chest_4")
self.arenaBoxTxTitle:setText(I18N:getGlobalText(I18N.GlobalConst.ARENA_DESC_34))
end
ModuleManager.ArenaManager:markAdBox(self.isWin)
end
function BattleBossRushResultUI:refreshArenaGradingSpine(gradingId, isUp)
if gradingId == nil then
return
end
if self.arenaSpine then
self.arenaSpine:playAnimComplete("vanish", false, false, function()
self.arenaSpine:destroy()
self.arenaSpine = nil
self:refreshArenaGradingSpine(gradingId, isUp)
end)
else
SpineManager:loadUISpineWidgetAsync(DataManager.ArenaData:getGradingIconName(gradingId).."_spine", self.arenaSpineRoot, function(spineObject)
self.arenaSpine = spineObject
self.arenaSpine:setLocalScale(0.8, 0.8, 1)
self.arenaSpine:setSkin(DataManager.ArenaData:getGradingNumName(gradingId))
self.arenaSpine:playAnimComplete("born", false, false, function()
if self.arenaSpine then
self.arenaSpine:playAnim("idle", true, false)
end
end)
end)
if isUp then
EffectManager:loadUIEffectAsync("assets/prefabs/effects/ui/vfx_ui_".. DataManager.ArenaData:getGradingIconName(gradingId) ..".prefab", self, self.arenaSpineRoot, GConst.UI_EFFECT_ORDER.LEVEL5, function(obj)
obj:play()
end)
end
end
end
function BattleBossRushResultUI:refreshRewards()
self.animRewards = {}
self.rewardNode:setVisible(true)
self.goldPigNode:setVisible(false)
self.rewardTxTitle:setText(I18N:getGlobalText(I18N.GlobalConst.REWARD_DESC))
self.continue:setText(I18N:getGlobalText(I18N.GlobalConst.CONTINUE_DESC))
self.rewardScrollRectComp:addInitCallback(function()
return GConst.TYPEOF_LUA_CLASS.REWARD_CELL
end)
self.rewardScrollRectComp:addRefreshCallback(function(index, cell)
cell:refresh(self.rewards[index])
if index <= MAX_SCROLL_SHOW_COUNT and self.animRewards[index] == nil then
self.animRewards[index] = self:showRewardAppearAnim(index, cell)
end
cell:showRightUpIcon(index <= self.mysteryBoxIdx, GConst.ATLAS_PATH.COMMON, "common_chest_1")
cell:showFirstPass(index <= self.firstPassIdx)
end)
if self:hasArenaBoxNode() then
self.rewardScrollRect:setSizeDeltaY(SCROLL_LINE_HEIGHT)
self.rewardScrollRect:setAnchoredPositionY(-255)
else
self.rewardScrollRect:setSizeDeltaY(SCROLL_LINE_HEIGHT * 2)
self.rewardScrollRect:setAnchoredPositionY(-268)
end
self.rewardScrollRectComp:setFadeArgs(0.05, 0.3)
self.rewardScrollRectComp:clearCells()
local rewardCount = #self.rewards
if rewardCount > MAX_SCROLL_SHOW_COUNT then
local comp = self.rewardScrollRect:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_SCROLL_RECT)
comp.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic
self.rewardScrollRectComp:setPerLineNum(5)
self.rewardScrollRect:setSizeDeltaX(560)
else
local comp = self.rewardScrollRect:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_SCROLL_RECT)
comp.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Clamped
if rewardCount >= 5 then
self.rewardScrollRectComp:setPerLineNum(5)
self.rewardScrollRect:setSizeDeltaX(560)
elseif rewardCount <= 0 then
self.rewardScrollRectComp:setPerLineNum(1)
self.rewardScrollRect:setSizeDeltaX(560)
else
self.rewardScrollRectComp:setPerLineNum(rewardCount)
self.rewardScrollRect:setSizeDeltaX(112*rewardCount)
end
end
self.rewardScrollRectComp:refillCells(rewardCount)
end
function BattleBossRushResultUI:refreshUnitInfo()
if not self.atkReport then
self.unitNode:setVisible(false)
return
end
self.unitNode:setVisible(true)
for index, cell in ipairs(self.unitResultReportCells) do
local info = self.atkReport[index]
cell:getBaseObject():setVisible(info ~= nil)
if info then
cell:refresh(info, self.totalDmg)
end
end
self.unitTxDesc2:setText(self.wave)
self.unitTxDesc3:setText(I18N:getGlobalText(I18N.GlobalConst.BATTLE_DESC_7, GFunc.num2Str(self.totalDmg)))
local iconName = "common_dec_3"
if self.battleType == GConst.BattleConst.BATTLE_TYPE.DUNGEON_GOLD then
iconName = "common_dec_15"
local round = self.remainRound or 0
self.unitTxDesc2:setText(round)
self.unitTxDesc1:setText(I18N:getGlobalText(I18N.GlobalConst.ROUND_LEFT))
else
self.unitTxDesc1:setText(GConst.EMPTY_STRING)
end
self.unitImgBattleIcon:setSprite(GConst.ATLAS_PATH.COMMON, iconName)
GFunc.centerImgAndTx(self.unitImgBattleIcon, self.unitTxDesc2, 7)
end
function BattleBossRushResultUI:tryShowGoldPig()
self.isTryShowGoldPig = true
if self.battleType ~= GConst.BattleConst.BATTLE_TYPE.STAGE then
return false
end
if not DataManager.GoldPigData:getIsOpen() then
return false
end
self.rewardNode:setVisible(false)
self.goldPigNode:setVisible(true)
local lastGemCount = DataManager.GoldPigData:getLastCount()
local currGemCount = DataManager.GoldPigData:getCount()
local maxGemCount = DataManager.GoldPigData:getMaxCount()
if lastGemCount > currGemCount then
lastGemCount = currGemCount
end
self.animPig = self.root:createBindTweenSequence()
self.animPig:Insert(0, self.canvasGroupPigGem:DOFade(0, 0))
self.animPig:Insert(1.5, self.canvasGroupPigGem:DOFade(1, 0.3))
self.animPig:SetAutoKill(false)
self.animPig:OnComplete(function()
self.animPig = nil
end)
self.goldPigSpine:playAnimComplete("idle1", false, false, function()
self.goldPigSpine:playAnim("idle2", true, false)
end)
self.goldPigTxGem:setText("+" .. currGemCount - lastGemCount)
GFunc.centerImgAndTx(self.goldPigImgGem, self.goldPigTxGem, 0, -4)
if currGemCount > lastGemCount then
self.sliderSequence = DOTweenManager:createSeqWithIntId()
local curProgress = 0
local remain = currGemCount - lastGemCount
local startPercent = lastGemCount / maxGemCount
local remainPercent = currGemCount / maxGemCount - startPercent
self.goldPigSlider.value = startPercent
self.goldPigTxSlider:setText(lastGemCount .. "/" .. currGemCount)
local tween = DOTweenManager:createDOTweenTo(
function()
return curProgress
end,
function(value)
curProgress = value
self.goldPigSlider.value = startPercent + remainPercent*curProgress
self.goldPigTxSlider:setText(lastGemCount + math.floor(remain*curProgress) .. "/" .. maxGemCount)
end,
1, 1)
self.sliderSequence:Append(tween)
self.sliderSequence:AppendCallback(function()
self.sliderSequence = nil
end)
else -- 相等就不跑动画了
self.goldPigSlider.value = currGemCount / maxGemCount
self.goldPigTxSlider:setText(currGemCount .. "/" .. maxGemCount)
end
return true
end
-- 展示结算奖励的出现动画
function BattleBossRushResultUI:showRewardAppearAnim(idx, cell)
local canvasGroup = cell.baseObject:getComponent(GConst.TYPEOF_UNITY_CLASS.CANVAS_GROUP)
local selfObj = cell.baseObject
local delay = (idx - 1) * 0.05
local scaleX = selfObj:fastGetLocalScale()
cell:setTouchEnable(false)
local animRewardAppear = selfObj:createBindTweenSequence()
animRewardAppear:Insert(0, canvasGroup:DOFade(0, 0))
animRewardAppear:Insert(0, selfObj:getTransform():DOScale(scaleX * 0.6, 0))
animRewardAppear:Insert(0.3 + delay, selfObj:getTransform():DOScale(scaleX * 1.1, 0.1))
animRewardAppear:Insert(0.3 + delay, canvasGroup:DOFade(1, 0.1))
animRewardAppear:Insert(0.4 + delay, selfObj:getTransform():DOScale(scaleX * 1, 0.13))
animRewardAppear:OnComplete(function()
animRewardAppear = nil
cell:setTouchEnable(true)
end)
return animRewardAppear
end
return BattleBossRushResultUI

View File

@ -14,6 +14,7 @@ ActBossRushData.REWARD_TYPE = {
function ActBossRushData:clear() function ActBossRushData:clear()
self.data.isDirty = false self.data.isDirty = false
self.startTime = 0
self.endTime = 0 self.endTime = 0
-- 战斗相关 -- 战斗相关
self.stageRandomSeed = 0 self.stageRandomSeed = 0
@ -22,6 +23,8 @@ function ActBossRushData:clear()
self.todayMaxRound = 0 self.todayMaxRound = 0
self.todayFightCount = 0 self.todayFightCount = 0
self.fightCount = 0 self.fightCount = 0
self.todayMaxWave = 0
self.todayMaxWaveRound = 0
-- 兑换 -- 兑换
self.shop = {} self.shop = {}
-- 战令 -- 战令
@ -53,25 +56,45 @@ function ActBossRushData:ctor()
self:clear() self:clear()
end end
function ActBossRushData:setActivityInfo(activity)
self.startTime = GFunc.formatTimeStep(activity.start_at)
self.endTime = GFunc.formatTimeStep(activity.end_at)
end
function ActBossRushData:init(data) function ActBossRushData:init(data)
if not data then if not data then
return return
end end
self.activity_id = data.activity_id
-- 战斗 -- 战斗
self.stageRandomSeed = data.self.stageRandomSeed or Time:getBeginningOfServerToday() if data.heroes then
self.todayFightCount = data.todayFightCount or 0 DataManager.FormationData:initFormationByType(GConst.BattleConst.FORMATION_TYPE.BOSS_RUSH, data.heroes)
self.fightCount = data.fightCount or 0
self.stageList = {}
for id, info in ipairs(ConfigManager:getConfig("activity_boss_rush_chapter")) do
table.insert(self.stageList, id)
end end
self.stageList = table.shuffleBySeed(self.stageList, self.stageRandomSeed) self.todayFightCount = data.challenge or 0
self.fightCount = data.fight_count or 0
self.todayMaxWave = data.max_wave or 0
self.todayMaxWaveRound = data.min_round or 0
-- 兑换 -- 兑换
self.shop = data.shop self.shop = data.exchanged or {}
-- 战令 -- 战令
self.waveCount = data.accum_wave or 0
if data.collected then
for level, bossrushgrade in pairs(data.collected) do
if bossrushgrade.normal then
self:setFreeGot(level)
end
if bossrushgrade.superior then
self:setProGot(level)
end
if bossrushgrade.superior_max then
self:setUtralGot(level)
end
end
end
self.waveLevelListCount = 0 self.waveLevelListCount = 0
local list = self:getBountyList() local list = self:getBountyList()
for _, id in ipairs(list) do for _, id in ipairs(list) do
@ -91,6 +114,12 @@ function ActBossRushData:init(data)
end end
end end
self.proBounght = false
self:getProBought()
self.utralBounght = false
self:getUtralBought()
DataManager:registerCrossDayFunc("ActBossRushData", function() DataManager:registerCrossDayFunc("ActBossRushData", function()
self.todayMaxWave = 0 self.todayMaxWave = 0
self.todayMaxRound = 0 self.todayMaxRound = 0
@ -108,7 +137,8 @@ end
function ActBossRushData:getIsOpen() function ActBossRushData:getIsOpen()
-- 开启条件 -- 开启条件
return self.endTime > Time:getServerTime() local time = Time:getServerTime()
return self.endTime > time and time > self.startTime
end end
function ActBossRushData:getRp() function ActBossRushData:getRp()
@ -140,11 +170,22 @@ function ActBossRushData:getIsFirstDay()
end end
---- 战斗 ---- 战斗
function ActBossRushData:updateStageSeed(seed)
if self.stageRandomSeed == seed then
return
end
self.stageRandomSeed = seed
self.stageList = {}
for id, info in ipairs(ConfigManager:getConfig("activity_boss_rush_chapter")) do
table.insert(self.stageList, id)
end
self.stageList = table.shuffleBySeed(self.stageList, self.stageRandomSeed)
end
function ActBossRushData:getStageList() function ActBossRushData:getStageList()
return self.stageList return self.stageList
end end
function ActBossRushData:getTodayMaxWave() function ActBossRushData:getTodayMaxWave()
return self.todayMaxWave or 0 return self.todayMaxWave or 0
end end
@ -237,7 +278,10 @@ function ActBossRushData:setNeedUpdateRank()
end end
function ActBossRushData:updateRankInfo(info) function ActBossRushData:updateRankInfo(info)
-- -todo self.lastRankList = info.yesterday_top50
self.lastSelfRank = info.yesterday_self
self.rankList = info.today_top50
self.selfRank = info.today_self
self.needUpdateRank = Time:getServerTime() self.needUpdateRank = Time:getServerTime()
end end
@ -287,7 +331,7 @@ end
function ActBossRushData:getBountyList() function ActBossRushData:getBountyList()
if not self.bountyList then if not self.bountyList then
self.bountyList = GFunc.getTable(DataManager:getActivityBountyLevelByActId(ACT_ID) or {}) self.bountyList = GFunc.getTable(DataManager:getActivityBountyLevelByActId(self.activity_id or ACT_ID) or {})
end end
return self.bountyList return self.bountyList
end end
@ -426,6 +470,18 @@ function ActBossRushData:gotFundReward(idWithLv)
self:setDirty() self:setDirty()
end end
function ActBossRushData:gotSingleFundReward(level, grade)
if grade == 0 then
self:setFreeGot(level)
elseif grade == 1 then
self:setProGot(level)
elseif grade == 2 then
self:setUtralGot(level)
end
self:setDirty()
end
function ActBossRushData:getFreeCanGet(level) function ActBossRushData:getFreeCanGet(level)
if self:getFreeGot(level) then if self:getFreeGot(level) then
return false return false
@ -517,7 +573,7 @@ end
function ActBossRushData:getExchangeList() function ActBossRushData:getExchangeList()
if not self.exchangeList then if not self.exchangeList then
self.exchangeList = GFunc.getTable(DataManager:getActivityExchangeByActId(ACT_ID) or {}) self.exchangeList = GFunc.getTable(DataManager:getActivityExchangeByActId(self.activity_id or ACT_ID) or {})
end end
return self.exchangeList return self.exchangeList

View File

@ -74,6 +74,20 @@ function FormationData:initDungeonArmor(heroes)
end end
end end
function FormationData:initFormationByType(formationType, heroes)
if self.formations == nil then
self.formations = {}
end
self.formations[formationType] = {}
for idx, id in pairs(heroes) do
if id and id ~= 0 then
local matchType = DataManager.HeroData:getHeroById(id):getMatchType()
self.formations[formationType][matchType] = id
end
end
end
function FormationData:getStageFormation() function FormationData:getStageFormation()
return self:getFormation(GConst.BattleConst.FORMATION_TYPE.STAGE) return self:getFormation(GConst.BattleConst.FORMATION_TYPE.STAGE)
end end