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

215 lines
8.7 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")
WishEquipBuyOnePanel = Inherit(BasePanel)
local this=WishEquipBuyOnePanel
local ItemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
local gameSetting=ConfigManager.GetConfig(ConfigName.GameSetting)
local lotterySetting = ConfigManager.GetConfig(ConfigName.LotterySetting)
local privilegeConfig=ConfigManager.GetConfig(ConfigName.PrivilegeTypeConfig)
local artResourcesConfig =ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
local activityConfig=ConfigManager.GetConfigData(ConfigName.ActivityGroups,203)
local itemNum=0 --抽卡小号道具数量
local isFree=false
local itemId = 0
local RecruitMaxtimesId = 0
local freeTimesId = 0
local recType = {}
local orginLayer
--初始化组件(用于子类重写)
function WishEquipBuyOnePanel:InitComponent()
this.spLoader = SpriteLoader.New()
orginLayer = 10
self.bg = Util.GetGameObject(self.gameObject, "effect")
-- self.dibiao = Util.GetGameObject(self.bg, "dibiao")
-- self.dibiao.gameObject:SetActive(false)
this.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform, { showType = UpViewOpenType.ShowLeft, panelType = PanelType.Recruit })
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.detailImage:SetActive(false)
this.content3=Util.GetGameObject(self.gameObject,"bottom/openOneAgainButton/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.itemInfo3=Util.GetGameObject(this.content3, "info"):GetComponent("Text")
this.itemInfo3.text="单次"
end
--绑定事件(用于子类重写)
function WishEquipBuyOnePanel:BindEvent()
Util.AddClick(this.btnBack, function ()
self:ClosePanel()
end)
Util.AddClick(this.openOneAgainButton, function ()
Log(tostring(this.recruitType))
if PrivilegeManager.GetPrivilegeUsedTimes(self.singleConfig.MaxTimes)+this.recruitType>privilegeConfig[self.singleConfig.MaxTimes].Condition[1][2] then
PopupTipPanel.ShowTip("无法超出每日召唤次数上限!")
return
end
if itemId==16 and PrivilegeManager.GetPrivilegeRemainValue(self.singleConfig.MaxTimes)<this.recruitType then
PopupTipPanel.ShowTip("无法超出每日妖晶召唤次数上限!")
return
end
RecruitManager.RecruitRequest(self.singleConfig.Id, function(msg)
PrivilegeManager.RefreshPrivilegeUsedTimes(self.singleConfig.MaxTimes,this.recruitType)--记录抽卡次数
if itemId==16 then
PrivilegeManager.RefreshPrivilegeUsedTimes(self.singleConfig.MoneyTimes,this.recruitType)
end
UIManager.OpenPanel(UIName.WishEquipBuyOnePanel,msg.drop,self.singleConfig.Id,{activityConfig.ShopData[3][1],activityConfig.ShopData[3][2]})
CheckRedPointStatus(activityConfig.RpType)
end,self.singleConfig.FreeTimes)
end)
end
--添加事件监听(用于子类重写)
function WishEquipBuyOnePanel:AddListener()
end
--移除事件监听(用于子类重写)
function WishEquipBuyOnePanel:RemoveListener()
end
function WishEquipBuyOnePanel: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 WishEquipBuyOnePanel: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 WishEquipBuyOnePanel:OnOpen(...)
self.bg.gameObject:SetActive(false)
self.bg.gameObject:SetActive(true)
SoundManager.PlaySound(SoundConfig.UI_Siyuanzhen)
this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.Recruit })
local args = { ... }
this.drop=args[1]
this.recruitType=args[2]
recType = args[3]
self.singleConfig = ConfigManager.GetConfigDataByDoubleKey(ConfigName.LotterySetting,"LotteryType",TableRecruitType.Youqing,"PerCount",1)
--获取免费次数
local currLottery= ConfigManager.GetConfigData(ConfigName.LotterySetting,RecruitType.FriendSingle)
freeTimesId=currLottery.FreeTimes
RecruitMaxtimesId = currLottery.MaxTimes
local freeTime=0
if freeTimesId>0 then
freeTime= PrivilegeManager.GetPrivilegeRemainValue(freeTimesId)
RecruitManager.freeUseTimeList[freeTimesId] = freeTime
end
isFree=freeTime and freeTime >= 1
if isFree then
itemId=0
this.itemNum3.gameObject:SetActive(false)
this.itemIcon3.gameObject:SetActive(false)
this.itemInfo3.text=Language[10489]
this.tipText.gameObject:SetActive(false)
else
this.itemNum3.gameObject:SetActive(true)
this.itemIcon3.gameObject:SetActive(true)
this.itemInfo3.text="单次"
itemId=0
local d = RecruitManager.GetExpendData(this.recruitType)
itemId = d[1]
itemNum = d[2]
--是否激活特权
-- local isActive = PrivilegeManager.GetPrivilegeOpenStatusById(3004)
-- if itemId == 16 and isActive then
-- local currPrivilege = privilegeConfig[3004]
-- local curShenzunLv=GetShenzunLv()
-- local conditionIndex=curShenzunLv+1
-- itemNum = itemNum * (1+currPrivilege.Condition[conditionIndex][2]/10000)
-- end
-- if itemId ==16 then
-- this.tipText.gameObject:SetActive(true)
-- this.tipText.text=string.format(Language[11424],PrivilegeManager.GetPrivilegeRemainValue(YaojingCallPrivilegeId), PrivilegeManager.GetPrivilegeNumber(YaojingCallPrivilegeId))
-- else
-- this.tipText.gameObject:SetActive(false)
-- end
this.itemIcon3.sprite=this.spLoader:LoadSprite(artResourcesConfig[ItemConfig[itemId].ResourceID].Name)
this.itemNum3.text= "×"..itemNum
end
Util.ClearChild(Util.GetTransform(this.content, "itemContent1"))
this.itemDataList={}
this.itemDataList=BagManager.GetTableByBackDropData(this.drop)
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()
end
--界面关闭时调用(用于子类重写)
function WishEquipBuyOnePanel:OnClose()
end
--界面销毁时调用(用于子类重写)
function WishEquipBuyOnePanel:OnDestroy()
this.spLoader:Destroy()
SubUIManager.Close(this.UpView)
this.view = 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.openOneAgainButton:SetActive(false)
PopupTipPanel.ShowTip(Language[11842])
return
end
timeDown = timeDown - 1
end, 1, -1, true)
this.timer:Start()
end
return WishEquipBuyOnePanel