miduo_client/Assets/ManagedResources/~Lua/Modules/DynamicActivity/QianKunBoxBuyTenPanel.lua

283 lines
11 KiB
Lua
Raw Normal View History

2021-04-21 13:12:04 +08:00
require("Base/BasePanel")
2020-07-10 17:55:11 +08:00
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)
2020-07-13 20:07:06 +08:00
local artResourcesConfig =ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
local recType = {}
2020-07-10 17:55:11 +08:00
--活动抽卡类型(动态的数据)
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
2021-05-28 10:36:55 +08:00
local isLimitUpHero=false
2020-07-10 17:55:11 +08:00
--初始化组件(用于子类重写)
function QianKunBoxBuyTenPanel:InitComponent()
2021-04-21 13:12:04 +08:00
this.spLoader = SpriteLoader.New()
2020-07-10 17:55:11 +08:00
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")
2020-07-13 20:07:06 +08:00
this.content3=Util.GetGameObject(self.gameObject,"bottom/openTenAgainButton/Content3")
2021-05-28 10:36:55 +08:00
this.detailImage3=Util.GetGameObject(this.content3, "Tip")
2021-11-27 17:59:07 +08:00
this.detailText2 = Util.GetGameObject(this.detailImage3, "contentDetailText"):GetComponent("Text")
2020-07-13 20:07:06 +08:00
this.itemIcon3=Util.GetGameObject(this.content3, "icon"):GetComponent("Image")
this.itemNum3=Util.GetGameObject(this.content3, "num"):GetComponent("Text")
this.itemInfo3=Util.GetGameObject(this.content3, "info"):GetComponent("Text")
2020-07-10 17:55:11 +08:00
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
end
--绑定事件(用于子类重写)
function QianKunBoxBuyTenPanel:BindEvent()
2020-07-10 17:55:11 +08:00
Util.AddClick(this.btnBack, function ()
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
self:ClosePanel()
end)
Util.AddClick(this.openTenAgainButton, function ()
2021-05-28 10:36:55 +08:00
if isLimitUpHero then
if this.tenFunc then
this.tenFunc()
end
return
end
local d=RecruitManager.GetExpendData(this.recruitType)
2021-06-23 16:11:30 +08:00
local tempItemId=d[1]
local tempItemNum=d[2]
local maxtimesId=lotterySetting[this.recruitType].MaxTimes
local freeTimesId=lotterySetting[this.recruitType].FreeTimes
2022-12-05 18:26:25 +08:00
local moneyTime=lotterySetting[this.recruitType].MoneyTimes
local tempItemId=d[1]
2021-06-23 16:11:30 +08:00
if BagManager.GetItemCountById(tempItemId)>=tempItemNum then
local recruitTen = function()
self:ClosePanel()
RecruitManager.RecruitRequest(this.recruitType, function(msg)
PrivilegeManager.RefreshPrivilegeUsedTimes(maxtimesId,10)--记录抽卡次数
UIManager.OpenPanel(UIName.QianKunBoxBuyTenPanel,msg.drop,this.recruitType,recType)
CheckRedPointStatus(RedPointType.QianKunBox)
end,freeTimesId)
end
2022-12-05 18:26:25 +08:00
if tempItemId == 16 then
if moneyTime and moneyTime > 0 and PrivilegeManager.GetPrivilegeRemainValue(moneyTime) < 1 then
PopupTipPanel.ShowTip(Language[11423])
return
end
end
if tempItemId == 16 and moneyTime and moneyTime > 0 then
PrivilegeManager.RefreshPrivilegeUsedTimes(moneyTime,10)--记录妖晶限购抽卡次数
end
local state = PlayerPrefs.GetInt(PlayerManager.uid.."GeneralPopup_RecruitConfirm"..recType[2])
2021-06-23 16:11:30 +08:00
if state==0 and tempItemId == 16 then
UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.RecruitConfirm,this.recruitType,recruitTen)
else
recruitTen()
end
2020-07-10 17:55:11 +08:00
else
--UIManager.OpenPanel(UIName.QuickPurchasePanel, { type = UpViewRechargeType.DemonCrystal })--应跳到充值界面,现在是用之前的货币换取妖晶
2021-11-30 09:35:37 +08:00
PopupTipPanel.ShowTip(string.format("%s不足",ItemConfig[tempItemId].Name))
2020-07-10 17:55:11 +08:00
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
2021-11-27 15:29:46 +08:00
function QianKunBoxBuyTenPanel:GetSendStr()
local str = ""
2022-05-23 11:29:10 +08:00
local wish=ConfigManager.GetConfigData(ConfigName.WishActivitySetting,1)
if this.recruitType==51 then
if wish and wish.Recruit then
-- for k,v in ipairs(wish.Recruit) do
if str == "" then
str = str.."赠送"
else
str = str..""
end
str = str.."10"..""..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.."赠送"
else
str = str..""
end
str = str..v[2]..""..ItemConfig[v[1]].Name
2021-11-27 17:13:28 +08:00
end
2021-11-27 15:29:46 +08:00
end
end
2022-05-23 11:29:10 +08:00
2021-11-27 15:29:46 +08:00
return str
end
2020-07-10 17:55:11 +08:00
--界面打开时调用(用于子类重写)
function QianKunBoxBuyTenPanel:OnOpen(...)
2021-06-01 13:42:36 +08:00
SoundManager.PlaySound(SoundConfig.UI_Siyuanzhen)
2021-04-21 13:12:04 +08:00
-- this.itemIcon1.sprite=this.spLoader:LoadSprite(GetResourcePath(ItemConfig[SecretBoxManager.MainCost[2][1][1]].ResourceID))
2020-07-10 17:55:11 +08:00
local args = { ... }
this.drop=args[1]
this.recruitType = args[2]
recType = args[3]
2021-06-07 18:06:23 +08:00
drawtType.FindFairySingle=recType[1]
drawtType.FindFairyTen=recType[2]
2021-05-28 10:36:55 +08:00
if args[4] then
this.tenFunc=args[4]
end
this.detailImage:SetActive(true)
2020-07-13 20:07:06 +08:00
this.content1:SetActive(false)
this.content2:SetActive(false)
this.content3:SetActive(true)
2021-07-19 11:31:13 +08:00
isLimitUpHero=false
2020-07-13 20:07:06 +08:00
local itemId=0
local itemNum=0
local d
2021-07-22 14:17:40 +08:00
local upConfig = this.recruitType == RecruitType.PrayerSingle or this.recruitType == RecruitType.PrayerTen
2021-05-28 10:36:55 +08:00
if upConfig then
local wish=ConfigManager.GetConfigData(ConfigName.WishActivitySetting,1)
if wish then
if not this.UpView then
this.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform, { showType = UpViewOpenType.ShowLeft, panelType = PanelType.ElementDrawCard })
end
this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.TimelimitCall })
2021-05-28 10:36:55 +08:00
isLimitUpHero=true
this.itemInfo3.text="10次"
local num=PrivilegeManager.GetPrivilegeRemainValue(wish.DiamondMaxTimes)
d = RecruitManager.GetExpendDataByCostItem(wish.CostItemMul,2,num)
2021-05-28 10:36:55 +08:00
end
else
2021-07-22 14:17:40 +08:00
isLimitUpHero = false
2021-05-28 10:36:55 +08:00
d = RecruitManager.GetExpendData(this.recruitType)
if this.UpView then
SubUIManager.Close(this.UpView)
this.UpView = nil
end
2021-05-28 10:36:55 +08:00
end
2020-07-13 20:07:06 +08:00
itemId=d[1]
itemNum=d[2]
2021-04-21 13:12:04 +08:00
this.itemIcon3.sprite=this.spLoader:LoadSprite(artResourcesConfig[ItemConfig[itemId].ResourceID].Name)
2022-10-19 18:04:28 +08:00
this.itemNum3.text= PrintWanNum2(itemNum)
2020-07-10 17:55:11 +08:00
local itemDataList={}
2022-05-23 11:29:10 +08:00
LogError("#drop len=="..#this.drop)
2020-07-10 17:55:11 +08:00
itemDataList=BagManager.GetTableByBackDropData(this.drop)
2022-05-23 11:29:10 +08:00
if this.recruitType==51 then
for key, value in pairs(itemDataList) do
if value.sId==1011 then
table.removebyvalue(itemDataList,value)
end
end
end
2020-07-10 17:55:11 +08:00
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
2022-05-23 11:29:10 +08:00
local str = this:GetSendStr()
this.detailText.text = str
this.detailText1.text = str
this.detailText2.text = str
2020-07-10 17:55:11 +08:00
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()()
2021-05-28 10:36:55 +08:00
if isLimitUpHero then
2022-05-23 11:29:10 +08:00
-- this.detailImage:SetActive(false)
-- this.detailImage3:SetActive(false)
2021-05-28 10:36:55 +08:00
end
2020-07-10 17:55:11 +08:00
end
--界面关闭时调用(用于子类重写)
function QianKunBoxBuyTenPanel:OnClose()
end
--界面销毁时调用(用于子类重写)
function QianKunBoxBuyTenPanel:OnDestroy()
2021-04-21 13:12:04 +08:00
this.spLoader:Destroy()
2021-07-19 10:59:13 +08:00
if this.UpView then
SubUIManager.Close(this.UpView)
this.UpView = nil
end
2020-07-10 17:55:11 +08:00
this.views = nil
end
return QianKunBoxBuyTenPanel