From d7bee9480c339e0b38f10e84164a0362d63c1669 Mon Sep 17 00:00:00 2001 From: xiekaidong Date: Wed, 17 May 2023 20:17:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9D=E7=AE=B1=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/ui/main_city/component/main_comp.lua | 9 +++++++ lua/app/userdata/chapter/chapter_data.lua | 26 +++++++++++++++++--- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/lua/app/ui/main_city/component/main_comp.lua b/lua/app/ui/main_city/component/main_comp.lua index 238bbac5..14f9240f 100644 --- a/lua/app/ui/main_city/component/main_comp.lua +++ b/lua/app/ui/main_city/component/main_comp.lua @@ -95,7 +95,16 @@ function MainComp:refreshChapter(force) end end + local mysteryBoxCount = DataManager.ChapterData:getChapterMysteryBoxRewardCount(chapterId) + local mysteryBoxIcon = self.uiMap["main_comp.chapter.img.mystery_box_icon"] + mysteryBoxIcon:setVisible(mysteryBoxCount > 0) + if mysteryBoxCount > 0 then + local remainCount = math.max(mysteryBoxCount - DataManager.ChapterData:getChapterMysteryBoxGotCount(chapterId), 0) + self.uiMap["main_comp.chapter.img.mystery_box_icon.desc"]:setText(remainCount .. "/" .. mysteryBoxCount) + end + local rewardChapterId = DataManager.ChapterData:getIsHaveRewardsMinId() + Logger.logHighlight("rewardChapterId " .. rewardChapterId) if rewardChapterId > chapterId then rewardChapterId = chapterId end diff --git a/lua/app/userdata/chapter/chapter_data.lua b/lua/app/userdata/chapter/chapter_data.lua index 5747712e..3d35598b 100644 --- a/lua/app/userdata/chapter/chapter_data.lua +++ b/lua/app/userdata/chapter/chapter_data.lua @@ -328,10 +328,6 @@ function ChapterData:fightChapter(chapterId, maxChapterId, maxWave, mysteryBoxId self:setDirty() end -function ChapterData:getChapterMysteryBox(chapterId) - return self.data.chapterInfo[chapterId].mystery_box_idx -end - function ChapterData:getChapterMysteryBoxReward(chapterId) local cfg = self:getChapterCfg()[chapterId] if not cfg then @@ -340,6 +336,18 @@ function ChapterData:getChapterMysteryBoxReward(chapterId) return cfg.mystery_box_reward end +function ChapterData:getChapterMysteryBoxRewardCount(chapterId) + local cfg = self:getChapterCfg()[chapterId] + if not cfg then + return 0 + end + if cfg.mystery_box_reward then + return #cfg.mystery_box_reward + else + return 0 + end +end + function ChapterData:getChapterMysteryBoxIsGot(chapterId, index) if not self.data.chapterInfo[chapterId] then return false @@ -355,4 +363,14 @@ function ChapterData:getChapterMysteryBoxIsGot(chapterId, index) return false end +function ChapterData:getChapterMysteryBoxGotCount(chapterId) + if not self.data.chapterInfo[chapterId] then + return 0 + end + if not self.data.chapterInfo[chapterId].mystery_box_idx then + return 0 + end + return #self.data.chapterInfo[chapterId].mystery_box_idx +end + return ChapterData \ No newline at end of file