2021-07-08 18:40:43 +08:00
|
|
|
|
ElementDrawCardPanelNew = {}
|
|
|
|
|
function ElementDrawCardPanelNew:New(gameObject)
|
|
|
|
|
local b = {}
|
|
|
|
|
b.gameObject = gameObject
|
|
|
|
|
b.transform = gameObject.transform
|
|
|
|
|
setmetatable(b, { __index = ElementDrawCardPanelNew })
|
|
|
|
|
return b
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
|
|
|
|
|
function ElementDrawCardPanelNew:InitComponent()
|
|
|
|
|
self.spLoader = SpriteLoader.New()
|
|
|
|
|
|
|
|
|
|
self.getCardPanel = Util.GetGameObject(self.transform, "getCardPanel")
|
2021-07-20 10:08:06 +08:00
|
|
|
|
self.getCardPanel.gameObject:SetActive(false)
|
2021-07-08 18:40:43 +08:00
|
|
|
|
self.buyOneBtn = Util.GetGameObject(self.getCardPanel,"content2/btn1")
|
|
|
|
|
self.titleImageText = Util.GetGameObject(self.getCardPanel,"content1/titleImage/Text"):GetComponent("Text")
|
|
|
|
|
self.Image1 = Util.GetGameObject(self.getCardPanel,"content1/Image/Image1"):GetComponent("Image")
|
|
|
|
|
self.Image2Text = Util.GetGameObject(self.getCardPanel,"content1/Image/Image2/Text"):GetComponent("Text")
|
|
|
|
|
self.Image3 = Util.GetGameObject(self.getCardPanel,"content1/Image/Image3"):GetComponent("Image")
|
|
|
|
|
self.detailText1=Util.GetGameObject(self.getCardPanel,"content1/Image2/detailText1"):GetComponent("Text")
|
|
|
|
|
self.detailText2=Util.GetGameObject(self.getCardPanel,"content1/Image2/detailText2"):GetComponent("Text")
|
|
|
|
|
self.btnBack=Util.GetGameObject(self.getCardPanel,"btnBack")
|
|
|
|
|
|
|
|
|
|
self.itemPre = Util.GetGameObject(self.transform, "enterCardPanel/itemPre")
|
|
|
|
|
self.itemPos = {}
|
|
|
|
|
for i = 1,4 do
|
|
|
|
|
self.itemPos[i] = {}
|
|
|
|
|
self.itemPos[i].pos = Util.GetGameObject(self.transform, "enterCardPanel/itemPos"..i)
|
|
|
|
|
self.itemPos[i].go = newObjToParent(self.itemPre,self.itemPos[i].pos)
|
2021-07-16 14:09:53 +08:00
|
|
|
|
self.itemPos[i].go.name = "itemPre"
|
2021-07-08 18:40:43 +08:00
|
|
|
|
self.itemPos[i].goImage = self.itemPos[i].go:GetComponent("Image")
|
|
|
|
|
self.itemPos[i].goImage.sprite = self.spLoader:LoadSprite(PropertyTypeImageBySiYuan[i].Image1)
|
|
|
|
|
self.itemPos[i].PropertyImage = Util.GetGameObject(self.itemPos[i].go, "Image"):GetComponent("Image")
|
|
|
|
|
self.itemPos[i].PropertyImage.sprite = self.spLoader:LoadSprite(PropertyTypeImageBySiYuan[i].image3)
|
|
|
|
|
end
|
|
|
|
|
self.effect=Util.GetGameObject(self.transform, "effect")
|
|
|
|
|
self.bgImage=Util.GetGameObject(self.transform, "bgImage")
|
|
|
|
|
self.previewBtn = Util.GetGameObject(self.transform, "enterCardPanel/previewBtn")
|
|
|
|
|
self.shopBtn = Util.GetGameObject(self.transform, "enterCardPanel/shopBtn")
|
|
|
|
|
self.helpBtn = Util.GetGameObject(self.transform, "enterCardPanel/helpBtn")
|
|
|
|
|
self.exchangeBtn = Util.GetGameObject(self.transform, "enterCardPanel/exchangeBtn")
|
|
|
|
|
screenAdapte(self.bgImage)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--绑定事件(用于子类重写)
|
|
|
|
|
function ElementDrawCardPanelNew:BindEvent()
|
|
|
|
|
|
|
|
|
|
Util.AddClick(self.buyOneBtn, function ()
|
2021-07-19 21:35:11 +08:00
|
|
|
|
local index = self.index > 0 and self.index or RecruitManager.recruitSubIndex
|
2021-07-08 18:40:43 +08:00
|
|
|
|
local singleConfig = ConfigManager.TryGetConfigDataByThreeKey(ConfigName.LotterySetting,"LotteryType",TableRecruitType.Siyuanzhen,"PropertyType",self.index,"PerCount",1)
|
|
|
|
|
local costnum = singleConfig.CostItem[1][2]
|
|
|
|
|
local costId = singleConfig.CostItem[1][1]
|
|
|
|
|
LogGreen("costnum:"..costnum.." costId:"..costId)
|
|
|
|
|
if BagManager.GetItemCountById(costId) < costnum then
|
|
|
|
|
PopupTipPanel.ShowTip(GetLanguageStrById(itemConfig[costId].Name)..Language[10486])
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
RecruitManager.RecruitRequest(singleConfig.Id, function(msg)
|
|
|
|
|
UIManager.OpenPanel(UIName.SecretBoxBuyOnePanel,msg.drop,singleConfig.Id)
|
|
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.Bag.BagGold)
|
|
|
|
|
end)
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
Util.AddClick(self.btnBack, function ()
|
|
|
|
|
self.getCardPanel:SetActive(false)
|
2021-07-20 10:08:06 +08:00
|
|
|
|
self.parent.AddTrigger()
|
2021-07-08 18:40:43 +08:00
|
|
|
|
self.effect:SetActive(false)
|
|
|
|
|
SoundManager.PlayMusic(SoundConfig.BGM_Main)
|
|
|
|
|
RecruitManager.recruitSubIndex = 0
|
|
|
|
|
self.parent.tabbox.gameObject:SetActive(true)
|
|
|
|
|
self.parent.btnBack.gameObject:SetActive(true)
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
|
for i = 1, #self.itemPos do
|
|
|
|
|
Util.AddClick(self.itemPos[i].go, function()
|
|
|
|
|
self.index = i
|
2021-07-19 21:35:11 +08:00
|
|
|
|
RecruitManager.recruitSubIndex = i
|
2021-07-08 18:40:43 +08:00
|
|
|
|
self:BtnAction(i)
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function ElementDrawCardPanelNew:BtnAction(index)
|
|
|
|
|
if not index or index < 1 or index > 4 then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
self.parent.btnBack.gameObject:SetActive(false)
|
|
|
|
|
self.parent.tabbox.gameObject:SetActive(false)
|
|
|
|
|
self.getCardPanel.gameObject:SetActive(true)
|
2021-07-20 10:08:06 +08:00
|
|
|
|
self.parent.RemoveTrigger()
|
2021-07-08 18:40:43 +08:00
|
|
|
|
self.effect:SetActive(true)
|
|
|
|
|
self.Image2Text.text = string.format("%s神将碎片",PropertyType[index])
|
|
|
|
|
SetTextVerTial(self.Image2Text,Vector3.New(134.88,-5.9,0),"MiddleLeft")
|
|
|
|
|
self.Image3.sprite = self.spLoader:LoadSprite(PropertyTypeImageBySiYuan[index].image3)
|
|
|
|
|
self.Image1.sprite = self.spLoader:LoadSprite(PropertyTypeImageBySiYuan[index].Image1)
|
|
|
|
|
self.titleImageText.text = string.format("阵营召唤·%s",PropertyTypeImageBySiYuan[index].property)
|
|
|
|
|
self.detailText1.text = string.format("必得<color=#EDB54B>%s</color>神将碎片",PropertyType[index])
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--添加事件监听(用于子类重写)
|
|
|
|
|
function ElementDrawCardPanelNew:AddListener()
|
|
|
|
|
Game.GlobalEvent:AddEvent(GameEvent.SecretBox.OnOpenOneReward, self.OpenOneRewardPanel)
|
|
|
|
|
Game.GlobalEvent:AddEvent(GameEvent.SecretBox.OnOpenTenReward, self.OpenTenRewardPanel)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--移除事件监听(用于子类重写)
|
|
|
|
|
function ElementDrawCardPanelNew:RemoveListener()
|
|
|
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.SecretBox.OnOpenOneReward,self.OpenOneRewardPanel)
|
|
|
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.SecretBox.OnOpenTenReward,self.OpenTenRewardPanel)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function ElementDrawCardPanelNew.OpenOneRewardPanel(drop)
|
|
|
|
|
UIManager.OpenPanel(UIName.SecretBoxBuyOnePanel,drop)
|
|
|
|
|
end
|
|
|
|
|
function ElementDrawCardPanelNew.OpenTenRewardPanel(drop)
|
|
|
|
|
UIManager.OpenPanel(UIName.SecretBoxBuyTenPanel,drop)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function ElementDrawCardPanelNew:OnSortingOrderChange(sortingOrder)
|
|
|
|
|
self.sortingOrder = sortingOrder
|
|
|
|
|
Util.SetParticleSortLayer(self.gameObject, self.sortingOrder + 1)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
|
|
|
function ElementDrawCardPanelNew:OnOpen(_Config,_index, parent)
|
|
|
|
|
self.config = _Config
|
|
|
|
|
self.parent = parent
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
|
|
|
|
|
function ElementDrawCardPanelNew:OnShow(orginLayer)
|
|
|
|
|
self.sortingOrder = orginLayer
|
|
|
|
|
self.gameObject:SetActive(true)
|
|
|
|
|
self.effect:SetActive(false)
|
|
|
|
|
self.index = RecruitManager.recruitSubIndex
|
|
|
|
|
self:BtnAction(self.index)
|
2021-07-15 19:33:34 +08:00
|
|
|
|
self.parent.mask2.sprite = self.spLoader:LoadSprite(self.config.Icon[3])
|
|
|
|
|
self.parent.mask1.sprite = self.spLoader:LoadSprite(self.config.Icon[3])
|
2021-07-08 18:40:43 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
|
|
|
function ElementDrawCardPanelNew:OnClose()
|
|
|
|
|
self.gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
|
|
|
function ElementDrawCardPanelNew:OnDestroy()
|
|
|
|
|
self.spLoader:Destroy()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return ElementDrawCardPanelNew
|