宝箱修改

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 =
{
MAIN_DESC_1 = "MAIN_DESC_1",
MAIN_BTN_1 = "MAIN_BTN_1",
QLT_DESC_1 = "QLT_DESC_1",
QLT_DESC_2 = "QLT_DESC_2",

View File

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

View File

@ -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,9 +133,13 @@ function MainComp:refreshChapter(force)
objs.box:removeRedPoint()
end
objs.desc:setAnchoredPositionX(x)
if boxCount == index then
objs.desc:setText(I18N:getGlobalText(I18N.GlobalConst.MAIN_DESC_1, rewardChapterId))
else
objs.desc:setText(num)
end
end
end
self.uiMap["main_comp.fight_btn.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.START_DESC))
local cost = DataManager.ChapterData:getFightCost()

View File

@ -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
if not chapterBefore then
chapterBefore = self:getNextChapter(self.data.maxChapterId)
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 == 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
-- 此章节是否有可领但是未领取的奖励