220 lines
		
	
	
		
			7.5 KiB
		
	
	
	
		
			Lua
		
	
			
		
		
	
	
			220 lines
		
	
	
		
			7.5 KiB
		
	
	
	
		
			Lua
		
	
----- 通用奖励领取弹窗 -----
 | 
						||
require("Base/BasePanel")
 | 
						||
local GeneralRewardPopup = Inherit(BasePanel)
 | 
						||
local this = GeneralRewardPopup
 | 
						||
local trialKillConfig=ConfigManager.GetConfig(ConfigName.TrialKillConfig)
 | 
						||
local GodSacrificeConfig=ConfigManager.GetConfig(ConfigName.GodSacrificeConfig)
 | 
						||
local ActivityRewardConfig = ConfigManager.GetConfig(ConfigName.ActivityRewardConfig)
 | 
						||
local itemList={} --预设容器
 | 
						||
 | 
						||
local curRewardType = 1
 | 
						||
local ActivityType = nil
 | 
						||
 | 
						||
local ActInfo = {}
 | 
						||
local ActReward = {}
 | 
						||
 | 
						||
local sortingOrder=0
 | 
						||
function GeneralRewardPopup:InitComponent()
 | 
						||
    this.panel=Util.GetGameObject(this.gameObject,"Panel")
 | 
						||
    this.backBtn=Util.GetGameObject(this.panel,"BackBtn")
 | 
						||
 | 
						||
    this.scroll=Util.GetGameObject(this.panel,"Scroll")
 | 
						||
    this.pre=Util.GetGameObject(this.panel,"Scroll/Pre")
 | 
						||
    this.pre2=Util.GetGameObject(this.panel,"Scroll/Pre2")
 | 
						||
    this.scrollView1=SubUIManager.Open(SubUIConfig.ScrollCycleView,this.scroll.transform,this.pre, nil,
 | 
						||
    Vector2.New(this.scroll.transform.rect.width,this.scroll.transform.rect.height),1,1,Vector2.New(0,10))
 | 
						||
    this.scrollView1.gameObject:GetComponent("RectTransform").anchoredPosition= Vector2.New(0,0)
 | 
						||
    this.scrollView1.gameObject:GetComponent("RectTransform").anchorMin = Vector2.New(0.5, 0.5)
 | 
						||
    this.scrollView1.gameObject:GetComponent("RectTransform").anchorMax = Vector2.New(0.5, 0.5)
 | 
						||
    this.scrollView1.gameObject:GetComponent("RectTransform").pivot = Vector2.New(0.5, 0.5)
 | 
						||
    this.scrollView1.moveTween.MomentumAmount = 1
 | 
						||
    this.scrollView1.moveTween.Strength = 2
 | 
						||
 | 
						||
    this.scrollView2=SubUIManager.Open(SubUIConfig.ScrollCycleView,this.scroll.transform,this.pre2, nil,
 | 
						||
    Vector2.New(this.scroll.transform.rect.width,this.scroll.transform.rect.height),1,1,Vector2.New(0,10))
 | 
						||
    this.scrollView2.gameObject:GetComponent("RectTransform").anchoredPosition= Vector2.New(0,0)
 | 
						||
    this.scrollView2.gameObject:GetComponent("RectTransform").anchorMin = Vector2.New(0.5, 0.5)
 | 
						||
    this.scrollView2.gameObject:GetComponent("RectTransform").anchorMax = Vector2.New(0.5, 0.5)
 | 
						||
    this.scrollView2.gameObject:GetComponent("RectTransform").pivot = Vector2.New(0.5, 0.5)
 | 
						||
    this.scrollView2.moveTween.MomentumAmount = 1
 | 
						||
    this.scrollView2.moveTween.Strength = 2
 | 
						||
 | 
						||
end
 | 
						||
 | 
						||
function GeneralRewardPopup:BindEvent()
 | 
						||
    Util.AddClick(this.backBtn,function()
 | 
						||
        PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
 | 
						||
        DynamicActivityManager.SheJiCheckRedPoint()
 | 
						||
        self:ClosePanel()
 | 
						||
    end)
 | 
						||
end
 | 
						||
 | 
						||
function GeneralRewardPopup:AddListener()
 | 
						||
end
 | 
						||
 | 
						||
