宝箱修改

This commit is contained in:
xiekaidong 2023-04-24 11:21:26 +08:00
parent 7000ea6f30
commit 0d0d0ca50b
4 changed files with 27 additions and 60 deletions

View File

@ -1,5 +1,6 @@
local LocalizationGlobalConst = local LocalizationGlobalConst =
{ {
MAIN_DESC_1 = "MAIN_DESC_1",
MAIN_BTN_1 = "MAIN_BTN_1", MAIN_BTN_1 = "MAIN_BTN_1",
QLT_DESC_1 = "QLT_DESC_1", QLT_DESC_1 = "QLT_DESC_1",
QLT_DESC_2 = "QLT_DESC_2", QLT_DESC_2 = "QLT_DESC_2",

View File

@ -41,6 +41,8 @@ local localization_global =
["HERO_DESC_10"] = "通关章节{0}解锁", ["HERO_DESC_10"] = "通关章节{0}解锁",
["BATTLE_DESC_8"] = "还有可上阵英雄", ["BATTLE_DESC_8"] = "还有可上阵英雄",
["MAIN_BTN_2"] = "英雄", ["MAIN_BTN_2"] = "英雄",
["MAIN_DESC_1"] = "第{0}章",
} }
return localization_global return localization_global

View File

@ -76,18 +76,6 @@ function MainComp:refreshChapter(force)
self.leftArrow:setVisible(true) self.leftArrow:setVisible(true)
self.rightArrow:setVisible(not DataManager.ChapterData:isFinalChapter(chapterId)) self.rightArrow:setVisible(not DataManager.ChapterData:isFinalChapter(chapterId))
end 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 self.currChapterId = chapterId
local chapterInfo = ConfigManager:getConfig("chapter")[chapterId] local chapterInfo = ConfigManager:getConfig("chapter")[chapterId]
@ -110,9 +98,10 @@ function MainComp:refreshChapter(force)
end end
end end
local curMaxWave = DataManager.ChapterData:getChapterMaxWave() local rewardChapterId = DataManager.ChapterData:getIsHaveRewardsMinId()
local boxCount = DataManager.ChapterData:getChapterBoxCount() local curMaxWave = DataManager.ChapterData:getChapterMaxWave(rewardChapterId)
local maxWave = DataManager.ChapterData:getChapterBoxNum(chapterId, boxCount) local boxCount = DataManager.ChapterData:getChapterBoxCount(rewardChapterId)
local maxWave = DataManager.ChapterData:getChapterBoxNum(rewardChapterId, boxCount)
slider:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER).value = curMaxWave / maxWave slider:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER).value = curMaxWave / maxWave
for index, objs in ipairs(self.boxObjs) do for index, objs in ipairs(self.boxObjs) do
@ -120,18 +109,18 @@ function MainComp:refreshChapter(force)
objs.box:setActive(show) objs.box:setActive(show)
objs.desc:setActive(show) objs.desc:setActive(show)
if show then if show then
local needWave = DataManager.ChapterData:getChapterBoxNum(chapterId, index) local needWave = DataManager.ChapterData:getChapterBoxNum(rewardChapterId, index)
local x = 370 * (index / boxCount) local x = 370 * (index / boxCount)
local rewards = DataManager.ChapterData:getChapterBoxRewards(nil, index) local rewards = DataManager.ChapterData:getChapterBoxRewards(rewardChapterId, index)
local num = DataManager.ChapterData:getChapterBoxNum(nil, index) local num = DataManager.ChapterData:getChapterBoxNum(rewardChapterId, index)
local rewardGot = DataManager.ChapterData:getChapterBoxRewardGot(nil, index) local rewardGot = DataManager.ChapterData:getChapterBoxRewardGot(rewardChapterId, index)
local icon = BOX_ICON[1] local icon = BOX_ICON[1]
if rewardGot then if rewardGot then
icon = BOX_ICON[2] icon = BOX_ICON[2]
end end
objs.box:addClickListener(function() objs.box:addClickListener(function()
if needWave <= curMaxWave and not rewardGot then if needWave <= curMaxWave and not rewardGot then
ModuleManager.ChapterManager:openBox(chapterId, index) ModuleManager.ChapterManager:openBox(rewardChapterId, index)
else else
ModuleManager.TipsManager:showRewardsTips(rewards, nil, objs.box) ModuleManager.TipsManager:showRewardsTips(rewards, nil, objs.box)
end end
@ -144,7 +133,11 @@ function MainComp:refreshChapter(force)
objs.box:removeRedPoint() objs.box:removeRedPoint()
end end
objs.desc:setAnchoredPositionX(x) 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
end end

View File

@ -178,23 +178,22 @@ function ChapterData:getMaxChapterId()
return self.data.maxChapterId return self.data.maxChapterId
end end
-- 此章节之前是否有未领取的奖励 -- 得到有奖励的最小章节,如果没有,就是当前章节
function ChapterData:getIsHaveRewardsBeforeId(chapterId) function ChapterData:getIsHaveRewardsMinId()
if chapterId == MIN_CHAPTER_ID then
return false
end
local chapterBefore = MIN_CHAPTER_ID local chapterBefore = MIN_CHAPTER_ID
local chapterCfg = self:getChapterCfg() local chapterCfg = self:getChapterCfg()
local chapterInfo = chapterCfg[chapterBefore] local chapterInfo = chapterCfg[chapterBefore]
while true do while true do
if self:getIsHaveRewards(chapterBefore) then if self:getIsHaveRewards(chapterBefore) then
return true break
end end
chapterBefore = chapterInfo.next_chapter chapterBefore = chapterInfo.next_chapter
if chapterBefore == nil then if chapterBefore == nil then
break break
end end
if chapterBefore == chapterId then if chapterBefore == self.maxChapterId then
chapterBefore = self:getNextChapter(self.data.maxChapterId)
break break
end end
chapterInfo = chapterCfg[chapterBefore] chapterInfo = chapterCfg[chapterBefore]
@ -202,40 +201,12 @@ function ChapterData:getIsHaveRewardsBeforeId(chapterId)
break break
end end
end end
return false
end
-- 此章节之后是否有未领取的奖励 if not chapterBefore then
function ChapterData:getIsHaveRewardsAfterId(chapterId) chapterBefore = self:getNextChapter(self.data.maxChapterId)
if chapterId == MIN_CHAPTER_ID then
return false
end end
if chapterId == self.data.maxChapterId + 1 then -- 未开启的章节不算
return false return chapterBefore
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
end end
-- 此章节是否有可领但是未领取的奖励 -- 此章节是否有可领但是未领取的奖励