200 lines
		
	
	
		
			8.0 KiB
		
	
	
	
		
			Lua
		
	
			
		
		
	
	
			200 lines
		
	
	
		
			8.0 KiB
		
	
	
	
		
			Lua
		
	
require("Base/BasePanel")
 | 
						|
AdventureExploreRewardPanel = Inherit(BasePanel)
 | 
						|
local this=AdventureExploreRewardPanel
 | 
						|
local baseDrop={}
 | 
						|
local randomDrop={}
 | 
						|
local randomList = {}
 | 
						|
local itemListPrefab={}
 | 
						|
local isOpenGeiSSRAvtivity = 0--五星成长礼拍脸
 | 
						|
local gameSetting = ConfigManager.GetConfig(ConfigName.GameSetting)
 | 
						|
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
 | 
						|
this.selfsortingOrder = 0
 | 
						|
--初始化组件(用于子类重写)
 | 
						|
function AdventureExploreRewardPanel:InitComponent()
 | 
						|
    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")
 | 
						|
    this.vipAddShowText1=Util.GetGameObject(self.gameObject, "Bg/top/vipAddShow1/vipAddShow1Text"):GetComponent("Text")
 | 
						|
    this.vipAddShowText2=Util.GetGameObject(self.gameObject, "Bg/top/vipAddShow2/vipAddShow2Text"):GetComponent("Text")
 | 
						|
    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
 | 
						|
           
 | 
						|
        --     PlayerManager.IsGetFiveStarHero = false
 | 
						|
        -- end Game.GlobalEvent:AddEvent(GameEvent.PatFace.PatFaceSend
 | 
						|
    end)
 | 
						|
end
 | 
						|
--添加事件监听(用于子类重写) 
 | 
						|
function AdventureExploreRewardPanel:AddListener()
 | 
						|
 | 
						|
end
 | 
						|
 | 
						|
--移除事件监听(用于子类重写)
 | 
						|
function AdventureExploreRewardPanel:RemoveListener()
 | 
						|
 | 
						|
end
 | 
						|
 | 
						|
--界面打开时调用(用于子类重写)
 | 
						|
function AdventureExploreRewardPanel:OnOpen(...)
 | 
						|
    Log("挂机时长是 --- " .. TimeToHMS(AdventureManager.stateTime))
 | 
						|
    this.selfsortingOrder = self.sortingOrder
 | 
						|
    local args = {...}
 | 
						|
    baseDrop=args[1]
 | 
						|
    randomDrop = args[2]
 | 
						|
    local itemDataList={}
 | 
						|
    local baseContentList1={}
 | 
						|
    local callList1 = Stack.New()
 | 
						|
    itemDataList=BagManager.GetTableByBackDropData(baseDrop)
 | 
						|
    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)
 | 
						|
    self:SetItemShow(baseDrop,itemDataList,this.rewardGrid.transform,callList1,baseContentList1)
 | 
						|
  
 | 
						|
    --随机掉落
 | 
						|
    if(randomDrop~=nil) then
 | 
						|
        local callList2 = Stack.New()
 | 
						|
        local itemRandomDataList={}
 | 
						|
        local baseContentList2={}
 | 
						|
        itemRandomDataList=BagManager.GetTableByBackDropData(randomDrop)
 | 
						|
 | 
						|
        -- 按品质排序
 | 
						|
        if #itemRandomDataList > 1 then
 | 
						|
            table.sort(itemRandomDataList, function(a, b)
 | 
						|
                return a.configData.Quantity > b.configData.Quantity
 | 
						|
            end)
 | 
						|
        end
 | 
						|
 | 
						|
        BagManager.GoIntoBackData(randomDrop)
 | 
						|
        -- for i = 1, #itemRandomDataList do
 | 
						|
        --     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)
 | 
						|
        self:SetItemShow(randomDrop,itemRandomDataList,this.randomDropGrid.transform,callList2,baseContentList2)
 | 
						|
    end
 | 
						|
    local hours = AdventureManager.adventureOffline  --gameSetting[1].AdventureOffline
 | 
						|
    local time = AdventureManager.stateTime >= hours * 60 * 60 and hours * 60 * 60 or AdventureManager.stateTime
 | 
						|
    this.hangOnTime.text = Language[10038] .. TimeToHMS(time)
 | 
						|
end
 | 
						|
 | 
						|
 | 
						|
-- 根据物品列表数据显示物品
 | 
						|
function  AdventureExploreRewardPanel:SetItemShow(drop,dataList,transform,callList,baseContentList)
 | 
						|
    BagManager.OnShowTipDropNumZero(drop)
 | 
						|
    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)
 | 
						|
            go.gameObject.name = "frame"..i
 | 
						|
            baseContentList[i] = go
 | 
						|
        end
 | 
						|
        go.gameObject:SetActive(false)
 | 
						|
    end
 | 
						|
 | 
						|
    callList:Clear()
 | 
						|
    callList:Push(function ()
 | 
						|
        if isOpenGeiSSRAvtivityTime then
 | 
						|
            isOpenGeiSSRAvtivityTime:Stop()
 | 
						|
            isOpenGeiSSRAvtivityTime = nil
 | 
						|
        end
 | 
						|
        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]
 | 
						|
        local curItemData=dataList[i]
 | 
						|
        view:OnOpen(true,curItemData,1.15,true,true,false,self.sortingOrder)
 | 
						|
        --view.gameObject:SetActive(false)
 | 
						|
        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])
 | 
						|
                Timer.New(function ()
 | 
						|
                    isPopGetSSR = false
 | 
						|
                    callList:Pop()()
 | 
						|
                end, 0.05):Start()
 | 
						|
            end
 | 
						|
            if curItemData.configData and curItemData.itemType==3 and curItemData.configData.Quality == 5 then
 | 
						|
                isPopGetSSR = true
 | 
						|
                isOpenGeiSSRAvtivity = curItemData.configData.Star
 | 
						|
                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--皮肤 坐骑
 | 
						|
                isPopGetSSR = true
 | 
						|
                UIManager.OpenPanel(UIName.DropGetPlayerDecorateShopPanel,curItemData.backData, 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
 | 
						|
               return a.itemConfig.Id < b.itemConfig.Id
 | 
						|
            else
 | 
						|
                return a.itemConfig.ItemType < b.itemConfig.ItemType
 | 
						|
            end
 | 
						|
        else
 | 
						|
           return a.itemConfig.Quantity > b.itemConfig.Quantity
 | 
						|
        end
 | 
						|
    end)
 | 
						|
end
 | 
						|
 | 
						|
--界面关闭时调用(用于子类重写)
 | 
						|
function AdventureExploreRewardPanel:OnClose()
 | 
						|
    FightPointPassManager.isBeginFight = false
 | 
						|
    if FightPointPassManager.oldLevel<PlayerManager.level then
 | 
						|
            UIManager.OpenPanel(UIName.FightEndLvUpPanel,FightPointPassManager.oldLevel,PlayerManager.level)
 | 
						|
    end
 | 
						|
end
 | 
						|
 | 
						|
--界面销毁时调用(用于子类重写)
 | 
						|
function AdventureExploreRewardPanel:OnDestroy()
 | 
						|
 | 
						|
    randomList = {}
 | 
						|
end
 | 
						|
 | 
						|
return AdventureExploreRewardPanel |