297 lines
13 KiB
Lua
297 lines
13 KiB
Lua
|
----- 日常任务弹窗 -----
|
|||
|
local this = {}
|
|||
|
--传入父脚本模块
|
|||
|
local parent
|
|||
|
--传入特效层级
|
|||
|
local sortingOrder=0
|
|||
|
local fun
|
|||
|
local SingleDailyMissionState = {
|
|||
|
NoFinish = 0, --未完成
|
|||
|
Finish = 1, --完成未领取
|
|||
|
GetFinish = 2, --已领取
|
|||
|
}
|
|||
|
local SortDailyMissionState = {
|
|||
|
[1]=1,
|
|||
|
[0]=2,
|
|||
|
[2]=3
|
|||
|
}
|
|||
|
local dailyTasksConfig={}--静态数据
|
|||
|
local curDailyMissionData={}--每日任务条目
|
|||
|
local curDailyMissionBoxData={}--宝箱
|
|||
|
local boxList={}--宝箱按钮
|
|||
|
local allMissionDailyPres = {}
|
|||
|
local allMissionDailyItemPres = {}
|
|||
|
local allMissionDailyBoxItemPres = {}
|
|||
|
local myGo
|
|||
|
function this:InitComponent(gameObject)
|
|||
|
myGo = gameObject
|
|||
|
--this.grid = Util.GetGameObject(gameObject, "infoOb/rect/grid")
|
|||
|
--for i = 1, 9 do
|
|||
|
-- allMissionDailyPres[i] = Util.GetGameObject(gameObject, "infoOb/rect/grid/dayMissionPre ("..i..")")
|
|||
|
-- allMissionDailyItemPres[i] = SubUIManager.Open(SubUIConfig.ItemView, Util.GetGameObject(allMissionDailyPres[i].transform, "itemRect/itemGrid").transform)
|
|||
|
--end
|
|||
|
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 重复利用
|
|||
|
|
|||
|
this.boxItemGrid = Util.GetGameObject(gameObject, "rewardBg/RewardPanel/ViewRect/grid").transform
|
|||
|
for i = 1, 3 do
|
|||
|
boxList[i] = Util.GetGameObject(gameObject, "rewardBg/btnList/BoxBtn"..i)
|
|||
|
allMissionDailyBoxItemPres[i] = SubUIManager.Open(SubUIConfig.ItemView, this.boxItemGrid)
|
|||
|
end
|
|||
|
this.BoxThree = Util.GetGameObject(gameObject, "rewardBg/BoxThree")
|
|||
|
this.BoxSix = Util.GetGameObject(gameObject, "rewardBg/BoxSix")
|
|||
|
this.BoxNine = Util.GetGameObject(gameObject, "rewardBg/BoxNine")
|
|||
|
|
|||
|
this.RewardPanelGetInfo = Util.GetGameObject(gameObject, "rewardBg/RewardPanel/getInfo")
|
|||
|
this.RewardPanelGrid = Util.GetGameObject(gameObject, "rewardBg/RewardPanel/ViewRect/grid")
|
|||
|
this.RewardPanel = Util.GetGameObject(gameObject, "rewardBg/RewardPanel")
|
|||
|
this.rewardMaskBtn = Util.GetGameObject(gameObject, "rewardBg/RewardPanel/rewardMaskBtn")
|
|||
|
this.progressBottom = Util.GetGameObject(gameObject, "rewardBg/progressBottom/Image"):GetComponent("Image")
|
|||
|
this.totalPro = Util.GetGameObject(gameObject, "rewardBg/totalProImage/totalPro"):GetComponent("Text")
|
|||
|
this.getInfo = Util.GetGameObject(gameObject, "rewardBg/RewardPanel/getInfo"):GetComponent("Text")
|
|||
|
end
|
|||
|
|
|||
|
function this:BindEvent()
|
|||
|
Util.AddClick(this.rewardMaskBtn, function()
|
|||
|
this.rewardMaskBtn:SetActive(false)
|
|||
|
this.RewardPanel:SetActive(false)
|
|||
|
end)
|
|||
|
end
|
|||
|
function this:AddListener()
|
|||
|
Game.GlobalEvent:AddEvent(GameEvent.MissionDaily.OnMissionDailyChanged, this.OnShowData)
|
|||
|
end
|
|||
|
|
|||
|
function this:RemoveListener()
|
|||
|
Game.GlobalEvent:RemoveEvent(GameEvent.MissionDaily.OnMissionDailyChanged,this.OnShowData)
|
|||
|
end
|
|||
|
|
|||
|
function this:OnShow(_parent,...)
|
|||
|
parent=_parent
|
|||
|
sortingOrder = _parent.sortingOrder
|
|||
|
--不定参中包含的不定参 _args[1]为面板类型 _args[2]之后(包括)为打开面板后传入的不定参
|
|||
|
local args = {...}
|
|||
|
fun = args[1]
|
|||
|
this.OnShowData()
|
|||
|
end
|
|||
|
function this:OnSortingOrderChange()
|
|||
|
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.OnShowData()
|
|||
|
dailyTasksConfig=ConfigManager.GetConfig(ConfigName.DailyTasksConfig)
|
|||
|
curDailyMissionData = {}
|
|||
|
curDailyMissionBoxData = {}
|
|||
|
for i, v in pairs(TaskManager.GetTypeTaskList(TaskTypeDef.DayTask)) do
|
|||
|
if v.missionId < 10000 then
|
|||
|
--if this.GetCurIsOpen(dailyTasksConfig[v.missionId].OpenLevel) then
|
|||
|
if dailyTasksConfig[v.missionId].OpenLevel or ActTimeCtrlManager.SingleFuncState(dailyTasksConfig[v.missionId].OpenLevel) then
|
|||
|
table.insert(curDailyMissionData,v)
|
|||
|
end
|
|||
|
else
|
|||
|
--if this.GetCurIsOpen(dailyTasksConfig[v.missionId].OpenLevel) then
|
|||
|
if dailyTasksConfig[v.missionId].OpenLevel or ActTimeCtrlManager.SingleFuncState(dailyTasksConfig[v.missionId].OpenLevel) then
|
|||
|
table.insert(curDailyMissionBoxData,v)
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
table.sort(curDailyMissionData, function(a,b)
|
|||
|
if a.state == b.state then
|
|||
|
return a.missionId<b.missionId
|
|||
|
else
|
|||
|
return SortDailyMissionState[a.state]<SortDailyMissionState[b.state]
|
|||
|
end
|
|||
|
end)
|
|||
|
local AllData = TaskManager.GetTypeTaskList(TaskTypeDef.Achievement)
|
|||
|
--LogError(" ``````````` "..LengthOfTable(AllData))
|
|||
|
this.ScrollView:SetData(curDailyMissionData, function (index, go)
|
|||
|
--this.SingleDataShow(go, curDailyMissionData[index])
|
|||
|
this.SingleMissionDatasDataShow(go,curDailyMissionData[index])
|
|||
|
end)
|
|||
|
--this.SetDailyMission(curDailyMissionData)
|
|||
|
this.SetDailyMissionBox(curDailyMissionBoxData)
|
|||
|
end
|
|||
|
function this.SetDailyMission(_missionDatas)
|
|||
|
for i = 1, math.max(#_missionDatas, #allMissionDailyPres) do
|
|||
|
local go = allMissionDailyPres[i]
|
|||
|
if not go then
|
|||
|
go = newObject(allMissionDailyPres[1])
|
|||
|
go.transform:SetParent(this.grid.transform)
|
|||
|
go.name = "dayMissionPre ("..i..")"
|
|||
|
go.transform.localScale = Vector3.one
|
|||
|
go.transform.localPosition = Vector3.zero
|
|||
|
allMissionDailyPres[i] = go
|
|||
|
Util.ClearChild(Util.GetGameObject(allMissionDailyPres[i].transform, "itemRect/itemGrid").transform)
|
|||
|
local goItemPres = SubUIManager.Open(SubUIConfig.ItemView, Util.GetGameObject(allMissionDailyPres[i].transform, "itemRect/itemGrid").transform)
|
|||
|
--goItemPres.transform:SetParent(allMissionDailyPres[i].transform)
|
|||
|
goItemPres.transform.localScale = Vector3.one
|
|||
|
goItemPres.transform.localPosition = Vector3.zero
|
|||
|
allMissionDailyItemPres[i] = goItemPres
|
|||
|
end
|
|||
|
go.gameObject:SetActive(false)
|
|||
|
end
|
|||
|
|
|||
|
|
|||
|
for i = 1, #_missionDatas do
|
|||
|
allMissionDailyPres[i]:SetActive(true)
|
|||
|
this.SingleMissionDatasDataShow(allMissionDailyPres[i],allMissionDailyItemPres[i],_missionDatas[i])
|
|||
|
end
|
|||
|
end
|
|||
|
function this.SingleMissionDatasDataShow(_go,_missionData)
|
|||
|
local missionData = _missionData
|
|||
|
local missionConfigData = dailyTasksConfig[missionData.missionId]
|
|||
|
_go:SetActive(true)
|
|||
|
local titleText = Util.GetGameObject(_go, "titleImage/titleText"):GetComponent("Text")
|
|||
|
titleText.text =string.format(missionConfigData.Desc,missionConfigData.Values[2][1])
|
|||
|
local itemGroup = Util.GetGameObject(_go, "content")
|
|||
|
--滚动条复用重设itemview
|
|||
|
if this.NoviceItemList[_go] then
|
|||
|
for i = 1, 4 do
|
|||
|
this.NoviceItemList[_go][i].gameObject:SetActive(false)
|
|||
|
end
|
|||
|
for i = 1, #missionConfigData.Reward do
|
|||
|
if this.NoviceItemList[_go][i] then
|
|||
|
this.NoviceItemList[_go][i]:OnOpen(false, {missionConfigData.Reward[i][1],missionConfigData.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, #missionConfigData.Reward do
|
|||
|
this.NoviceItemList[_go][i]:OnOpen(false, {missionConfigData.Reward[i][1],missionConfigData.Reward[i][2]}, 0.9,false,false,false,sortingOrder)
|
|||
|
this.NoviceItemList[_go][i].gameObject:SetActive(true)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
local lingquButton = Util.GetGameObject(_go.gameObject, "lingquButton")
|
|||
|
Util.GetGameObject(lingquButton.gameObject, "redPoint"):SetActive(false)
|
|||
|
local qianwangButton = Util.GetGameObject(_go.gameObject, "qianwangButton")
|
|||
|
local getFinishText = Util.GetGameObject(_go.gameObject, "getFinishText")
|
|||
|
local getRewardProgress = Util.GetGameObject(_go.gameObject, "getRewardProgress")
|
|||
|
local state=missionData.state--0:未完成 1:完成未领取 2:已达成(已领取)
|
|||
|
lingquButton:SetActive(state == SingleDailyMissionState.Finish)
|
|||
|
qianwangButton:SetActive(state == SingleDailyMissionState.NoFinish)
|
|||
|
getFinishText:SetActive(state == SingleDailyMissionState.GetFinish)
|
|||
|
getRewardProgress:SetActive(state ~= SingleDailyMissionState.Finish)
|
|||
|
getRewardProgress:GetComponent("Text").text = missionData.progress.."/"..missionConfigData.Values[2][1]
|
|||
|
Util.AddOnceClick(qianwangButton, function()
|
|||
|
if missionConfigData.Jump then
|
|||
|
JumpManager.GoJump(missionConfigData.Jump)
|
|||
|
end
|
|||
|
end)
|
|||
|
Util.AddOnceClick(lingquButton, function()
|
|||
|
NetManager.TakeMissionRewardRequest(TaskTypeDef.DayTask,missionData.missionId,function (msg)
|
|||
|
UIManager.OpenPanel(UIName.RewardItemPopup,msg.drop,1,function()
|
|||
|
TaskManager.SetTypeTaskState(TaskTypeDef.DayTask, missionData.missionId, SingleDailyMissionState.GetFinish)
|
|||
|
this.OnShowData()
|
|||
|
-- 检测红点状态
|
|||
|
CheckRedPointStatus(RedPointType.DailyTask)
|
|||
|
CheckRedPointStatus(RedPointType.SecretTer)
|
|||
|
end)
|
|||
|
end)
|
|||
|
end)
|
|||
|
end
|
|||
|
--每日任务宝箱赋值
|
|||
|
function this.SetDailyMissionBox(_missionDatas)
|
|||
|
for i = 1, math.max(#_missionDatas, #boxList) do
|
|||
|
local go = boxList[i]
|
|||
|
if not go then
|
|||
|
go = newObject(boxList[3])
|
|||
|
go.transform:SetParent(Util.GetGameObject(myGo, "rewardBg/btnList").transform)
|
|||
|
go.name = "BoxBtn"..i
|
|||
|
go.transform.localScale = Vector3.one
|
|||
|
go.transform.localPosition = Vector3.zero
|
|||
|
boxList[i] = go
|
|||
|
end
|
|||
|
go.gameObject:SetActive(false)
|
|||
|
end
|
|||
|
|
|||
|
|
|||
|
local curGetRewardNum=0
|
|||
|
for i, v in pairs(curDailyMissionBoxData) do
|
|||
|
--LogGreen("v.missionId "..v.missionId.." "..v.progress)
|
|||
|
if v.progress > curGetRewardNum then
|
|||
|
curGetRewardNum = v.progress
|
|||
|
end
|
|||
|
end
|
|||
|
this.progressBottom.fillAmount=curGetRewardNum/dailyTasksConfig[_missionDatas[#_missionDatas].missionId].Values[2][1]
|
|||
|
this.totalPro.text= "当前活跃度:"..curGetRewardNum--.."/"..LengthOfTable(curDailyMissionData)
|
|||
|
for i, v in pairs(_missionDatas) do
|
|||
|
boxList[i]:SetActive(true)
|
|||
|
local missionConfigData = dailyTasksConfig[v.missionId]
|
|||
|
Util.GetGameObject(boxList[i], "num"):GetComponent("Text").text = missionConfigData.Values[2][1]
|
|||
|
Util.GetGameObject(boxList[i], "getFinish"):SetActive(v.state==SingleDailyMissionState.GetFinish)
|
|||
|
Util.GetGameObject(boxList[i], "redPoint"):SetActive(v.state==SingleDailyMissionState.Finish)
|
|||
|
Util.AddOnceClick(boxList[i], function()
|
|||
|
this.MissionBoxClick(boxList[i],v)
|
|||
|
end)
|
|||
|
end
|
|||
|
end
|
|||
|
function this.MissionBoxClick(btn,_singleData)
|
|||
|
if _singleData.state == SingleDailyMissionState.NoFinish or _singleData.state == SingleDailyMissionState.GetFinish then
|
|||
|
local curConfig = dailyTasksConfig[_singleData.missionId]
|
|||
|
this.getInfo.text="活跃度达到"..curConfig.Values[2][1].."获得:"
|
|||
|
|
|||
|
local reward = dailyTasksConfig[_singleData.missionId]
|
|||
|
if reward then
|
|||
|
for i = 1, math.max(#allMissionDailyBoxItemPres, #reward.Reward) do
|
|||
|
local go = allMissionDailyBoxItemPres[i]
|
|||
|
if not go then
|
|||
|
go = SubUIManager.Open(SubUIConfig.ItemView, this.boxItemGrid)
|
|||
|
go.gameObject.name = "frame"..i
|
|||
|
allMissionDailyBoxItemPres[i] = go
|
|||
|
end
|
|||
|
go.gameObject:SetActive(false)
|
|||
|
end
|
|||
|
for i = 1, #reward.Reward do
|
|||
|
allMissionDailyBoxItemPres[i].gameObject:SetActive(true)
|
|||
|
allMissionDailyBoxItemPres[i]:OnOpen(false,reward.Reward[i],0.75)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
this.rewardMaskBtn:SetActive(true)
|
|||
|
this.RewardPanel:SetActive(true)
|
|||
|
elseif _singleData.state == SingleDailyMissionState.Finish then
|
|||
|
NetManager.TakeMissionRewardRequest(TaskTypeDef.DayTask,_singleData.missionId,function (msg)
|
|||
|
TaskManager.SetTypeTaskState(TaskTypeDef.DayTask, _singleData.missionId, SingleDailyMissionState.GetFinish)
|
|||
|
UIManager.OpenPanel(UIName.RewardItemPopup,msg.drop,1)
|
|||
|
this.OnShowData()
|
|||
|
end)
|
|||
|
end
|
|||
|
end
|
|||
|
function this.GetCurIsOpen(LevelRegion)
|
|||
|
if LevelRegion[1] == 1 then--等级
|
|||
|
return PlayerManager.level >= LevelRegion[2]
|
|||
|
elseif LevelRegion[1] == 2 then--关卡
|
|||
|
return FightPointPassManager.GetFightIsOpenById(LevelRegion[2])
|
|||
|
end
|
|||
|
end
|
|||
|
--跳转显示新手提示圈
|
|||
|
function this.ShowGuideGo()
|
|||
|
--JumpManager.ShowGuide(UIName.MissionDailyPanel, Util.GetGameObject(allMissionDailyPres[1].transform, "getAwardBtn"))
|
|||
|
end
|
|||
|
function this:OnClose()
|
|||
|
FightPointPassManager.isBeginFight = false
|
|||
|
end
|
|||
|
function this:OnDestroy()
|
|||
|
allMissionDailyPres = {}
|
|||
|
allMissionDailyItemPres = {}
|
|||
|
boxList = {}
|
|||
|
allMissionDailyBoxItemPres = {}
|
|||
|
end
|
|||
|
|
|||
|
return this
|