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

249 lines
10 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
QianKunBoxBuyOnePanel = Inherit(BasePanel)
local this=QianKunBoxBuyOnePanel
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 artConfig = ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
local privilegeConfig=ConfigManager.GetConfig(ConfigName.PrivilegeTypeConfig)
local artResourcesConfig =ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
local recType = {}
2020-07-10 17:55:11 +08:00
--活动抽卡类型(动态的数据)
2021-06-03 19:44:39 +08:00
-- local drawtType={
-- FindFairySingle=0,
-- }
2020-07-10 17:55:11 +08:00
local orginLayer
2021-05-28 10:36:55 +08:00
local isLimitUpHero=false
2020-07-10 17:55:11 +08:00
--初始化组件(用于子类重写)
function QianKunBoxBuyOnePanel:InitComponent()
2021-04-21 13:12:04 +08:00
this.spLoader = SpriteLoader.New()
2020-07-10 17:55:11 +08:00
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")
2021-03-04 20:35:21 +08:00
this.itemIcon1=Util.GetGameObject(this.content1, "icon"):GetComponent("Image")
2020-07-10 17:55:11 +08:00
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/openOneAgainButton/Content3")
2021-05-28 10:36:55 +08:00
this.detailImage3=Util.GetGameObject(this.content3, "Tip")
2021-11-27 15:29:46 +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")
2020-07-10 17:55:11 +08:00
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数据
2021-06-03 19:44:39 +08:00
-- local curActivityId=ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.QianKunBox)
-- drawtType.FindFairySingle=ConfigManager.GetConfigDataByDoubleKey(ConfigName.LotterySetting,"PerCount",1,"ActivityId",curActivityId).Id
2020-07-10 17:55:11 +08:00
end
--绑定事件(用于子类重写)
function QianKunBoxBuyOnePanel:BindEvent()
Util.AddClick(this.btnBack, function ()
self:ClosePanel()
end)
Util.AddClick(this.openOneAgainButton, function ()
2021-05-28 10:36:55 +08:00
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
2021-05-28 10:36:55 +08:00
end
return
end
local d=RecruitManager.GetExpendData(this.recruitType)
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
2021-06-23 16:13:26 +08:00
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
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,1)--记录妖晶限购抽卡次数
end
local state = PlayerPrefs.GetInt(PlayerManager.uid.."GeneralPopup_RecruitConfirm"..recType[2])
2021-06-23 16:13:26 +08:00
if state==0 and tempItemId == 16 then
UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.RecruitConfirm,this.recruitType,recruitOne)
else
recruitOne()
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 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
2021-05-28 10:36:55 +08:00
2021-11-27 15:29:46 +08:00
function QianKunBoxBuyOnePanel:GetSendStr()
local str = ""
2022-05-23 11:29:10 +08:00
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.."赠送"
else
str = str..""
end
str = str..wish.Recruit[2]..""..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 QianKunBoxBuyOnePanel:OnOpen(...)
2021-05-26 19:40:03 +08:00
SoundManager.PlaySound(SoundConfig.UI_Siyuanzhen)
2020-07-10 17:55:11 +08:00
local args = { ... }
this.drop=args[1]
this.recruitType = args[2]
recType = args[3]
2021-05-28 10:36:55 +08:00
if not this.func then
this.func=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)
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
this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.TimelimitCall })
local num=PrivilegeManager.GetPrivilegeRemainValue(wish.DiamondMaxTimes)
d = RecruitManager.GetExpendDataByCostItem(wish.CostItemSingle,1,num)
2021-05-28 10:36:55 +08:00
isLimitUpHero=true
end
else
2021-07-22 14:17:40 +08:00
isLimitUpHero = false
2021-11-27 18:28:11 +08:00
if lotterySetting[this.recruitType] and lotterySetting[this.recruitType].LotteryType == 13 then
this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.tiandihonglu })
2021-12-06 09:58:04 +08:00
elseif lotterySetting[this.recruitType] and lotterySetting[this.recruitType].LotteryType == 14 then
this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.fagncunxunbao })
2021-11-27 18:28:11 +08:00
else
this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.QianKunBox })
end
2021-05-28 10:36:55 +08:00
d = RecruitManager.GetExpendData(this.recruitType)
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)
2021-11-27 15:29:46 +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
Util.ClearChild(Util.GetTransform(this.content, "itemContent1"))
this.itemDataList={}
this.itemDataList=BagManager.GetTableByBackDropData(this.drop)
2022-05-23 11:29:10 +08:00
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
2020-07-10 17:55:11 +08:00
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()
2021-05-28 10:36:55 +08:00
if isLimitUpHero then
2024-01-03 15:24:49 +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 QianKunBoxBuyOnePanel:OnClose()
end
--界面销毁时调用(用于子类重写)
function QianKunBoxBuyOnePanel:OnDestroy()
2021-04-21 13:12:04 +08:00
this.spLoader:Destroy()
2020-07-10 17:55:11 +08:00
SubUIManager.Close(this.UpView)
this.view = nil
2020-07-10 17:55:11 +08:00
end
return QianKunBoxBuyOnePanel