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

168 lines
6.2 KiB
Lua
Raw Normal View History

2023-08-31 15:02:13 +08:00
require("Base/BasePanel")
WishGemBuyOnePanel = Inherit(BasePanel)
local this=WishGemBuyOnePanel
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
local costId=0
2023-08-31 19:12:02 +08:00
local activityId=0
2023-08-31 15:02:13 +08:00
--初始化组件(用于子类重写)
function WishGemBuyOnePanel: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)
2023-09-01 18:04:52 +08:00
this.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform, { showType = UpViewOpenType.ShowLeft, panelType = PanelType.Gem })
2023-08-31 15:02:13 +08:00
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")
2023-09-01 17:36:15 +08:00
this.detailImage:SetActive(true)
this.detailText.text="仅保留高品质命石属性"
2023-08-31 15:02:13 +08:00
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 WishGemBuyOnePanel:BindEvent()
Util.AddClick(this.btnBack, function ()
self:ClosePanel()
end)
Util.AddClick(this.openOneAgainButton, function ()
Log(tostring(this.recruitType))
NetManager.GemNewDrawRequest(this.recruitType,1,function(msg)
2023-08-31 19:12:02 +08:00
UIManager.OpenPanel(UIName.WishGemBuyOnePanel,msg.drop,this.recruitType,costId,activityId)
2023-10-28 15:41:17 +08:00
2023-08-31 15:02:13 +08:00
--CheckRedPointStatus(self.config.RpType)
end)
end)
end
--添加事件监听(用于子类重写)
function WishGemBuyOnePanel:AddListener()
end
--移除事件监听(用于子类重写)
function WishGemBuyOnePanel:RemoveListener()
end
function WishGemBuyOnePanel:OnSortingOrderChange()
Util.AddParticleSortLayer(self.bg, self.sortingOrder - orginLayer)
orginLayer = self.sortingOrder
2023-10-28 15:41:17 +08:00
-- if this.view then
-- this.view:OnOpen(true,this.itemDataList[1],1.4,true,false,false,self.sortingOrder)
-- end
2023-08-31 15:02:13 +08:00
end
--界面打开时调用(用于子类重写)
function WishGemBuyOnePanel:OnOpen(...)
self.bg.gameObject:SetActive(false)
self.bg.gameObject:SetActive(true)
SoundManager.PlaySound(SoundConfig.UI_Siyuanzhen)
2023-09-01 18:04:52 +08:00
this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.Gem })
2023-08-31 15:02:13 +08:00
local args = { ... }
this.drop=args[1]
this.recruitType=args[2]
2023-08-31 19:12:02 +08:00
activityId=args[4]
2023-08-31 15:02:13 +08:00
costId = args[3]
local str= ConfigManager.GetConfigData(ConfigName.SpecialConfig,costId).Value
str=StringToTable(str)
local d = RecruitManager.GetExpendDataByCostItem(str,1,100)
this.itemNum3.gameObject:SetActive(true)
this.itemIcon3.gameObject:SetActive(true)
this.itemInfo3.text="单次"
itemId=0
itemId = d[1]
itemNum = d[2]
this.itemIcon3.sprite=this.spLoader:LoadSprite(artResourcesConfig[ItemConfig[itemId].ResourceID].Name)
this.itemNum3.text= "×"..itemNum
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
2023-08-31 19:12:02 +08:00
2023-08-31 15:02:13 +08:00
end, 0.5)
time:Start()
2023-08-31 19:12:02 +08:00
end
function WishGemBuyOnePanel:OnShow()
local lv=0
2023-09-01 17:36:15 +08:00
local showLv = PlayerPrefs.GetInt(PlayerManager.uid.."newGem"..activityId)
2023-08-31 19:12:02 +08:00
local actconfigs=ActivityGiftManager.GetActivityInfoByType(activityId)
local progresss=0
if actconfigs then
for i = 1,#actconfigs.mission do
progresss=actconfigs.mission[i].progress
2023-09-01 12:34:34 +08:00
local config=ConfigManager.TryGetConfigData(ConfigName.GemLotteryConfig,actconfigs.mission[i].missionId) --ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.GemLotteryConfig,"Library",this.recruitType,"Level",actconfigs.mission[i].missionId)
2023-08-31 19:12:02 +08:00
if actconfigs.mission[i].state==0 and progresss>=config.LibraryNumber then
lv=config.Level
end
end
end
if lv>0 and lv>showLv then
2023-09-01 17:36:15 +08:00
CheckRedPointStatus(RedPointType.Gem_1)
CheckRedPointStatus(RedPointType.Gem_2)
PlayerPrefs.SetInt(PlayerManager.uid.."newGem"..activityId,lv)
2023-08-31 19:12:02 +08:00
UIManager.OpenPanel(UIName.GemBoxLvUpPopup,lv)
end
2023-08-31 15:02:13 +08:00
end
2023-08-31 19:12:02 +08:00
2023-08-31 15:02:13 +08:00
--界面关闭时调用(用于子类重写)
function WishGemBuyOnePanel:OnClose()
2023-09-01 12:34:34 +08:00
--LogError("单抽界面关闭------------------------------------")
--Game.GlobalEvent:DispatchEvent(GameEvent.Gem.RefreshPanel)
2023-08-31 15:02:13 +08:00
end
--界面销毁时调用(用于子类重写)
function WishGemBuyOnePanel:OnDestroy()
this.spLoader:Destroy()
SubUIManager.Close(this.UpView)
2023-10-28 15:41:17 +08:00
if this.view then
this.view = nil
end
2023-08-31 15:02:13 +08:00
if this.timer then
this.timer:Stop()
this.timer = nil
end
end
2023-08-31 19:12:02 +08:00
2023-08-31 15:02:13 +08:00
return WishGemBuyOnePanel