158 lines
		
	
	
		
			6.0 KiB
		
	
	
	
		
			Lua
		
	
			
		
		
	
	
			158 lines
		
	
	
		
			6.0 KiB
		
	
	
	
		
			Lua
		
	
local Expert_UpLv = quick_class("Expert_UpLv")
 | 
						|
local this = Expert_UpLv
 | 
						|
local itemList = {}--优化itemView使用
 | 
						|
local activityRewardConfig
 | 
						|
local activeData
 | 
						|
local activityId = 43
 | 
						|
local isPlayAnim = true
 | 
						|
function Expert_UpLv:ctor(mainPanel, gameObject)
 | 
						|
    self.mainPanel = mainPanel
 | 
						|
    self.gameObject = gameObject
 | 
						|
    self:InitComponent(gameObject)
 | 
						|
    self:BindEvent()
 | 
						|
end
 | 
						|
--初始化组件(用于子类重写)
 | 
						|
function Expert_UpLv:InitComponent(gameObject)
 | 
						|
    this.spLoader = SpriteLoader.New()
 | 
						|
    this.timeTextExpertgo = Util.GetGameObject(gameObject, "timeText")
 | 
						|
    this.timeTextExpert = Util.GetGameObject(gameObject, "timeText"):GetComponent("Text")
 | 
						|
    this.titleTextExpert = Util.GetGameObject(gameObject, "Image/Text")
 | 
						|
    this.expertRewardGridGo =  Util.GetGameObject(gameObject, "rect")
 | 
						|
    this.rewardPre = Util.GetGameObject(gameObject, "rewardPre")
 | 
						|
    local v2 = this.expertRewardGridGo:GetComponent("RectTransform").rect
 | 
						|
    this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, this.expertRewardGridGo.transform,
 | 
						|
            this.rewardPre, nil, Vector2.New(-v2.x*2, -v2.y*2), 1, 1, Vector2.New(50,15))
 | 
						|
    this.ScrollView.moveTween.MomentumAmount = 1
 | 
						|
    this.ScrollView.moveTween.Strength = 1
 | 
						|
end
 | 
						|
 | 
						|
--绑定事件(用于子类重写)
 | 
						|
function Expert_UpLv:BindEvent()
 | 
						|
end
 | 
						|
 | 
						|
--添加事件监听(用于子类重写)
 | 
						|
function Expert_UpLv:AddListener()
 | 
						|
end
 | 
						|
 | 
						|
--移除事件监听(用于子类重写)
 | 
						|
function Expert_UpLv:RemoveListener()
 | 
						|
end
 | 
						|
 | 
						|
local sortingOrder = 0
 | 
						|
--界面打开时调用(用于子类重写)
 | 
						|
function Expert_UpLv:OnOpen()
 | 
						|
end
 | 
						|
 | 
						|
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
 | 
						|
function Expert_UpLv:OnShow(index,_sortingOrder)
 | 
						|
    isPlayAnim = true
 | 
						|
    sortingOrder = _sortingOrder
 | 
						|
    this:Refresh(index)
 | 
						|
end
 | 
						|
 | 
						|
function Expert_UpLv:Refresh(index)
 | 
						|
    activityRewardConfig = ConfigManager.GetConfig(ConfigName.ActivityRewardConfig)
 | 
						|
    ActivityGiftManager.RefreshAcitvityData({activityId},function ()
 | 
						|
        this:OnShowData(index,true,true)
 | 
						|
    end)
 | 
						|
end
 | 
						|
 | 
						|
function Expert_UpLv:OnSortingOrderChange(cursortingOrder)
 | 
						|
    for i, v in pairs(itemList) do
 | 
						|
        for j = 1, #v do
 | 
						|
            v[j]:SetEffectLayer(cursortingOrder)
 | 
						|
        end
 | 
						|
    end
 | 
						|
end
 | 
						|
 | 
						|
function Expert_UpLv:OnShowData(isTop,isAni)
 | 
						|
    local activityId = ActivityGiftManager.GetOpenExpertIdByActivityType(ActivityTypeDef.UpLvAct)
 | 
						|
    if activityId <= 0 then
 | 
						|
        return
 | 
						|
    end
 | 
						|
    local globalActive = ConfigManager.GetConfigData(ConfigName.GlobalActivity,activityId)
 | 
						|
    activeData = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.UpLvAct)
 | 
						|
    PatFaceManager.RemainTimeDown(this.timeTextExpertgo,this.timeTextExpert,activeData.endTime - GetTimeStamp())
 | 
						|
    table.sort(activeData.mission, function(a,b)
 | 
						|
        if a.state == b.state then
 | 
						|
            return a.missionId < b.missionId
 | 
						|
        else
 | 
						|
            return a.state < b.state
 | 
						|
        end
 | 
						|
    end)
 | 
						|
    this.ScrollView:SetData(activeData.mission, function (index, go)
 | 
						|
        this.SingleItemDataShow(go, activeData.mission[index])
 | 
						|
    end,isTop,not isAni)
 | 
						|
    if isPlayAnim then
 | 
						|
        SecTorPlayAnimByScroll(self.ScrollView)
 | 
						|
        isPlayAnim = false
 | 
						|
    end
 | 
						|
