miduo_client/Assets/ManagedResources/~Lua/Modules/Adventure/AdventureExploreRewardPanel...

205 lines
8.2 KiB
Lua
Raw Normal View History

2025-03-14 11:58:20 +08:00
require("Base/BasePanel")
2020-05-09 13:31:21 +08:00
AdventureExploreRewardPanel = Inherit(BasePanel)
2024-09-06 10:38:56 +08:00
local this = AdventureExploreRewardPanel
local baseDrop = {}
local randomDrop = {}
2020-05-09 13:31:21 +08:00
local randomList = {}
2024-09-06 10:38:56 +08:00
local itemListPrefab = {}
local isOpenGeiSSRAvtivity = 0 --五星成长礼拍脸
2020-05-09 13:31:21 +08:00
local gameSetting = ConfigManager.GetConfig(ConfigName.GameSetting)
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
2020-05-09 13:31:21 +08:00
this.selfsortingOrder = 0
--初始化组件(用于子类重写)
function AdventureExploreRewardPanel:InitComponent()
2021-04-21 13:12:04 +08:00
this.spLoader = SpriteLoader.New()
2020-05-09 13:31:21 +08:00
this.btnBack = Util.GetGameObject(self.gameObject, "maskImage")
this.rewardGrid = Util.GetGameObject(self.gameObject, "top/grid")
this.randomDropGrid = Util.GetGameObject(self.gameObject, "Bg/scroll/grid")
this.vipAddShow1 = Util.GetGameObject(self.gameObject, "Bg/top/vipAddShow1")
this.vipAddShow2 = Util.GetGameObject(self.gameObject, "Bg/top/vipAddShow2")
2024-09-06 10:38:56 +08:00
this.vipAddShowText1 = Util.GetGameObject(self.gameObject, "Bg/top/vipAddShow1/vipAddShow1Text"):GetComponent("Text")
this.vipAddShowText2 = Util.GetGameObject(self.gameObject, "Bg/top/vipAddShow2/vipAddShow2Text"):GetComponent("Text")
2020-05-09 13:31:21 +08:00
this.hangOnTime = Util.GetGameObject(self.gameObject, "Bg/hangOnTime"):GetComponent("Text")
end
--绑定事件(用于子类重写)
function AdventureExploreRewardPanel:BindEvent()
Util.AddClick(this.btnBack, function()
self:ClosePanel()
--Game.GlobalEvent:DispatchEvent(GameEvent.PatFace.PatFaceSend, FacePanelType.UpgradePac)
-- if PlayerManager.IsGetFiveStarHero then--and OperatingManager.IsShowFiveStarPatch then
2024-09-06 10:38:56 +08:00
-- PlayerManager.IsGetFiveStarHero = false
-- end Game.GlobalEvent:AddEvent(GameEvent.PatFace.PatFaceSend
2020-05-09 13:31:21 +08:00
end)
end
2024-09-06 10:38:56 +08:00
--添加事件监听(用于子类重写)
2020-05-09 13:31:21 +08:00
function AdventureExploreRewardPanel:AddListener()
end
--移除事件监听(用于子类重写)
function AdventureExploreRewardPanel:RemoveListener()
end
--界面打开时调用(用于子类重写)
function AdventureExploreRewardPanel:OnOpen(...)
Log("挂机时长是 --- " .. TimeToHMS(AdventureManager.stateTime))
2021-05-18 14:24:09 +08:00
SoundManager.PlaySound(SoundConfig.UI_Guajijiangli)
2020-05-09 13:31:21 +08:00
this.selfsortingOrder = self.sortingOrder
2024-09-06 10:38:56 +08:00
local args = { ... }
baseDrop = args[1]
2020-05-09 13:31:21 +08:00
randomDrop = args[2]
2024-09-06 10:38:56 +08:00
local itemDataList = {}
local baseContentList1 = {}
local callList1 = Stack.New()
2024-09-06 10:38:56 +08:00
itemDataList = BagManager.GetTableByBackDropData(baseDrop)
2020-05-09 13:31:21 +08:00
BagManager.GoIntoBackData(baseDrop)
--固定掉落
-- for i = 1, #itemDataList do
-- local view
-- if not baseContentList[i] then
-- view = SubUIManager.Open(SubUIConfig.ItemView,this.rewardGrid.transform)
-- baseContentList[i] = view
-- end
-- baseContentList[i]:OnOpen(true,itemDataList[i],1,true,false,false,this.selfsortingOrder)
-- end
ClearChild(this.rewardGrid.transform)
2024-09-06 10:38:56 +08:00
self:SetItemShow(baseDrop, itemDataList, this.rewardGrid.transform, callList1, baseContentList1)
--随机掉落
2024-09-06 10:38:56 +08:00
if (randomDrop ~= nil) then
local callList2 = Stack.New()
2024-09-06 10:38:56 +08:00
local itemRandomDataList = {}
local baseContentList2 = {}
itemRandomDataList = BagManager.GetTableByBackDropData(randomDrop)
2020-05-09 13:31:21 +08:00
-- 按品质排序
if #itemRandomDataList > 1 then
table.sort(itemRandomDataList, function(a, b)
2020-05-09 13:31:21 +08:00
return a.configData.Quantity > b.configData.Quantity
end)
end
BagManager.GoIntoBackData(randomDrop)
-- for i = 1, #itemRandomDataList do
2024-09-06 10:38:56 +08:00
-- if not randomList[i] then
-- local view = SubUIManager.Open(SubUIConfig.ItemView,this.randomDropGrid.transform)
-- randomList[i] = view
-- end
-- randomList[i]:OnOpen(true,itemDataList[i], 1.1, true)
-- end
ClearChild(this.randomDropGrid.transform)
2024-09-06 10:38:56 +08:00
self:SetItemShow(randomDrop, itemRandomDataList, this.randomDropGrid.transform, callList2, baseContentList2)
2020-05-09 13:31:21 +08:00
end
2024-09-06 10:38:56 +08:00
local hours = AdventureManager.adventureOffline --gameSetting[1].AdventureOffline
2020-05-09 13:31:21 +08:00
local time = AdventureManager.stateTime >= hours * 60 * 60 and hours * 60 * 60 or AdventureManager.stateTime
2021-03-02 16:53:12 +08:00
this.hangOnTime.text = Language[10038] .. TimeToHMS(time)
2020-05-09 13:31:21 +08:00
end
-- 根据物品列表数据显示物品
2024-09-06 10:38:56 +08:00
function AdventureExploreRewardPanel:SetItemShow(drop, dataList, transform, callList, baseContentList)
BagManager.OnShowTipDropNumZero(drop)
2024-09-06 10:38:56 +08:00
if drop == nil then return end
for i = 1, #dataList do
dataList[i].itemConfig = itemConfig[dataList[i].sId]
end
self:ItemDataListSort(dataList)
for i = 1, math.max(#dataList, #baseContentList) do
local go = baseContentList[i]
if not go then
go = SubUIManager.Open(SubUIConfig.ItemView, transform)
2024-09-06 10:38:56 +08:00
go.gameObject.name = "frame" .. i
baseContentList[i] = go
end
go.gameObject:SetActive(false)
end
callList:Clear()
2024-09-06 10:38:56 +08:00
callList:Push(function()
if isOpenGeiSSRAvtivityTime then
isOpenGeiSSRAvtivityTime:Stop()
isOpenGeiSSRAvtivityTime = nil
end
2024-09-06 10:38:56 +08:00
isOpenGeiSSRAvtivityTime = Timer.New(function()
isPlayerAniEnd = true
if isOpenGeiSSRAvtivity > 0 then
HeroManager.DetectionOpenFiveStarActivity(isOpenGeiSSRAvtivity)
end
end, 0.5):Start()
--在关卡界面获得装备 刷新下btview成员红点
-- Game.GlobalEvent:DispatchEvent(GameEvent.Equip.EquipChange)
end)
for i = #dataList, 1, -1 do
isPlayerAniEnd = false
local view = baseContentList[i]
2024-09-06 10:38:56 +08:00
local curItemData = dataList[i]
view:OnOpen(true, curItemData, 1.15, true, true, false, self.sortingOrder)
--view.gameObject:SetActive(false)
2024-09-06 10:38:56 +08:00
callList:Push(function()
local func = function()
view.gameObject:SetActive(true)
local btn = Util.GetGameObject(view.gameObject, "item/frame"):GetComponent("Button")
btn.enabled = false
PlayUIAnim(view.gameObject, function()
btn.enabled = true
end)
--改为后端更新
--this.SetItemData2(itemDataList[i])
2024-09-06 10:38:56 +08:00
Timer.New(function()
isPopGetSSR = false
callList:Pop()()
end, 0.05):Start()
end
2024-09-06 10:38:56 +08:00
if curItemData.configData and curItemData.itemType == 3 and curItemData.configData.Quality == 5 then
isPopGetSSR = true
isOpenGeiSSRAvtivity = curItemData.configData.Star
2024-09-06 10:38:56 +08:00
UIManager.OpenPanel(UIName.DropGetSSRHeroShopPanel, curItemData.backData, func)
elseif curItemData.configData and curItemData.itemType == 1 and
(curItemData.configData.ItemType == ItemType.Title or curItemData.configData.ItemType == ItemType.Ride or
curItemData.configData.ItemType == ItemType.Skin) then --皮肤 坐骑
2021-03-30 10:28:03 +08:00
-- isPopGetSSR = true
-- UIManager.OpenPanel(UIName.DropGetPlayerDecorateShopPanel,curItemData.backData, func)
func()
else
func()
end
end)
end
callList:Pop()()
end
--掉落物品排序
function AdventureExploreRewardPanel:ItemDataListSort(itemDataList)
table.sort(itemDataList, function(a, b)
if a.itemConfig.Quantity == b.itemConfig.Quantity then
if a.itemConfig.ItemType == b.itemConfig.ItemType then
2024-09-06 10:38:56 +08:00
return a.itemConfig.Id < b.itemConfig.Id
else
return a.itemConfig.ItemType < b.itemConfig.ItemType
end
else
2024-09-06 10:38:56 +08:00
return a.itemConfig.Quantity > b.itemConfig.Quantity
end
end)
end
2020-05-09 13:31:21 +08:00
--界面关闭时调用(用于子类重写)
function AdventureExploreRewardPanel:OnClose()
FightPointPassManager.isBeginFight = false
2024-05-06 17:49:43 +08:00
-- if FightPointPassManager.oldLevel<PlayerManager.level then
-- UIManager.OpenPanel(UIName.FightEndLvUpPanel,FightPointPassManager.oldLevel,PlayerManager.level)
-- end
2020-05-09 13:31:21 +08:00
end
--界面销毁时调用(用于子类重写)
function AdventureExploreRewardPanel:OnDestroy()
2021-04-21 13:12:04 +08:00
this.spLoader:Destroy()
2020-05-09 13:31:21 +08:00
randomList = {}
end
2024-09-06 10:38:56 +08:00
return AdventureExploreRewardPanel