291 lines
		
	
	
		
			13 KiB
		
	
	
	
		
			Lua
		
	
			
		
		
	
	
			291 lines
		
	
	
		
			13 KiB
		
	
	
	
		
			Lua
		
	
local Expert = quick_class("Expert")
 | 
						|
local this = Expert
 | 
						|
local expertRewardGrid = {}--七种达人 + 周卡 限时兑换
 | 
						|
local expertRewardItemsGrid = {}
 | 
						|
local expertRewardTabs = {}
 | 
						|
local activeIndext = 0
 | 
						|
local titleImageSprites = {[10]="x_xianshihuodong_jishudarenbanner_zh",[11]="r_daren_jingji_zh",[9]="r_daren_banner_01_zh",[12]="r_daren_zhuangbei_zh",[13]="x_xianshihuodong_dianjindarenbanner_zh",--"r_daren_dianjing",
 | 
						|
                            [14]="r_daren_fuben_zh",[15]="r_daren_fuben_zh",[16]="r_daren_fabao_01_zh",[17]="r_daren_hunyin_01_zh",[7]="r_huodong_leiji_zh",
 | 
						|
                           [19]="r_daren_xubao3",[20]="r_daren_tanbao_zh",[21]="r_daren_zhengmu_zh",[22]="r_daren_mibao_zh",[26]="g_gonghui_banner_zh",[27]="s_senluohuanjing_banner_zh"}
 | 
						|
function Expert:ctor(mainPanel, gameObject)
 | 
						|
    self.mainPanel = mainPanel
 | 
						|
    self.gameObject = gameObject
 | 
						|
    self:InitComponent(gameObject)
 | 
						|
    self:BindEvent()
 | 
						|
end
 | 
						|
local isPlayshow = true
 | 
						|
--初始化组件(用于子类重写)
 | 
						|
function Expert:InitComponent(gameObject)
 | 
						|
    this.spLoader = SpriteLoader.New()
 | 
						|
 | 
						|
    this.rewardBtn = Util.GetGameObject(gameObject, "rewardBtn")
 | 
						|
    this.sortBtn = Util.GetGameObject(gameObject, "sortBtn")
 | 
						|
    this.timeTextExpertgo = Util.GetGameObject(gameObject, "timeText")
 | 
						|
    this.timeTextExpert = Util.GetGameObject(gameObject, "timeText"):GetComponent("Text")
 | 
						|
    this.titleImageExpert1 = Util.GetGameObject(gameObject, "Image")
 | 
						|
    this.titleImageExpert2 = Util.GetGameObject(gameObject, "Image2")
 | 
						|
    this.xunbaoTextImage = Util.GetGameObject(gameObject, "xunbaoTextImage")
 | 
						|
    this.titleTextExpert = Util.GetGameObject(gameObject, "Image/Text")
 | 
						|
    this.titleTextExpert2 = Util.GetGameObject(gameObject, "Image2/Text")
 | 
						|
    this.titleTextExpert2Go = Util.GetGameObject(gameObject, "Image2")
 | 
						|
    this.titleBg = Util.GetGameObject(gameObject, "titleBg"):GetComponent("Image")
 | 
						|
    this.expertRewardGridGo =  Util.GetGameObject(gameObject, "rect/rect (1)/grid")
 | 
						|
    for i = 1, 10 do
 | 
						|
        expertRewardGrid[i] = Util.GetGameObject(gameObject, "rect/rect (1)/grid/rewardPre ("..i..")")
 | 
						|
        local curexpertRewardItemsGri = {}
 | 
						|
        for j = 1, 4 do
 | 
						|
            curexpertRewardItemsGri[j] = SubUIManager.Open(SubUIConfig.ItemView, Util.GetGameObject(expertRewardGrid[i], "content").transform)
 | 
						|
            end
 | 
						|
        expertRewardItemsGrid[i] = curexpertRewardItemsGri
 | 
						|
    end
 | 
						|
    this.HelpBtn = Util.GetGameObject(self.gameObject,"helpBtn")
 | 
						|
    this.helpPosition=this.HelpBtn:GetComponent("RectTransform").localPosition
 | 
						|
