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

208 lines
8.7 KiB
Lua
Raw Normal View History

2020-05-09 13:31:21 +08:00
require("Base/BasePanel")
SecretBoxBuyOnePanel = Inherit(BasePanel)
local this=SecretBoxBuyOnePanel
local ItemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
local gameSetting=ConfigManager.GetConfig(ConfigName.GameSetting)
2020-06-08 13:57:30 +08:00
-- local onceData={}
2020-05-09 13:31:21 +08:00
local lotterySetting = ConfigManager.GetConfig(ConfigName.LotterySetting)
--活动抽卡类型(动态的数据)
2020-06-08 13:57:30 +08:00
-- local drawtType={
-- FindFairySingle=0,
-- }
2020-05-09 13:31:21 +08:00
local orginLayer
--初始化组件(用于子类重写)
function SecretBoxBuyOnePanel:InitComponent()
orginLayer = 10
self.bg = Util.GetGameObject(self.gameObject, "effect")
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.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数据
2020-06-08 13:57:30 +08:00
-- local curActivityId=ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.FindFairy)
-- drawtType.FindFairySingle=ConfigManager.GetConfigDataByDoubleKey(ConfigName.LotterySetting,"PerCount",1,"ActivityId",curActivityId).Id
-- onceData=ConfigManager.GetConfigData(ConfigName.LotterySetting,drawtType.FindFairySingle)
2020-05-09 13:31:21 +08:00
end
--绑定事件(用于子类重写)
function SecretBoxBuyOnePanel:BindEvent()
Util.AddClick(this.btnBack, function ()
self:ClosePanel()
end)
Util.AddClick(this.openOneAgainButton, function ()
Log(tostring(this.recruitType))
if this.recruitType then
self:ClosePanel()
2020-06-08 13:57:30 +08:00
-- if this.recruitType==drawtType.FindFairySingle then
-- --如果道具不足 要做判断
-- local cost = lotterySetting[this.recruitType].CostItem
-- local itemId=cost[2][1] --默认为妖晶
-- local itemNum=cost[2][2] --默认妖晶的数量
-- if BagManager.GetItemCountById(cost[1][1])>0 then --如果有寻仙玉
-- itemId=cost[1][1]
-- itemNum=cost[1][2]
-- end
-- if BagManager.GetItemCountById(itemId) < itemNum then
-- if PrivilegeManager.GetPrivilegeRemainValue(32)<=0 then --如果免费次数不足
-- PopupTipPanel.ShowTip("道具不足!")
-- return
-- end
-- end
-- end
2020-05-09 13:31:21 +08:00
RecruitManager.RecruitRequest(this.recruitType, function(msg) --这已经做了道具不足检查了
UIManager.OpenPanel(UIName.SecretBoxBuyOnePanel,msg.drop,this.recruitType)
Game.GlobalEvent:DispatchEvent(GameEvent.Bag.BagGold)
end)
else
if(BagManager.GetItemCountById(SecretBoxManager.MainCost[2][1][1])>=1) then
self:ClosePanel()
if(SecretBoxManager.SeasonTime>1) then
SecretBoxManager.GetSecretBoxRewardRequest(SecretBoxManager.typeId[2*SecretBoxManager.SeasonTime-1],1)
end
else
UIManager.OpenPanel(UIName.QuickPurchasePanel, { type = UpViewRechargeType.GhostRing })
end
end
end)
end
--添加事件监听(用于子类重写)
function SecretBoxBuyOnePanel:AddListener()
end
--移除事件监听(用于子类重写)
function SecretBoxBuyOnePanel:RemoveListener()
end
function SecretBoxBuyOnePanel: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 SecretBoxBuyOnePanel:OnOpen(...)
2020-06-08 13:57:30 +08:00
-- this.itemIcon1.sprite=Util.LoadSprite(GetResourcePath(ItemConfig[SecretBoxManager.MainCost[1][1][1]].ResourceID))
2020-05-09 13:31:21 +08:00
local args = { ... }
this.drop=args[1]
this.recruitType=args[2]
--面板特殊处理
if this.recruitType then --如果有类型
this.detailImage:SetActive(this.recruitType <= RecruitType.LightDarkSingle)
this.content1:SetActive(this.recruitType <= RecruitType.LightDarkSingle)
2020-06-08 13:57:30 +08:00
-- this.content2:SetActive(this.recruitType == drawtType.FindFairySingle)
-- this.detailText.enabled=this.recruitType~=drawtType.FindFairySingle
-- this.detailText1.enabled=this.recruitType~=drawtType.FindFairySingle
this.content2:SetActive(false)
2020-05-09 13:31:21 +08:00
if this.recruitType <= RecruitType.LightDarkSingle then --光暗什么...的抽卡
this.itemIcon1.sprite=Util.LoadSprite("r_RareItem_Specail_0002")
this.detailText.text = "赠送1个混沌玉"
this.detailText1.text = "赠送1个混沌玉"
2020-06-08 13:57:30 +08:00
-- elseif this.recruitType == drawtType.FindFairySingle then --东海寻仙
-- this.FindFairyCountDown(FindFairyManager.GetActivityTime())
-- FindFairyManager.SetFreeExtract(1)
-- this.itemIcon2.enabled=(FindFairyManager.myScore)/10%15~=0
-- if PrivilegeManager.GetPrivilegeRemainValue(32)>0 then
-- this.itemNum2.text="免费"..PrivilegeManager.GetPrivilegeRemainValue(32).."次"
-- this.itemIcon2.enabled=false
-- else
-- this.itemIcon2.enabled=true
-- this.itemIcon2.sprite=SetIcon(onceData.CostItem[2][1])--默认显示妖晶
-- this.itemNum2.text=onceData.CostItem[2][2]
-- if BagManager.GetItemCountById(onceData.CostItem[1][1])>0 then--若有寻仙玉
-- this.itemIcon2.sprite=SetIcon(onceData.CostItem[1][1])
-- this.itemNum2.text=onceData.CostItem[1][2]
-- end
-- end
2020-05-09 13:31:21 +08:00
end
else --如果没类型
this.detailImage:SetActive(not this.recruitType)
this.content1:SetActive(not this.recruitType)
this.content2:SetActive(this.recruitType)
this.itemIcon1.sprite=Util.LoadSprite("r_RareItem_Specail_0008")
this.detailText.text = "赠送1个妖灵玉"
this.detailText1.text = "赠送1个妖灵玉"
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 SecretBoxBuyOnePanel:OnClose()
end
--界面销毁时调用(用于子类重写)
function SecretBoxBuyOnePanel:OnDestroy()
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("活动结束!")
return
end
timeDown = timeDown - 1
end, 1, -1, true)
this.timer:Start()
end
return SecretBoxBuyOnePanel