战令定位
This commit is contained in:
parent
4a162302ff
commit
e07eb6a961
@ -29,6 +29,9 @@ function BountyMainUI:onClose()
|
||||
self.autoRotateTween:Kill()
|
||||
end
|
||||
self:clearPreviewRewardAnimation()
|
||||
if self.rewardsContentMoveTween then
|
||||
self.rewardsContentMoveTween:Kill()
|
||||
end
|
||||
end
|
||||
|
||||
function BountyMainUI:onLoadRootComplete()
|
||||
@ -120,7 +123,6 @@ function BountyMainUI:initRewards()
|
||||
self.scrollrectComp = self.scrollrect:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
|
||||
self.scrollrectComp:clearCells()
|
||||
self.scrollrectComp:setTotalCount(0)
|
||||
self.scrollrectComp:setFadeArgs(0, 0.3)
|
||||
self.scrollrectComp:addInitCallback(function()
|
||||
return "app/ui/bounty/cell/bounty_cell"
|
||||
end)
|
||||
@ -136,6 +138,7 @@ function BountyMainUI:initRewards()
|
||||
self.refreshIndex = index
|
||||
local totalCount = self.scrollrectComp:getTotalCount()
|
||||
local isFinalCell = index == totalCount
|
||||
if not self.disablePreviewReward then
|
||||
if isFinalCell then
|
||||
self.rewardCellIdx = index
|
||||
self:hidePreviewReward()
|
||||
@ -148,6 +151,7 @@ function BountyMainUI:initRewards()
|
||||
self:showNextPreviewReward()
|
||||
end
|
||||
end
|
||||
end
|
||||
cell:refresh(index, isFinalCell)
|
||||
local lv = DataManager.BountyData:getLevel()
|
||||
if index > lv - 1 or index < lv + 1 then
|
||||
@ -160,7 +164,7 @@ function BountyMainUI:initRewards()
|
||||
end
|
||||
self.repeatRewardRoot:getTransform():SetAsLastSibling()
|
||||
end)
|
||||
self.cellHeight = 200
|
||||
self.cellHeight = self.uiMap["bounty_main_ui.mid_node.scrollrect.viewport.content.cell"]:getRectHeight()
|
||||
local scrollBottom = 106
|
||||
local scrollTop = 464
|
||||
local height = self.root:getRectHeight()
|
||||
@ -264,10 +268,16 @@ function BountyMainUI:refreshRewards()
|
||||
end
|
||||
local maxLv = DataManager.BountyData:getMaxLevel()
|
||||
local lv = DataManager.BountyData:getLevel()
|
||||
if self.scrollrectComp:getTotalCount() <= 0 then
|
||||
if self.scrollrectComp:getTotalCount() <= 0 then -- 打开界面的时候定位到当前可领取的最低等级奖励,如果没有则定位到当前等级
|
||||
self.scrollrectComp:refillCells(maxLv)
|
||||
local level = DataManager.BountyData:getMinUnclaimedRewardIndex()
|
||||
if level > 1 then
|
||||
self:scrollToIndex(level)
|
||||
end
|
||||
else
|
||||
self.disablePreviewReward = true
|
||||
self.scrollrectComp:updateAllCell()
|
||||
self.disablePreviewReward = false
|
||||
end
|
||||
if lv >= maxLv then
|
||||
self.line:setVisible(false)
|
||||
@ -372,33 +382,47 @@ function BountyMainUI:clearPreviewRewardAnimation()
|
||||
end
|
||||
|
||||
function BountyMainUI:scrollToIndex(targetIndex)
|
||||
-- 未避免scrollrect没填充完毕,延迟一帧执行
|
||||
if self.rewardsContentSid then
|
||||
self:unscheduleGlobal(self.rewardsContentSid)
|
||||
end
|
||||
self.rewardsContentSid = self:performWithDelayGlobal(function()
|
||||
self.rewardsContentSid = nil
|
||||
if self.rewardsContentMaxY == nil then
|
||||
local maxLv = DataManager.BountyData:getMaxLevel()
|
||||
local cellHeight = self.cellHeight
|
||||
local cellListHeight = self.scrollView:getTransform().rect.height
|
||||
local posY = cellHeight*(targetIndex - 6)
|
||||
local targetPosY = cellHeight*(targetIndex - 1)
|
||||
targetPosY = math.min(targetPosY, maxLv*cellHeight - cellListHeight)
|
||||
if self.scrollSid then
|
||||
self:unscheduleGlobal(self.scrollSid)
|
||||
self.scrollSid = nil
|
||||
self.rewardsContentMaxY = maxLv*self.cellHeight - self.scrollrectViewport:getRectHeight()
|
||||
end
|
||||
if targetIndex <= 6 then
|
||||
self.scrollrectComp:moveToIndex(targetIndex)
|
||||
-- 最多移动6格,超过6格就先整体移动后再移动6格
|
||||
local moveTimePerCell = 0.05
|
||||
local moveCount = 6
|
||||
local moveTime = moveCount * moveTimePerCell
|
||||
if targetIndex > 7 then
|
||||
local tartgetY = (targetIndex - 7)*self.cellHeight
|
||||
if tartgetY > self.rewardsContentMaxY then
|
||||
self.rewardsContent:setAnchoredPositionY(self.rewardsContentMaxY)
|
||||
return
|
||||
else
|
||||
self.scrollrectComp:moveToIndex(targetIndex - 6)
|
||||
self.scrollSid = self:scheduleGlobal(function(inter)
|
||||
posY = posY + 40*inter/0.015
|
||||
if posY >= targetPosY then
|
||||
posY = targetPosY
|
||||
self.rewardsContent:setAnchoredPositionY(tartgetY)
|
||||
end
|
||||
self.rewardsContent:setAnchoredPositionY(posY)
|
||||
if posY >= targetPosY then
|
||||
self:unscheduleGlobal(self.scrollSid)
|
||||
self.scrollSid = nil
|
||||
else
|
||||
moveTime = (targetIndex - 1) * moveTimePerCell
|
||||
end
|
||||
local y = (targetIndex - 1) * self.cellHeight
|
||||
if y > self.rewardsContentMaxY then
|
||||
y = self.rewardsContentMaxY
|
||||
end
|
||||
if self.rewardsContentMoveTween == nil then
|
||||
self.rewardsContentMoveTween = self.rewardsContent:getTransform():DOAnchorPosY(y, moveTime)
|
||||
self.rewardsContentMoveTween:SetAutoKill(false)
|
||||
else
|
||||
local CacheVector2 = BF.CacheVector2
|
||||
CacheVector2.x = 0
|
||||
CacheVector2.y = y
|
||||
self.rewardsContentMoveTween:ChangeEndValue(CacheVector2, moveTime, true)
|
||||
self.rewardsContentMoveTween:Restart()
|
||||
end
|
||||
end, 0)
|
||||
end
|
||||
end
|
||||
|
||||
function BountyMainUI:updateTime()
|
||||
local remainTime = self.endTime - Time:getServerTime()
|
||||
|
||||
@ -178,6 +178,31 @@ function BountyData:getIfCanBuyLevel()
|
||||
return false
|
||||
end
|
||||
|
||||
-- 未领取的最小奖励的index
|
||||
function BountyData:getMinUnclaimedRewardIndex()
|
||||
local level = self.level
|
||||
local maxLevel = self:getMaxLevel()
|
||||
if level > maxLevel then
|
||||
level = maxLevel
|
||||
end
|
||||
if self.claimedCount < self.level then
|
||||
for i = 1, level do
|
||||
if not self.claimed[i] then
|
||||
return i
|
||||
end
|
||||
end
|
||||
end
|
||||
if self.bought and self.proClaimedCount < self:getMaxLevel() then
|
||||
for i = 1, level do
|
||||
if not self.proClaimed[i] then
|
||||
return i
|
||||
end
|
||||
end
|
||||
end
|
||||
return level
|
||||
end
|
||||
|
||||
-- 是否有未领取的奖励
|
||||
function BountyData:getIfCanClaimReward()
|
||||
if not self:getIsOpen() then
|
||||
return false
|
||||
@ -191,6 +216,7 @@ function BountyData:getIfCanClaimReward()
|
||||
return false
|
||||
end
|
||||
|
||||
-- 是否可以领取重复奖励
|
||||
function BountyData:getIfCanClaimRepeatReward()
|
||||
local maxLevel = self:getMaxLevel()
|
||||
if maxLevel <= 0 then
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user