2021-01-09 14:20:06 +08:00
|
|
|
|
----- 通用奖励领取弹窗 -----
|
2020-10-24 18:20:43 +08:00
|
|
|
|
require("Base/BasePanel")
|
|
|
|
|
local GeneralRewardPopup = Inherit(BasePanel)
|
|
|
|
|
local this = GeneralRewardPopup
|
|
|
|
|
local trialKillConfig=ConfigManager.GetConfig(ConfigName.TrialKillConfig)
|
|
|
|
|
local GodSacrificeConfig=ConfigManager.GetConfig(ConfigName.GodSacrificeConfig)
|
|
|
|
|
local ActivityRewardConfig = ConfigManager.GetConfig(ConfigName.ActivityRewardConfig)
|
|
|
|
|
local itemList={} --预设容器
|
|
|
|
|
|
|
|
|
|
local curRewardType = 1
|
|
|
|
|
local ActivityType = nil
|
|
|
|
|
|
|
|
|
|
local ActInfo = {}
|
|
|
|
|
local ActReward = {}
|
2021-03-12 15:55:31 +08:00
|
|
|
|
local func
|
2020-10-24 18:20:43 +08:00
|
|
|
|
|
|
|
|
|
local sortingOrder=0
|
|
|
|
|
function GeneralRewardPopup:InitComponent()
|
2021-04-21 13:12:04 +08:00
|
|
|
|
this.spLoader = SpriteLoader.New()
|
2020-10-24 18:20:43 +08:00
|
|
|
|
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.pre2=Util.GetGameObject(this.panel,"Scroll/Pre2")
|
|
|
|
|
this.scrollView1=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.scrollView1.gameObject:GetComponent("RectTransform").anchoredPosition= Vector2.New(0,0)
|
|
|
|
|
this.scrollView1.gameObject:GetComponent("RectTransform").anchorMin = Vector2.New(0.5, 0.5)
|
|
|
|
|
this.scrollView1.gameObject:GetComponent("RectTransform").anchorMax = Vector2.New(0.5, 0.5)
|
|
|
|
|
this.scrollView1.gameObject:GetComponent("RectTransform").pivot = Vector2.New(0.5, 0.5)
|
|
|
|
|
this.scrollView1.moveTween.MomentumAmount = 1
|
|
|
|
|
this.scrollView1.moveTween.Strength = 2
|
|
|
|
|
|
|
|
|
|
this.scrollView2=SubUIManager.Open(SubUIConfig.ScrollCycleView,this.scroll.transform,this.pre2, nil,
|
|
|
|
|
Vector2.New(this.scroll.transform.rect.width,this.scroll.transform.rect.height),1,1,Vector2.New(0,10))
|
|
|
|
|
this.scrollView2.gameObject:GetComponent("RectTransform").anchoredPosition= Vector2.New(0,0)
|
|
|
|
|
this.scrollView2.gameObject:GetComponent("RectTransform").anchorMin = Vector2.New(0.5, 0.5)
|
|
|
|
|
this.scrollView2.gameObject:GetComponent("RectTransform").anchorMax = Vector2.New(0.5, 0.5)
|
|
|
|
|
this.scrollView2.gameObject:GetComponent("RectTransform").pivot = Vector2.New(0.5, 0.5)
|
|
|
|
|
this.scrollView2.moveTween.MomentumAmount = 1
|
|
|
|
|
this.scrollView2.moveTween.Strength = 2
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function GeneralRewardPopup:BindEvent()
|
|
|
|
|
Util.AddClick(this.backBtn,function()
|
|
|
|
|
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
|
|
|
|
|
DynamicActivityManager.SheJiCheckRedPoint()
|
|
|
|
|
self:ClosePanel()
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function GeneralRewardPopup:AddListener()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function GeneralRewardPopup:RemoveListener()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function GeneralRewardPopup:OnSortingOrderChange()
|
|
|
|
|
sortingOrder = self.sortingOrder
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--rewardType==1 是一般奖励,配在ActivityRewardConfig中的,234567是配在特殊表里的
|
2021-03-12 15:55:31 +08:00
|
|
|
|
function GeneralRewardPopup:OnOpen(rewardType,activityType,activityId,_func)
|
2020-10-24 18:20:43 +08:00
|
|
|
|
curRewardType = rewardType
|
|
|
|
|
if rewardType == 1 then
|
|
|
|
|
ActivityType = activityType
|
|
|
|
|
ActInfo = ActivityGiftManager.GetActivityTypeInfo(activityType)--活动数据
|
|
|
|
|
ActReward = ConfigManager.GetAllConfigsDataByKey(ConfigName.ActivityRewardConfig,"ActivityId",activityId)
|
|
|
|
|
elseif rewardType == 2 then
|
|
|
|
|
-- body
|
|
|
|
|
end
|
2021-03-12 15:55:31 +08:00
|
|
|
|
if _func then
|
|
|
|
|
func = _func
|
|
|
|
|
end
|
2020-10-24 18:20:43 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function GeneralRewardPopup:OnShow()
|
2021-04-09 15:58:20 +08:00
|
|
|
|
this.RefreshPanel(false,false)
|
2020-10-24 18:20:43 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function GeneralRewardPopup:OnClose()
|
|
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.DynamicTask.OnGetReward)
|
2021-03-12 15:55:31 +08:00
|
|
|
|
if func then
|
|
|
|
|
func()
|
|
|
|
|
func = nil
|
|
|
|
|
end
|
2020-10-24 18:20:43 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function GeneralRewardPopup:OnDestroy()
|
2021-04-21 13:12:04 +08:00
|
|
|
|
this.spLoader:Destroy()
|
2020-10-24 18:20:43 +08:00
|
|
|
|
this.scrollView=nil
|
2021-03-12 15:55:31 +08:00
|
|
|
|
itemList = {}
|
2020-10-24 18:20:43 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--刷新
|
2021-04-09 15:58:20 +08:00
|
|
|
|
function this.RefreshPanel(isTop,isAnim)
|
2020-10-24 18:20:43 +08:00
|
|
|
|
local d={}
|
|
|
|
|
|
|
|
|
|
if curRewardType == 1 then
|
|
|
|
|
d = ActReward
|
|
|
|
|
this.scrollView2:SetData(d,function(index,root)
|
|
|
|
|
this.SetScrollPre2(root,d[index])
|
2021-04-09 15:58:20 +08:00
|
|
|
|
end,isTop,isAnim)
|
2020-10-24 18:20:43 +08:00
|
|
|
|
this.scrollView2:SetIndex(1)
|
|
|
|
|
|
|
|
|
|
elseif curRewardType == 2 then
|
|
|
|
|
for _, configInfo in ConfigPairs(trialKillConfig) do
|
|
|
|
|
table.insert(d, configInfo)
|
|
|
|
|
end
|
|
|
|
|
this.scrollView1:SetData(d,function(index,root)
|
|
|
|
|
this.SetScrollPre1(root,d[index])
|
2021-04-09 15:58:20 +08:00
|
|
|
|
end,isTop,isAnim)
|
2020-10-24 18:20:43 +08:00
|
|
|
|
this.scrollView1:SetIndex(1)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2021-03-12 10:32:32 +08:00
|
|
|
|
function this.GetState(missionId)
|
|
|
|
|
for i = 1,#ActInfo.mission do
|
|
|
|
|
if ActInfo.mission[i].missionId == missionId then
|
|
|
|
|
return ActInfo.mission[i].state
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return 0
|
|
|
|
|
end
|
|
|
|
|
|
2020-10-24 18:20:43 +08:00
|
|
|
|
--设置每条数据
|
|
|
|
|
function this.SetScrollPre2(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")
|
|
|
|
|
|
2021-01-26 17:08:39 +08:00
|
|
|
|
info.text = GetLanguageStrById(data.ContentsShow)
|
2020-10-24 18:20:43 +08:00
|
|
|
|
ResetItemView(root,grid.transform,itemList,#data.Reward,0.9,sortingOrder,false,data.Reward)
|
|
|
|
|
|
|
|
|
|
--按钮状态
|
2021-03-12 10:32:32 +08:00
|
|
|
|
local s = this.GetState(data.Id)
|
2020-10-24 18:20:43 +08:00
|
|
|
|
|
|
|
|
|
--社稷大典需要根据贡献等级重构state
|
|
|
|
|
if ActivityType == ActivityTypeDef.Celebration then
|
|
|
|
|
local level = DynamicActivityManager.curLevel
|
|
|
|
|
if s == 0 then
|
|
|
|
|
if data.Sort <= level then
|
|
|
|
|
s = 1
|
|
|
|
|
else
|
|
|
|
|
s = 2
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
s = 0
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
goBtn:GetComponent("Button").interactable=s~=0
|
|
|
|
|
if s==0 then
|
2021-01-09 14:20:06 +08:00
|
|
|
|
-- goText.text="已领取"
|
2021-04-21 13:12:04 +08:00
|
|
|
|
mask:GetComponent("Image").sprite = this.spLoader:LoadSprite("s_slbz_yilingqu_zh")
|
2020-10-24 18:20:43 +08:00
|
|
|
|
mask:SetActive(true)
|
|
|
|
|
goBtn:SetActive(false)
|
|
|
|
|
getBtn:SetActive(false)
|
|
|
|
|
elseif s==1 then
|
2021-01-09 14:20:06 +08:00
|
|
|
|
-- goText.text="领取"
|
2020-10-24 18:20:43 +08:00
|
|
|
|
mask:SetActive(false)
|
|
|
|
|
goBtn:SetActive(false)
|
|
|
|
|
getBtn:SetActive(true)
|
|
|
|
|
elseif s==2 then
|
2021-01-09 14:20:06 +08:00
|
|
|
|
-- goText.text="前往"
|
2020-10-24 18:20:43 +08:00
|
|
|
|
mask:SetActive(false)
|
|
|
|
|
goBtn:SetActive(true)
|
|
|
|
|
getBtn:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Util.AddOnceClick(goBtn,function()
|
2021-03-02 16:53:12 +08:00
|
|
|
|
PopupTipPanel.ShowTip(Language[11482])
|
2020-10-24 18:20:43 +08:00
|
|
|
|
end)
|
|
|
|
|
Util.AddOnceClick(getBtn,function()
|
2021-03-12 10:32:32 +08:00
|
|
|
|
NetManager.GetActivityRewardRequest(data.Id, ActInfo.activityId, function(_drop)
|
2020-10-24 18:20:43 +08:00
|
|
|
|
UIManager.OpenPanel(UIName.RewardItemPopup, _drop, 1,function()
|
2021-04-09 15:58:20 +08:00
|
|
|
|
this.RefreshPanel(false,true)
|
2020-10-24 18:20:43 +08:00
|
|
|
|
CheckRedPointStatus(RedPointType.Celebration)
|
|
|
|
|
end)
|
|
|
|
|
end)
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--设置每条数据
|
|
|
|
|
function this.SetScrollPre1(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")
|
|
|
|
|
|
2021-03-02 16:53:12 +08:00
|
|
|
|
info.text=string.format( Language[11483],data.Count,MapTrialManager.GetKilCount(),data.Count)
|
2020-10-24 18:20:43 +08:00
|
|
|
|
ResetItemView(root,grid.transform,itemList,#data.BoxReward,0.9,sortingOrder,false,data.BoxReward)
|
|
|
|
|
|
|
|
|
|
--按钮状态
|
|
|
|
|
local s=MapTrialManager.GetTrialRewardState(data.Id)
|
|
|
|
|
goBtn:GetComponent("Button").interactable=s~=0
|
|
|
|
|
if s==0 then
|
2021-01-09 14:20:06 +08:00
|
|
|
|
-- goText.text="已领取"
|
2020-10-24 18:20:43 +08:00
|
|
|
|
mask:SetActive(true)
|
|
|
|
|
goBtn:SetActive(false)
|
|
|
|
|
getBtn:SetActive(false)
|
|
|
|
|
elseif s==1 then
|
2021-01-09 14:20:06 +08:00
|
|
|
|
-- goText.text="领取"
|
2020-10-24 18:20:43 +08:00
|
|
|
|
mask:SetActive(false)
|
|
|
|
|
goBtn:SetActive(false)
|
|
|
|
|
getBtn:SetActive(true)
|
|
|
|
|
elseif s==2 then
|
2021-01-09 14:20:06 +08:00
|
|
|
|
-- goText.text="前往"
|
2020-10-24 18:20:43 +08:00
|
|
|
|
mask:SetActive(false)
|
|
|
|
|
goBtn:SetActive(true)
|
|
|
|
|
getBtn:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Util.AddOnceClick(goBtn,function()
|
|
|
|
|
this:ClosePanel()
|
|
|
|
|
end)
|
|
|
|
|
Util.AddOnceClick(getBtn,function()
|
|
|
|
|
NetManager.RequestLevelReward(data.Id, function(msg)
|
|
|
|
|
MapTrialManager.SetTrialRewardInfo(data.Id) --本地记录已领奖励信息
|
|
|
|
|
UIManager.OpenPanel(UIName.RewardItemPopup,msg.drop,1,function()
|
|
|
|
|
mask:SetActive(true)
|
|
|
|
|
getBtn:SetActive(false)
|
2021-04-09 15:58:20 +08:00
|
|
|
|
this.RefreshPanel(false,true)
|
2020-10-24 18:20:43 +08:00
|
|
|
|
CheckRedPointStatus(RedPointType.TrialReward)
|
|
|
|
|
CheckRedPointStatus(RedPointType.Trial)
|
|
|
|
|
end)
|
|
|
|
|
end)
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return GeneralRewardPopup
|