红点逻辑
This commit is contained in:
parent
8683156a3c
commit
67cc032ffb
@ -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]
|
||||
|
||||
@ -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
|
||||
Loading…
x
Reference in New Issue
Block a user