function GeneralRewardPopup:RemoveListener()
 | 
						||
end
 | 
						||
 | 
						||
function GeneralRewardPopup:OnSortingOrderChange()
 | 
						||
    sortingOrder = self.sortingOrder
 | 
						||
end
 | 
						||
 | 
						||
--rewardType==1 是一般奖励,配在ActivityRewardConfig中的,234567是配在特殊表里的
 | 
						||
function GeneralRewardPopup:OnOpen(rewardType,activityType,activityId)
 | 
						||
    curRewardType = rewardType
 | 
						||
    if rewardType == 1 then
 | 
						||
        ActivityType = activityType
 | 
						||
        ActInfo = ActivityGiftManager.GetActivityTypeInfo(activityType)--活动数据
 | 
						||
        ActReward = ConfigManager.GetAllConfigsDataByKey(ConfigName.ActivityRewardConfig,"ActivityId",activityId)
 | 
						||
    elseif rewardType == 2 then
 | 
						||
        -- body
 | 
						||
    end
 | 
						||
    
 | 
						||
end
 | 
						||
 | 
						||
function GeneralRewardPopup:OnShow()
 | 
						||
    this.RefreshPanel()
 | 
						||
end
 | 
						||
 | 
						||
function GeneralRewardPopup:OnClose()
 | 
						||
    Game.GlobalEvent:DispatchEvent(GameEvent.DynamicTask.OnGetReward)
 | 
						||
end
 | 
						||
 | 
						||
function GeneralRewardPopup:OnDestroy()
 | 
						||
    this.scrollView=nil
 | 
						||
    itemList={}
 | 
						||
end
 | 
						||
 | 
						||
 | 
						||
--刷新
 | 
						||
function this.RefreshPanel()
 | 
						||
    local d={}
 | 
						||
 | 
						||
    if curRewardType == 1 then
 | 
						||
        d = ActReward
 | 
						||
        this.scrollView2:SetData(d,function(index,root)
 | 
						||
            this.SetScrollPre2(root,d[index])
 | 
						||
        end)
 | 
						||
        this.scrollView2:SetIndex(1)
 | 
						||
 | 
						||
    elseif curRewardType == 2 then
 | 
						||
        for _, configInfo in ConfigPairs(trialKillConfig) do
 | 
						||
            table.insert(d, configInfo)
 | 
						||
        end
 | 
						||
        this.scrollView1:SetData(d,function(index,root)
 | 
						||
            this.SetScrollPre1(root,d[index])
 | 
						||
        end)
 | 
						||
        this.scrollView1:SetIndex(1)
 | 
						||
    end
 | 
						||
end
 | 
						||
 | 
						||
--设置每条数据
 | 
						||