end
 | 
						|
 | 
						|
function this.SingleItemDataShow(go,data)
 | 
						|
    local activityRewardGo = go
 | 
						|
    --LogError("data.missionId         "..data.missionId)
 | 
						|
 | 
						|
    -- if isPlayAnim then
 | 
						|
    --     activityRewardGo:SetActive(false)
 | 
						|
    -- else
 | 
						|
    --     activityRewardGo:SetActive(true)
 | 
						|
    -- end
 | 
						|
 | 
						|
    local curConfigData = activityRewardConfig[data.missionId]
 | 
						|
    if not itemList[go.name] then
 | 
						|
        itemList[go.name] = {}
 | 
						|
    end
 | 
						|
    for i = 1, #curConfigData.Reward do
 | 
						|
        if itemList[go.name][i] then
 | 
						|
            itemList[go.name][i]:OnOpen(false, curConfigData.Reward[i], 0.8,false,false,false,sortingOrder)
 | 
						|
        else
 | 
						|
            itemList[go.name][i] = SubUIManager.Open(SubUIConfig.ItemView, Util.GetGameObject(go, "content").transform)
 | 
						|
            itemList[go.name][i]:OnOpen(false, curConfigData.Reward[i], 0.8,false,false,false,sortingOrder)
 | 
						|
        end
 | 
						|
    end
 | 
						|
    local titleText = Util.GetGameObject(activityRewardGo, "titleImage/titleText"):GetComponent("Text") titleText.text =
 | 
						|
    Language[10578]..curConfigData.Values[2][1]..Language[10579].. activeData.value .."/"..curConfigData.Values[2][1] ..")"
 | 
						|
    local lingquButton = Util.GetGameObject(activityRewardGo.gameObject, "lingquButton")
 | 
						|
    Util.GetGameObject(lingquButton.gameObject, "redPoint"):SetActive(false)
 | 
						|
    local qianwangButton = Util.GetGameObject(activityRewardGo.gameObject, "qianwangButton")
 | 
						|
    local getFinishText = Util.GetGameObject(activityRewardGo.gameObject, "getFinishText")
 | 
						|
    local getRewardProgress = Util.GetGameObject(activityRewardGo.gameObject, "getRewardProgress")
 | 
						|
    --限时累计活动特殊数值读取处理
 | 
						|
    lingquButton:SetActive(data.state == 0 and activeData.value >= curConfigData.Values[2][1])
 | 
						|
    qianwangButton:SetActive(data.state == 0 and activeData.value < curConfigData.Values[2][1])
 | 
						|
    getFinishText:SetActive(data.state == 1)
 | 
						|
    Util.SetGray(getFinishText,data.state == 1)
 | 
						|
    getRewardProgress:SetActive(data.state ~= 1)
 | 
						|
    getRewardProgress:GetComponent("Text").text = Language[10580]..data.progress
 | 
						|
    local isZero = data.progress <= 0
 | 
						|
    Util.SetGray(getRewardProgress, isZero)
 | 
						|
    Util.SetGray(lingquButton, isZero)
 | 
						|
    lingquButton:GetComponent("Button").enabled = not isZero
 | 
						|
    Util.AddOnceClick(qianwangButton, function()
 | 
						|
        JumpManager.GoJump(curConfigData.Jump[1])
 | 
						|
    end)
 | 
						|
    Util.AddOnceClick(lingquButton, function()
 | 
						|
        --Log("达人领取奖励           "..data.missionId.."           "..activityId)
 | 
						|
        NetManager.GetActivityRewardRequest(data.missionId, activityId, function(drop)
 | 
						|
            UIManager.OpenPanel(UIName.RewardItemPopup,drop,1,function()
 | 
						|
                this:OnShowData(false,false)
 | 
						|
            end)
 | 
						|
        end)
 | 
						|
    end)
 | 
						|
end
 | 
						|
 | 
						|
--界面关闭时调用(用于子类重写)
 | 
						|
function Expert_UpLv:OnClose()
 | 
						|
 | 
						|
end
 | 
						|
 | 
						|
--界面销毁时调用(用于子类重写)
 | 
						|
function Expert_UpLv:OnDestroy()
 | 
						|
    this.spLoader:Destroy()
 | 
						|
 | 
						|
    sortingOrder = 0
 | 
						|
    itemList = {}
 | 
						|
end
 | 
						|
 | 
						|
return Expert_UpLv |