end
 | 
						|
 | 
						|
--绑定事件(用于子类重写)
 | 
						|
function Expert:BindEvent()
 | 
						|
 | 
						|
    Util.AddClick(this.rewardBtn, function()
 | 
						|
        local activityId = ActivityGiftManager.IsActivityTypeOpen(numExChange[activeIndext])
 | 
						|
        UIManager.OpenPanel(UIName.ExpertRewardSortPanel,activityId,2,activeIndext)
 | 
						|
    end)
 | 
						|
end
 | 
						|
 | 
						|
--添加事件监听(用于子类重写)
 | 
						|
function Expert:AddListener()
 | 
						|
 | 
						|
end
 | 
						|
 | 
						|
--移除事件监听(用于子类重写)
 | 
						|
function Expert:RemoveListener()
 | 
						|
 | 
						|
end
 | 
						|
local sortingOrder = 0
 | 
						|
--界面打开时调用(用于子类重写)
 | 
						|
function Expert:OnOpen()
 | 
						|
 | 
						|
end
 | 
						|
 | 
						|
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
 | 
						|
function Expert:OnShow(index,_sortingOrder)
 | 
						|
 | 
						|
    sortingOrder = _sortingOrder
 | 
						|
    isPlayshow = true
 | 
						|
    this:OnShowData(index)
 | 
						|
end
 | 
						|
function Expert:OnSortingOrderChange(cursortingOrder)
 | 
						|
    for i, v in pairs(expertRewardItemsGrid) do
 | 
						|
        for j = 1, #v do
 | 
						|
            v[j]:SetEffectLayer(cursortingOrder)
 | 
						|
        end
 | 
						|
    end
 | 
						|
end
 | 
						|
