249 lines
11 KiB
Lua
249 lines
11 KiB
Lua
require("Base/BasePanel")
|
|
QianKunBoxBuyOnePanel = Inherit(BasePanel)
|
|
local this = QianKunBoxBuyOnePanel
|
|
local ItemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
|
|
local gameSetting = ConfigManager.GetConfig(ConfigName.GameSetting)
|
|
local lotterySetting = ConfigManager.GetConfig(ConfigName.LotterySetting)
|
|
local artConfig = ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
|
|
local privilegeConfig = ConfigManager.GetConfig(ConfigName.PrivilegeTypeConfig)
|
|
local artResourcesConfig = ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
|
|
local recType = {}
|
|
|
|
--活动抽卡类型(动态的数据)
|
|
-- local drawtType={
|
|
-- FindFairySingle=0,
|
|
-- }
|
|
|
|
local orginLayer
|
|
local isLimitUpHero = false
|
|
--初始化组件(用于子类重写)
|
|
function QianKunBoxBuyOnePanel:InitComponent()
|
|
this.spLoader = SpriteLoader.New()
|
|
|
|
orginLayer = 10
|
|
self.bg = Util.GetGameObject(self.gameObject, "effect")
|
|
this.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform,
|
|
{ showType = UpViewOpenType.ShowLeft, panelType = PanelType.ElementDrawCard })
|
|
screenAdapte(self.bg)
|
|
this.btnBack = Util.GetGameObject(self.gameObject, "bottom/backButton")
|
|
this.content = Util.GetGameObject(self.gameObject, "content")
|
|
this.openOneAgainButton = Util.GetGameObject(self.gameObject, "bottom/openOneAgainButton")
|
|
|
|
this.detailImage = Util.GetGameObject(self.gameObject, "Tip")
|
|
this.detailText = Util.GetGameObject(this.detailImage, "Text"):GetComponent("Text")
|
|
|
|
this.content1 = Util.GetGameObject(self.gameObject, "bottom/openOneAgainButton/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.content3 = Util.GetGameObject(self.gameObject, "bottom/openOneAgainButton/Content3")
|
|
this.detailImage3 = Util.GetGameObject(this.content3, "Tip")
|
|
this.detailText2 = Util.GetGameObject(this.detailImage3, "contentDetailText"):GetComponent("Text")
|
|
this.itemIcon3 = Util.GetGameObject(this.content3, "icon"):GetComponent("Image")
|
|
this.itemNum3 = Util.GetGameObject(this.content3, "num"):GetComponent("Text")
|
|
|
|
this.content2 = Util.GetGameObject(self.gameObject, "bottom/openOneAgainButton/Content2")
|
|
this.itemIcon2 = Util.GetGameObject(this.content2, "Icon"):GetComponent("Image")
|
|
this.itemNum2 = Util.GetGameObject(this.content2, "Num"):GetComponent("Text")
|
|
|
|
-- 关于抽卡的LotterySetting数据
|
|
-- local curActivityId=ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.QianKunBox)
|
|
-- drawtType.FindFairySingle=ConfigManager.GetConfigDataByDoubleKey(ConfigName.LotterySetting,"PerCount",1,"ActivityId",curActivityId).Id
|
|
end
|
|
|
|
--绑定事件(用于子类重写)
|
|
function QianKunBoxBuyOnePanel:BindEvent()
|
|
Util.AddClick(this.btnBack, function()
|
|
self:ClosePanel()
|
|
end)
|
|
Util.AddClick(this.openOneAgainButton, function()
|
|
if isLimitUpHero then
|
|
if this.func then
|
|
local isShow = this.func()
|
|
if not isShow then
|
|
self.bg.gameObject:SetActive(false)
|
|
self.bg.gameObject:SetActive(true)
|
|
end
|
|
end
|
|
return
|
|
end
|
|
local d = RecruitManager.GetExpendData(this.recruitType)
|
|
local maxtimesId = lotterySetting[this.recruitType].MaxTimes
|
|
local freeTimesId = lotterySetting[this.recruitType].FreeTimes
|
|
local moneyTime = lotterySetting[this.recruitType].MoneyTimes
|
|
local tempItemId = d[1]
|
|
local tempItemNum = d[2]
|
|
if BagManager.GetItemCountById(tempItemId) >= tempItemNum then
|
|
local recruitOne = function()
|
|
self:ClosePanel()
|
|
RecruitManager.RecruitRequest(this.recruitType, function(msg)
|
|
PrivilegeManager.RefreshPrivilegeUsedTimes(maxtimesId, 1) --记录抽卡次数
|
|
UIManager.OpenPanel(UIName.QianKunBoxBuyOnePanel, msg.drop, this.recruitType, recType)
|
|
CheckRedPointStatus(RedPointType.QianKunBox)
|
|
end, freeTimesId)
|
|
end
|
|
if tempItemId == 16 then
|
|
if moneyTime and moneyTime > 0 and PrivilegeManager.GetPrivilegeRemainValue(moneyTime) < 1 then
|
|
PopupTipPanel.ShowTip(Language[10599])
|
|
return
|
|
end
|
|
end
|
|
if tempItemId == 16 and moneyTime and moneyTime > 0 then
|
|
PrivilegeManager.RefreshPrivilegeUsedTimes(moneyTime, 1) --记录妖晶限购抽卡次数
|
|
end
|
|
local state = PlayerPrefs.GetInt(PlayerManager.uid .. "GeneralPopup_RecruitConfirm" .. recType[2])
|
|
if state == 0 and tempItemId == 16 then
|
|
UIManager.OpenPanel(UIName.GeneralPopup, GENERAL_POPUP_TYPE.RecruitConfirm, this.recruitType, recruitOne)
|
|
else
|
|
recruitOne()
|
|
end
|
|
else
|
|
--UIManager.OpenPanel(UIName.QuickPurchasePanel, { type = UpViewRechargeType.DemonCrystal })--应跳到充值界面,现在是用之前的货币换取妖晶
|
|
PopupTipPanel.ShowTip(string.format(Language[10600], GetLanguageStrById(ItemConfig[tempItemId].Name)))
|
|
self:ClosePanel()
|
|
end
|
|
end)
|
|
end
|
|
|
|
--添加事件监听(用于子类重写)
|
|
function QianKunBoxBuyOnePanel:AddListener()
|
|
|
|
end
|
|
|
|
--移除事件监听(用于子类重写)
|
|
function QianKunBoxBuyOnePanel:RemoveListener()
|
|
|
|
end
|
|
|
|
function QianKunBoxBuyOnePanel:OnSortingOrderChange()
|
|
Util.AddParticleSortLayer(self.bg, self.sortingOrder - orginLayer)
|
|
orginLayer = self.sortingOrder
|
|
|
|
if this.view then
|
|
this.view:OnOpen(true, this.itemDataList[1], 1.4, true, false, false, self.sortingOrder)
|
|
end
|
|
end
|
|
|
|
function QianKunBoxBuyOnePanel:GetSendStr()
|
|
local str = ""
|
|
if this.recruitType == 50 then
|
|
local wish = ConfigManager.GetConfigData(ConfigName.WishActivitySetting, 1)
|
|
if wish and wish.Recruit then
|
|
--for k,v in ipairs(wish.Recruit) do
|
|
if str == "" then
|
|
str = str .. Language[10601]
|
|
else
|
|
str = str .. Language[10602]
|
|
end
|
|
str = str .. wish.Recruit[2] .. Language[10227] .. ItemConfig[wish.Recruit[1]].Name
|
|
--end
|
|
end
|
|
else
|
|
if lotterySetting[this.recruitType] and lotterySetting[this.recruitType].TenTimesMustGetItem and #lotterySetting[this.recruitType].TenTimesMustGetItem > 0 then
|
|
for k, v in ipairs(lotterySetting[this.recruitType].TenTimesMustGetItem) do
|
|
if str == "" then
|
|
str = str .. Language[10601]
|
|
else
|
|
str = str .. Language[10602]
|
|
end
|
|
str = str .. v[2] .. Language[10227] .. ItemConfig[v[1]].Name
|
|
end
|
|
end
|
|
end
|
|
|
|
return str
|
|
end
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
function QianKunBoxBuyOnePanel:OnOpen(...)
|
|
SoundManager.PlaySound(SoundConfig.UI_Siyuanzhen)
|
|
local args = { ... }
|
|
this.drop = args[1]
|
|
this.recruitType = args[2]
|
|
recType = args[3]
|
|
if not this.func then
|
|
this.func = args[4]
|
|
end
|
|
this.detailImage:SetActive(true)
|
|
this.content1:SetActive(false)
|
|
this.content2:SetActive(false)
|
|
this.content3:SetActive(true)
|
|
|
|
local itemId = 0
|
|
local itemNum = 0
|
|
local d
|
|
local upConfig = this.recruitType == RecruitType.PrayerSingle or this.recruitType == RecruitType.PrayerTen
|
|
if upConfig then
|
|
local wish = ConfigManager.GetConfigData(ConfigName.WishActivitySetting, 1)
|
|
if wish then
|
|
this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.TimelimitCall })
|
|
local num = PrivilegeManager.GetPrivilegeRemainValue(wish.DiamondMaxTimes)
|
|
d = RecruitManager.GetExpendDataByCostItem(wish.CostItemSingle, 1, num)
|
|
isLimitUpHero = true
|
|
end
|
|
else
|
|
isLimitUpHero = false
|
|
if lotterySetting[this.recruitType] and lotterySetting[this.recruitType].LotteryType == 13 then
|
|
this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.tiandihonglu })
|
|
elseif lotterySetting[this.recruitType] and lotterySetting[this.recruitType].LotteryType == 14 then
|
|
this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.fagncunxunbao })
|
|
else
|
|
this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.QianKunBox })
|
|
end
|
|
d = RecruitManager.GetExpendData(this.recruitType)
|
|
end
|
|
|
|
itemId = d[1]
|
|
itemNum = d[2]
|
|
this.itemIcon3.sprite = this.spLoader:LoadSprite(artResourcesConfig[ItemConfig[itemId].ResourceID].Name)
|
|
this.itemNum3.text = PrintWanNum2(itemNum)
|
|
local str = this:GetSendStr()
|
|
this.detailText.text = str
|
|
this.detailText1.text = str
|
|
this.detailText2.text = str
|
|
Util.ClearChild(Util.GetTransform(this.content, "itemContent1"))
|
|
this.itemDataList = {}
|
|
this.itemDataList = BagManager.GetTableByBackDropData(this.drop)
|
|
itemDataList = BagManager.GetTableByBackDropData(this.drop)
|
|
if this.recruitType == 50 then
|
|
for key, value in pairs(itemDataList) do
|
|
if value.sId == 1011 then
|
|
table.removebyvalue(itemDataList, value)
|
|
end
|
|
end
|
|
end
|
|
this.view = SubUIManager.Open(SubUIConfig.ItemView, Util.GetTransform(this.content, "itemContent1"))
|
|
this.view:OnOpen(true, this.itemDataList[1], 1.4, true, false, false, self.sortingOrder)
|
|
|
|
this.openOneAgainButton:GetComponent("Button").enabled = false
|
|
local time = Timer.New(function()
|
|
this.openOneAgainButton:GetComponent("Button").enabled = true
|
|
local itemDataList = BagManager.GetTableByBackDropData(this.drop)
|
|
if itemDataList and #itemDataList > 0 then
|
|
local singleItemConfigData = itemDataList[1].configData
|
|
if singleItemConfigData and singleItemConfigData.ItemType == 4 and singleItemConfigData.Quantity >= gameSetting[1].IfVersion then
|
|
UIManager.OpenPanel(UIName.SecretBoxShowPokemonPanel, singleItemConfigData.Id)
|
|
end
|
|
end
|
|
end, 0.5)
|
|
time:Start()
|
|
if isLimitUpHero then
|
|
this.detailImage:SetActive(false)
|
|
this.detailImage3:SetActive(false)
|
|
end
|
|
end
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
function QianKunBoxBuyOnePanel:OnClose()
|
|
end
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
function QianKunBoxBuyOnePanel:OnDestroy()
|
|
this.spLoader:Destroy()
|
|
SubUIManager.Close(this.UpView)
|
|
this.view = nil
|
|
end
|
|
|
|
return QianKunBoxBuyOnePanel
|