2025-03-14 11:58:20 +08:00
|
|
|
|
require("Base/BasePanel")
|
2020-11-11 16:53:04 +08:00
|
|
|
|
LingShouBaoGeOneResultPanel = Inherit(BasePanel)
|
2024-09-06 10:38:56 +08:00
|
|
|
|
local this = LingShouBaoGeOneResultPanel
|
2020-11-11 16:53:04 +08:00
|
|
|
|
local ItemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
|
|
|
|
|
|
local lotterySetting = ConfigManager.GetConfig(ConfigName.LotterySetting)
|
2024-09-06 10:38:56 +08:00
|
|
|
|
local privilegeConfig = ConfigManager.GetConfig(ConfigName.PrivilegeTypeConfig)
|
|
|
|
|
|
local artResourcesConfig = ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
|
|
|
|
|
|
local itemNum = 0 --抽卡小号道具数量
|
|
|
|
|
|
local isFree = false
|
2020-11-11 16:53:04 +08:00
|
|
|
|
local itemId = 0
|
|
|
|
|
|
local RecruitMaxtimesId = 0
|
|
|
|
|
|
local freeTimesId = 0
|
|
|
|
|
|
local activityId = nil
|
|
|
|
|
|
local singleRecruit = nil
|
|
|
|
|
|
local tenRecruit = nil
|
2024-09-06 10:38:56 +08:00
|
|
|
|
local recType = {}
|
2020-11-11 16:53:04 +08:00
|
|
|
|
--活动抽卡类型(动态的数据)
|
2024-09-06 10:38:56 +08:00
|
|
|
|
local drawtType = {
|
|
|
|
|
|
FindFairySingle = 0,
|
2020-11-11 16:53:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
local orginLayer
|
|
|
|
|
|
local itemViewList = {}
|
|
|
|
|
|
--初始化组件(用于子类重写)
|
|
|
|
|
|
function LingShouBaoGeOneResultPanel:InitComponent()
|
2021-04-21 13:12:04 +08:00
|
|
|
|
this.spLoader = SpriteLoader.New()
|
2020-11-11 16:53:04 +08:00
|
|
|
|
orginLayer = 10
|
|
|
|
|
|
self.bg = Util.GetGameObject(self.gameObject, "effect")
|
2024-09-06 10:38:56 +08:00
|
|
|
|
this.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform,
|
|
|
|
|
|
{ showType = UpViewOpenType.ShowLeft, panelType = PanelType.LingShouBaoGe })
|
2020-11-11 16:53:04 +08:00
|
|
|
|
screenAdapte(self.bg)
|
2024-09-06 10:38:56 +08:00
|
|
|
|
this.btnBack = Util.GetGameObject(self.gameObject, "bottom/backButton")
|
|
|
|
|
|
this.openOneAgainButton = Util.GetGameObject(self.gameObject, "bottom/openOneAgainButton")
|
|
|
|
|
|
|
|
|
|
|
|
this.content3 = Util.GetGameObject(self.gameObject, "bottom/openOneAgainButton/Content3")
|
|
|
|
|
|
this.itemIcon3 = Util.GetGameObject(this.content3, "icon"):GetComponent("Image")
|
|
|
|
|
|
this.itemNum3 = Util.GetGameObject(this.content3, "num"):GetComponent("Text")
|
|
|
|
|
|
this.itemInfo3 = Util.GetGameObject(this.content3, "info"):GetComponent("Text")
|
|
|
|
|
|
this.tipText = Util.GetGameObject(this.openOneAgainButton, "Text"):GetComponent("Text")
|
|
|
|
|
|
this.content = Util.GetGameObject(self.gameObject, "content")
|
|
|
|
|
|
this.detailImage = Util.GetGameObject(self.gameObject, "Tip")
|
2020-11-11 16:53:04 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--绑定事件(用于子类重写)
|
|
|
|
|
|
function LingShouBaoGeOneResultPanel:BindEvent()
|
2024-09-06 10:38:56 +08:00
|
|
|
|
Util.AddClick(this.btnBack, function()
|
2020-11-11 16:53:04 +08:00
|
|
|
|
self:ClosePanel()
|
|
|
|
|
|
end)
|
2024-09-06 10:38:56 +08:00
|
|
|
|
Util.AddClick(this.openOneAgainButton, function()
|
2020-11-11 16:53:04 +08:00
|
|
|
|
--是否超过每日最大上限
|
2024-09-06 10:38:56 +08:00
|
|
|
|
local d = RecruitManager.GetExpendData(this.recruitType)
|
2020-11-11 16:53:04 +08:00
|
|
|
|
if PrivilegeManager.GetPrivilegeRemainValue(RecruitMaxtimesId) < 1 then
|
2024-08-29 21:36:51 +08:00
|
|
|
|
PopupTipPanel.ShowTip(Language[10587])
|
2020-11-11 16:53:04 +08:00
|
|
|
|
return
|
|
|
|
|
|
end
|
|
|
|
|
|
if not isFree then
|
|
|
|
|
|
if BagManager.GetItemCountById(itemId) < itemNum then
|
2024-09-06 10:38:56 +08:00
|
|
|
|
PopupTipPanel.ShowTip(GetLanguageStrById(ItemConfig[itemId].Name) .. Language[10584])
|
2020-11-11 16:53:04 +08:00
|
|
|
|
return
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
2020-12-29 14:24:45 +08:00
|
|
|
|
local recruitOne = function()
|
|
|
|
|
|
RecruitManager.RecruitRequest(this.recruitType, function(msg)
|
2024-09-06 10:38:56 +08:00
|
|
|
|
PrivilegeManager.RefreshPrivilegeUsedTimes(RecruitMaxtimesId, 1) --记录抽卡次数
|
|
|
|
|
|
UIManager.OpenPanel(UIName.PokemonSingleResultPanel, this.recruitType, msg.drop, activityId, recType)
|
|
|
|
|
|
end, freeTimesId, itemId, itemNum)
|
2020-12-29 14:24:45 +08:00
|
|
|
|
end
|
2024-09-06 10:38:56 +08:00
|
|
|
|
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, recruitOne)
|
2020-12-29 14:24:45 +08:00
|
|
|
|
else
|
|
|
|
|
|
recruitOne()
|
|
|
|
|
|
end
|
2020-11-11 16:53:04 +08:00
|
|
|
|
end)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--添加事件监听(用于子类重写)
|
|
|
|
|
|
function LingShouBaoGeOneResultPanel:AddListener()
|
|
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--移除事件监听(用于子类重写)
|
|
|
|
|
|
function LingShouBaoGeOneResultPanel:RemoveListener()
|
|
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function LingShouBaoGeOneResultPanel:OnSortingOrderChange()
|
|
|
|
|
|
Util.AddParticleSortLayer(self.bg, self.sortingOrder - orginLayer)
|
|
|
|
|
|
orginLayer = self.sortingOrder
|
|
|
|
|
|
if this.view then
|
2024-09-06 10:38:56 +08:00
|
|
|
|
this.view:OnOpen(true, this.itemDataList[1], 1.4, true, false, false, self.sortingOrder)
|
2020-11-11 16:53:04 +08:00
|
|
|
|
end
|
|
|
|
|
|
end
|
2024-09-06 10:38:56 +08:00
|
|
|
|
|
2020-11-11 16:53:04 +08:00
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
|
|
|
|
function LingShouBaoGeOneResultPanel:OnOpen(...)
|
2024-09-06 10:38:56 +08:00
|
|
|
|
this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.LingShouBaoGe })
|
2020-11-11 16:53:04 +08:00
|
|
|
|
local args = { ... }
|
2024-09-06 10:38:56 +08:00
|
|
|
|
this.drop = args[1]
|
2020-11-11 16:53:04 +08:00
|
|
|
|
this.recruitType = args[2]
|
|
|
|
|
|
activityId = args[3]
|
2020-12-29 14:24:45 +08:00
|
|
|
|
recType = args[4]
|
2020-11-11 16:53:04 +08:00
|
|
|
|
this.detailImage:SetActive(false)
|
|
|
|
|
|
this.content3:SetActive(true)
|
|
|
|
|
|
--获取免费次数
|
2024-09-06 10:38:56 +08:00
|
|
|
|
local array = ConfigManager.GetAllConfigsDataByKey(ConfigName.LotterySetting, "ActivityId", activityId)
|
2020-11-11 16:53:04 +08:00
|
|
|
|
singleRecruit = array[1]
|
|
|
|
|
|
tenRecruit = array[2]
|
2024-09-06 10:38:56 +08:00
|
|
|
|
local currLottery = ConfigManager.GetConfigData(ConfigName.LotterySetting, singleRecruit.Id)
|
|
|
|
|
|
freeTimesId = currLottery.FreeTimes
|
2020-11-11 16:53:04 +08:00
|
|
|
|
RecruitMaxtimesId = currLottery.MaxTimes
|
2024-09-06 10:38:56 +08:00
|
|
|
|
local curTimes = PrivilegeManager.GetPrivilegeRemainValue(currLottery.MoneyTimes)
|
|
|
|
|
|
local freeTime = 0
|
|
|
|
|
|
if freeTimesId > 0 then
|
|
|
|
|
|
freeTime = PrivilegeManager.GetPrivilegeRemainValue(freeTimesId)
|
2020-11-11 16:53:04 +08:00
|
|
|
|
RecruitManager.freeUseTimeList[freeTimesId] = freeTime
|
|
|
|
|
|
end
|
2024-09-06 10:38:56 +08:00
|
|
|
|
isFree = freeTime and freeTime >= 1
|
2020-11-11 16:53:04 +08:00
|
|
|
|
if isFree then
|
|
|
|
|
|
this.itemNum3.gameObject:SetActive(false)
|
|
|
|
|
|
this.itemIcon3.gameObject:SetActive(false)
|
2024-09-06 10:38:56 +08:00
|
|
|
|
this.itemInfo3.text = Language[10588]
|
2020-11-11 16:53:04 +08:00
|
|
|
|
this.tipText.gameObject:SetActive(false)
|
|
|
|
|
|
else
|
|
|
|
|
|
this.itemNum3.gameObject:SetActive(true)
|
|
|
|
|
|
this.itemIcon3.gameObject:SetActive(true)
|
2024-09-06 10:38:56 +08:00
|
|
|
|
this.itemInfo3.text = Language[10589]
|
|
|
|
|
|
itemId = 0
|
|
|
|
|
|
local d = RecruitManager.GetExpendDataByCostItem(currLottery.CostItem, 1, curTimes)
|
2020-11-11 16:53:04 +08:00
|
|
|
|
itemId = d[1]
|
|
|
|
|
|
itemNum = d[2]
|
2024-09-06 10:38:56 +08:00
|
|
|
|
if itemId == 16 then
|
|
|
|
|
|
RecruitMaxtimesId = currLottery.MoneyTimes
|
2022-08-04 16:40:37 +08:00
|
|
|
|
end
|
2020-11-11 16:53:04 +08:00
|
|
|
|
this.tipText.gameObject:SetActive(false)
|
2024-09-06 10:38:56 +08:00
|
|
|
|
this.itemIcon3.sprite = this.spLoader:LoadSprite(artResourcesConfig[ItemConfig[itemId].ResourceID].Name)
|
|
|
|
|
|
this.itemNum3.text = "×" .. itemNum
|
2020-11-11 16:53:04 +08:00
|
|
|
|
end
|
|
|
|
|
|
this.itemDataList = {}
|
|
|
|
|
|
this.itemDataList = BagManager.GetTableByBackDropData(this.drop)
|
|
|
|
|
|
|
|
|
|
|
|
if not itemViewList then
|
|
|
|
|
|
itemViewList = {}
|
2024-09-06 10:38:56 +08:00
|
|
|
|
end
|
|
|
|
|
|
for k, v in pairs(itemViewList) do
|
2020-11-11 16:53:04 +08:00
|
|
|
|
v.gameObject:SetActive(false)
|
|
|
|
|
|
end
|
|
|
|
|
|
for i = 1, #this.itemDataList do
|
|
|
|
|
|
if not itemViewList[i] then
|
2024-09-06 10:38:56 +08:00
|
|
|
|
Util.GetTransform(this.content, "itemContent" .. i).gameObject:SetActive(true)
|
|
|
|
|
|
itemViewList[i] = SubUIManager.Open(SubUIConfig.ItemView, Util.GetTransform(this.content, "itemContent" .. i))
|
|
|
|
|
|
end
|
2020-11-11 16:53:04 +08:00
|
|
|
|
itemViewList[i].gameObject:SetActive(true)
|
2024-09-06 10:38:56 +08:00
|
|
|
|
itemViewList[i]:OnOpen(true, this.itemDataList[i], 1.4, true, false, false, self.sortingOrder)
|
2020-11-11 16:53:04 +08:00
|
|
|
|
end
|
|
|
|
|
|
end
|
2024-09-06 10:38:56 +08:00
|
|
|
|
|
2020-11-11 16:53:04 +08:00
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
|
|
|
|
function LingShouBaoGeOneResultPanel:OnClose()
|
|
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
|
|
|
|
function LingShouBaoGeOneResultPanel:OnDestroy()
|
2021-04-21 13:12:04 +08:00
|
|
|
|
this.spLoader:Destroy()
|
2020-11-11 16:53:04 +08:00
|
|
|
|
SubUIManager.Close(this.UpView)
|
|
|
|
|
|
this.view = nil
|
|
|
|
|
|
itemViewList = {}
|
|
|
|
|
|
end
|
|
|
|
|
|
|
2024-09-06 10:38:56 +08:00
|
|
|
|
return LingShouBaoGeOneResultPanel
|