function Expert:OnShowData(index)
 | 
						|
    activeIndext = index
 | 
						|
    local index=index
 | 
						|
    self.rewardBtn:SetActive(false)
 | 
						|
    self.sortBtn:SetActive(false)
 | 
						|
    --local globalActive = ConfigManager.GetConfigData(ConfigName.GlobalActivity,numExChange[activeIndext] )
 | 
						|
    local globalActive = ConfigManager.GetConfigData(ConfigName.GlobalActivity,ActivityGiftManager.GetOpenExpertIdByActivityType(numExChange[activeIndext] ))
 | 
						|
    if globalActive and globalActive.OpenRanking == 1 then
 | 
						|
        this.rewardBtn:SetActive(true)
 | 
						|
        this.sortBtn:SetActive(true)
 | 
						|
        Util.AddOnceClick(this.sortBtn, function()
 | 
						|
            --LogGreen("index       "..index)
 | 
						|
            if index == 13 then
 | 
						|
                UIManager.OpenPanel(UIName.RankingSingleListPanel,rankKingList[5])
 | 
						|
            elseif index == 10 then
 | 
						|
                UIManager.OpenPanel(UIName.RankingSingleListPanel,rankKingList[7])
 | 
						|
            elseif index == 19 then
 | 
						|
                UIManager.OpenPanel(UIName.RankingSingleListPanel,rankKingList[9])
 | 
						|
            elseif index == 26 then
 | 
						|
                UIManager.OpenPanel(UIName.RankingSingleListPanel,rankKingList[10])
 | 
						|
            elseif index == 27 then
 | 
						|
                UIManager.OpenPanel(UIName.RankingSingleListPanel,rankKingList[12])
 | 
						|
            end
 | 
						|
            
 | 
						|
        end)
 | 
						|
    end
 | 
						|
    expertRewardTabs = ActivityGiftManager.GetActivityTypeInfo(numExChange[activeIndext])
 | 
						|
    self.titleBg.sprite = this.spLoader:LoadSprite(titleImageSprites[activeIndext])
 | 
						|
    for i = 1, math.max(#expertRewardTabs.mission, #expertRewardGrid) do
 | 
						|
        local go = expertRewardGrid[i]
 | 
						|
        if not go then
 | 
						|
            go = newObject(expertRewardGrid[1])
 | 
						|
            go.transform:SetParent(this.expertRewardGridGo.transform)
 | 
						|
            go.transform.localScale = Vector3.one
 | 
						|
            go.transform.localPosition = Vector3.zero
 | 
						|
            expertRewardGrid[i] = go
 | 
						|
        end
 | 
						|
        go.gameObject:SetActive(false)
 | 
						|
    end
 | 
						|
 | 
						|
    this.titleTextExpert2Go:SetActive(false)
 | 
						|
    this.titleTextExpert:SetActive(false)
 | 
						|
    this.titleImageExpert1:SetActive(false)
 | 
						|
    this.titleImageExpert2:SetActive(false)
 | 
						|
    this.xunbaoTextImage:SetActive(false)
 | 
						|
    local conFigData = ConfigManager.GetConfigData(ConfigName.GlobalActivity,ActivityGiftManager.GetOpenExpertIdByActivityType(numExChange[index]))
 | 
						|
    if conFigData then
 | 
						|
        local ExpertDec = string.split(GetLanguageStrById(conFigData.ExpertDec), "#")
 | 
						|
        if conFigData.ExpertDec then
 | 
						|
            if numExChange[activeIndext] == ActivityTypeDef.AccumulativeRechargeExper then
 | 
						|
                this.titleImageExpert2:SetActive(true)
 | 
						|
                this.titleTextExpert2Go:SetActive(true)
 | 
						|
                this.titleTextExpert2:GetComponent("Text").text = ExpertDec[1]
 | 
						|
                this.titleTextExpert2:GetComponent("Text").fontSize = GetCurLanguage() ~= 2 and 33 or 25
 | 
						|
            elseif numExChange[activeIndext] == ActivityTypeDef.GoldExper then
 | 
						|
            elseif numExChange[activeIndext] == ActivityTypeDef.FindTreasureExper then
 | 
						|
                this.xunbaoTextImage:GetComponent("Image").sprite = this.spLoader:LoadSprite("r_daren_xubao1_zh")
 | 
						|
                this.xunbaoTextImage:SetActive(true)
 | 
						|
                this.titleImageExpert1:SetActive(true)
 | 
						|
                this.titleTextExpert:SetActive(true)
 | 
						|
                this.titleTextExpert:GetComponent("Text").text = ExpertDec[1]
 | 
						|
            else
 | 
						|
                this.titleImageExpert1:SetActive(true)
 | 
						|
                this.titleTextExpert:SetActive(true)
 | 
						|
                this.titleTextExpert:GetComponent("Text").text = ExpertDec[1]
 | 
						|
            end
 | 
						|
        end
 | 
						|
    end
 | 
						|
    if numExChange[activeIndext] == ActivityTypeDef.AccumulativeRechargeExper then--今日累计充值特殊判断
 | 
						|
        PatFaceManager.RemainTimeDown(this.timeTextExpertgo,this.timeTextExpert,CalculateSecondsNowTo_N_OClock(0))
 | 
						|
    else
 | 
						|
        PatFaceManager.RemainTimeDown(this.timeTextExpertgo,this.timeTextExpert,expertRewardTabs.endTime - GetTimeStamp())
 | 
						|
    end
 | 
						|
    this:WarPowerRewardTabsChangState()
 | 
						|
    this:WarPowerRewardTabsSort(expertRewardTabs.mission)
 | 
						|
    local prefab = {}
 | 
						|
    for i = 1, #expertRewardTabs.mission do
 | 
						|
        this:ActivityRewardSingleShow(i,expertRewardTabs.mission[i])
 | 
						|
        if isPlayshow then
 | 
						|
            expertRewardGrid[i].gameObject:SetActive(false)
 | 
						|
        end
 | 
						|
        table.insert(prefab,expertRewardGrid[i])
 | 
						|
    end
 | 
						|
    if isPlayshow then
 | 
						|
        SecTorPlayAnim(prefab)
 | 
						|
        isPlayshow = false
 | 
						|
    end
 | 
						|
    if index == 26 then
 | 
						|
        this.HelpBtn:SetActive(true)
 | 
						|
        Util.AddOnceClick(this.HelpBtn, function()
 | 
						|
            UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.Expert_Expedition,this.helpPosition.x,this.helpPosition.y) 
 | 
						|
        end)
 | 
						|
    else
 | 
						|
        this.HelpBtn:SetActive(false)
 | 
						|
    end
 | 
						|
