miduo_client/Assets/ManagedResources/~Lua/Modules/Popup/TrialRewardPopup.lua

127 lines
3.8 KiB
Lua
Raw Normal View History

2020-08-25 15:46:38 +08:00
----- 试练副本奖励弹窗 -----
2020-06-08 13:57:30 +08:00
require("Base/BasePanel")
local TrialRewardPopup = Inherit(BasePanel)
local this = TrialRewardPopup
local rewardConfig
2020-06-08 13:57:30 +08:00
local itemList={} --预设容器
local sortingOrder=0
local getFunc = {}
2020-06-08 13:57:30 +08:00
function TrialRewardPopup:InitComponent()
this.panel=Util.GetGameObject(this.gameObject,"Panel")
this.backBtn=Util.GetGameObject(this.panel,"BackBtn")
this.scroll=Util.GetGameObject(this.panel,"Scroll")
this.pre=Util.GetGameObject(this.panel,"Scroll/Pre")
this.scrollView=SubUIManager.Open(SubUIConfig.ScrollCycleView,this.scroll.transform,this.pre, nil,
Vector2.New(this.scroll.transform.rect.width,this.scroll.transform.rect.height),1,1,Vector2.New(0,10))
this.scrollView.gameObject:GetComponent("RectTransform").anchoredPosition= Vector2.New(0,0)
this.scrollView.gameObject:GetComponent("RectTransform").anchorMin = Vector2.New(0.5, 0.5)
this.scrollView.gameObject:GetComponent("RectTransform").anchorMax = Vector2.New(0.5, 0.5)
this.scrollView.gameObject:GetComponent("RectTransform").pivot = Vector2.New(0.5, 0.5)
this.scrollView.moveTween.MomentumAmount = 1
this.scrollView.moveTween.Strength = 2
end
function TrialRewardPopup:BindEvent()
Util.AddClick(this.backBtn,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 = {...}
rewardConfig = arg[1]
getFunc = arg[2]
2020-06-08 13:57:30 +08:00
end
function TrialRewardPopup:OnShow()
this.RefreshPanel()
end
function TrialRewardPopup:OnClose()
end
function TrialRewardPopup:OnDestroy()
this.scrollView=nil
itemList={}
end
--刷新
function this.RefreshPanel()
this.scrollView:SetData(rewardConfig,function(index,root)
this.SetScrollPre(root,rewardConfig[index])
2020-06-08 13:57:30 +08:00
end)
this.scrollView:SetIndex(1)
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")
2020-06-12 18:04:22 +08:00
info.text=data.info --string.format( Language[11616],data.Count,MapTrialManager.GetKilCount(),data.Count)
2020-07-16 16:59:46 +08:00
ResetItemView(root,grid.transform,itemList,#data.BoxReward,0.9,sortingOrder,false,data.BoxReward)
2020-06-12 18:04:22 +08:00
--按钮状态
--local s=MapTrialManager.GetTrialRewardState(data.Id)
goBtn:GetComponent("Button").interactable=data.state~=0
if data.state==0 then
2020-07-16 16:59:46 +08:00
-- goText.text=Language[10350]
mask:SetActive(true)
goBtn:SetActive(false)
getBtn:SetActive(false)
elseif data.state==1 then
2020-07-16 16:59:46 +08:00
-- goText.text=Language[10022]
mask:SetActive(false)
goBtn:SetActive(false)
getBtn:SetActive(true)
elseif data.state==2 then
2020-07-16 16:59:46 +08:00
-- goText.text=Language[10023]
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()
end)
Util.AddOnceClick(getBtn,function()
if getFunc then
getFunc(data.Id,function()
2020-07-16 16:59:46 +08:00
mask:SetActive(true)
getBtn:SetActive(false)
this.ChangeState(data.Id)
2020-07-16 16:59:46 +08:00
this.RefreshPanel()
2020-08-28 13:48:09 +08:00
CheckRedPointStatus(RedPointType.TrialReward)
2020-08-28 17:29:38 +08:00
CheckRedPointStatus(RedPointType.Trial)
2020-06-12 18:04:22 +08:00
end)
end
2020-06-08 13:57:30 +08:00
end)
end
function this.ChangeState(id)
for k,v in ipairs(rewardConfig) do
if v.Id == data.Id then
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