miduo_client/Assets/ManagedResources/~Lua/Modules/Recruit/ElementDrawCardPanel.lua

284 lines
13 KiB
Lua

require("Base/BasePanel")
ElementDrawCardPanel = Inherit(BasePanel)
local canDrag=true
local i=1
local this=ElementDrawCardPanel
local orginLayer
local AllActSetConfig = ConfigManager.GetConfig(ConfigName.GlobalSystemConfig)
local lotterySetting=ConfigManager.GetConfig(ConfigName.LotterySetting)
local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
local itemId=20 --元素神符
--初始化组件(用于子类重写)
function ElementDrawCardPanel:InitComponent()
this.getCardPanelList = {}
this.spLoader = SpriteLoader.New()
orginLayer = 0
this.btnBack=Util.GetGameObject(self.gameObject, "enterCardPanel/btnBack")
this.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform, { showType = UpViewOpenType.ShowLeft, panelType = PanelType.ElementDrawCard })
this.item1BuyOneBtn=Util.GetGameObject(self.transform, "getCardPanel1/content2/btn1")
-- this.item1BuyTenBtn=Util.GetGameObject(self.transform, "getCardPanel1/content2/btn10")
this.item2BuyOneBtn=Util.GetGameObject(self.transform, "getCardPanel2/content2/btn1")
-- this.item2BuyTenBtn=Util.GetGameObject(self.transform, "getCardPanel2/content2/btn10")
this.item3BuyOneBtn=Util.GetGameObject(self.transform, "getCardPanel3/content2/btn1")
-- this.item3BuyTenBtn=Util.GetGameObject(self.transform, "getCardPanel3/content2/btn10")
this.item4BuyOneBtn=Util.GetGameObject(self.transform, "getCardPanel4/content2/btn1")
-- this.item4BuyTenBtn=Util.GetGameObject(self.transform, "getCardPanel4/content2/btn10")
-- this.item5BuyOneBtn=Util.GetGameObject(self.transform, "getCardPanel5/content2/btn1")
-- this.item5BuyTenBtn=Util.GetGameObject(self.transform, "getCardPanel5/content2/btn10")
this.itemBtn1=Util.GetGameObject(self.transform, "enterCardPanel/item1")
this.itemBtn2=Util.GetGameObject(self.transform, "enterCardPanel/item2")
this.itemBtn3=Util.GetGameObject(self.transform, "enterCardPanel/item3")
this.itemBtn4=Util.GetGameObject(self.transform, "enterCardPanel/item4")
-- this.itemBtn5=Util.GetGameObject(self.transform, "enterCardPanel/item5")
this.getCardPanel1=Util.GetGameObject(self.transform, "getCardPanel1")
this.getCardPanel2=Util.GetGameObject(self.transform, "getCardPanel2")
this.getCardPanel3=Util.GetGameObject(self.transform, "getCardPanel3")
this.getCardPanel4=Util.GetGameObject(self.transform, "getCardPanel4")
table.insert(this.getCardPanelList,this.getCardPanel1)
table.insert(this.getCardPanelList,this.getCardPanel2)
table.insert(this.getCardPanelList,this.getCardPanel3)
table.insert(this.getCardPanelList,this.getCardPanel4)
-- this.getCardPanel5=Util.GetGameObject(self.transform, "getCardPanel5")
this.getCardPanelBtnBack1=Util.GetGameObject(self.transform, "getCardPanel1/btnBack")
this.getCardPanelBtnBack2=Util.GetGameObject(self.transform, "getCardPanel2/btnBack")
this.getCardPanelBtnBack3=Util.GetGameObject(self.transform, "getCardPanel3/btnBack")
this.getCardPanelBtnBack4=Util.GetGameObject(self.transform, "getCardPanel4/btnBack")
-- this.getCardPanelBtnBack5=Util.GetGameObject(self.transform, "getCardPanel5/btnBack")
this.effect=Util.GetGameObject(self.transform, "effect")
this.bgImage=Util.GetGameObject(self.transform, "bgImage")
self.previewBtn = Util.GetGameObject(self.transform, "previewBtn")
self.shopBtn = Util.GetGameObject(self.transform, "shopBtn")
self.helpBtn = Util.GetGameObject(self.transform, "helpBtn")
self.exchangeBtn = Util.GetGameObject(self.transform, "exchangeBtn")
screenAdapte(this.bgImage)
-- RecruitManager.GetRewardPreviewData()
end
--绑定事件(用于子类重写)
function ElementDrawCardPanel:BindEvent()
Util.AddClick(this.btnBack, function ()
self:ClosePanel()
--UIManager.OpenPanel(UIName.MainPanel)
end)
Util.AddClick(this.item1BuyOneBtn, function ()
if BagManager.GetItemCountById(itemId)<lotterySetting[RecruitType.FireSingle].CostItem[1][2] then
PopupTipPanel.ShowTip(GetLanguageStrById(itemConfig[itemId].Name)..Language[10486])
return
end
RecruitManager.RecruitRequest(RecruitType.FireSingle, function(msg)
UIManager.OpenPanel(UIName.SecretBoxBuyOnePanel,msg.drop,RecruitType.FireSingle)
Game.GlobalEvent:DispatchEvent(GameEvent.Bag.BagGold)
end)
end)
-- Util.AddClick(this.item1BuyTenBtn, function ()
-- RecruitManager.RecruitRequest(RecruitType.FireTen, function(msg)
-- UIManager.OpenPanel(UIName.SecretBoxBuyTenPanel,msg.drop,RecruitType.FireTen)
-- Game.GlobalEvent:DispatchEvent(GameEvent.Bag.BagGold)
-- end)
-- end)
Util.AddClick(this.item2BuyOneBtn, function ()
if BagManager.GetItemCountById(itemId)<lotterySetting[RecruitType.WindySingle].CostItem[1][2] then
PopupTipPanel.ShowTip(GetLanguageStrById(itemConfig[itemId].Name)..Language[10486])
return
end
RecruitManager.RecruitRequest(RecruitType.WindySingle, function(msg)
UIManager.OpenPanel(UIName.SecretBoxBuyOnePanel,msg.drop,RecruitType.WindySingle)
Game.GlobalEvent:DispatchEvent(GameEvent.Bag.BagGold)
end)
end)
-- Util.AddClick(this.item2BuyTenBtn, function ()
-- RecruitManager.RecruitRequest(RecruitType.WindyTen, function(msg)
-- UIManager.OpenPanel(UIName.SecretBoxBuyTenPanel,msg.drop,RecruitType.WindyTen)
-- Game.GlobalEvent:DispatchEvent(GameEvent.Bag.BagGold)
-- end)
-- end)
Util.AddClick(this.item3BuyOneBtn, function ()
if BagManager.GetItemCountById(itemId)<lotterySetting[RecruitType.WaterSingle].CostItem[1][2] then
PopupTipPanel.ShowTip(GetLanguageStrById(itemConfig[itemId].Name)..Language[10486])
return
end
RecruitManager.RecruitRequest(RecruitType.WaterSingle, function(msg)
UIManager.OpenPanel(UIName.SecretBoxBuyOnePanel,msg.drop,RecruitType.WaterSingle)
Game.GlobalEvent:DispatchEvent(GameEvent.Bag.BagGold)
end)
end)
-- Util.AddClick(this.item3BuyTenBtn, function ()
-- RecruitManager.RecruitRequest(RecruitType.WaterTen, function(msg)
-- UIManager.OpenPanel(UIName.SecretBoxBuyTenPanel,msg.drop,RecruitType.WaterTen)
-- Game.GlobalEvent:DispatchEvent(GameEvent.Bag.BagGold)
-- end)
-- end)
Util.AddClick(this.item4BuyOneBtn, function ()
if BagManager.GetItemCountById(itemId)<lotterySetting[RecruitType.GroundSingle].CostItem[1][2] then
PopupTipPanel.ShowTip(GetLanguageStrById(itemConfig[itemId].Name)..Language[10486])
return
end
RecruitManager.RecruitRequest(RecruitType.GroundSingle, function(msg)
UIManager.OpenPanel(UIName.SecretBoxBuyOnePanel,msg.drop,RecruitType.GroundSingle)
Game.GlobalEvent:DispatchEvent(GameEvent.Bag.BagGold)
end)
end)
-- Util.AddClick(this.item4BuyTenBtn, function ()
-- RecruitManager.RecruitRequest(RecruitType.GroundTen, function(msg)
-- UIManager.OpenPanel(UIName.SecretBoxBuyTenPanel,msg.drop,RecruitType.GroundTen)
-- Game.GlobalEvent:DispatchEvent(GameEvent.Bag.BagGold)
-- end)
-- end)
-- Util.AddClick(this.item5BuyOneBtn, function ()
-- RecruitManager.RecruitRequest(RecruitType.LightDarkSingle, function(msg)
-- UIManager.OpenPanel(UIName.SecretBoxBuyOnePanel,msg.drop,RecruitType.LightDarkSingle)
-- Game.GlobalEvent:DispatchEvent(GameEvent.Bag.BagGold)
-- end)
-- end)
-- Util.AddClick(this.item5BuyTenBtn, function ()
-- RecruitManager.RecruitRequest(RecruitType.LightDarkTen, function(msg)
-- UIManager.OpenPanel(UIName.SecretBoxBuyTenPanel,msg.drop,RecruitType.LightDarkTen)
-- Game.GlobalEvent:DispatchEvent(GameEvent.Bag.BagGold)
-- end)
-- end)
Util.AddClick(this.itemBtn1, function ()
this:BtnAction(1,this.getCardPanel1)
end)
Util.AddClick(this.itemBtn2, function ()
this:BtnAction(2,this.getCardPanel2)
end)
Util.AddClick(this.itemBtn3, function ()
this:BtnAction(3,this.getCardPanel3)
end)
Util.AddClick(this.itemBtn4, function ()
this:BtnAction(4,this.getCardPanel4)
end)
-- Util.AddClick(this.itemBtn5, function ()
-- this.getCardPanel1:SetActive(false)
-- this.getCardPanel2:SetActive(false)
-- this.getCardPanel3:SetActive(false)
-- this.getCardPanel4:SetActive(false)
-- this.getCardPanel5:SetActive(true)
-- this.getCardPanel5:GetComponent("PlayFlyAnim"):PlayAnim(true)
-- this.effect:SetActive(true)
-- end)
Util.AddClick(this.getCardPanelBtnBack1, function ()
this.getCardPanel1:SetActive(false)
this.effect:SetActive(false)
SoundManager.PlayMusic(SoundConfig.BGM_Main)
end)
Util.AddClick(this.getCardPanelBtnBack2, function ()
this.getCardPanel2:SetActive(false)
this.effect:SetActive(false)
SoundManager.PlayMusic(SoundConfig.BGM_Main)
end)
Util.AddClick(this.getCardPanelBtnBack3, function ()
this.getCardPanel3:SetActive(false)
this.effect:SetActive(false)
SoundManager.PlayMusic(SoundConfig.BGM_Main)
end)
Util.AddClick(this.getCardPanelBtnBack4, function ()
this.getCardPanel4:SetActive(false)
this.effect:SetActive(false)
SoundManager.PlayMusic(SoundConfig.BGM_Main)
end)
-- Util.AddClick(this.getCardPanelBtnBack5, function ()
-- this.getCardPanel5:SetActive(false)
-- this.effect:SetActive(false)
-- end)
Util.AddClick(self.previewBtn, function()
UIManager.OpenPanel(UIName.HeroPreviewPanel,false)
end)
Util.AddClick(self.shopBtn, function()
JumpManager.GoJump(20008)
end)
Util.AddClick(self.helpBtn, function()
local pos = self.helpBtn.transform.localPosition
UIManager.OpenPanel(UIName.HelpPopup, HELP_TYPE.ElementDraw, pos.x, pos.y)
end)
Util.AddClick(self.exchangeBtn, function()
UIManager.OpenPanel(UIName.CompoundHeroPanel,2)
end)
end
function ElementDrawCardPanel:BtnAction(index)
this.getCardPanel1:SetActive(index == 1)
this.getCardPanel2:SetActive(index == 2)
this.getCardPanel3:SetActive(index == 3)
this.getCardPanel4:SetActive(index == 4)
if index == 0 then
return
end
-- this.getCardPanel5:SetActive(false)
this.getCardPanelList[index]:GetComponent("PlayFlyAnim"):PlayAnim(true)
this.effect:SetActive(true)
-- 音效
SoundManager.PlaySound(SoundConfig.Sound_syz)
SoundManager.PlayMusic(SoundConfig.Sound_syz_loop)
end
--添加事件监听(用于子类重写)
function ElementDrawCardPanel:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.SecretBox.OnOpenOneReward, this.OpenOneRewardPanel)
Game.GlobalEvent:AddEvent(GameEvent.SecretBox.OnOpenTenReward, this.OpenTenRewardPanel)
end
--移除事件监听(用于子类重写)
function ElementDrawCardPanel:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.SecretBox.OnOpenOneReward,this.OpenOneRewardPanel)
Game.GlobalEvent:RemoveEvent(GameEvent.SecretBox.OnOpenTenReward,this.OpenTenRewardPanel)
end
function ElementDrawCardPanel.OpenOneRewardPanel(drop)
UIManager.OpenPanel(UIName.SecretBoxBuyOnePanel,drop)
end
function ElementDrawCardPanel.OpenTenRewardPanel(drop)
UIManager.OpenPanel(UIName.SecretBoxBuyTenPanel,drop)
end
function ElementDrawCardPanel:OnSortingOrderChange(...)
Util.AddParticleSortLayer(this.gameObject, this.sortingOrder - orginLayer)
orginLayer = this.sortingOrder
end
--界面打开时调用(用于子类重写)
function ElementDrawCardPanel:OnOpen(...)
for i = 1,4 do
local parent = Util.GetGameObject(self.transform, "getCardPanel"..i.."/content1/Image/Image (1)/Image (1)")
SetTextVerTial(Util.GetGameObject(parent, "Text"),Vector3.New(134.88,-5.9,0),"MiddleLeft")
end
local args = {...}
this.index = args[1] or 0
end
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function ElementDrawCardPanel:OnShow()
this.effect:SetActive(false)
--this.BtView:OnOpen(self, { sortOrder = self.sortingOrder, panelType = PanelTypeView.ElementDrawCardPanel })
--this.BtView.transform:SetSiblingIndex(2)
this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.ElementDrawCard })
Util.GetGameObject(this.getCardPanel1, "content2/btn1/Text"):GetComponent("Text").fontSize = GetCurLanguage() ~= 2 and 38 or 30
Util.GetGameObject(this.getCardPanel2, "content2/btn1/Text"):GetComponent("Text").fontSize = GetCurLanguage() ~= 2 and 38 or 30
Util.GetGameObject(this.getCardPanel3, "content2/btn1/Text"):GetComponent("Text").fontSize = GetCurLanguage() ~= 2 and 38 or 30
Util.GetGameObject(this.getCardPanel4, "content2/btn1/Text"):GetComponent("Text").fontSize = GetCurLanguage() ~= 2 and 38 or 30
this:BtnAction(this.index)
end
--界面关闭时调用(用于子类重写)
function ElementDrawCardPanel:OnClose()
end
--界面销毁时调用(用于子类重写)
function ElementDrawCardPanel:OnDestroy()
this.spLoader:Destroy()
--SubUIManager.Close(this.BtView)
SubUIManager.Close(this.UpView)
end
return ElementDrawCardPanel