From 2023930d622218e54ea4caf26a366949165042e2 Mon Sep 17 00:00:00 2001 From: xiekaidong Date: Wed, 17 May 2023 19:19:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9D=E7=AE=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/module/battle/battle_manager.lua | 4 ++-- lua/app/module/chapter/chapter_manager.lua | 20 +++++++++++++++----- lua/app/ui/battle/battle_result_ui.lua | 2 ++ lua/app/ui/common/cell/reward_cell.lua | 9 +++++++++ lua/app/userdata/chapter/chapter_data.lua | 10 ++++++++-- 5 files changed, 36 insertions(+), 9 deletions(-) diff --git a/lua/app/module/battle/battle_manager.lua b/lua/app/module/battle/battle_manager.lua index cc4328c2..f87d74d3 100644 --- a/lua/app/module/battle/battle_manager.lua +++ b/lua/app/module/battle/battle_manager.lua @@ -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) diff --git a/lua/app/module/chapter/chapter_manager.lua b/lua/app/module/chapter/chapter_manager.lua index 4c8ccf7e..831a3aae 100644 --- a/lua/app/module/chapter/chapter_manager.lua +++ b/lua/app/module/chapter/chapter_manager.lua @@ -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() diff --git a/lua/app/ui/battle/battle_result_ui.lua b/lua/app/ui/battle/battle_result_ui.lua index c8d0a314..2a3be616 100644 --- a/lua/app/ui/battle/battle_result_ui.lua +++ b/lua/app/ui/battle/battle_result_ui.lua @@ -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() diff --git a/lua/app/ui/common/cell/reward_cell.lua b/lua/app/ui/common/cell/reward_cell.lua index 1e0760e7..44ae8ddc 100644 --- a/lua/app/ui/common/cell/reward_cell.lua +++ b/lua/app/ui/common/cell/reward_cell.lua @@ -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 \ No newline at end of file diff --git a/lua/app/userdata/chapter/chapter_data.lua b/lua/app/userdata/chapter/chapter_data.lua index 3fa9aa06..5747712e 100644 --- a/lua/app/userdata/chapter/chapter_data.lua +++ b/lua/app/userdata/chapter/chapter_data.lua @@ -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