miduo_client/Assets/ManagedResources/~Lua/Modules/Mission/MissionDailyPanel_Achieveme...

135 lines
4.9 KiB
Lua
Raw Normal View History

2020-08-25 15:46:38 +08:00
----- 日常任务弹窗 -----
2020-06-03 19:09:01 +08:00
local this = {}
--传入父脚本模块
local parent
--传入特效层级
local sortingOrder=0
local fun
--item容器
local itemList = {}
local curAllData = {}
local achievementConfig = ConfigManager.GetConfig(ConfigName.AchievementConfig)
local itemGrid = {}
function this:InitComponent(gameObject)
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,-5))
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,...)
parent=_parent
sortingOrder = _parent.sortingOrder
--不定参中包含的不定参 _args[1]为面板类型 _args[2]之后(包括)为打开面板后传入的不定参
local args = {...}
fun = args[1]
this.OnShowPanelData()
end
2020-06-08 20:18:49 +08:00
function this:OnSortingOrderChange(sortingOrder)
2020-06-03 19:09:01 +08:00
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()
local curAllData = TaskManager.GetCurShowAllAchievementData(TaskTypeDef.Achievement)
local AllData = {}
for i, v in pairs(curAllData) do
table.insert(AllData,v)
end
this.RewardTabsSort(AllData)
this.ScrollView:SetData(AllData, function (index, go)
this.SingleDataShow(go, AllData[index])
end)
end
function this.SingleDataShow(go,rewardData)
local activityRewardGo = go
activityRewardGo:SetActive(true)
local sConFigData = achievementConfig[rewardData.missionId]
local titleText = Util.GetGameObject(activityRewardGo, "titleImage/titleText"):GetComponent("Text")
titleText.text = 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.9,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.9,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 = math.abs(rewardData.progress) .."/"..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()
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()
end
2020-06-23 18:36:24 +08:00
return this