From 67cc032ffb9b9a9f94ba7db538e1fa50cba4938c Mon Sep 17 00:00:00 2001 From: chenxi Date: Fri, 21 Apr 2023 11:56:41 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BA=A2=E7=82=B9=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/ui/main_city/component/main_comp.lua | 16 +++- lua/app/userdata/chapter/chapter_data.lua | 78 ++++++++++++++++++++ 2 files changed, 92 insertions(+), 2 deletions(-) diff --git a/lua/app/ui/main_city/component/main_comp.lua b/lua/app/ui/main_city/component/main_comp.lua index 4d26f851..36ab1e3f 100644 --- a/lua/app/ui/main_city/component/main_comp.lua +++ b/lua/app/ui/main_city/component/main_comp.lua @@ -66,16 +66,28 @@ end function MainComp:refreshChapter(force) local chapterId = DataManager.ChapterData:getChapterId() if self.currChapterId ~= chapterId or force then - if DataManager.ChapterData:getIsFirstChapter(chapterId) then + if DataManager.ChapterData:getIsFirstChapter(chapterId) then -- 第一章不需要左箭头 self.leftArrow:setVisible(false) self.rightArrow:setVisible(true) - elseif DataManager.ChapterData:getIsFinalChapter(chapterId) then + elseif chapterId == DataManager.ChapterData:getMaxChapterId() + 1 then -- 只能看打的最远的关卡 self.leftArrow:setVisible(true) self.rightArrow:setVisible(false) else self.leftArrow:setVisible(true) self.rightArrow:setVisible(true) end + local isHaveLeftRewards = DataManager.ChapterData:getIsHaveRewardsBeforeId(chapterId) + if isHaveLeftRewards then + self.leftArrow:addRedPoint(16, 28, 0.6) + else + self.leftArrow:removeRedPoint() + end + local isHaveRightRewards = DataManager.ChapterData:getIsHaveRewardsAfterId(chapterId) + if isHaveRightRewards then + self.rightArrow:addRedPoint(-10, 28, 0.6) + else + self.rightArrow:removeRedPoint() + end self.currChapterId = chapterId local chapterInfo = ConfigManager:getConfig("chapter")[chapterId] diff --git a/lua/app/userdata/chapter/chapter_data.lua b/lua/app/userdata/chapter/chapter_data.lua index c775e364..5c8e47e7 100644 --- a/lua/app/userdata/chapter/chapter_data.lua +++ b/lua/app/userdata/chapter/chapter_data.lua @@ -166,4 +166,82 @@ function ChapterData:getMaxChapterId() return self.data.maxChapterId end +-- 此章节之前是否有未领取的奖励 +function ChapterData:getIsHaveRewardsBeforeId(chapterId) + if chapterId == MIN_CHAPTER_ID then + return false + end + local chapterBefore = MIN_CHAPTER_ID + local chapterCfg = self:getChapterCfg() + local chapterInfo = chapterCfg[chapterBefore] + while true do + if self:getIsHaveRewards(chapterBefore) then + return true + end + chapterBefore = chapterInfo.next_chapter + if chapterBefore == chapterId then + break + end + chapterInfo = chapterCfg[chapterBefore] + if chapterInfo == nil then + break + end + end + return false +end + +-- 此章节之后是否有未领取的奖励 +function ChapterData:getIsHaveRewardsAfterId(chapterId) + if chapterId == MIN_CHAPTER_ID then + return false + end + if chapterId == self.data.maxChapterId + 1 then -- 未开启的章节不算 + return false + end + local chapterAfter = chapterId + 1 + local chapterCfg = self:getChapterCfg() + local chapterInfo = chapterCfg[chapterAfter] + if chapterInfo == nil then + return false + end + while true do + if self:getIsHaveRewards(chapterAfter) then + return true + end + chapterAfter = chapterInfo.next_chapter + if chapterAfter > self.data.maxChapterId + 1 then -- 未开启的章节不算 + break + end + chapterInfo = chapterCfg[chapterAfter] + if chapterInfo == nil then + break + end + end + return false +end + +-- 此章节是否有可领但是未领取的奖励 +function ChapterData:getIsHaveRewards(chapterId) + if chapterId > self.data.maxChapterId + 1 then + return false + end + local chapterStr = tostring(chapterId) + local list = self.data.chapterBoxInfo[chapterStr] + local count = self:getChapterBoxCount(chapterId) + if list and #list == count then -- 数量一致说明都领完了 + return false + elseif chapterId < self.data.maxChapterId then + return true + end + local curMaxWave = self:getChapterMaxWave(chapterStr) + for i = 1, count do + local needWave = self:getChapterBoxNum(chapterId, i) + local rewardGot = self:getChapterBoxRewardGot(chapterStr, i) + if needWave <= curMaxWave and not rewardGot then -- 有可以领但是没有领的奖励 + return true + end + end + return false +end + return ChapterData \ No newline at end of file