----- 日常任务弹窗 ----- local this = {} --传入父脚本模块 local parent --传入特效层级 local sortingOrder=0 local fun --item容器 local itemList = {} local curAllData = {} local achievementConfig = ConfigManager.GetConfig(ConfigName.AchievementConfig) local itemGrid = {} local isPlayAnim = true function this:InitComponent(gameObject) this.spLoader = SpriteLoader.New() this.rewardPre = Util.GetGameObject(gameObject, "rewardPre") local v = Util.GetGameObject(gameObject, "rect"):GetComponent("RectTransform").rect this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, Util.GetGameObject(gameObject, "rect").transform, this.rewardPre, nil, Vector2.New(v.width, v.height), 1, 1, Vector2.New(0,10)) this.ScrollView.moveTween.MomentumAmount = 1 this.ScrollView.moveTween.Strength = 1 this.NoviceItemList={}--存储itemview 重复利用 end function this:BindEvent() end function this:AddListener() end function this:RemoveListener() end function this:OnShow(_parent,...) isPlayAnim = true parent=_parent sortingOrder = _parent.sortingOrder --不定参中包含的不定参 _args[1]为面板类型 _args[2]之后(包括)为打开面板后传入的不定参 local args = {...} fun = args[1] this.OnShowPanelData(true,true) end function this:OnSortingOrderChange(sortingOrder) for i, v in pairs(this.NoviceItemList) do for j = 1, #this.NoviceItemList[i] do if this.NoviceItemList[i][j] and this.NoviceItemList[i][j].gameObject then this.NoviceItemList[i][j]:SetEffectLayer(sortingOrder) end end end end function this.OnShowPanelData(isTop,isAni) local curAllData = TaskManager.GetCurShowAllAchievementData(TaskTypeDef.Achievement) local AllData = {} for i, v in pairs(curAllData) do table.insert(AllData,v) end this.RewardTabsSort(AllData) -- LogRed("isTop "..tostring(not isTop).." isAni "..tostring(not isAni)) this.ScrollView:SetData(AllData, function (index, go) this.SingleDataShow(go, AllData[index]) end, not isTop,not isAni) -- if isPlayAnim then -- SecTorPlayAnimByScroll(this.ScrollView) -- isPlayAnim = false -- end end function this.SingleDataShow(go,rewardData) local activityRewardGo = go -- if isPlayAnim then -- activityRewardGo:SetActive(false) -- else -- activityRewardGo:SetActive(true) -- end local sConFigData = achievementConfig[rewardData.missionId] local titleText = Util.GetGameObject(activityRewardGo, "titleImage/titleText"):GetComponent("Text") titleText.text = GetLanguageStrById(sConFigData.ContentsShow) local itemGroup = Util.GetGameObject(activityRewardGo, "content") --滚动条复用重设itemview if this.NoviceItemList[go] then for i = 1, 4 do this.NoviceItemList[go][i].gameObject:SetActive(false) end for i = 1, #sConFigData.Reward do if this.NoviceItemList[go][i] then this.NoviceItemList[go][i]:OnOpen(false, {sConFigData.Reward[i][1],sConFigData.Reward[i][2]}, 0.7,false,false,false,sortingOrder) this.NoviceItemList[go][i].gameObject:SetActive(true) end end else this.NoviceItemList[go]={} for i = 1, 4 do this.NoviceItemList[go][i] = SubUIManager.Open(SubUIConfig.ItemView, itemGroup.transform) this.NoviceItemList[go][i].gameObject:SetActive(false) end for i = 1, #sConFigData.Reward do this.NoviceItemList[go][i]:OnOpen(false, {sConFigData.Reward[i][1],sConFigData.Reward[i][2]}, 0.7,false,false,false,sortingOrder) this.NoviceItemList[go][i].gameObject:SetActive(true) end 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 = sConFigData.Values[2][1] lingquButton:SetActive(state == 1) qianwangButton:SetActive(state == 0) getFinishText:SetActive(state == 2) getRewardProgress:SetActive(state == 0) getRewardProgress:GetComponent("Text").text =PrintWanNum(math.abs(rewardData.progress)) .."/"..PrintWanNum(math.abs(value)) Util.AddOnceClick(qianwangButton, function() if sConFigData.Jump then JumpManager.GoJump(sConFigData.Jump[1]) end end) Util.AddOnceClick(lingquButton, function() NetManager.TakeMissionRewardRequest(TaskTypeDef.Achievement,rewardData.missionId, function(msg) UIManager.OpenPanel(UIName.RewardItemPopup,msg.drop,1,function() this.OnShowPanelData(false,false) end) end) end) end local sortTable = { [1] = 2, [2] = 0, [0] = 1, } function this.RewardTabsSort(missions) table.sort(missions,function(a,b) if a.state == b.state then return a.missionId < b.missionId else return sortTable[a.state] > sortTable[b.state] end end) end function this:OnClose() end function this:OnDestroy() this.spLoader:Destroy() end return this