From 0d0d0ca50b252d969a303d4d1b1cf744ccfed48c Mon Sep 17 00:00:00 2001 From: xiekaidong Date: Mon, 24 Apr 2023 11:21:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9D=E7=AE=B1=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../localization_global_const.lua | 1 + lua/app/config/strings/cn/global.lua | 2 + lua/app/ui/main_city/component/main_comp.lua | 35 ++++++------- lua/app/userdata/chapter/chapter_data.lua | 49 ++++--------------- 4 files changed, 27 insertions(+), 60 deletions(-) diff --git a/lua/app/config/localization/localization_global_const.lua b/lua/app/config/localization/localization_global_const.lua index 23f992d1..e4e78f2f 100644 --- a/lua/app/config/localization/localization_global_const.lua +++ b/lua/app/config/localization/localization_global_const.lua @@ -1,5 +1,6 @@ local LocalizationGlobalConst = { + MAIN_DESC_1 = "MAIN_DESC_1", MAIN_BTN_1 = "MAIN_BTN_1", QLT_DESC_1 = "QLT_DESC_1", QLT_DESC_2 = "QLT_DESC_2", diff --git a/lua/app/config/strings/cn/global.lua b/lua/app/config/strings/cn/global.lua index 7f3f8850..0ab6e6db 100644 --- a/lua/app/config/strings/cn/global.lua +++ b/lua/app/config/strings/cn/global.lua @@ -41,6 +41,8 @@ local localization_global = ["HERO_DESC_10"] = "通关章节{0}解锁", ["BATTLE_DESC_8"] = "还有可上阵英雄", ["MAIN_BTN_2"] = "英雄", + + ["MAIN_DESC_1"] = "第{0}章", } return localization_global \ No newline at end of file diff --git a/lua/app/ui/main_city/component/main_comp.lua b/lua/app/ui/main_city/component/main_comp.lua index f8f4a2f9..5b9bc23e 100644 --- a/lua/app/ui/main_city/component/main_comp.lua +++ b/lua/app/ui/main_city/component/main_comp.lua @@ -76,18 +76,6 @@ function MainComp:refreshChapter(force) self.leftArrow:setVisible(true) self.rightArrow:setVisible(not DataManager.ChapterData:isFinalChapter(chapterId)) end - local isHaveLeftRewards = DataManager.ChapterData:getIsHaveRewardsBeforeId(chapterId) - if isHaveLeftRewards then - self.leftArrow:addRedPoint(-20, 28, 0.5) - else - self.leftArrow:removeRedPoint() - end - local isHaveRightRewards = DataManager.ChapterData:getIsHaveRewardsAfterId(chapterId) - if isHaveRightRewards then - self.rightArrow:addRedPoint(20, 28, 0.5) - else - self.rightArrow:removeRedPoint() - end self.currChapterId = chapterId local chapterInfo = ConfigManager:getConfig("chapter")[chapterId] @@ -110,9 +98,10 @@ function MainComp:refreshChapter(force) end end - local curMaxWave = DataManager.ChapterData:getChapterMaxWave() - local boxCount = DataManager.ChapterData:getChapterBoxCount() - local maxWave = DataManager.ChapterData:getChapterBoxNum(chapterId, boxCount) + local rewardChapterId = DataManager.ChapterData:getIsHaveRewardsMinId() + local curMaxWave = DataManager.ChapterData:getChapterMaxWave(rewardChapterId) + local boxCount = DataManager.ChapterData:getChapterBoxCount(rewardChapterId) + local maxWave = DataManager.ChapterData:getChapterBoxNum(rewardChapterId, boxCount) slider:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER).value = curMaxWave / maxWave for index, objs in ipairs(self.boxObjs) do @@ -120,18 +109,18 @@ function MainComp:refreshChapter(force) objs.box:setActive(show) objs.desc:setActive(show) if show then - local needWave = DataManager.ChapterData:getChapterBoxNum(chapterId, index) + local needWave = DataManager.ChapterData:getChapterBoxNum(rewardChapterId, index) local x = 370 * (index / boxCount) - local rewards = DataManager.ChapterData:getChapterBoxRewards(nil, index) - local num = DataManager.ChapterData:getChapterBoxNum(nil, index) - local rewardGot = DataManager.ChapterData:getChapterBoxRewardGot(nil, index) + local rewards = DataManager.ChapterData:getChapterBoxRewards(rewardChapterId, index) + local num = DataManager.ChapterData:getChapterBoxNum(rewardChapterId, index) + local rewardGot = DataManager.ChapterData:getChapterBoxRewardGot(rewardChapterId, index) local icon = BOX_ICON[1] if rewardGot then icon = BOX_ICON[2] end objs.box:addClickListener(function() if needWave <= curMaxWave and not rewardGot then - ModuleManager.ChapterManager:openBox(chapterId, index) + ModuleManager.ChapterManager:openBox(rewardChapterId, index) else ModuleManager.TipsManager:showRewardsTips(rewards, nil, objs.box) end @@ -144,7 +133,11 @@ function MainComp:refreshChapter(force) objs.box:removeRedPoint() end objs.desc:setAnchoredPositionX(x) - objs.desc:setText(num) + if boxCount == index then + objs.desc:setText(I18N:getGlobalText(I18N.GlobalConst.MAIN_DESC_1, rewardChapterId)) + else + objs.desc:setText(num) + end end end diff --git a/lua/app/userdata/chapter/chapter_data.lua b/lua/app/userdata/chapter/chapter_data.lua index a833ff6f..8dd5376a 100644 --- a/lua/app/userdata/chapter/chapter_data.lua +++ b/lua/app/userdata/chapter/chapter_data.lua @@ -178,23 +178,22 @@ function ChapterData:getMaxChapterId() return self.data.maxChapterId end --- 此章节之前是否有未领取的奖励 -function ChapterData:getIsHaveRewardsBeforeId(chapterId) - if chapterId == MIN_CHAPTER_ID then - return false - end +-- 得到有奖励的最小章节,如果没有,就是当前章节 +function ChapterData:getIsHaveRewardsMinId() local chapterBefore = MIN_CHAPTER_ID local chapterCfg = self:getChapterCfg() local chapterInfo = chapterCfg[chapterBefore] while true do if self:getIsHaveRewards(chapterBefore) then - return true + break end + chapterBefore = chapterInfo.next_chapter if chapterBefore == nil then break end - if chapterBefore == chapterId then + if chapterBefore == self.maxChapterId then + chapterBefore = self:getNextChapter(self.data.maxChapterId) break end chapterInfo = chapterCfg[chapterBefore] @@ -202,40 +201,12 @@ function ChapterData:getIsHaveRewardsBeforeId(chapterId) break end end - return false -end --- 此章节之后是否有未领取的奖励 -function ChapterData:getIsHaveRewardsAfterId(chapterId) - if chapterId == MIN_CHAPTER_ID then - return false + if not chapterBefore then + chapterBefore = self:getNextChapter(self.data.maxChapterId) 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 == nil then - break - end - if chapterAfter > self.data.maxChapterId + 1 then -- 未开启的章节不算 - break - end - chapterInfo = chapterCfg[chapterAfter] - if chapterInfo == nil then - break - end - end - return false + + return chapterBefore end -- 此章节是否有可领但是未领取的奖励