miduo_client/Assets/ManagedResources/~Lua/Modules/ActivityGift/OpenSeverWelfarePanel.lua

303 lines
12 KiB
Lua
Raw Normal View History

2021-04-21 13:12:04 +08:00
require("Base/BasePanel")
2020-06-03 19:09:01 +08:00
OpenSeverWelfarePanel = Inherit(BasePanel)
local this = OpenSeverWelfarePanel
2020-06-08 13:57:30 +08:00
local activityRewardConfig = ConfigManager.GetConfig(ConfigName.ActivityRewardConfig)
local sortingOrder = 0
local isPlayAnim = true
local firstData=nil
local isShowNeedGetUpTextId = 0
local activityData = {}
2020-06-03 19:09:01 +08:00
--初始化组件(用于子类重写)
function OpenSeverWelfarePanel:InitComponent()
2021-04-21 13:12:04 +08:00
this.spLoader = SpriteLoader.New()
2020-06-03 19:09:01 +08:00
this.closeBtn = Util.GetGameObject(self.transform, "bg/closeBtn")
2023-10-31 16:52:59 +08:00
this.titleText = Util.GetGameObject(self.transform, "titleText"):GetComponent("Text")
2020-06-08 13:57:30 +08:00
this.timeText = Util.GetGameObject(self.transform, "timeText"):GetComponent("Text")
this.timeTextGo = Util.GetGameObject(self.transform, "timeText")
2020-06-03 19:09:01 +08:00
this.rewardPre = Util.GetGameObject(self.gameObject, "rewardPre")
local v = Util.GetGameObject(self.gameObject, "rect"):GetComponent("RectTransform").rect
this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, Util.GetGameObject(self.gameObject, "rect").transform,
2023-10-31 16:52:59 +08:00
this.rewardPre, nil, Vector2.New(v.width, v.height), 1, 1, Vector2.New(0,10))
2020-06-03 19:09:01 +08:00
this.ScrollView.moveTween.MomentumAmount = 1
this.ScrollView.moveTween.Strength = 1
this.NoviceItemList={}--存储itemview 重复利用
2022-10-17 16:13:47 +08:00
this.getBtn=Util.GetGameObject(self.transform, "title/lingquButton")
this.getTxt=Util.GetGameObject(self.transform, "title/lingquButton/Text"):GetComponent("Text")
this.goBtn=Util.GetGameObject(self.transform, "title/qianwangButton")
this.title=Util.GetGameObject(self.transform, "title")
this.content=Util.GetGameObject(self.transform, "title/content")
2020-06-03 19:09:01 +08:00
end
--绑定事件(用于子类重写)
function OpenSeverWelfarePanel:BindEvent()
Util.AddClick(this.closeBtn, function()
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
2020-06-03 19:09:01 +08:00
self:ClosePanel()
end)
2022-10-17 16:13:47 +08:00
Util.AddClick(this.getBtn,function()
if firstData.state ==1 then
NetManager.GetActivityRewardRequest(firstData.missionId, activityData.activityId, function(drop)
--ActivityGiftManager.GetActivityRewardRequest(ActivityTypeDef.OpenSeverWelfare,rewardData.missionId, function(msg)
UIManager.OpenPanel(UIName.RewardItemPopup,drop,1,function()
this.OnShowPanelData(false,false)
Game.GlobalEvent:DispatchEvent(GameEvent.Mission.GetOpenServerRewardRefreshFightPoint)
end)
end)
end
end)
2022-10-17 16:13:47 +08:00
2020-06-03 19:09:01 +08:00
end
--添加事件监听(用于子类重写)
function OpenSeverWelfarePanel:AddListener()
end
--移除事件监听(用于子类重写)
function OpenSeverWelfarePanel:RemoveListener()
end
--界面打开时调用(用于子类重写)
function OpenSeverWelfarePanel:OnOpen(...)
end
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function OpenSeverWelfarePanel:OnShow()
isPlayAnim = true
2021-02-26 10:37:39 +08:00
this.OnShowPanelData(true,true)
2020-06-03 19:09:01 +08:00
end
function OpenSeverWelfarePanel:OnSortingOrderChange()
for i, v in pairs(this.NoviceItemList) do
for j = 1, #this.NoviceItemList[i] do
if this.NoviceItemList[i][j] and this.NoviceItemList[i][j].gameObject then
this.NoviceItemList[i][j]:SetEffectLayer(self.sortingOrder)
end
end
end
sortingOrder = self.sortingOrder
2020-06-03 19:09:01 +08:00
end
2021-02-26 10:37:39 +08:00
function this.OnShowPanelData(isTop,isAni)
this.titleText.text = "送无限充抽"
2022-10-17 16:13:47 +08:00
activityData = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.SongWuXianChou)
2020-06-08 13:57:30 +08:00
isShowNeedGetUpTextId = 0
if activityData then
this.RemainTimeDown(this.timeTextGo,this.timeText,activityData.endTime - GetTimeStamp())
2022-10-17 16:13:47 +08:00
local missions={}
local first={}
for i = 1, #activityData.mission do
if activityData.mission[i].missionId==20016 then
first=activityData.mission[i]
else
table.insert(missions,activityData.mission[i])
end
end
ActivityGiftManager.OpenSeverWelfareRewardTabsSort(missions)
this.ScrollView:SetData(missions, function (index, go)
this.SingleDataShow(go, missions[index])
2021-02-26 10:37:39 +08:00
end,not isTop,not isAni)
2022-10-17 16:13:47 +08:00
--顶部每日奖励
if first then
local sConFigData = activityRewardConfig[first.missionId]
if this.NoviceItemList[this.title] then
for i = 1, 4 do
this.NoviceItemList[this.title][i].gameObject:SetActive(false)
end
for i = 1, #sConFigData.Reward do
if this.NoviceItemList[this.title][i] then
this.NoviceItemList[this.title][i]:OnOpen(false, {sConFigData.Reward[i][1],sConFigData.Reward[i][2]}, 0.9,false,false,false,sortingOrder)
this.NoviceItemList[this.title][i].gameObject:SetActive(true)
end
end
else
this.NoviceItemList[this.title]={}
for i = 1, 4 do
this.NoviceItemList[this.title][i] = SubUIManager.Open(SubUIConfig.ItemView, this.content.transform)
this.NoviceItemList[this.title][i].gameObject:SetActive(false)
end
for i = 1, #sConFigData.Reward do
this.NoviceItemList[this.title][i]:OnOpen(false, {sConFigData.Reward[i][1],sConFigData.Reward[i][2]}, 0.9,false,false,false,sortingOrder)
this.NoviceItemList[this.title][i].gameObject:SetActive(true)
end
end
local state = first.state
firstData=first
2022-10-17 16:13:47 +08:00
local value = sConFigData.Values[2][1]
--local isPass = FightPointPassManager.IsFightPointPass2(value)
-- if state==0 and isPass then
-- this.getBtn:SetActive(true)
-- else
-- this.getBtn:SetActive(state>0)
-- end
this.getBtn:SetActive(state>0)
this.goBtn:SetActive(state == 0 and not isPass)
if state == 1 then
this.getTxt.text = Language[11948]
Util.SetGray(this.getBtn,false)
this.getBtn:GetComponent("Button").interactable = true
elseif state==2 then
this.getTxt.text = Language[10101]
Util.SetGray(this.getBtn,true)
this.getBtn:GetComponent("Button").interactable = false
elseif state==0 and isPass then
this.getTxt.text = Language[11948]
Util.SetGray(this.getBtn,false)
this.getBtn:GetComponent("Button").interactable = true
end
2022-10-17 16:13:47 +08:00
Util.AddClick(this.goBtn,function()
if sConFigData.Jump then
JumpManager.GoJump(sConFigData.Jump[1])
end
end)
end
if isPlayAnim then
SecTorPlayAnimByScroll(this.ScrollView)
isPlayAnim = false
end
2020-06-03 19:09:01 +08:00
end
end
function this.SingleDataShow(go,rewardData)
local activityRewardGo = go
-- if isPlayAnim then
-- activityRewardGo:SetActive(false)
-- else
-- activityRewardGo:SetActive(true)
-- end
2020-06-08 13:57:30 +08:00
local sConFigData = activityRewardConfig[rewardData.missionId]
2023-10-31 16:52:59 +08:00
local titleText = Util.GetGameObject(activityRewardGo, "titleText"):GetComponent("Text")
2021-01-26 17:08:39 +08:00
titleText.text = GetLanguageStrById(sConFigData.ContentsShow)
2020-06-03 19:09:01 +08:00
local itemGroup = Util.GetGameObject(activityRewardGo, "content")
--滚动条复用重设itemview
if this.NoviceItemList[go] then
for i = 1, 4 do
this.NoviceItemList[go][i].gameObject:SetActive(false)
end
for i = 1, #sConFigData.Reward do
if this.NoviceItemList[go][i] then
2023-10-31 16:52:59 +08:00
this.NoviceItemList[go][i]:OnOpen(false, {sConFigData.Reward[i][1],sConFigData.Reward[i][2]}, 0.7,false,false,false,sortingOrder)
2020-06-03 19:09:01 +08:00
this.NoviceItemList[go][i].gameObject:SetActive(true)
end
end
else
this.NoviceItemList[go]={}
for i = 1, 4 do
this.NoviceItemList[go][i] = SubUIManager.Open(SubUIConfig.ItemView, itemGroup.transform)
this.NoviceItemList[go][i].gameObject:SetActive(false)
end
for i = 1, #sConFigData.Reward do
2023-10-31 16:52:59 +08:00
this.NoviceItemList[go][i]:OnOpen(false, {sConFigData.Reward[i][1],sConFigData.Reward[i][2]}, 0.7,false,false,false,sortingOrder)
2020-06-03 19:09:01 +08:00
this.NoviceItemList[go][i].gameObject:SetActive(true)
end
end
local lingquButton = Util.GetGameObject(activityRewardGo.gameObject, "lingquButton")
2021-03-19 16:18:10 +08:00
local text = Util.GetGameObject(activityRewardGo.gameObject, "lingquButton/Text"):GetComponent("Text")
2020-06-03 19:09:01 +08:00
Util.GetGameObject(lingquButton.gameObject, "redPoint"):SetActive(false)
local qianwangButton = Util.GetGameObject(activityRewardGo.gameObject, "qianwangButton")
local getFinishText = Util.GetGameObject(activityRewardGo.gameObject, "getFinishText")
local getRewardProgress = Util.GetGameObject(activityRewardGo.gameObject, "getRewardProgress")
2020-06-08 13:57:30 +08:00
local needGetUpText = Util.GetGameObject(activityRewardGo.gameObject, "needGetUpText")
2020-06-03 19:09:01 +08:00
local state = rewardData.state
2022-10-17 16:13:47 +08:00
local value = sConFigData.Values[2][1]
2020-06-08 13:57:30 +08:00
local isPass = FightPointPassManager.IsFightPointPass(value)
2022-10-17 16:13:47 +08:00
lingquButton:SetActive(state>0)
2020-06-08 13:57:30 +08:00
qianwangButton:SetActive(state == 0 and not isPass)
2021-03-19 16:18:10 +08:00
if state == 1 then
2022-10-17 16:13:47 +08:00
text.text = Language[11948]
Util.SetGray(lingquButton,false)
lingquButton:GetComponent("Button").interactable = true
elseif state==2 then
2021-03-19 16:18:10 +08:00
text.text = Language[10101]
Util.SetGray(lingquButton,true)
lingquButton:GetComponent("Button").interactable = false
else
2022-10-17 16:13:47 +08:00
2021-03-19 16:18:10 +08:00
end
-- getFinishText:SetActive(state == 1)
getFinishText:SetActive(false)
2022-10-17 16:13:47 +08:00
--needGetUpText:SetActive(state == 0)
-- if isShowNeedGetUpTextId == 0 and state == 0 or isShowNeedGetUpTextId == rewardData.missionId then
-- isShowNeedGetUpTextId = rewardData.missionId
-- needGetUpText:SetActive(false)
-- end
needGetUpText:SetActive(false)
2020-06-03 19:09:01 +08:00
getRewardProgress:SetActive(state == 0)
2020-06-08 13:57:30 +08:00
if state == 0 and isPass then
getRewardProgress:GetComponent("Text").text = "(1/1)"
else
getRewardProgress:GetComponent("Text").text = "(0/1)"
end
2020-06-03 19:09:01 +08:00
Util.AddOnceClick(qianwangButton, function()
if sConFigData.Jump then
JumpManager.GoJump(sConFigData.Jump[1])
end
end)
Util.AddOnceClick(lingquButton, function()
2022-10-17 16:13:47 +08:00
-- if isShowNeedGetUpTextId ~= rewardData.missionId then
-- PopupTipPanel.ShowTip(Language[10022])
-- return
-- end
2020-06-08 13:57:30 +08:00
NetManager.GetActivityRewardRequest(rewardData.missionId, activityData.activityId, function(drop)
--ActivityGiftManager.GetActivityRewardRequest(ActivityTypeDef.OpenSeverWelfare,rewardData.missionId, function(msg)
UIManager.OpenPanel(UIName.RewardItemPopup,drop,1,function()
2021-02-26 10:37:39 +08:00
this.OnShowPanelData(false,false)
2020-06-08 13:57:30 +08:00
Game.GlobalEvent:DispatchEvent(GameEvent.Mission.GetOpenServerRewardRefreshFightPoint)
2020-06-03 19:09:01 +08:00
end)
end)
end)
end
2020-06-08 13:57:30 +08:00
this.timer = Timer.New()
--刷新倒计时显示
function this.RemainTimeDown(_timeTextExpertgo,_timeTextExpert,timeDown)
if timeDown > 0 then
if _timeTextExpertgo then
_timeTextExpertgo:SetActive(true)
2020-06-03 19:09:01 +08:00
end
2020-06-08 13:57:30 +08:00
if _timeTextExpert then
2021-03-02 16:53:12 +08:00
_timeTextExpert.text = Language[10023]..GetLeftTimeStrByDeltaTime2(timeDown)
2020-06-08 13:57:30 +08:00
end
if this.timer then
this.timer:Stop()
this.timer = nil
end
this.timer = Timer.New(function()
if _timeTextExpert then
2021-03-02 16:53:12 +08:00
_timeTextExpert.text = Language[10023]..GetLeftTimeStrByDeltaTime2(timeDown)
2020-06-08 13:57:30 +08:00
end
if timeDown < 0 then
if _timeTextExpertgo then
_timeTextExpertgo:SetActive(false)
end
this.timer:Stop()
this.timer = nil
end
timeDown = timeDown - 1
end, 1, -1, true)
this.timer:Start()
else
if _timeTextExpertgo then
_timeTextExpertgo:SetActive(false)
end
end
2020-06-03 19:09:01 +08:00
end
2020-06-08 13:57:30 +08:00
2020-06-03 19:09:01 +08:00
--界面关闭时调用(用于子类重写)
function OpenSeverWelfarePanel:OnClose()
2020-06-08 13:57:30 +08:00
if this.timer then
this.timer:Stop()
this.timer = nil
end
2020-06-03 19:09:01 +08:00
end
--界面销毁时调用(用于子类重写)
function OpenSeverWelfarePanel:OnDestroy()
2021-04-21 13:12:04 +08:00
this.spLoader:Destroy()
2020-06-03 19:09:01 +08:00
end
2020-06-23 18:36:24 +08:00
return OpenSeverWelfarePanel