miduo_client/Assets/ManagedResources/~Lua/Modules/SecretBox/WishEquipBuyTenPanel.lua

232 lines
9.1 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

require("Base/BasePanel")
require("Base/Stack")
WishEquipBuyTenPanel = Inherit(BasePanel)
local this=WishEquipBuyTenPanel
local ItemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
local gameSetting=ConfigManager.GetConfig(ConfigName.GameSetting)
local artResourcesConfig=ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
local YaojingCallPrivilegeId = 2006
local itemId=0
local itemNum=0 --抽卡小号道具数量
local lotterySetting = ConfigManager.GetConfig(ConfigName.LotterySetting)
local callList = Stack.New()
local recType={}
this.contentList={}
this.contentListParent={}
this.isElementDrawPanel=false
local orginLayer
--初始化组件(用于子类重写)
function WishEquipBuyTenPanel:InitComponent()
this.spLoader = SpriteLoader.New()
orginLayer = 0
self.bg = Util.GetGameObject(self.gameObject, "effect")
screenAdapte(self.bg)
this.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform, { showType = UpViewOpenType.ShowLeft, panelType = PanelType.Recruit})
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.detailImage:SetActive(false)
this.content3=Util.GetGameObject(self.gameObject,"bottom/openTenAgainButton/Content3")
this.content3:SetActive(true)
this.itemIcon3=Util.GetGameObject(this.content3, "icon"):GetComponent("Image")
this.itemTip3=Util.GetGameObject(this.content3, "icon/Tip")
this.itemTip3:SetActive(false)
this.itemNum3=Util.GetGameObject(this.content3, "num"):GetComponent("Text")
this.itemNum3.text="X10"
this.itemInfo3=Util.GetGameObject(this.content3, "info"):GetComponent("Text")
--this.tipText=Util.GetGameObject(this.openOneAgainButton, "Text"):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 WishEquipBuyTenPanel:BindEvent()
Util.AddClick(this.btnBack, function ()
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
self:ClosePanel()
end)
Util.AddClick(this.openTenAgainButton, function ()
local maxTimesId = lotterySetting[RecruitType.FriendTen].MaxTimes
local freeTimesId = lotterySetting[RecruitType.FriendTen].FreeTimes
--是否超过每日最大上限
local d=RecruitManager.GetExpendData(this.recruitType)
if PrivilegeManager.GetPrivilegeRemainValue(maxTimesId) < 10 then
--LogGreen("maxTimesId:"..maxTimesId.." times"..PrivilegeManager.GetPrivilegeRemainValue(maxTimesId))
PopupTipPanel.ShowTip(Language[10485])
return
end
--是否妖晶,是否超过每日妖晶最大上限
if itemId == 16 then
if PrivilegeManager.GetPrivilegeRemainValue(YaojingCallPrivilegeId) < 10 then
PopupTipPanel.ShowTip(Language[11423])
return
end
end
if BagManager.GetItemCountById(itemId) < itemNum then
PopupTipPanel.ShowTip(GetLanguageStrById(ItemConfig[itemId].Name)..Language[10486])
return
end
local recruitTen = function()
RecruitManager.RecruitRequest(this.recruitType, function(msg)
PrivilegeManager.RefreshPrivilegeUsedTimes(maxTimesId,10)--记录抽卡次数
if itemId == 16 then
PrivilegeManager.RefreshPrivilegeUsedTimes(YaojingCallPrivilegeId,10)--记录妖晶抽卡次数
end
UIManager.OpenPanel(UIName.WishEquipBuyTenPanel,msg.drop,this.recruitType,recType)
--CheckRedPointStatus(RedPointType.QianKunBox)
end,freeTimesId,itemId,itemNum)
end
local state = PlayerPrefs.GetInt(PlayerManager.uid.."GeneralPopup_RecruitConfirm"..recType[2])
if state==0 and d[1] == 16 then
UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.RecruitConfirm,this.recruitType,recruitTen,itemNum)
else
recruitTen()
end
end)
end
--添加事件监听(用于子类重写)
function WishEquipBuyTenPanel:AddListener()
end
--移除事件监听(用于子类重写)
function WishEquipBuyTenPanel:RemoveListener()
end
function WishEquipBuyTenPanel: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 WishEquipBuyTenPanel:GetSendStr()
local str = ""
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
end
end
return str
end
--界面打开时调用(用于子类重写)
function WishEquipBuyTenPanel:OnOpen(...)
SoundManager.PlaySound(SoundConfig.UI_Siyuanzhen)
this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.Recruit})
-- this.itemIcon1.sprite=this.spLoader:LoadSprite(GetResourcePath(ItemConfig[SecretBoxManager.MainCost[2][1][1]].ResourceID))
local args = { ... }
this.drop=args[1]
this.recruitType=args[2]
recType=args[3]
local d
d = RecruitManager.GetExpendData(this.recruitType)
itemId = d[1]
itemNum = d[2]
this.itemIcon3.sprite=this.spLoader:LoadSprite(artResourcesConfig[ItemConfig[itemId].ResourceID].Name)
local itemDataList={}
local list=BagManager.GetTableByBackDropData(this.drop)
for k, v in pairs(list) do
if v.sId~=94 then
table.insert(itemDataList,v)
end
end
LogError("itemDataList len==============="..#itemDataList)
this.openTenAgainButton:GetComponent("Button").enabled=false
this.btnBack:GetComponent("Button").enabled=false
callList:Clear()
callList:Push(function ()
Log("结束了!!!")
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.25,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 WishEquipBuyTenPanel:OnClose()
end
--界面销毁时调用(用于子类重写)
function WishEquipBuyTenPanel:OnDestroy()
this.spLoader:Destroy()
SubUIManager.Close(this.UpView)
this.views = nil
if this.timer then
this.timer:Stop()
this.timer = nil
end
end
---寻仙倒计时(活动结束切换表现)
function this.FindFairyCountDown(timeDown)
if this.timer then
this.timer:Stop()
this.timer = nil
end
this.timer = Timer.New(function()
if timeDown < 1 then
this.timer:Stop()
this.timer = nil
this.btnBack:GetComponent("RectTransform"):DOAnchorPosX(0, 0, true)
this.openTenAgainButton:SetActive(false)
PopupTipPanel.ShowTip(Language[11842])
return
end
timeDown = timeDown - 1
end, 1, -1, true)
this.timer:Start()
end
return WishEquipBuyTenPanel