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

268 lines
12 KiB
Lua
Raw Normal View History

2020-05-09 13:31:21 +08:00
require("Base/BasePanel")
ElementDrawCardPanel = Inherit(BasePanel)
local canDrag=true
local i=1
local this=ElementDrawCardPanel
local orginLayer
local AllActSetConfig = ConfigManager.GetConfig(ConfigName.GlobalSystemConfig)
2020-05-25 19:16:23 +08:00
local lotterySetting=ConfigManager.GetConfig(ConfigName.LotterySetting)
local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
local itemId=20 --元素神符
2020-05-09 13:31:21 +08:00
--初始化组件(用于子类重写)
function ElementDrawCardPanel:InitComponent()
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.BtView = SubUIManager.Open(SubUIConfig.BtView, self.gameObject.transform)
this.item1BuyOneBtn=Util.GetGameObject(self.transform, "getCardPanel1/content2/btn1")
2020-05-25 19:16:23 +08:00
-- this.item1BuyTenBtn=Util.GetGameObject(self.transform, "getCardPanel1/content2/btn10")
2020-05-09 13:31:21 +08:00
this.item2BuyOneBtn=Util.GetGameObject(self.transform, "getCardPanel2/content2/btn1")
2020-05-25 19:16:23 +08:00
-- this.item2BuyTenBtn=Util.GetGameObject(self.transform, "getCardPanel2/content2/btn10")
2020-05-09 13:31:21 +08:00
this.item3BuyOneBtn=Util.GetGameObject(self.transform, "getCardPanel3/content2/btn1")
2020-05-25 19:16:23 +08:00
-- this.item3BuyTenBtn=Util.GetGameObject(self.transform, "getCardPanel3/content2/btn10")
2020-05-09 13:31:21 +08:00
this.item4BuyOneBtn=Util.GetGameObject(self.transform, "getCardPanel4/content2/btn1")
2020-05-25 19:16:23 +08:00
-- 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")
2020-05-09 13:31:21 +08:00
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")
2020-05-25 19:16:23 +08:00
-- this.itemBtn5=Util.GetGameObject(self.transform, "enterCardPanel/item5")
2020-05-09 13:31:21 +08:00
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")
2020-05-25 19:16:23 +08:00
-- this.getCardPanel5=Util.GetGameObject(self.transform, "getCardPanel5")
2020-05-09 13:31:21 +08:00
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")
2020-05-25 19:16:23 +08:00
-- this.getCardPanelBtnBack5=Util.GetGameObject(self.transform, "getCardPanel5/btnBack")
2020-05-09 13:31:21 +08:00
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")
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 ()
2020-05-25 19:16:23 +08:00
if BagManager.GetItemCountById(itemId)<lotterySetting[RecruitType.FireSingle].CostItem[1][2] then
PopupTipPanel.ShowTip(itemConfig[itemId].Name.."数量不足!")
return
end
2020-05-09 13:31:21 +08:00
RecruitManager.RecruitRequest(RecruitType.FireSingle, function(msg)
UIManager.OpenPanel(UIName.SecretBoxBuyOnePanel,msg.drop,RecruitType.FireSingle)
Game.GlobalEvent:DispatchEvent(GameEvent.Bag.BagGold)
end)
end)
2020-05-25 19:16:23 +08:00
-- 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)
2020-05-09 13:31:21 +08:00
Util.AddClick(this.item2BuyOneBtn, function ()
2020-05-25 19:16:23 +08:00
if BagManager.GetItemCountById(itemId)<lotterySetting[RecruitType.WindySingle].CostItem[1][2] then
PopupTipPanel.ShowTip(itemConfig[itemId].Name.."数量不足!")
return
end
2020-05-09 13:31:21 +08:00
RecruitManager.RecruitRequest(RecruitType.WindySingle, function(msg)
UIManager.OpenPanel(UIName.SecretBoxBuyOnePanel,msg.drop,RecruitType.WindySingle)
Game.GlobalEvent:DispatchEvent(GameEvent.Bag.BagGold)
end)
end)
2020-05-25 19:16:23 +08:00
-- 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)
2020-05-09 13:31:21 +08:00
Util.AddClick(this.item3BuyOneBtn, function ()
2020-05-25 19:16:23 +08:00
if BagManager.GetItemCountById(itemId)<lotterySetting[RecruitType.WaterSingle].CostItem[1][2] then
PopupTipPanel.ShowTip(itemConfig[itemId].Name.."数量不足!")
return
end
2020-05-09 13:31:21 +08:00
RecruitManager.RecruitRequest(RecruitType.WaterSingle, function(msg)
UIManager.OpenPanel(UIName.SecretBoxBuyOnePanel,msg.drop,RecruitType.WaterSingle)
Game.GlobalEvent:DispatchEvent(GameEvent.Bag.BagGold)
end)
end)
2020-05-25 19:16:23 +08:00
-- 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)
2020-05-09 13:31:21 +08:00
Util.AddClick(this.item4BuyOneBtn, function ()
2020-05-25 19:16:23 +08:00
if BagManager.GetItemCountById(itemId)<lotterySetting[RecruitType.GroundSingle].CostItem[1][2] then
PopupTipPanel.ShowTip(itemConfig[itemId].Name.."数量不足!")
return
end
2020-05-09 13:31:21 +08:00
RecruitManager.RecruitRequest(RecruitType.GroundSingle, function(msg)
UIManager.OpenPanel(UIName.SecretBoxBuyOnePanel,msg.drop,RecruitType.GroundSingle)
Game.GlobalEvent:DispatchEvent(GameEvent.Bag.BagGold)
end)
end)
2020-05-25 19:16:23 +08:00
-- 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)
2020-05-09 13:31:21 +08:00
Util.AddClick(this.itemBtn1, function ()
this.getCardPanel1:SetActive(true)
this.getCardPanel2:SetActive(false)
this.getCardPanel3:SetActive(false)
this.getCardPanel4:SetActive(false)
2020-05-25 19:16:23 +08:00
-- this.getCardPanel5:SetActive(false)
2020-05-09 13:31:21 +08:00
this.getCardPanel1:GetComponent("PlayFlyAnim"):PlayAnim(true)
this.effect:SetActive(true)
end)
Util.AddClick(this.itemBtn2, function ()
this.getCardPanel1:SetActive(false)
this.getCardPanel2:SetActive(true)
this.getCardPanel3:SetActive(false)
this.getCardPanel4:SetActive(false)
2020-05-25 19:16:23 +08:00
-- this.getCardPanel5:SetActive(false)
2020-05-09 13:31:21 +08:00
this.getCardPanel2:GetComponent("PlayFlyAnim"):PlayAnim(true)
this.effect:SetActive(true)
end)
Util.AddClick(this.itemBtn3, function ()
this.getCardPanel1:SetActive(false)
this.getCardPanel2:SetActive(false)
this.getCardPanel3:SetActive(true)
this.getCardPanel4:SetActive(false)
2020-05-25 19:16:23 +08:00
-- this.getCardPanel5:SetActive(false)
2020-05-09 13:31:21 +08:00
this.getCardPanel3:GetComponent("PlayFlyAnim"):PlayAnim(true)
this.effect:SetActive(true)
end)
Util.AddClick(this.itemBtn4, function ()
this.getCardPanel1:SetActive(false)
this.getCardPanel2:SetActive(false)
this.getCardPanel3:SetActive(false)
this.getCardPanel4:SetActive(true)
2020-05-25 19:16:23 +08:00
-- this.getCardPanel5:SetActive(false)
2020-05-09 13:31:21 +08:00
this.getCardPanel4:GetComponent("PlayFlyAnim"):PlayAnim(true)
this.effect:SetActive(true)
end)
2020-05-25 19:16:23 +08:00
-- 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)
2020-05-09 13:31:21 +08:00
Util.AddClick(this.getCardPanelBtnBack1, function ()
this.getCardPanel1:SetActive(false)
this.effect:SetActive(false)
end)
Util.AddClick(this.getCardPanelBtnBack2, function ()
this.getCardPanel2:SetActive(false)
this.effect:SetActive(false)
end)
Util.AddClick(this.getCardPanelBtnBack3, function ()
this.getCardPanel3:SetActive(false)
this.effect:SetActive(false)
end)
Util.AddClick(this.getCardPanelBtnBack4, function ()
this.getCardPanel4:SetActive(false)
this.effect:SetActive(false)
end)
2020-05-25 19:16:23 +08:00
-- Util.AddClick(this.getCardPanelBtnBack5, function ()
-- this.getCardPanel5:SetActive(false)
-- this.effect:SetActive(false)
-- end)
2020-05-09 13:31:21 +08:00
Util.AddClick(self.previewBtn, function()
2020-05-25 19:16:23 +08:00
UIManager.OpenPanel(UIName.HeroPreviewPanel,false)
2020-05-09 13:31:21 +08:00
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)
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(...)
end
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function ElementDrawCardPanel:OnShow()
this.effect:SetActive(false)
--this.BtView:OnOpen({ sortOrder = self.sortingOrder, panelType = PanelTypeView.ElementDrawCardPanel })
--this.BtView.transform:SetSiblingIndex(2)
this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.ElementDrawCard })
end
--界面关闭时调用(用于子类重写)
function ElementDrawCardPanel:OnClose()
end
--界面销毁时调用(用于子类重写)
function ElementDrawCardPanel:OnDestroy()
--SubUIManager.Close(this.BtView)
SubUIManager.Close(this.UpView)
end
return ElementDrawCardPanel