miduo_client/Assets/ManagedResources/~Lua/Modules/Expert/PatFacePanel.lua

376 lines
17 KiB
Lua

require("Base/BasePanel")
PatFacePanel = Inherit(BasePanel)
local patFaceSingleData = {}
local callBackEvent = nil
local openPanle
local peijianTabs = {}--天恩神赐异妖配件
local diffItemTabs = {}--天恩神赐异妖获得物品
local guildWarRewardTabs = {}--公会战奖励
local cursortingOrder
local PatFaceFindFairy = require("Modules/Expert/PatFaceFindFairy")
local patFaceFindFairy
--初始化组件(用于子类重写)
function PatFacePanel:InitComponent()
--self.btnBack1 = Util.GetGameObject(self.transform, "frame")
cursortingOrder = 0
--神兵天降 抽卡
self.btnBack1 = Util.GetGameObject(self.transform, "frame/obg1/btnBack")
self.btnBack2 = Util.GetGameObject(self.transform, "frame/obg2/btnBack")
self.btnBack3 = Util.GetGameObject(self.transform, "frame/obg3/btnBack")
self.btnBack5 = Util.GetGameObject(self.transform, "frame/obg5/btnBack")
self.obg1 = Util.GetGameObject(self.transform, "frame/obg1")
self.goJumpBtn = Util.GetGameObject(self.transform, "frame/obg1/goJumpBtn")
self.goJumpBtnText = Util.GetGameObject(self.transform, "frame/obg1/goJumpBtn/Text"):GetComponent("Text")
self.activity1Icon = Util.GetGameObject(self.transform, "frame/obg1/activityIcon"):GetComponent("Image")
self.activity1TextIcon = Util.GetGameObject(self.transform, "frame/obg1/activityTextIcon"):GetComponent("Image")
--天恩神赐 异妖直购
self.obg2 = Util.GetGameObject(self.transform, "frame/obg2")
self.activity2Icon = Util.GetGameObject(self.transform, "frame/obg2/activityIcon"):GetComponent("Image")
self.activity2TextIcon = Util.GetGameObject(self.transform, "frame/obg2/activityTextIcon"):GetComponent("Image")
self.nameBtn = Util.GetGameObject(self.transform, "frame/obg2/nameBtn")
self.nameBtnText = Util.GetGameObject(self.transform, "frame/obg2/nameBtn/Text"):GetComponent("Text")
self.goJumpBtn2 = Util.GetGameObject(self.transform, "frame/obg2/goJumpBtn")
self.goJumpBtn2Text = Util.GetGameObject(self.transform, "frame/obg2/goJumpBtn/Text"):GetComponent("Text")
self.titleText = Util.GetGameObject(self.transform, "frame/obg2/titleTextAndTime/Text"):GetComponent("Text")
self.timeText = Util.GetGameObject(self.transform, "frame/obg2/titleTextAndTime/time"):GetComponent("Text")
for i = 1, 4 do
peijianTabs[i] = Util.GetGameObject(self.transform, "frame/obg2/peijians/peijianFrame (" .. i .. ")")
end
diffItemTabs = {}
for i = 1, 5 do
diffItemTabs[i] = SubUIManager.Open(SubUIConfig.ItemView, Util.GetGameObject(self.transform, "frame/obg2/rect/grid").transform)
end
-- 公会战系列
self.obg3 = Util.GetGameObject(self.transform, "frame/obg3")
self.obg3nameText = Util.GetGameObject(self.transform, "frame/obg3/nameText"):GetComponent("Text")
self.obg3goJumpBtn = Util.GetGameObject(self.transform, "frame/obg3/goJumpBtn")
self.cancelBtn = Util.GetGameObject(self.transform, "frame/obg3/cancelBtn")
self.cancelBtnText = Util.GetGameObject(self.transform, "frame/obg3/cancelBtn/Text"):GetComponent("Text")
self.infoText = Util.GetGameObject(self.transform, "frame/obg3/infoText"):GetComponent("Text")
guildWarRewardTabs = {}
for i = 1, 5 do
guildWarRewardTabs[i] = SubUIManager.Open(SubUIConfig.ItemView, Util.GetGameObject(self.transform, "frame/obg3/rect/grid").transform)
end
--类似萌新活动系列 需要弹其他窗口
self.obg4 = Util.GetGameObject(self.transform, "frame/obg4")
--五星成长礼
self.obg5 = Util.GetGameObject(self.transform, "frame/obg5")
self.obg5goJumpBtn = Util.GetGameObject(self.transform, "frame/obg5/goJumpBtn")
self.obg5cancelBtn = Util.GetGameObject(self.transform, "frame/obg5/cancelBtn")
self.obg5cancelBtnText = Util.GetGameObject(self.transform, "frame/obg5/cancelBtn/Text"):GetComponent("Text")
self.obg5infoText = Util.GetGameObject(self.transform, "frame/obg5/infoText"):GetComponent("Text")
--特效
self.effext1 = Util.GetGameObject(self.transform, "frame/obg2/effect/UI_effect_PatFacePanel_obg2_normal_particle")
self.effext2 = Util.GetGameObject(self.transform, "frame/obg2/effect/UI_effect_PatFacePanel_obg2_start")
self.effext3 = Util.GetGameObject(self.transform, "frame/obg1/effect/UI_effect_PatFacePanel_obg1_normal_particle")
self.effext4 = Util.GetGameObject(self.transform, "frame/obg1/effect/UI_effect_PatFacePanel_obg1_start")
--东海寻仙拍脸
patFaceFindFairy = PatFaceFindFairy.new(self, Util.GetGameObject(self.transform, "frame/obg6"))
self.obg6 = Util.GetGameObject(self.transform, "frame/obg6")
self.obg6goJumpBtn = Util.GetGameObject(self.transform, "frame/obg6/goJumpBtn")
self.tipImage=Util.GetGameObject(self.transform,"frame/obg6/activityTextIcon/Image"):GetComponent("Image")
end
--绑定事件(用于子类重写)
function PatFacePanel:BindEvent()
--Util.AddClick(self.btnBack1, function()
-- self:ClosePanel()
--end)
Util.AddClick(self.btnBack1, function()
self:ClosePanel()
end)
Util.AddClick(self.btnBack2, function()
self:ClosePanel()
end)
Util.AddClick(self.btnBack3, function()
self:ClosePanel()
end)
Util.AddClick(self.btnBack5, function()
self:ClosePanel()
end)
end
--添加事件监听(用于子类重写)
function PatFacePanel:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.PatFace.PatFaceClear, self.JumpBtnClickEvent, self)
end
--移除事件监听(用于子类重写)
function PatFacePanel:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.PatFace.PatFaceClear, self.JumpBtnClickEvent, self)
end
--界面打开时调用(用于子类重写)
function PatFacePanel:OnOpen(_patFaceAllData,_callBackEvent,_openPanle)
patFaceSingleData = _patFaceAllData
callBackEvent = _callBackEvent
openPanle = _openPanle
end
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function PatFacePanel:OnShow()
self:OnShowPatFaceData()
end
function PatFacePanel:OnShowPatFaceData()
if patFaceSingleData then
self.obg1:SetActive(patFaceSingleData.Type == FacePanelType.Sbtj)
self.obg2:SetActive(patFaceSingleData.Type == FacePanelType.Tesc)
self.obg3:SetActive(patFaceSingleData.Type == FacePanelType.GuildFight or patFaceSingleData.Type == FacePanelType.Championship)
self.obg4:SetActive(patFaceSingleData.Type == FacePanelType.SupremeHero)
self.obg5:SetActive(patFaceSingleData.Type == FacePanelType.GrowGift)
self.obg6:SetActive(patFaceSingleData.Type == FacePanelType.FindFairy)
if patFaceSingleData.Type == FacePanelType.Sbtj then
self:OnShowOb1Data()
elseif patFaceSingleData.Type == FacePanelType.Tesc then
self:OnShowOb2Data()
elseif patFaceSingleData.Type == FacePanelType.GuildFight or patFaceSingleData.Type == FacePanelType.Championship then
self:OnShowOb3Data()
elseif patFaceSingleData.Type == FacePanelType.SupremeHero then
self:OnShowOb4Data()
elseif patFaceSingleData.Type == FacePanelType.GrowGift then
self:OnShowOb5Data()
elseif patFaceSingleData.Type == FacePanelType.FindFairy then
local curActivityId=ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.FindFairy)
local artId=ConfigManager.GetConfigDataByKey(ConfigName.LoginPosterConfig,"Values",curActivityId).BackgroundString
self.tipImage.sprite=Util.LoadSprite(ConfigManager.GetConfigData(ConfigName.ArtResourcesConfig,artId).Name)
self:OnShowOb6Data()
end
end
end
function PatFacePanel:OnSortingOrderChange()
Util.AddParticleSortLayer( self.effext1, self.sortingOrder - cursortingOrder)
Util.AddParticleSortLayer( self.effext2, self.sortingOrder - cursortingOrder)
Util.AddParticleSortLayer( self.effext3, self.sortingOrder - cursortingOrder)
Util.AddParticleSortLayer( self.effext4, self.sortingOrder - cursortingOrder)
cursortingOrder = self.sortingOrder
end
--第一种显示 神兵天降
function PatFacePanel:OnShowOb1Data()
self.activity1Icon.sprite = Util.LoadSprite(GetResourcePath(patFaceSingleData.Background))
self.activity1TextIcon.sprite = Util.LoadSprite(GetResourcePath(patFaceSingleData.BackgroundString))
self.goJumpBtnText.text = patFaceSingleData.Btn
Util.AddOnceClick(self.goJumpBtn, function()
self:JumpBtnClickEvent()
end)
end
--第二种显示 天恩神赐
function PatFacePanel:OnShowOb2Data()
self.activity2Icon.sprite = Util.LoadSprite(GetResourcePath(patFaceSingleData.Background))
self.activity2TextIcon.sprite = Util.LoadSprite(GetResourcePath(patFaceSingleData.BackgroundString))
local differDemonsConFig = ConfigManager.GetConfigData(ConfigName.DifferDemonsConfig,patFaceSingleData.Values)
local rechargeCommodityConfig = ConfigManager.GetConfigData(ConfigName.RechargeCommodityConfig,patFaceSingleData.ShopId)
if rechargeCommodityConfig == nil or differDemonsConFig == nil then return end
local shopItemData = OperatingManager.GetGiftGoodsInfo(rechargeCommodityConfig.Type,rechargeCommodityConfig.Id)
self.nameBtnText.text = differDemonsConFig.Name
self.titleText.text = patFaceSingleData.Desc
self.timeText.text = "活动时间:"..PatFaceManager.GetTimeStrBySeconds(shopItemData.startTime).."-"..PatFaceManager.GetTimeStrBySeconds(shopItemData.endTime)
self.goJumpBtn2Text.text = "立即前往"
--if shopItemData.buyTimes <= 0 then
-- self.goJumpBtn2Text.text = "立即前往"
-- --self.goJumpBtn2Text.text ="¥ " .. patFaceSingleData.Btn
--else
-- self.goJumpBtn2Text.text = "已购买"
--end
for i = 1, 4 do
if #rechargeCommodityConfig.RewardShow >= i then
peijianTabs[i]:SetActive(true)
local itemSId = rechargeCommodityConfig.RewardShow[i][1]
local itemConfigData = ConfigManager.GetConfigData(ConfigName.ItemConfig,itemSId)
Util.GetGameObject(peijianTabs[i].transform, "peijianIcon"):GetComponent("Image").sprite = Util.LoadSprite(GetResourcePath(itemConfigData.ResourceID))
Util.AddOnceClick(peijianTabs[i], function()
UIManager.OpenPanel(UIName.RewardItemSingleShowPopup, itemSId,nil)
end)
else
peijianTabs[i]:SetActive(false)
end
end
for i = 1, math.max(#diffItemTabs, #rechargeCommodityConfig.BaseReward) do
local go = diffItemTabs[i]
if not go then
go = SubUIManager.Open(SubUIConfig.ItemView, Util.GetGameObject(self.transform, "frame/obg3/rect/grid").transform)
diffItemTabs[i] = go
end
go.gameObject:SetActive(false)
end
for i = 1, #rechargeCommodityConfig.BaseReward do
diffItemTabs[i].gameObject:SetActive(true)
diffItemTabs[i]:OnOpen(false,rechargeCommodityConfig.BaseReward[i],1,false,false,false,self.sortingOrder)
end
Util.AddOnceClick(self.goJumpBtn2, function()
--if shopItemData.buyTimes <= 0 then
--if AppConst.isSDK then
-- PayManager.Pay({ Id = rechargeCommodityConfig.Id })
--else
-- NetManager.RequestBuyGiftGoods(rechargeCommodityConfig.Id, function()
-- FirstRechargeManager.RefreshAccumRechargeValue(rechargeCommodityConfig.Id)
-- OperatingManager.RefreshGiftGoodsBuyTimes(GoodsTypeDef.DirectPurchaseGift, rechargeCommodityConfig.Id)
-- self:ClosePanel()
-- end)
--end
if openPanle then
openPanle.patFaceCallList:Clear()
end
if callBackEvent then
callBackEvent = nil
end
if ActTimeCtrlManager.SingleFuncState(42) then
UIManager.OpenPanel(UIName.ExpertPanel,ExperType.DiffMonster)
else
PopupTipPanel.ShowTip(ActTimeCtrlManager.GetFuncTip(42))
end
--end
end)
Util.AddOnceClick(self.nameBtn, function()
UIManager.OpenPanel(UIName.PatFaceDiffMonsterInfoPanel,patFaceSingleData.Values)
end)
end
--第三种显示 公会战
local timeOb3
function PatFacePanel:OnShowOb3Data()
self.infoText.text = patFaceSingleData.Desc
local rewardTableStr = ""
if patFaceSingleData.OpenRules[1] == 6 then
self.obg3nameText.text = "公会战"
rewardTableStr = ConfigManager.GetConfigData(ConfigName.GuildRewardConfig,1).Reward--策划让默认直接读取公会战第一名奖励
local rewardTable = string.split(rewardTableStr, "|")
for i = 1, math.max(#guildWarRewardTabs, #rewardTable) do
local go = guildWarRewardTabs[i]
if not go then
go = SubUIManager.Open(SubUIConfig.ItemView, Util.GetGameObject(self.transform, "frame/obg3/rect/grid").transform)
guildWarRewardTabs[i] = go
end
go.gameObject:SetActive(false)
end
for i = 1, #rewardTable do
local rewardItemTable = string.split(rewardTable[i],"#")
guildWarRewardTabs[i].gameObject:SetActive(true)
guildWarRewardTabs[i]:OnOpen(false,{rewardItemTable[1],0},1,false,false,false,self.sortingOrder)
end
elseif patFaceSingleData.OpenRules[1] == 7 then
self.obg3nameText.text = "巅峰赛"
local rewardTable = {}
if patFaceSingleData.Id == 24 then--特殊写 id 不能变
rewardTable = ConfigManager.GetConfigData(ConfigName.ChampionshipReward,1).SeasonReward--巅峰战
else
local rewardInfo = {77,0}
rewardTable[1] = rewardInfo--巅峰战
end
for i = 1, math.max(#guildWarRewardTabs, #rewardTable) do
local go = guildWarRewardTabs[i]
if not go then
go = SubUIManager.Open(SubUIConfig.ItemView, Util.GetGameObject(self.transform, "frame/obg3/rect/grid").transform)
guildWarRewardTabs[i] = go
end
go.gameObject:SetActive(false)
end
for i = 1, #rewardTable do
local rewardItemTable = rewardTable[i]
guildWarRewardTabs[i].gameObject:SetActive(true)
guildWarRewardTabs[i]:OnOpen(false,{rewardItemTable[1],0},1,false,false,false,self.sortingOrder)
end
end
Util.AddOnceClick(self.obg3goJumpBtn, function()
self:JumpBtnClickEvent()
end)
Util.AddOnceClick(self.cancelBtn, function()
self:ClosePanel()
end)
local timeDownNum = 5
if timeOb3 then
timeOb3:Stop()
timeOb3 = nil
end
timeOb3 = Timer.New(function()
self.cancelBtnText.text = "取消("..timeDownNum..")"
if timeDownNum < 0 then
self:ClosePanel()
if timeOb3 then
timeOb3:Stop()
timeOb3 = nil
end
end
timeDownNum = timeDownNum - 1
end, 1, -1, true)
timeOb3:Start()
end
--第四种显示
function PatFacePanel:OnShowOb4Data()
UIManager.OpenPanel(UIName.SupremeHeroPopup,function() self:ClosePanel() end)
end
--第五种显示 五星成长礼
local timeOb5
function PatFacePanel:OnShowOb5Data()
self.obg5infoText.text = patFaceSingleData.Desc
Util.AddOnceClick(self.obg5goJumpBtn, function()
self:JumpBtnClickEvent()
end)
Util.AddOnceClick(self.obg5cancelBtn, function()
self:ClosePanel()
end)
local timeDownNum = 5
self.obg5cancelBtnText.text = "取消("..timeDownNum..")"
if timeOb5 then
timeOb5:Stop()
timeOb5 = nil
end
timeOb5 = Timer.New(function()
self.obg5cancelBtnText.text = "取消("..timeDownNum..")"
if timeDownNum < 0 then
self:ClosePanel()
if timeOb5 then
timeOb5:Stop()
timeOb5 = nil
end
end
timeDownNum = timeDownNum - 1
end, 1, -1, true)
timeOb5:Start()
end
function PatFacePanel:OnShowOb6Data()
patFaceFindFairy.OnShow(self,patFaceSingleData)
Util.AddOnceClick(self.obg6goJumpBtn, function()
self:JumpBtnClickEvent()
end)
end
function PatFacePanel:JumpBtnClickEvent()
if openPanle then
openPanle.patFaceCallList:Clear()
end
if callBackEvent then
callBackEvent = nil
end
if patFaceSingleData.Jump then
JumpManager.GoJump( patFaceSingleData.Jump)
self:ClosePanel()
end
end
--界面关闭时调用(用于子类重写)
function PatFacePanel:OnClose()
if callBackEvent then
callBackEvent()
end
if timeOb3 then
timeOb3:Stop()
timeOb3 = nil
end
if timeOb5 then
timeOb5:Stop()
timeOb5 = nil
end
patFaceFindFairy.OnClose()
end
--界面销毁时调用(用于子类重写)
function PatFacePanel:OnDestroy()
end
return PatFacePanel