2025-03-14 11:58:20 +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
|
2024-09-06 10:38:56 +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()
|
2024-09-06 10:38:56 +08:00
|
|
|
|
this.panel = Util.GetGameObject(this.gameObject, "Panel")
|
|
|
|
|
|
this.backBtn = Util.GetGameObject(this.panel, "BackBtn")
|
|
|
|
|
|
this.maskBtn = Util.GetGameObject(this.gameObject, "Mask")
|
|
|
|
|
|
this.title = Util.GetGameObject(this.panel, "Title"):GetComponent("Text")
|
|
|
|
|
|
|
|
|
|
|
|
this.scroll = Util.GetGameObject(this.panel, "Scroll")
|
|
|
|
|
|
pres[1] = Util.GetGameObject(this.panel, "Scroll/Pre")
|
|
|
|
|
|
pres[2] = Util.GetGameObject(this.panel, "Scroll/Pre3")
|
|
|
|
|
|
pres[4] = Util.GetGameObject(this.panel, "Scroll/Pre4")
|
|
|
|
|
|
pres[5] = Util.GetGameObject(this.panel, "Scroll/Pre3")
|
|
|
|
|
|
scrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, this.scroll.transform, pres[MonsterCampManager.preType],
|
|
|
|
|
|
nil,
|
|
|
|
|
|
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)
|
2021-03-04 21:01:21 +08:00
|
|
|
|
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()
|
2024-09-06 10:38:56 +08:00
|
|
|
|
Util.AddClick(this.backBtn, function()
|
2020-06-08 13:57:30 +08:00
|
|
|
|
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
|
|
|
|
|
|
self:ClosePanel()
|
|
|
|
|
|
end)
|
2024-09-06 10:38:56 +08:00
|
|
|
|
Util.AddClick(this.maskBtn, function()
|
2021-12-30 20:09:16 +08:00
|
|
|
|
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(...)
|
2024-09-06 10:38:56 +08:00
|
|
|
|
local arg = { ... }
|
2021-01-07 19:24:04 +08:00
|
|
|
|
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()
|
2024-09-06 10:38:56 +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()
|
2024-09-06 10:38:56 +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
|
|
|
|
--刷新
|
2024-09-06 10:38:56 +08:00
|
|
|
|
function this.RefreshPanel(isTop, isAni)
|
2021-04-23 19:37:15 +08:00
|
|
|
|
if curType ~= 4 then
|
2024-09-06 10:38:56 +08:00
|
|
|
|
table.sort(rewardConfig, function(a, b)
|
2021-04-23 19:37:15 +08:00
|
|
|
|
if sortIndex[a.state] == sortIndex[b.state] then
|
|
|
|
|
|
return a.Id < b.Id
|
|
|
|
|
|
end
|
|
|
|
|
|
return sortIndex[a.state] > sortIndex[b.state]
|
|
|
|
|
|
end)
|
2024-09-06 10:38:56 +08:00
|
|
|
|
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)
|
2021-04-23 19:37:15 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
2024-08-29 21:36:51 +08:00
|
|
|
|
this.title.text = Language[10035]
|
2022-01-08 10:33:31 +08:00
|
|
|
|
if curType == 5 then
|
2024-08-29 21:36:51 +08:00
|
|
|
|
this.title.text = Language[12263]
|
2022-01-08 10:33:31 +08:00
|
|
|
|
end
|
2020-06-08 13:57:30 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--设置每条数据
|
2024-09-06 10:38:56 +08:00
|
|
|
|
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")
|
|
|
|
|
|
local getBtn = Util.GetGameObject(root, "GetBtn")
|
|
|
|
|
|
local mask = Util.GetGameObject(root, "mask")
|
|
|
|
|
|
local pregress = Util.GetGameObject(root, "getRewardProgress")
|
2021-01-14 15:24:51 +08:00
|
|
|
|
if pregress then
|
|
|
|
|
|
if curType == 2 then
|
2021-05-26 22:00:33 +08:00
|
|
|
|
pregress.gameObject:SetActive(true)
|
2024-09-06 10:38:56 +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
|
2024-09-06 10:38:56 +08:00
|
|
|
|
info.text = data.info --string.format( Language[11799],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
|
2024-09-06 10:38:56 +08:00
|
|
|
|
for k, v in ipairs(itemList[root]) do
|
2021-01-12 19:21:20 +08:00
|
|
|
|
v.gameObject:SetActive(false)
|
|
|
|
|
|
end
|
2024-09-06 10:38:56 +08:00
|
|
|
|
for i = 1, #data.BoxReward do
|
2021-01-12 19:21:20 +08:00
|
|
|
|
if not itemList[root][i] then
|
2024-09-06 10:38:56 +08:00
|
|
|
|
itemList[root][i] = SubUIManager.Open(SubUIConfig.ItemView, grid.transform)
|
2021-01-12 19:21:20 +08:00
|
|
|
|
itemList[root][i].gameObject:SetActive(false)
|
|
|
|
|
|
end
|
2024-09-06 10:38:56 +08:00
|
|
|
|
itemList[root][i]:OnOpen(false, data.BoxReward[i], 0.9, false, false, false, sortingOrder)
|
2021-01-12 19:21:20 +08:00
|
|
|
|
itemList[root][i].gameObject:SetActive(true)
|
|
|
|
|
|
end
|
2024-09-06 10:38:56 +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)
|
2024-09-06 10:38:56 +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)
|
2024-09-06 10:38:56 +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
|
|
|
|
|
2024-09-06 10:38:56 +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)
|
2024-09-06 10:38:56 +08:00
|
|
|
|
Util.AddOnceClick(getBtn, function()
|
2021-01-07 19:24:04 +08:00
|
|
|
|
if getFunc then
|
2024-09-06 10:38:56 +08:00
|
|
|
|
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)
|
2024-09-06 10:38:56 +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
|
|
|
|
--设置每条数据
|
2024-09-06 10:38:56 +08:00
|
|
|
|
function this.SetScrollPre2(root, data)
|
|
|
|
|
|
local info = Util.GetGameObject(root, "Title/Info"):GetComponent("Text")
|
|
|
|
|
|
local grid = Util.GetGameObject(root, "Grid")
|
|
|
|
|
|
local mask = Util.GetGameObject(root, "mask")
|
|
|
|
|
|
info.text = string.format(Language[12264], data.otherData.Sort, data.otherData.Values[1][1])
|
2021-04-23 19:37:15 +08:00
|
|
|
|
|
|
|
|
|
|
if not itemList[root] then
|
|
|
|
|
|
itemList[root] = {}
|
|
|
|
|
|
end
|
2024-09-06 10:38:56 +08:00
|
|
|
|
for k, v in ipairs(itemList[root]) do
|
2021-04-23 19:37:15 +08:00
|
|
|
|
v.gameObject:SetActive(false)
|
|
|
|
|
|
end
|
2024-09-06 10:38:56 +08:00
|
|
|
|
for i = 1, #data.otherData.Reward do
|
2021-04-23 19:37:15 +08:00
|
|
|
|
if not itemList[root][i] then
|
2024-09-06 10:38:56 +08:00
|
|
|
|
itemList[root][i] = SubUIManager.Open(SubUIConfig.ItemView, grid.transform)
|
2021-04-23 19:37:15 +08:00
|
|
|
|
itemList[root][i].gameObject:SetActive(false)
|
|
|
|
|
|
end
|
2024-09-06 10:38:56 +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)
|
2024-09-06 10:38:56 +08:00
|
|
|
|
if data.state == 0 then
|
2021-05-19 15:06:02 +08:00
|
|
|
|
mask:GetComponent("Image").sprite = this.spLoader:LoadSprite("g_ghhb_weidacheng_zh")
|
2024-09-06 10:38:56 +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)
|
2024-09-06 10:38:56 +08:00
|
|
|
|
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
|
2024-09-06 10:38:56 +08:00
|
|
|
|
end
|
2021-01-07 19:24:04 +08:00
|
|
|
|
end
|
|
|
|
|
|
end
|
2020-06-08 13:57:30 +08:00
|
|
|
|
|
2024-09-06 10:38:56 +08:00
|
|
|
|
return TrialRewardPopup
|