miduo_client/Assets/ManagedResources/~Lua/Modules/Popup/RewardItemPopup.lua

519 lines
21 KiB
Lua

require("Base/BasePanel")
RewardItemPopup = Inherit(BasePanel)
local this = RewardItemPopup
local userLevelData = ConfigManager.GetConfig(ConfigName.PlayerLevelConfig)
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
local itemListPrefab
local itemListPrefabMax
local func
local bagType=0 --1 正常背包 2 临时背包 3 公会车迟显示
--需要显示的小组件类型
-- 1 -- > 界面显示升级
-- 2 -- > 显示地图自由探索按钮
local compShowType = 0
local sortingOrderNum = 0
local callList = Stack.New()
local isPopGetSSR = false
local isOpenGeiSSRAvtivity = 0--五星成长礼拍脸
local isOpenGeiSSRAvtivityTime
local isPlayerAniEnd = true
local itemDataList
local showHero = 1
--初始化组件(用于子类重写)
--此界面无奈做了两套显示逻辑一个是掉落小于等于25时背景根据元素数量做拉伸状态 另一个是元素大于25做界面做可滑动
function RewardItemPopup:InitComponent()
this.btnBack = Util.GetGameObject(self.gameObject, "btnBack")
this.dropPrefab = Util.GetGameObject(self.gameObject, "frame")
--第一种显示
this.ScrollView = Util.GetGameObject(self.gameObject, "ScrollView")
this.dropGrid= Util.GetGameObject(self.gameObject, "ScrollView/Content")
itemListPrefab = {}
for i = 1, 10 do --初始缓存10个
local view = SubUIManager.Open(SubUIConfig.ItemView, this.dropGrid.transform)
view.gameObject.name = "frame"..i
itemListPrefab[i] = view
end
--关卡等级经验
this.lvAndExpGo=Util.GetGameObject(self.gameObject, "ScrollView/Content/bg/lvAndExpGo")
this.lv=Util.GetGameObject(self.gameObject, "ScrollView/Content/bg/lvAndExpGo/lv"):GetComponent("Text")
this.exp=Util.GetGameObject(self.gameObject, "ScrollView/Content/bg/lvAndExpGo/exp"):GetComponent("Slider")
this.expText=Util.GetGameObject(self.gameObject, "ScrollView/Content/bg/lvAndExpGo/exp/Text"):GetComponent("Text")
this.lvUpImage=Util.GetGameObject(self.gameObject, "ScrollView/Content/bg/lvAndExpGo/lvUpImage")
-- 地图探索按钮
this.btnMapBack = Util.GetGameObject(self.gameObject, "ScrollView/Content/bg/btnBack")
-- 战斗结果按钮
this.btnResult = Util.GetGameObject(self.gameObject, "ScrollView/Content/bg/btnResult")
-- 任意位置继续
this.btnGoOn = Util.GetGameObject(self.gameObject, "btnBack/Image")
--第二种显示当超过25个元素时
this.ScrollView2 = Util.GetGameObject(self.gameObject, "bg")
this.dropGridMax= Util.GetGameObject(self.gameObject, "bg/ScrollView2/ScrollView2/Content")
itemListPrefabMax = {}
for i = 1, 25 do --初始缓存10个
local view = SubUIManager.Open(SubUIConfig.ItemView, this.dropGridMax.transform)
view.gameObject.name = "frame"..i
itemListPrefabMax[i] = view
end
this.lvAndExpGoMax=Util.GetGameObject(self.gameObject, "bg/lvAndExpGo")
this.lvMax=Util.GetGameObject(self.gameObject, "bg/lvAndExpGo/lv"):GetComponent("Text")
this.expMax=Util.GetGameObject(self.gameObject, "bg/lvAndExpGo/exp"):GetComponent("Slider")
this.expTextMax=Util.GetGameObject(self.gameObject, "bg/lvAndExpGo/exp/Text"):GetComponent("Text")
this.lvUpImageMax=Util.GetGameObject(self.gameObject, "bg/lvAndExpGo/lvUpImage")
-- 战斗结果按钮
this.btnResultMax = Util.GetGameObject(self.gameObject, "bg/btnResult")
this.btnMapBackMax = Util.GetGameObject(self.gameObject, "bg/btnBack")
--车迟斗法 显示
this.guildCarDelay = Util.GetGameObject(self.gameObject, "ScrollView/Content/bg/guildCarDelay")
this.guildCarDelaysoreNum = Util.GetGameObject(this.guildCarDelay.gameObject, "soreNum"):GetComponent("Text")
this.guildCarDelayhurtNum = Util.GetGameObject(this.guildCarDelay.gameObject, "hurtNum"):GetComponent("Text")
--公会十绝阵显示
this.guildDeathPos=Util.GetGameObject(self.gameObject,"ScrollView/Content/bg/guildDeathPos")
this.guildDeathPos_CurScore=Util.GetGameObject(this.guildDeathPos,"curScore/num"):GetComponent("Text")
this.guildDeathPos_State=Util.GetGameObject(this.guildDeathPos,"curScore/state"):GetComponent("Image")
this.guildDeathPos_MaxScore=Util.GetGameObject(this.guildDeathPos,"maxScore/num"):GetComponent("Text")
--大闹天功显示
this.expeditionGo=Util.GetGameObject(self.gameObject,"ScrollView/Content/bg/expeditionGo")
--公会副本
this.guildTranscript=Util.GetGameObject(self.gameObject,"ScrollView/Content/bg/guildTranscript")
this.guildTranscript_CurScore=Util.GetGameObject(this.guildTranscript,"curScore/num"):GetComponent("Text")
end
--绑定事件(用于子类重写)
function RewardItemPopup:BindEvent()
Util.AddClick(this.btnBack, function()
if isPlayerAniEnd then
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
self:ClosePanel()
end
end)
Util.AddClick(this.btnMapBack, function ()
self:ClosePanel()
end)
Util.AddClick(this.btnMapBackMax, function ()
self:ClosePanel()
end)
Util.AddClick(this.btnResult, function ()
UIManager.OpenPanel(UIName.DamageResultPanel, 1)
end)
Util.AddClick(this.btnResultMax, function ()
UIManager.OpenPanel(UIName.DamageResultPanel, 1)
end)
end
--界面打开时调用(用于子类重写)
--bagType 1 正常背包 2 地图临时背包
--drop 后端掉落原始数据
--func 回调
function RewardItemPopup:OnOpen(...)
isPlayerAniEnd = true
isOpenGeiSSRAvtivity = 0
sortingOrderNum = self.sortingOrder
local args = {...}
local drop = args[1]
bagType=args[2]
func = args[3]
if args[4] then
compShowType = args[4]
end
if args[7] then
showHero = false
else
showHero = true
end
local haveRecord = BattleRecordManager.isHaveRecord()
this.btnResult:SetActive(haveRecord and args[5])
this.btnResultMax:SetActive(haveRecord and args[5])
-- 设置背景遮罩的显隐
local isHideBG = args[6]
this.btnBack:GetComponent("Image").color = Color.New(0, 0, 0, isHideBG and 0 or 0.8)
this.btnGoOn:SetActive(not isHideBG)
if not drop then
this.GuildCarDelayShow()
this.guildCarDelay:SetActive(compShowType == 3)
for i = 1, #itemListPrefab do
itemListPrefab[i].gameObject:SetActive(false)
end
return
end
this.expeditionGo:SetActive(compShowType == 5)
this.guildDeathPos:SetActive(compShowType == 4)
this.guildTranscript:SetActive(compShowType == 6)
if compShowType == 4 then
this.GuildDeathPosShow()
end
if compShowType == 6 then
this.GuildTranscriptShow()
end
local starItemDataList=BagManager.GetItemListFromTempBag(drop)
-- LogError("获取宝物的数量:".. LengthOfTable(starItemDataList))
--做装备叠加特殊组拼数据
local equips = {}
for i = 1, #starItemDataList do
this.SetItemData2(starItemDataList[i])
if starItemDataList[i].itemType == 2 then--装备叠加
if equips[starItemDataList[i].sId] then
equips[starItemDataList[i].sId].num = equips[starItemDataList[i].sId].num + 1
else
equips[starItemDataList[i].sId] = starItemDataList[i]
equips[starItemDataList[i].sId].num = 1
end
end
end
itemDataList = {}
for i, v in pairs(equips) do
table.insert(itemDataList, v)
end
for i, v in pairs(starItemDataList) do
if starItemDataList[i].itemType ~= 2 then
table.insert(itemDataList, v)
end
end
this.SetComPShowState(compShowType)
if #itemDataList < 1 then
self:ClosePanel()
self:SelectCanPopUpBagMaxMessage()
elseif #itemDataList <= 25 then
self:SetItemShow(drop)
elseif #itemDataList > 25 then
self:SetItemShowMax(drop)
end
SoundManager.PlaySound(SoundConfig.Sound_Reward)
this.ShowLvAndExp()
self:SelectCanPopUpBagMaxMessage()
end
--一些元素的显隐
function this.SetComPShowState(type)
this.btnBack:GetComponent("Button").enabled = type ~= 2
this.ScrollView:SetActive(#itemDataList <= 25 )
this.ScrollView2:SetActive(#itemDataList > 25 )
this.lvAndExpGo:SetActive(type == 1)
this.btnMapBack:SetActive(type == 2)
this.lvAndExpGoMax:SetActive(type == 1)
this.btnMapBackMax:SetActive(type == 2)
this.btnMapBackMax:SetActive(type == 2)
this.guildCarDelay:SetActive(type == 3)
this.guildDeathPos:SetActive(type == 4)
this.guildTranscript:SetActive(type == 6)
end
function this.GuildCarDelayShow()
if GuildCarDelayManager.score and GuildCarDelayManager.hurt then
this.guildCarDelaysoreNum.text =GuildCarDelayManager.score
this.guildCarDelayhurtNum.text = GuildCarDelayManager.hurt
end
end
--十绝阵 挑战奖励掉落弹窗表现
function this.GuildDeathPosShow()
if DeathPosManager.damage and DeathPosManager.historyMax then
this.guildDeathPos_CurScore.text =DeathPosManager.damage
this.guildDeathPos_MaxScore.text = DeathPosManager.historyMax
local b=DeathPosManager.damage>DeathPosManager.historyMax or DeathPosManager.damage<DeathPosManager.historyMax
this.guildDeathPos_State.gameObject:SetActive(b)
if DeathPosManager.damage>DeathPosManager.historyMax then
this.guildDeathPos_State.sprite=Util.LoadSprite("r_hero_zhanlishangsheng_png")
elseif DeathPosManager.damage<DeathPosManager.historyMax then
this.guildDeathPos_State.sprite=Util.LoadSprite("r_hero_zhanlixiajiang_png")
end
end
end
--公会副本
function this.GuildTranscriptShow()
if GuildTranscriptManager.damage then
this.guildTranscript_CurScore.text = GuildTranscriptManager.damage
end
end
--当前背包是否已满
function RewardItemPopup:SelectCanPopUpBagMaxMessage()
if(IndicationManager.canPopUpBagMaxMessage) then
PopupTipPanel.ShowTip(Language[11590])
IndicationManager.canPopUpBagMaxMessage=false
elseif(IndicationManager.getRewardFromMailMessage)then
PopupTipPanel.ShowTip(Language[11591])
IndicationManager.getRewardFromMailMessage=false
end
end
function RewardItemPopup:OnSortingOrderChange()
if not itemDataList then
return
end
for i = 1, #itemListPrefab do
local view = itemListPrefab[i]
local curItemData=itemDataList[i]
view:OnOpen(true,curItemData,1.15,true,true,false,self.sortingOrder)
end
for i = 1, #itemListPrefabMax do
local view = itemListPrefabMax[i]
local curItemData=itemDataList[i]
view:OnOpen(true,curItemData,1.15,true,true,false,self.sortingOrder)
end
end
-- 根据物品列表数据显示物品
function RewardItemPopup:SetItemShow(drop)
BagManager.OnShowTipDropNumZero(drop)
if drop==nil then return end
for i = 1, #itemDataList do
itemDataList[i].itemConfig = itemConfig[itemDataList[i].sId]
end
self:ItemDataListSort(itemDataList)
for i = 1, math.max(#itemDataList, #itemListPrefab) do
local go = itemListPrefab[i]
if not go then
go = SubUIManager.Open(SubUIConfig.ItemView, this.dropGrid.transform)
go.gameObject.name = "frame"..i
itemListPrefab[i] = go
end
go.gameObject:SetActive(false)
end
callList:Clear()
callList:Push(function ()
if isOpenGeiSSRAvtivityTime then
isOpenGeiSSRAvtivityTime:Stop()
isOpenGeiSSRAvtivityTime = nil
end
isOpenGeiSSRAvtivityTime = Timer.New(function ()
isPlayerAniEnd = true
if isOpenGeiSSRAvtivity > 0 then
HeroManager.DetectionOpenFiveStarActivity(isOpenGeiSSRAvtivity)
end
end, 0.5):Start()
--在关卡界面获得装备 刷新下btview成员红点
-- Game.GlobalEvent:DispatchEvent(GameEvent.Equip.EquipChange)
end)
for i = #itemDataList, 1, -1 do
isPlayerAniEnd = false
local view = itemListPrefab[i]
local curItemData=itemDataList[i]
view:OnOpen(true,curItemData,1.15,true,true,false,self.sortingOrder)
--view.gameObject:SetActive(false)
callList:Push(function ()
local func = function()
view.gameObject:SetActive(true)
local btn = Util.GetGameObject(view.gameObject, "item/frame"):GetComponent("Button")
btn.enabled = false
PlayUIAnim(view.gameObject, function()
btn.enabled = true
end)
--改为后端更新
--this.SetItemData2(itemDataList[i])
Timer.New(function ()
isPopGetSSR = false
callList:Pop()()
end, 0.05):Start()
end
if curItemData.configData and curItemData.itemType==3 and curItemData.configData.Quality == 5 and showHero then
isPopGetSSR = true
isOpenGeiSSRAvtivity = curItemData.configData.Star
UIManager.OpenPanel(UIName.DropGetSSRHeroShopPanel,curItemData.backData, func)
elseif curItemData.configData and curItemData.itemType==1 and
(curItemData.configData.ItemType == ItemType.Title or curItemData.configData.ItemType == ItemType.Ride or
curItemData.configData.ItemType == ItemType.Skin) then--皮肤 坐骑
isPopGetSSR = true
UIManager.OpenPanel(UIName.DropGetPlayerDecorateShopPanel,curItemData.backData, func)
else
func()
end
end)
end
callList:Pop()()
end
-- 根据物品列表数据显示物品
function RewardItemPopup:SetItemShowMax(drop)
BagManager.OnShowTipDropNumZero(drop)
if drop==nil then return end
for i = 1, #itemDataList do
itemDataList[i].itemConfig = itemConfig[itemDataList[i].sId]
end
self:ItemDataListSort(itemDataList)
for i = 1, math.max(#itemDataList, #itemListPrefabMax) do
local go = itemListPrefabMax[i]
if not go then
go = SubUIManager.Open(SubUIConfig.ItemView, this.dropGridMax.transform)
go.gameObject.name = "frame"..i
itemListPrefabMax[i] = go
end
go.gameObject:SetActive(false)
end
callList:Clear()
callList:Push(function ()
if isOpenGeiSSRAvtivityTime then
isOpenGeiSSRAvtivityTime:Stop()
isOpenGeiSSRAvtivityTime = nil
end
isOpenGeiSSRAvtivityTime = Timer.New(function ()
isPlayerAniEnd = true
if isOpenGeiSSRAvtivity > 0 then
HeroManager.DetectionOpenFiveStarActivity(isOpenGeiSSRAvtivity)
end
end, 0.5):Start()
isPlayerAniEnd = true
if isOpenGeiSSRAvtivity > 0 then
HeroManager.DetectionOpenFiveStarActivity(isOpenGeiSSRAvtivity)
end
--在关卡界面获得装备 刷新下btview成员红点
-- Game.GlobalEvent:DispatchEvent(GameEvent.Equip.EquipChange)
end)
for i = #itemDataList, 1, -1 do
isPlayerAniEnd = false
local view = itemListPrefabMax[i]
local curItemData=itemDataList[i]
view:OnOpen(true,curItemData,1.15,true,true,false,self.sortingOrder)
--view.gameObject:SetActive(false)
callList:Push(function ()
local func = function()
view.gameObject:SetActive(true)
local btn = Util.GetGameObject(view.gameObject, "item/frame"):GetComponent("Button")
btn.enabled = false
PlayUIAnim(view.gameObject, function()
btn.enabled = true
end)
--改为后端更新
--this.SetItemData2(itemDataList[i])
if i <= 25 then
Timer.New(function ()
isPopGetSSR = false
callList:Pop()()
end, 0.05):Start()
else
isPopGetSSR = false
callList:Pop()()
end
end
if curItemData.configData and curItemData.itemType==3 and curItemData.configData.Quality == 5 and showHero then--五星英雄
isPopGetSSR = true
isOpenGeiSSRAvtivity = curItemData.configData.Star
UIManager.OpenPanel(UIName.DropGetSSRHeroShopPanel,curItemData.backData, func)
elseif curItemData.configData and curItemData.itemType==1 and
(curItemData.configData.ItemType == ItemType.Title or curItemData.configData.ItemType == ItemType.Ride or
curItemData.configData.ItemType == ItemType.Skin) then--皮肤 坐骑
isPopGetSSR = true
UIManager.OpenPanel(UIName.DropGetPlayerDecorateShopPanel,curItemData.backData, func)
else
func()
end
end)
end
callList:Pop()()
end
--存储本地
function this.SetItemData2(itemdata)
if itemdata.itemType==1 then
--后端更新
elseif itemdata.itemType==2 then
if bagType==1 then
EquipManager.UpdateEquipData(itemdata.backData)
elseif bagType==2 then
EquipManager.InitMapShotTimeEquipBagData(itemdata.backData)
end
elseif itemdata.itemType==3 then
if bagType==1 then
HeroManager.UpdateHeroDatas(itemdata.backData)
elseif bagType==2 then
HeroManager.InitMapShotTimeHeroBagData(itemdata.backData)
end
elseif itemdata.itemType==4 then
if bagType==1 then
TalismanManager.InitUpdateSingleTalismanData(itemdata.backData)
elseif bagType==2 then
TalismanManager.InitMapShotTimeTalismanBagData(itemdata.backData)
end
elseif itemdata.itemType==5 then
if bagType==1 then
--SoulPrintManager.InitServerData(itemdata.data)
EquipTreasureManager.InitSingleTreasureData(itemdata.backData)
elseif bagType==2 then
--SoulPrintManager.InitMapShotTimeSoulPrintBagData(itemdata.backData)
--SoulPrintManager.StoreData(itemdata.data)
end
end
end
--关卡通关掉落时展示经验等级信息
function this.ShowLvAndExp()
--this.lvAndExpGo:SetActive(compShowType == 1)
if compShowType == 1 then
if #itemDataList <= 25 then
this.exp.value=PlayerManager.exp/userLevelData[PlayerManager.level].Exp
this.expText.text=PlayerManager.exp.."/"..userLevelData[PlayerManager.level].Exp
this.lv.text="LV."..PlayerManager.level
this.lvUpImage:SetActive(FightPointPassManager.oldLevel<PlayerManager.level)
elseif #itemDataList > 25 then
this.expMax.value=PlayerManager.exp/userLevelData[PlayerManager.level].Exp
this.expTextMax.text=PlayerManager.exp.."/"..userLevelData[PlayerManager.level].Exp
this.lvMax.text="LV."..PlayerManager.level
this.lvUpImageMax:SetActive(FightPointPassManager.oldLevel<PlayerManager.level)
end
end
end
--掉落物品排序
function RewardItemPopup:ItemDataListSort(itemDataList)
table.sort(itemDataList, function(a, b)
if a.itemConfig.Quantity == b.itemConfig.Quantity then
if a.itemConfig.ItemType == b.itemConfig.ItemType then
return a.itemConfig.Id < b.itemConfig.Id
else
return a.itemConfig.ItemType < b.itemConfig.ItemType
end
else
return a.itemConfig.Quantity > b.itemConfig.Quantity
end
end)
end
--界面关闭时调用(用于子类重写)
function RewardItemPopup:OnClose()
BagManager.SetDropIsSHowEquipPrint(true)
local fightConFigData = ConfigManager.GetConfigData(ConfigName.MainLevelConfig, FightPointPassManager.curOpenFight)
if compShowType == 1 then
compShowType = 0
if FightPointPassManager.oldLevel<PlayerManager.level then
if fightConFigData and fightConFigData.PicShow == 1 and FightPointPassManager.isOpenNewChapter then
UIManager.OpenPanel(UIName.FightEndLvUpPanel,FightPointPassManager.oldLevel,PlayerManager.level,function ()
func()
end)
else
UIManager.OpenPanel(UIName.FightEndLvUpPanel,FightPointPassManager.oldLevel,PlayerManager.level,func)
end
return
end
end
compShowType = 0
if func and not isPopGetSSR then
if fightConFigData and fightConFigData.PicShow == 1 and FightPointPassManager.isOpenNewChapter then
func()
else
func()
end
end
-- 展示完以后结束章节解锁状态
FightPointPassManager.isOpenNewChapter = false
if isOpenGeiSSRAvtivityTime then
isOpenGeiSSRAvtivityTime:Stop()
isOpenGeiSSRAvtivityTime = nil
end
--检测是否需要弹每日任务飘窗
TaskManager.RefreshShowDailyMissionTipPanel()
end
--界面销毁时调用(用于子类重写)
function RewardItemPopup:OnDestroy()
itemListPrefab = {}
end
return RewardItemPopup