228 lines
7.5 KiB
Lua
228 lines
7.5 KiB
Lua
----- 试练副本奖励弹窗 -----
|
||
require("Base/BasePanel")
|
||
local TrialRewardPopup = Inherit(BasePanel)
|
||
local this = TrialRewardPopup
|
||
local rewardConfig
|
||
local itemList = {} --预设容器
|
||
local type = 0
|
||
local sortingOrder = 0
|
||
local getFunc = {}
|
||
local pres = {}
|
||
local curType = 0
|
||
local scrollView = nil
|
||
function TrialRewardPopup:InitComponent()
|
||
this.spLoader = SpriteLoader.New()
|
||
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")
|
||
scrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, this.scroll.transform, pres[1], 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)
|
||
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
|
||
scrollView.elastic = false
|
||
end
|
||
|
||
function TrialRewardPopup:BindEvent()
|
||
Util.AddClick(this.backBtn, function()
|
||
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
|
||
self:ClosePanel()
|
||
end)
|
||
Util.AddClick(this.maskBtn, function()
|
||
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
|
||
self:ClosePanel()
|
||
end)
|
||
end
|
||
|
||
function TrialRewardPopup:AddListener()
|
||
end
|
||
|
||
function TrialRewardPopup:RemoveListener()
|
||
end
|
||
|
||
function TrialRewardPopup:OnSortingOrderChange()
|
||
sortingOrder = self.sortingOrder
|
||
end
|
||
|
||
function TrialRewardPopup:OnOpen(...)
|
||
local arg = { ... }
|
||
type = arg[1]
|
||
--getFunc = arg[2]
|
||
--curType = arg[3]
|
||
end
|
||
|
||
function TrialRewardPopup:OnShow()
|
||
this.RefreshPanel(true, true)
|
||
sortingOrder = self.sortingOrder
|
||
end
|
||
|
||
function TrialRewardPopup:OnClose()
|
||
end
|
||
|
||
function TrialRewardPopup:OnDestroy()
|
||
this.spLoader:Destroy()
|
||
scrollView = nil
|
||
itemList = {}
|
||
end
|
||
|
||
--0 已经领取,1 可领取,2不能领取·
|
||
local sortIndex = {
|
||
[0] = 0,
|
||
[1] = 2,
|
||
[2] = 1,
|
||
}
|
||
--刷新
|
||
local actId = 0
|
||
local actconfigs
|
||
function this.RefreshPanel(isTop, isAni)
|
||
LogError("type=============" .. type)
|
||
-- local configs=ConfigManager.TryGetAllConfigsDataByKey(ConfigName.WishConfig,"LotteryType",type)
|
||
-- table.sort(configs,function(a,b)
|
||
-- return a.Id < b.Id
|
||
-- end)
|
||
|
||
if type == 1 then
|
||
this.title.text = Language[12265]
|
||
actId = 11701
|
||
elseif type == 4 then
|
||
this.title.text = Language[12266]
|
||
actId = 11901
|
||
end
|
||
actconfigs = ActivityGiftManager.GetActivityInfoByType(actId)
|
||
--LogError("len================="..#actconfigs)
|
||
table.sort(actconfigs.mission, function(a, b)
|
||
if a.state == b.state then
|
||
return a.missionId < b.missionId
|
||
else
|
||
return a.state < b.state
|
||
end
|
||
end)
|
||
scrollView:SetData(actconfigs.mission, function(index, root)
|
||
this.SetScrollPre(root, actconfigs.mission[index])
|
||
end, not isTop, not isAni)
|
||
end
|
||
|
||
--设置每条数据
|
||
function this.SetScrollPre(root, data)
|
||
local wishData = ConfigManager.GetConfigData(ConfigName.WishConfig, data.missionId)
|
||
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 goText = Util.GetGameObject(root, "GetBtn/Text"):GetComponent("Text")
|
||
goBtn:SetActive(false)
|
||
getBtn:SetActive(false)
|
||
local mask = Util.GetGameObject(root, "mask")
|
||
if type == 1 then
|
||
info.text = Language[11002] .." "..
|
||
wishData.Level .." ".. Language[12267]
|
||
else
|
||
info.text = Language[11002].." " .. wishData.Level .. Language[12267]
|
||
end
|
||
|
||
if not itemList[root] then
|
||
itemList[root] = {}
|
||
end
|
||
for k, v in ipairs(itemList[root]) do
|
||
v.gameObject:SetActive(false)
|
||
end
|
||
for i = 1, #wishData.Reward 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, wishData.Reward[i], 0.9, false, false, false, sortingOrder)
|
||
itemList[root][i].gameObject:SetActive(true)
|
||
end
|
||
LogError("data.state==" .. data.state)
|
||
if data.state == 1 then
|
||
goText.text = Language[10025]
|
||
mask:GetComponent("Image").sprite = this.spLoader:LoadSprite("s_slbz_yilingqu_zh")
|
||
mask:SetActive(true)
|
||
goBtn:SetActive(false)
|
||
getBtn:SetActive(false)
|
||
else
|
||
if RecruitManager.drawTimes[type] and RecruitManager.drawTimes[type] >= wishData.DrawCardNumber then
|
||
goText.text = Language[10018]
|
||
mask:SetActive(false)
|
||
goBtn:SetActive(false)
|
||
getBtn:SetActive(true)
|
||
else
|
||
goText.text = Language[10019]
|
||
mask:SetActive(false)
|
||
goBtn:SetActive(true)
|
||
getBtn:SetActive(false)
|
||
end
|
||
end
|
||
|
||
Util.AddOnceClick(goBtn, function()
|
||
this:ClosePanel()
|
||
-- if data.jump and data.jump > 0 then
|
||
-- JumpManager.GoJump(data.jump)
|
||
-- end
|
||
end)
|
||
Util.AddOnceClick(getBtn, function()
|
||
-- if getFunc then
|
||
-- getFunc(data.Id,function()
|
||
-- mask:SetActive(true)
|
||
-- getBtn:SetActive(false)
|
||
-- this.ChangeState(data.Id)
|
||
-- this.RefreshPanel(false,false)
|
||
-- end)
|
||
-- end
|
||
ActivityGiftManager.GetActivityRewardRequest(actId, data.missionId, function()
|
||
mask:SetActive(true)
|
||
getBtn:SetActive(false)
|
||
this.ChangeState(data.missionId)
|
||
this.RefreshPanel(false, false)
|
||
end)
|
||
end)
|
||
end
|
||
|
||
--设置每条数据
|
||
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])
|
||
|
||
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
|
||
itemList[root][i]:OnOpen(false, data.otherData.Reward[i], 0.9, false, false, false, sortingOrder)
|
||
itemList[root][i].gameObject:SetActive(true)
|
||
end
|
||
mask:SetActive(true)
|
||
if data.state == 0 then
|
||
mask:GetComponent("Image").sprite = this.spLoader:LoadSprite("g_ghhb_weidacheng_zh")
|
||
elseif data.state == 1 then
|
||
mask:GetComponent("Image").sprite = this.spLoader:LoadSprite("g_ghhb_yidacheng_zh")
|
||
end
|
||
end
|
||
|
||
function this.ChangeState(id)
|
||
for k, v in ipairs(actconfigs) do
|
||
if v.missionId == id then
|
||
v.state = 0
|
||
return
|
||
end
|
||
end
|
||
end
|
||
|
||
return TrialRewardPopup
|