This commit is contained in:
xiekaidong 2023-05-17 19:19:24 +08:00
parent ad0ab2b8ba
commit 2023930d62
5 changed files with 36 additions and 9 deletions

View File

@ -14,8 +14,8 @@ function BattleManager:showPauseUI()
UIManager:showUI("app/ui/battle/battle_pause_ui")
end
function BattleManager:showBattleResultUI(rewards, combatReport)
UIManager:showUI("app/ui/battle/battle_result_ui", {rewards = rewards, combatReport = combatReport})
function BattleManager:showBattleResultUI(rewards, combatReport, mysteryBoxIdx)
UIManager:showUI("app/ui/battle/battle_result_ui", {rewards = rewards, combatReport = combatReport, mysteryBoxIdx = mysteryBoxIdx})
end
function BattleManager:playBattle(battleType, params, returnFunc)

View File

@ -58,7 +58,7 @@ function ChapterManager:endFight(id, combatReport, gotMysteryBoxIndexs)
local parmas = {
win = combatReport.victory,
chapter_id = id,
gotMysteryBoxIndexs = gotMysteryBoxIndexs,
mystery_box_idx = mystery_box_idx,
pass_wave = combatReport.wave,
combatReport = combatReport,
}
@ -70,12 +70,22 @@ function ChapterManager:endFightFinish(result)
if result.err_code == GConst.ERROR_STR.SUCCESS then
local reqData = result.reqData
local maxChapter = DataManager.ChapterData:getNewChapterId()
local rewards = {}
local newRewards = {}
if result.rewards then
GFunc.mergeRewards2(result.rewards, newRewards)
local mysteryBoxIdx = result.mystery
for i, reward in ipairs(result.rewards) do
if i <= mysteryBoxIdx then
table.insert(newRewards, reward)
else
table.insert(rewards, reward)
end
end
ModuleManager.BattleManager:showBattleResultUI(newRewards, reqData.combatReport)
DataManager.ChapterData:fightChapter(reqData.chapter_id, result.max_chapter_id, result.max_wave)
if rewards then
GFunc.mergeRewards2(rewards, newRewards)
end
ModuleManager.BattleManager:showBattleResultUI(newRewards, reqData.combatReport, mysteryBoxIdx)
DataManager.ChapterData:fightChapter(reqData.chapter_id, result.max_chapter_id, result.max_wave, reqData.mystery_box_idx)
-- 处理金猪
DataManager.GodPigData:addGoldPigCount()

View File

@ -9,6 +9,7 @@ end
function BattleResultUI:ctor(params)
self.rewards = params.rewards
self.combatReport = params.combatReport
self.mysteryBoxIdx = params.mysteryBoxIdx or 0
self.totalDmg = 0
if self.combatReport.atkReport then
for _, info in ipairs(self.combatReport.atkReport) do
@ -103,6 +104,7 @@ function BattleResultUI:refreshRewards()
end)
self.scrollRectComp:addRefreshCallback(function(index, cell)
cell:refresh(self.rewards[index])
cell:showLeftUpIcon(index <= self.mysteryBoxIdx, GConst.ATLAS_PATH.COMMON, "common_chest_1")
end)
self.scrollRectComp:setFadeArgs(0.05, 0.3)
self.scrollRectComp:clearCells()

View File

@ -8,6 +8,7 @@ function RewardCell:init()
self.check = uiMap["reward_cell.check"]
self.numTx = uiMap["reward_cell.item_bg.num"]
self.fragment = uiMap["reward_cell.item_bg.fragment"]
self.leftUpIcon = uiMap["reward_cell.item_bg.left_up_icon"]
self.frameAni = uiMap["reward_cell.frame_ani"]
self:hideFrameAnimation()
self.baseObject:addClickListener(function()
@ -131,4 +132,12 @@ function RewardCell:hideFrameAnimation()
self.frameAni:setVisible(false)
end
function RewardCell:showLeftUpIcon(show, atlas, iconName)
self.leftUpIcon:setVisible(show)
if not show then
return
end
self.leftUpIcon:setSprite(atlas, iconName)
end
return RewardCell

View File

@ -297,12 +297,12 @@ function ChapterData:openBox(chapterId, index)
self:setDirty()
end
function ChapterData:fightChapter(chapterId, maxChapterId, maxWave)
function ChapterData:fightChapter(chapterId, maxChapterId, maxWave, mysteryBoxIdx)
if not self.data.chapterInfo[chapterId] then
self.data.chapterInfo[chapterId] = {
total_count = 0,
index = {},
chapterId = {}
mystery_box_idx = {}
}
end
self.data.chapterInfo[chapterId].total_count = (self.data.chapterInfo[chapterId].total_count or 0) + 1
@ -319,6 +319,12 @@ function ChapterData:fightChapter(chapterId, maxChapterId, maxWave)
self.data.maxChapterId = maxChapterId - 1
end
for _, idx in ipairs(mysteryBoxIdx) do
if not self:getChapterMysteryBoxIsGot(chapterId, idx) then
table.insert(self.data.chapterInfo[chapterId].mystery_box_idx, idx)
end
end
self:setDirty()
end