165 lines
6.7 KiB
Lua
165 lines
6.7 KiB
Lua
require("Base/BasePanel")
|
|
require("Base/Stack")
|
|
QianKunBoxBuyTenPanel = Inherit(BasePanel)
|
|
local this=QianKunBoxBuyTenPanel
|
|
local ItemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
|
|
local gameSetting=ConfigManager.GetConfig(ConfigName.GameSetting)
|
|
local lotterySetting = ConfigManager.GetConfig(ConfigName.LotterySetting)
|
|
local maxtimesId=lotterySetting[RecruitType.QianKunBoxTen].MaxTimes
|
|
local freeTimesId=lotterySetting[RecruitType.QianKunBoxTen].FreeTimes
|
|
--活动抽卡类型(动态的数据)
|
|
local drawtType={
|
|
FindFairySingle=0,
|
|
FindFairyTen=0,
|
|
}
|
|
|
|
local lotterySetting = ConfigManager.GetConfig(ConfigName.LotterySetting)
|
|
local callList = Stack.New()
|
|
this.contentList={}
|
|
this.contentListParent={}
|
|
this.isElementDrawPanel=false
|
|
local orginLayer
|
|
--初始化组件(用于子类重写)
|
|
function QianKunBoxBuyTenPanel:InitComponent()
|
|
|
|
orginLayer = 0
|
|
self.bg = Util.GetGameObject(self.gameObject, "effect")
|
|
screenAdapte(self.bg)
|
|
this.btnBack=Util.GetGameObject(self.gameObject, "bottom/backButton")
|
|
this.openTenAgainButton=Util.GetGameObject(self.gameObject, "bottom/openTenAgainButton")
|
|
this.costImage=Util.GetGameObject(self.gameObject, "bottom/openTenAgainButton/Image")
|
|
|
|
this.detailImage=Util.GetGameObject(self.gameObject, "Tip")
|
|
this.detailText = Util.GetGameObject(this.detailImage, "Text"):GetComponent("Text")
|
|
|
|
this.content1=Util.GetGameObject(self.gameObject,"bottom/openTenAgainButton/Content1")
|
|
this.itemIcon1=Util.GetGameObject(this.content1,"Icon"):GetComponent("Image")
|
|
this.detailImage1=Util.GetGameObject(this.content1,"Tip")
|
|
this.detailText1 = Util.GetGameObject(this.detailImage1, "contentDetailText"):GetComponent("Text")
|
|
|
|
this.content2=Util.GetGameObject(self.gameObject,"bottom/openTenAgainButton/Content2")
|
|
this.itemIcon2=Util.GetGameObject(this.content2,"Icon"):GetComponent("Image")
|
|
this.itemNum2=Util.GetGameObject(this.content2,"Num"):GetComponent("Text")
|
|
|
|
for i = 1, 10 do
|
|
this.contentList[i]=Util.GetGameObject(self.gameObject, "content/itemAnimEffect"..i.."/image/Kuang/itemName/itemContent")
|
|
this.contentListParent[i]=Util.GetGameObject(self.gameObject, "content/itemAnimEffect"..i)
|
|
end
|
|
|
|
-- 关于抽卡的LotterySetting数据
|
|
local curActivityId=ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.FindFairy)
|
|
drawtType.FindFairySingle=ConfigManager.GetConfigDataByDoubleKey(ConfigName.LotterySetting,"PerCount",1,"ActivityId",curActivityId).Id
|
|
drawtType.FindFairyTen=ConfigManager.GetConfigDataByDoubleKey(ConfigName.LotterySetting,"PerCount",10,"ActivityId",curActivityId).Id
|
|
end
|
|
|
|
--绑定事件(用于子类重写)
|
|
function QianKunBoxBuyTenPanel:BindEvent()
|
|
|
|
Util.AddClick(this.btnBack, function ()
|
|
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
|
|
self:ClosePanel()
|
|
end)
|
|
Util.AddClick(this.openTenAgainButton, function ()
|
|
if(BagManager.GetItemCountById(16)>=2000) then--货币还没有,有了修改
|
|
self:ClosePanel()
|
|
RecruitManager.RecruitRequest(RecruitType.QianKunBoxTen, function(msg)
|
|
PrivilegeManager.RefreshPrivilegeUsedTimes(maxtimesId,10)--记录抽卡次数
|
|
UIManager.OpenPanel(UIName.QianKunBoxBuyTenPanel,msg.drop)
|
|
CheckRedPointStatus(RedPointType.QianKunBox)
|
|
end,freeTimesId)
|
|
else
|
|
--UIManager.OpenPanel(UIName.QuickPurchasePanel, { type = UpViewRechargeType.DemonCrystal })--应跳到充值界面,现在是用之前的货币换取妖晶
|
|
PopupTipPanel.ShowTip(Language[11139])
|
|
self:ClosePanel()
|
|
end
|
|
end)
|
|
end
|
|
|
|
--添加事件监听(用于子类重写)
|
|
function QianKunBoxBuyTenPanel:AddListener()
|
|
|
|
end
|
|
|
|
--移除事件监听(用于子类重写)
|
|
function QianKunBoxBuyTenPanel:RemoveListener()
|
|
|
|
end
|
|
|
|
function QianKunBoxBuyTenPanel:OnSortingOrderChange()
|
|
Util.AddParticleSortLayer(self.bg, self.sortingOrder - orginLayer)
|
|
for i = 1, 10 do
|
|
Util.AddParticleSortLayer(this.contentListParent[i], self.sortingOrder - orginLayer)
|
|
end
|
|
orginLayer = self.sortingOrder
|
|
|
|
if this.views and this.itemDataList then
|
|
for index, view in pairs(this.views) do
|
|
view:OnOpen(true,this.itemDataList[index],1.4,true,false,false,self.sortingOrder)
|
|
end
|
|
end
|
|
|
|
end
|
|
--界面打开时调用(用于子类重写)
|
|
function QianKunBoxBuyTenPanel:OnOpen(...)
|
|
-- this.itemIcon1.sprite=Util.LoadSprite(GetResourcePath(ItemConfig[SecretBoxManager.MainCost[2][1][1]].ResourceID))
|
|
local args = { ... }
|
|
this.drop=args[1]
|
|
|
|
|
|
this.detailImage:SetActive(not this.recruitType)
|
|
this.content1:SetActive(not this.recruitType)
|
|
this.content2:SetActive(this.recruitType)
|
|
this.itemIcon1.sprite=Util.LoadSprite("r_RareItem_Specail_0020")
|
|
this.detailText.text = "赠送10个乾坤令"
|
|
this.detailText1.text = "赠送10个乾坤令"
|
|
|
|
|
|
local itemDataList={}
|
|
itemDataList=BagManager.GetTableByBackDropData(this.drop)
|
|
this.openTenAgainButton:GetComponent("Button").enabled=false
|
|
this.btnBack:GetComponent("Button").enabled=false
|
|
callList:Clear()
|
|
callList:Push(function ()
|
|
this.openTenAgainButton:GetComponent("Button").enabled=true
|
|
this.btnBack:GetComponent("Button").enabled=true
|
|
end)
|
|
this.views = {}
|
|
this.itemDataList = itemDataList
|
|
local dataNum = #itemDataList > 10 and 10 or #itemDataList
|
|
for i = dataNum, 1, -1 do
|
|
Util.ClearChild(this.contentList[i].transform)
|
|
this.views[i] = SubUIManager.Open(SubUIConfig.ItemView,this.contentList[i].transform)
|
|
local curItemData=itemDataList[i]
|
|
local contentGO = this.contentListParent[i]
|
|
this.views[i]:OnOpen(true,curItemData,1.4,true,false,false,self.sortingOrder)
|
|
contentGO:SetActive(false)
|
|
callList:Push(function ()
|
|
if curItemData.configData and curItemData.configData.ItemType==4 and curItemData.configData.Quantity>=gameSetting[1].IfVersion then
|
|
UIManager.OpenPanel(UIName.SecretBoxShowPokemonPanel,curItemData.configData.Id, function ()
|
|
Timer.New(function ()
|
|
contentGO:SetActive(true)
|
|
callList:Pop()()
|
|
end, 0.2):Start()
|
|
end)
|
|
else
|
|
Timer.New(function ()
|
|
contentGO:SetActive(true)
|
|
callList:Pop()()
|
|
end, 0.2):Start()
|
|
end
|
|
end)
|
|
end
|
|
callList:Pop()()
|
|
end
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
function QianKunBoxBuyTenPanel:OnClose()
|
|
|
|
end
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
function QianKunBoxBuyTenPanel:OnDestroy()
|
|
this.views = nil
|
|
end
|
|
|
|
return QianKunBoxBuyTenPanel |