结算界面

This commit is contained in:
chenxi 2023-04-26 16:58:44 +08:00
parent 5b43ae2f27
commit 5ac0c46c82

View File

@ -90,21 +90,43 @@ function BattleResultUI:refreshDefeatNode()
end end
function BattleResultUI:refreshRewards() function BattleResultUI:refreshRewards()
if self.scrollRect then if self.scrollRectComp then
self.scrollRect:updateAllCell() self.scrollRectComp:updateAllCell()
return return
end end
local uiMap = self.root:genAllChildren() local uiMap = self.root:genAllChildren()
self.scrollRect = uiMap["battle_result_ui.scroll_rect"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE) local scrollRect = uiMap["battle_result_ui.scroll_rect"]
self.scrollRect:addInitCallback(function() self.scrollRectComp = scrollRect:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
self.scrollRectComp:addInitCallback(function()
return GConst.TYPEOF_LUA_CLASS.REWARD_CELL return GConst.TYPEOF_LUA_CLASS.REWARD_CELL
end) end)
self.scrollRect:addRefreshCallback(function(index, cell) self.scrollRectComp:addRefreshCallback(function(index, cell)
cell:refresh(self.rewards[index]) cell:refresh(self.rewards[index])
end) end)
self.scrollRect:clearCells() self.scrollRectComp:setFadeArgs(0.05, 0.3)
self.scrollRect:refillCells(#self.rewards) self.scrollRectComp:clearCells()
local rewardCount = #self.rewards
if rewardCount > 10 then
local comp = scrollRect:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_SCROLL_RECT)
comp.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic
self.scrollRectComp:setPerLineNum(5)
scrollRect:setSizeDeltaX(560)
else
local comp = scrollRect:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_SCROLL_RECT)
comp.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Clamped
if rewardCount >= 5 then
self.scrollRectComp:setPerLineNum(5)
scrollRect:setSizeDeltaX(560)
elseif rewardCount <= 0 then
self.scrollRectComp:setPerLineNum(1)
scrollRect:setSizeDeltaX(560)
else
self.scrollRectComp:setPerLineNum(rewardCount)
scrollRect:setSizeDeltaX(112*rewardCount)
end
end
self.scrollRectComp:refillCells(rewardCount, true)
end end
function BattleResultUI:refreshUnitInfo() function BattleResultUI:refreshUnitInfo()