2021-04-21 13:12:04 +08:00
|
|
|
|
----- 试练副本奖励弹窗 -----
|
2020-06-08 13:57:30 +08:00
|
|
|
|
require("Base/BasePanel")
|
|
|
|
|
local TrialRewardPopup = Inherit(BasePanel)
|
|
|
|
|
local this = TrialRewardPopup
|
2021-01-07 19:24:04 +08:00
|
|
|
|
local rewardConfig
|
2020-06-08 13:57:30 +08:00
|
|
|
|
local itemList={} --预设容器
|
|
|
|
|
local sortingOrder=0
|
2021-01-07 19:24:04 +08:00
|
|
|
|
local getFunc = {}
|
2021-01-14 15:24:51 +08:00
|
|
|
|
local pres = {}
|
|
|
|
|
local curType = 0
|
2021-01-15 10:50:27 +08:00
|
|
|
|
local scrollView = nil
|
2020-06-08 13:57:30 +08:00
|
|
|
|
function TrialRewardPopup:InitComponent()
|
2021-04-21 13:12:04 +08:00
|
|
|
|
this.spLoader = SpriteLoader.New()
|
2020-06-08 13:57:30 +08:00
|
|
|
|
this.panel=Util.GetGameObject(this.gameObject,"Panel")
|
|
|
|
|
this.backBtn=Util.GetGameObject(this.panel,"BackBtn")
|
2021-12-30 20:09:16 +08:00
|
|
|
|
this.maskBtn=Util.GetGameObject(this.gameObject,"Mask")
|
2022-01-08 10:33:31 +08:00
|
|
|
|
this.title = Util.GetGameObject(this.panel,"Title"):GetComponent("Text")
|
2020-06-08 13:57:30 +08:00
|
|
|
|
|
|
|
|
|
this.scroll=Util.GetGameObject(this.panel,"Scroll")
|
2021-01-14 15:24:51 +08:00
|
|
|
|
pres[1]=Util.GetGameObject(this.panel,"Scroll/Pre")
|
|
|
|
|
pres[2]=Util.GetGameObject(this.panel,"Scroll/Pre3")
|
2021-04-25 15:07:36 +08:00
|
|
|
|
pres[4]=Util.GetGameObject(this.panel,"Scroll/Pre4")
|
2021-12-29 14:03:16 +08:00
|
|
|
|
pres[5]=Util.GetGameObject(this.panel,"Scroll/Pre3")
|
2021-04-25 15:07:36 +08:00
|
|
|
|
scrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView,this.scroll.transform,pres[MonsterCampManager.preType], nil,
|
2021-03-04 21:01:21 +08:00
|
|
|
|
Vector2.New(this.scroll.transform.rect.width,this.scroll.transform.rect.height),1,1,Vector2.New(0,5))
|
|
|
|
|
scrollView.gameObject:GetComponent("RectTransform").anchoredPosition= Vector2.New(0,0)
|
|
|
|
|
scrollView.gameObject:GetComponent("RectTransform").anchorMin = Vector2.New(0.5, 0.5)
|
|
|
|
|
scrollView.gameObject:GetComponent("RectTransform").anchorMax = Vector2.New(0.5, 0.5)
|
|
|
|
|
scrollView.gameObject:GetComponent("RectTransform").pivot = Vector2.New(0.5, 0.5)
|
|
|
|
|
scrollView.moveTween.MomentumAmount = 1
|
|
|
|
|
scrollView.moveTween.Strength = 2
|
2021-12-29 14:03:16 +08:00
|
|
|
|
scrollView.elastic = false
|
2020-06-08 13:57:30 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function TrialRewardPopup:BindEvent()
|
|
|
|
|
Util.AddClick(this.backBtn,function()
|
|
|
|
|
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
|
|
|
|
|
self:ClosePanel()
|
|
|
|
|
end)
|
2021-12-30 20:09:16 +08:00
|
|
|
|
Util.AddClick(this.maskBtn,function()
|
|
|
|
|
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
|
|
|
|
|
self:ClosePanel()
|
|
|
|
|
end)
|
2020-06-08 13:57:30 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function TrialRewardPopup:AddListener()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function TrialRewardPopup:RemoveListener()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function TrialRewardPopup:OnSortingOrderChange()
|
|
|
|
|
sortingOrder = self.sortingOrder
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function TrialRewardPopup:OnOpen(...)
|
2021-01-07 19:24:04 +08:00
|
|
|
|
local arg = {...}
|
|
|
|
|
rewardConfig = arg[1]
|
|
|
|
|
getFunc = arg[2]
|
2021-01-15 15:27:21 +08:00
|
|
|
|
curType = arg[3]
|
2020-06-08 13:57:30 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function TrialRewardPopup:OnShow()
|
2021-02-26 14:52:59 +08:00
|
|
|
|
this.RefreshPanel(true,true)
|
2021-01-12 19:21:20 +08:00
|
|
|
|
sortingOrder = self.sortingOrder
|
2020-06-08 13:57:30 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function TrialRewardPopup:OnClose()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function TrialRewardPopup:OnDestroy()
|
2021-04-21 13:12:04 +08:00
|
|
|
|
this.spLoader:Destroy()
|
2021-01-15 10:50:27 +08:00
|
|
|
|
scrollView=nil
|
2021-03-04 21:01:21 +08:00
|
|
|
|
itemList = {}
|
2020-06-08 13:57:30 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-01-15 22:11:38 +08:00
|
|
|
|
--0 已经领取,1 可领取,2不能领取·
|
|
|
|
|
local sortIndex = {
|
|
|
|
|
[0] = 0,
|
|
|
|
|
[1] = 2,
|
|
|
|
|
[2] = 1,
|
|
|
|
|
}
|
2020-06-08 13:57:30 +08:00
|
|
|
|
--刷新
|
2021-02-26 14:52:59 +08:00
|
|
|
|
function this.RefreshPanel(isTop,isAni)
|
2021-04-23 19:37:15 +08:00
|
|
|
|
if curType ~= 4 then
|
|
|
|
|
table.sort(rewardConfig,function(a,b)
|
|
|
|
|
if sortIndex[a.state] == sortIndex[b.state] then
|
|
|
|
|
return a.Id < b.Id
|
|
|
|
|
end
|
|
|
|
|
return sortIndex[a.state] > sortIndex[b.state]
|
|
|
|
|
end)
|
|
|
|
|
scrollView:SetData(rewardConfig,function(index,root)
|
|
|
|
|
this.SetScrollPre(root,rewardConfig[index])
|
|
|
|
|
end,not isTop,not isAni)
|
|
|
|
|
else--踏碎凌霄-仅供展示
|
|
|
|
|
scrollView:SetData(rewardConfig,function(index,root)
|
|
|
|
|
this.SetScrollPre2(root,rewardConfig[index])
|
|
|
|
|
end,not isTop,not isAni)
|
|
|
|
|
end
|
|
|
|
|
|
2022-01-08 10:33:31 +08:00
|
|
|
|
this.title.text = "奖 励"
|
|
|
|
|
if curType == 5 then
|
|
|
|
|
this.title.text = "任 务"
|
|
|
|
|
end
|
2020-06-08 13:57:30 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--设置每条数据
|
|
|
|
|
function this.SetScrollPre(root,data)
|
|
|
|
|
local info=Util.GetGameObject(root,"Title/Info"):GetComponent("Text")
|
|
|
|
|
local grid=Util.GetGameObject(root,"Grid")
|
|
|
|
|
local goBtn=Util.GetGameObject(root,"GoBtn")
|
2020-07-16 16:59:46 +08:00
|
|
|
|
local getBtn=Util.GetGameObject(root,"GetBtn")
|
|
|
|
|
local mask=Util.GetGameObject(root,"mask")
|
2021-01-14 15:24:51 +08:00
|
|
|
|
local pregress = Util.GetGameObject(root,"getRewardProgress")
|
|
|
|
|
if pregress then
|
|
|
|
|
if curType == 2 then
|
2021-05-26 22:00:33 +08:00
|
|
|
|
pregress.gameObject:SetActive(true)
|
2021-01-15 10:50:27 +08:00
|
|
|
|
pregress:GetComponent("Text").text = "("..(MonsterCampManager.monsterWave - 1).."/"..data.Id..")"
|
2021-05-26 22:00:33 +08:00
|
|
|
|
else
|
|
|
|
|
pregress.gameObject:SetActive(false)
|
2021-01-14 15:24:51 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
2021-03-12 14:31:52 +08:00
|
|
|
|
info.text=data.info --string.format( Language[11483],data.Count,MapTrialManager.GetKilCount(),data.Count)
|
2021-01-12 19:21:20 +08:00
|
|
|
|
--ResetItemView(root,grid.transform,itemList,#data.BoxReward,0.9,sortingOrder,false,data.BoxReward)
|
|
|
|
|
if not itemList[root] then
|
|
|
|
|
itemList[root] = {}
|
|
|
|
|
end
|
|
|
|
|
for k,v in ipairs(itemList[root]) do
|
|
|
|
|
v.gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
for i = 1 , #data.BoxReward do
|
|
|
|
|
if not itemList[root][i] then
|
|
|
|
|
itemList[root][i] = SubUIManager.Open(SubUIConfig.ItemView,grid.transform)
|
|
|
|
|
itemList[root][i].gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
itemList[root][i]:OnOpen(false, data.BoxReward[i], 0.9,false,false,false,sortingOrder)
|
|
|
|
|
itemList[root][i].gameObject:SetActive(true)
|
|
|
|
|
end
|
2021-01-07 19:24:04 +08:00
|
|
|
|
if data.state==0 then
|
2021-03-02 15:59:29 +08:00
|
|
|
|
-- goText.text="已领取"
|
2021-04-21 13:12:04 +08:00
|
|
|
|
mask:GetComponent("Image").sprite = this.spLoader:LoadSprite("s_slbz_yilingqu_zh")
|
2020-07-16 16:59:46 +08:00
|
|
|
|
mask:SetActive(true)
|
|
|
|
|
goBtn:SetActive(false)
|
|
|
|
|
getBtn:SetActive(false)
|
2021-01-07 19:24:04 +08:00
|
|
|
|
elseif data.state==1 then
|
2021-03-02 15:59:29 +08:00
|
|
|
|
-- goText.text="领取"
|
2020-07-16 16:59:46 +08:00
|
|
|
|
mask:SetActive(false)
|
|
|
|
|
goBtn:SetActive(false)
|
|
|
|
|
getBtn:SetActive(true)
|
2021-01-07 19:24:04 +08:00
|
|
|
|
elseif data.state==2 then
|
2021-03-02 15:59:29 +08:00
|
|
|
|
-- goText.text="前往"
|
2020-07-16 16:59:46 +08:00
|
|
|
|
mask:SetActive(false)
|
|
|
|
|
goBtn:SetActive(true)
|
|
|
|
|
getBtn:SetActive(false)
|
2020-06-12 18:04:22 +08:00
|
|
|
|
end
|
2020-06-08 13:57:30 +08:00
|
|
|
|
|
|
|
|
|
Util.AddOnceClick(goBtn,function()
|
2020-07-16 16:59:46 +08:00
|
|
|
|
this:ClosePanel()
|
2021-06-09 11:03:18 +08:00
|
|
|
|
if data.jump and data.jump > 0 then
|
|
|
|
|
JumpManager.GoJump(data.jump)
|
|
|
|
|
end
|
2020-07-16 16:59:46 +08:00
|
|
|
|
end)
|
|
|
|
|
Util.AddOnceClick(getBtn,function()
|
2021-01-07 19:24:04 +08:00
|
|
|
|
if getFunc then
|
|
|
|
|
getFunc(data.Id,function()
|
2020-07-16 16:59:46 +08:00
|
|
|
|
mask:SetActive(true)
|
|
|
|
|
getBtn:SetActive(false)
|
2021-01-07 19:24:04 +08:00
|
|
|
|
this.ChangeState(data.Id)
|
2021-02-26 14:52:59 +08:00
|
|
|
|
this.RefreshPanel(false,false)
|
2020-06-12 18:04:22 +08:00
|
|
|
|
end)
|
2021-01-07 19:24:04 +08:00
|
|
|
|
end
|
2020-06-08 13:57:30 +08:00
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
2021-04-23 19:37:15 +08:00
|
|
|
|
--设置每条数据
|
2021-04-25 15:07:36 +08:00
|
|
|
|
function this.SetScrollPre2(root,data)
|
2021-04-23 19:37:15 +08:00
|
|
|
|
local info=Util.GetGameObject(root,"Title/Info"):GetComponent("Text")
|
|
|
|
|
local grid=Util.GetGameObject(root,"Grid")
|
|
|
|
|
local mask=Util.GetGameObject(root,"mask")
|
2021-05-11 17:03:09 +08:00
|
|
|
|
info.text = string.format(Language[12309],data.otherData.Sort,data.otherData.Values[1][1])
|
2021-04-23 19:37:15 +08:00
|
|
|
|
|
|
|
|
|
if not itemList[root] then
|
|
|
|
|
itemList[root] = {}
|
|
|
|
|
end
|
|
|
|
|
for k,v in ipairs(itemList[root]) do
|
|
|
|
|
v.gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
for i = 1 , #data.otherData.Reward do
|
|
|
|
|
if not itemList[root][i] then
|
|
|
|
|
itemList[root][i] = SubUIManager.Open(SubUIConfig.ItemView,grid.transform)
|
|
|
|
|
itemList[root][i].gameObject:SetActive(false)
|
|
|
|
|
end
|
2021-04-25 15:07:36 +08:00
|
|
|
|
itemList[root][i]:OnOpen(false, data.otherData.Reward[i], 0.9,false,false,false,sortingOrder)
|
2021-04-23 19:37:15 +08:00
|
|
|
|
itemList[root][i].gameObject:SetActive(true)
|
|
|
|
|
end
|
|
|
|
|
mask:SetActive(true)
|
|
|
|
|
if data.state==0 then
|
2021-05-19 15:06:02 +08:00
|
|
|
|
mask:GetComponent("Image").sprite = this.spLoader:LoadSprite("g_ghhb_weidacheng_zh")
|
2021-04-23 19:37:15 +08:00
|
|
|
|
elseif data.state==1 then
|
2021-05-19 15:06:02 +08:00
|
|
|
|
mask:GetComponent("Image").sprite = this.spLoader:LoadSprite("g_ghhb_yidacheng_zh")
|
2021-04-23 19:37:15 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2021-01-07 19:24:04 +08:00
|
|
|
|
function this.ChangeState(id)
|
|
|
|
|
for k,v in ipairs(rewardConfig) do
|
2021-01-12 19:21:20 +08:00
|
|
|
|
if v.Id == id then
|
2021-01-07 19:24:04 +08:00
|
|
|
|
v.state = 0
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2020-06-08 13:57:30 +08:00
|
|
|
|
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return TrialRewardPopup
|