end
 | 
						|
function Expert:WarPowerRewardTabsChangState()
 | 
						|
    for i = 1, #expertRewardTabs.mission do
 | 
						|
        local conFigData = ConfigManager.GetConfigData(ConfigName.ActivityRewardConfig,expertRewardTabs.mission[i].missionId)
 | 
						|
        local value = 0
 | 
						|
        --限时累计活动特殊数值读取处理
 | 
						|
        if numExChange[activeIndext] == ActivityTypeDef.AccumulativeRechargeExper then
 | 
						|
            value = conFigData.Values[1][1]
 | 
						|
        else
 | 
						|
            value = conFigData.Values[2][1]
 | 
						|
        end
 | 
						|
        if expertRewardTabs.mission[i].state == 0 then
 | 
						|
            if numExChange[activeIndext] == ActivityTypeDef.UpStarExper or numExChange[activeIndext] == ActivityTypeDef.Talisman
 | 
						|
                    or numExChange[activeIndext] == ActivityTypeDef.SoulPrint or numExChange[activeIndext] == ActivityTypeDef.EquipExper
 | 
						|
                    or numExChange[activeIndext] == ActivityTypeDef.FindTreasureExper  or  numExChange[activeIndext] == ActivityTypeDef.ExpeditionExper then--进阶因为每个都不一样 特殊判断
 | 
						|
                if expertRewardTabs.mission[i].progress < value then
 | 
						|
                    expertRewardTabs.mission[i].state = 10
 | 
						|
                else
 | 
						|
                    expertRewardTabs.mission[i].state = 0
 | 
						|
                end
 | 
						|
            else
 | 
						|
                if expertRewardTabs.value < value then
 | 
						|
                    expertRewardTabs.mission[i].state = 10
 | 
						|
                else
 | 
						|
                    expertRewardTabs.mission[i].state = 0
 | 
						|
                end
 | 
						|
            end
 | 
						|
        elseif expertRewardTabs.mission[i].state == 1 then
 | 
						|
            expertRewardTabs.mission[i].state = 20
 | 
						|
        end
 | 
						|
    end
 | 
						|
end
 | 
						|
function Expert:WarPowerRewardTabsSort(missions)
 | 
						|
    table.sort(missions,function(a,b)
 | 
						|
        if a.state < b.state then
 | 
						|
            return a.state < b.state
 | 
						|
        elseif a.state == b.state then
 | 
						|
            return a.missionId < b.missionId
 | 
						|
        end
 | 
						|
    end)
 | 
						|
end
 | 
						|
--活动奖励2
 | 
						|