function this.SetScrollPre2(root,data)
 | 
						||
    local info=Util.GetGameObject(root,"Title/Info"):GetComponent("Text")
 | 
						||
    local grid=Util.GetGameObject(root,"Grid")
 | 
						||
    local goBtn=Util.GetGameObject(root,"GoBtn")
 | 
						||
    local getBtn=Util.GetGameObject(root,"GetBtn")
 | 
						||
    local mask=Util.GetGameObject(root,"mask")
 | 
						||
 | 
						||
    info.text = data.ContentsShow
 | 
						||
    ResetItemView(root,grid.transform,itemList,#data.Reward,0.9,sortingOrder,false,data.Reward)
 | 
						||
 | 
						||
    --按钮状态
 | 
						||
    local s = ActInfo.mission[data.Sort].state
 | 
						||
 | 
						||
    --社稷大典需要根据贡献等级重构state
 | 
						||
    if ActivityType == ActivityTypeDef.Celebration then
 | 
						||
        local level = DynamicActivityManager.curLevel
 | 
						||
        if s == 0 then
 | 
						||
            if data.Sort <= level then
 | 
						||
                s = 1
 | 
						||
            else
 | 
						||
                s = 2
 | 
						||
            end
 | 
						||
        else
 | 
						||
            s = 0 
 | 
						||
        end
 | 
						||
    end
 | 
						||
 | 
						||
    goBtn:GetComponent("Button").interactable=s~=0
 | 
						||
    if s==0 then
 | 
						||
        -- goText.text=Language[10350]
 | 
						||
        mask:SetActive(true)
 | 
						||
        goBtn:SetActive(false)
 | 
						||
        getBtn:SetActive(false)
 | 
						||
    elseif s==1 then
 | 
						||
        -- goText.text=Language[10022]
 | 
						||
        mask:SetActive(false)
 | 
						||
        goBtn:SetActive(false)
 | 
						||
        getBtn:SetActive(true)
 | 
						||
    elseif s==2 then
 | 
						||
        -- goText.text=Language[10023]
 | 
						||
        mask:SetActive(false)
 | 
						||
        goBtn:SetActive(true)
 | 
						||
        getBtn:SetActive(false)
 | 
						||
    end
 | 
						||
 | 
						||
    Util.AddOnceClick(goBtn,function()
 | 
						||
        PopupTipPanel.ShowTip("领取条件未达成~")
 | 
						||
    end)
 | 
						||
    Util.AddOnceClick(getBtn,function()
 | 
						||
        NetManager.GetActivityRewardRequest(ActInfo.mission[data.Sort].missionId, ActInfo.activityId, function(_drop)
 | 
						||
            UIManager.OpenPanel(UIName.RewardItemPopup, _drop, 1,function()
 | 
						||
                this.RefreshPanel()
 | 
						||
                CheckRedPointStatus(RedPointType.Celebration)
 | 
						||
            end)
 | 
						||
        end)
 | 
						||
    end)
 | 
						||
end
 | 
						||
 | 
						||
 | 
						||
--设置每条数据
 | 
						||
function this.SetScrollPre1(root,data)
 | 
						||
    local info=Util.GetGameObject(root,"Title/Info"):GetComponent("Text")
 | 
						||
    local grid=Util.GetGameObject(root,"Grid")
 | 
						||
    local goBtn=Util.GetGameObject(root,"GoBtn")
 | 
						||
    local getBtn=Util.GetGameObject(root,"GetBtn")
 | 
						||
    local mask=Util.GetGameObject(root,"mask")
 | 
						||
 | 
						||
    info.text=string.format( Language[11616],data.Count,MapTrialManager.GetKilCount(),data.Count)
 | 
						||
    ResetItemView(root,grid.transform,itemList,#data.BoxReward,0.9,sortingOrder,false,data.BoxReward)
 | 
						||
 | 
						||
    --按钮状态
 | 
						||
    local s=MapTrialManager.GetTrialRewardState(data.Id)
 | 
						||
    goBtn:GetComponent("Button").interactable=s~=0
 | 
						||
    if s==0 then
 | 
						||
        -- goText.text=Language[10350]
 | 
						||
        mask:SetActive(true)
 | 
						||
        goBtn:SetActive(false)
 | 
						||
        getBtn:SetActive(false)
 | 
						||
    elseif s==1 then
 | 
						||
        -- goText.text=Language[10022]
 | 
						||
        mask:SetActive(false)
 | 
						||
        goBtn:SetActive(false)
 | 
						||
        getBtn:SetActive(true)
 | 
						||
    elseif s==2 then
 | 
						||
        -- goText.text=Language[10023]
 | 
						||
        mask:SetActive(false)
 | 
						||
        goBtn:SetActive(true)
 | 
						||
        getBtn:SetActive(false)
 | 
						||
    end
 | 
						||
 | 
						||
    Util.AddOnceClick(goBtn,function()
 | 
						||
        this:ClosePanel()
 | 
						||
    end)
 | 
						||
    Util.AddOnceClick(getBtn,function()
 | 
						||
        NetManager.RequestLevelReward(data.Id, function(msg)
 | 
						||
            MapTrialManager.SetTrialRewardInfo(data.Id) --本地记录已领奖励信息
 | 
						||
            UIManager.OpenPanel(UIName.RewardItemPopup,msg.drop,1,function()
 | 
						||
                mask:SetActive(true)
 | 
						||
                getBtn:SetActive(false)
 | 
						||
                this.RefreshPanel()
 | 
						||
                CheckRedPointStatus(RedPointType.TrialReward)
 | 
						||
                CheckRedPointStatus(RedPointType.Trial)
 | 
						||
            end)
 | 
						||
        end)
 | 
						||
    end)
 | 
						||
end
 | 
						||
 | 
						||
 | 
						||
return GeneralRewardPopup |