function Expert:ActivityRewardSingleShow(index,rewardData)
 | 
						|
    local activityRewardGo = expertRewardGrid[index]
 | 
						|
    activityRewardGo:SetActive(true)
 | 
						|
    local sConFigData = ConfigManager.GetConfigData(ConfigName.ActivityRewardConfig,rewardData.missionId)
 | 
						|
    local titleText = Util.GetGameObject(activityRewardGo, "titleImage/titleText"):GetComponent("Text")
 | 
						|
    titleText.text = GetLanguageStrById(sConFigData.ContentsShow)
 | 
						|
    local content = Util.GetGameObject(activityRewardGo, "content")
 | 
						|
    for i = 1, math.max(#sConFigData.Reward, #expertRewardItemsGrid[index]) do
 | 
						|
        local go = expertRewardItemsGrid[index][i]
 | 
						|
        if not go then
 | 
						|
            go = SubUIManager.Open(SubUIConfig.ItemView, content.transform)
 | 
						|
            expertRewardItemsGrid[index][i] = go
 | 
						|
        end
 | 
						|
        go.gameObject:SetActive(false)
 | 
						|
    end
 | 
						|
    for i = 1, #sConFigData.Reward do
 | 
						|
        expertRewardItemsGrid[index][i].gameObject:SetActive(true)
 | 
						|
        expertRewardItemsGrid[index][i]:OnOpen(false,sConFigData.Reward[i],0.9,false,false,false,sortingOrder)
 | 
						|
    end
 | 
						|
 | 
						|
    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")
 | 
						|
    local state = rewardData.state
 | 
						|
    local value = 0
 | 
						|
    --限时累计活动特殊数值读取处理
 | 
						|
    if numExChange[activeIndext] == ActivityTypeDef.AccumulativeRechargeExper then
 | 
						|
        value = sConFigData.Values[1][1]
 | 
						|
    else
 | 
						|
        value = sConFigData.Values[2][1]
 | 
						|
    end
 | 
						|
    lingquButton:SetActive(state == 0)
 | 
						|
    qianwangButton:SetActive(state == 10)
 | 
						|
    getFinishText:SetActive(state == 20)
 | 
						|
    Util.SetGray(getFinishText,state == 20)
 | 
						|
    getRewardProgress:SetActive(state == 10)
 | 
						|
    Util.GetGameObject(lingquButton.gameObject, "redPoint"):SetActive(state == 0)
 | 
						|
    if numExChange[activeIndext] == ActivityTypeDef.UpStarExper or numExChange[activeIndext] == ActivityTypeDef.Talisman
 | 
						|
            or numExChange[activeIndext] == ActivityTypeDef.SoulPrint or numExChange[activeIndext] == ActivityTypeDef.EquipExper
 | 
						|
            or numExChange[activeIndext] == ActivityTypeDef.FindTreasureExper or numExChange[activeIndext] == ActivityTypeDef.ExpeditionExper then --进阶因为每个都不一样 特殊判断
 | 
						|
        getRewardProgress:GetComponent("Text").text = rewardData.progress .."/"..value
 | 
						|
    else
 | 
						|
        getRewardProgress:GetComponent("Text").text = expertRewardTabs.value .."/"..value
 | 
						|
    end
 | 
						|
    Util.AddOnceClick(qianwangButton, function()
 | 
						|
        JumpManager.GoJump(sConFigData.Jump[1])
 | 
						|
    end)
 | 
						|
    Util.AddOnceClick(lingquButton, function()
 | 
						|
        Log("达人领取奖励           "..rewardData.missionId.."           "..expertRewardTabs.activityId)
 | 
						|
        NetManager.GetActivityRewardRequest(rewardData.missionId, expertRewardTabs.activityId, function(drop)
 | 
						|
            UIManager.OpenPanel(UIName.RewardItemPopup,drop,1,function()
 | 
						|
                this:OnShowData(activeIndext)
 | 
						|
                CheckRedPointStatus(RedPointType.Expert_FastExplore)
 | 
						|
            end)
 | 
						|
        end)
 | 
						|
    end)
 | 
						|
end
 | 
						|
--界面关闭时调用(用于子类重写)
 | 
						|
function Expert:OnClose()
 | 
						|
 | 
						|
end
 | 
						|
 | 
						|
--界面销毁时调用(用于子类重写)
 | 
						|
function Expert:OnDestroy()
 | 
						|
    this.spLoader:Destroy()
 | 
						|
 | 
						|
    sortingOrder = 0
 | 
						|
end
 | 
						|
 | 
						|
return Expert |