require("Base/BasePanel") RewardItemPopup = Inherit(BasePanel) local this = RewardItemPopup local userLevelData = ConfigManager.GetConfig(ConfigName.PlayerLevelConfig) local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig) local HardStageCondition = ConfigManager.GetConfig(ConfigName.HardStageCondition) local itemListPrefab = {} -- local itemListPrefabMax local func local bagType=0 --1 正常背包 2 临时背包 3 公会车迟显示 --需要显示的小组件类型 -- 1 -- > 界面显示升级 -- 2 -- > 显示地图自由探索按钮 local compShowType = 0 local sortingOrder = 0 local callList = Stack.New() local isPopGetSSR = false local isOpenGeiSSRAvtivity = 0--五星成长礼拍脸 local isOpenGeiSSRAvtivityTime local isPlayerAniEnd = true local itemDataList local showHero = 1 local isBackBattle = false local conditionGo = {} local starListEffect = {} --初始化组件(用于子类重写) --此界面无奈做了两套显示逻辑一个是掉落小于等于25时背景根据元素数量做拉伸状态 另一个是元素大于25做界面做可滑动 function RewardItemPopup:InitComponent() this.spLoader = SpriteLoader.New() 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/grid") this.dropGridArena= Util.GetGameObject(self.gameObject, "ScrollView/Content/grid2") this.dropGrid2= Util.GetGameObject(self.gameObject, "ScrollView/Content/grid2/scorll/grid") --关卡等级经验 this.lvAndExpGo=Util.GetGameObject(self.gameObject, "ScrollView/Content/bottom/grid/lvAndExpGo") this.lv=Util.GetGameObject(self.gameObject, "ScrollView/Content/bottom/grid/lvAndExpGo/lv"):GetComponent("Text") this.exp=Util.GetGameObject(self.gameObject, "ScrollView/Content/bottom/grid/lvAndExpGo/exp"):GetComponent("Slider") this.expText=Util.GetGameObject(self.gameObject, "ScrollView/Content/bottom/grid/lvAndExpGo/exp/Text"):GetComponent("Text") this.lvUpImage=Util.GetGameObject(self.gameObject, "ScrollView/Content/bottom/grid/lvAndExpGo/lvUpImage") -- 战斗结果按钮 this.btnResult = Util.GetGameObject(self.gameObject, "ScrollView/Content/bottom/grid/Btns/btnResult") this.btnBattleBack = Util.GetGameObject(self.gameObject, "ScrollView/Content/bottom/grid/Btns/btnBattleBack") -- 战斗回放按钮 --车迟斗法 显示 this.guildCarDelay = Util.GetGameObject(self.gameObject, "ScrollView/Content/Show/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/Show/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/Show/expeditionGo") --公会副本 this.guildTranscript=Util.GetGameObject(self.gameObject,"ScrollView/Content/Show/guildTranscript") this.guildTranscript_CurScore=Util.GetGameObject(this.guildTranscript,"curScore/num"):GetComponent("Text") this.shenying = Util.GetGameObject(self.gameObject, "shenying") this.shenying.gameObject:SetActive(false) this.shenyingTxt = Util.GetGameObject(this.shenying , "Content/bg/Text"):GetComponent("Text") --踏碎凌霄 this.tasuilingxiao=Util.GetGameObject(self.gameObject,"ScrollView/Content/Show/tasuilingxiao") this.tasuilingxiao_CurScore=Util.GetGameObject(this.tasuilingxiao,"curScore/num"):GetComponent("Text") this.tasuilingxiao_State=Util.GetGameObject(this.tasuilingxiao,"curScore/state"):GetComponent("Image") this.tasuilingxiao_MaxScore=Util.GetGameObject(this.tasuilingxiao,"maxScore/num"):GetComponent("Text") this.noRewardText = Util.GetGameObject(this.tasuilingxiao,"Text") --山河社稷图主 this.GXHD=Util.GetGameObject(self.gameObject,"ScrollView/Content/bg/Image") this.FightLevel2=Util.GetGameObject(self.gameObject,"ScrollView/Content/Show/FightLevel") this.FightLevel3=Util.GetGameObject(self.gameObject,"FightLevel3") --山河社稷图副关卡 this.FightLevelAssistant=Util.GetGameObject(self.gameObject,"ScrollView/Content/Show/FightLevelAssistant") starListEffect = {} this.Root=Util.GetGameObject(self.gameObject,"FightLevel3/Root") for i = 1, 3 do conditionGo[i] = Util.GetGameObject(this.FightLevel3, "Root/item (" .. i ..")") starListEffect[i] = Util.GetGameObject(this.FightLevel3, "isFirst/Fx_star_looping (" .. i ..")") end this.isFirstEffect = Util.GetGameObject(this.FightLevel3,"isFirst") --七界试炼挑战条件信息 this.qiJieCondition = Util.GetGameObject(self.gameObject, "ScrollView/Content/bottom/grid/qiJieInfo") end --绑定事件(用于子类重写) function RewardItemPopup:BindEvent() Util.AddClick(this.btnBack, function() if isPlayerAniEnd then PlaySoundWithoutClick(SoundConfig.Sound_UICancel) self:ClosePanel() if PlayerManager.IsGetFiveStarHero then--and OperatingManager.IsShowFiveStarPatch then Game.GlobalEvent:DispatchEvent(GameEvent.PatFace.PatFaceSend, FacePanelType.GrowGift, 5) PlayerManager.IsGetFiveStarHero = false end end end) Util.AddClick(this.btnResult, function () UIManager.OpenPanel(UIName.DamageResultPanel, 1) end) Util.AddClick(this.btnBattleBack, function () isBackBattle = true BattleManager.BattleBackFun() end) end --界面打开时调用(用于子类重写) --bagType 1 正常背包 2 地图临时背包 --drop 后端掉落原始数据 --func 回调 function RewardItemPopup:OnOpen(...) if #itemListPrefab > 0 then for i = 1, #itemListPrefab do destroy(itemListPrefab[i].gameObject) end end itemListPrefab = {} itemDataList = {} isBackBattle = false isPlayerAniEnd = true isOpenGeiSSRAvtivity = 0 local args = {...} local drop = args[1] bagType=args[2] func = args[3] if args[4] then compShowType = args[4] or 0 end if args[7] then showHero = false else showHero = true end this.shenying.gameObject:SetActive(false) --如果没有compShowType和Drop--背包已满 if not args[4] and (not drop or (#drop.itemlist < 1 and #drop.equipId < 1 and #drop.Hero < 1 and #drop.soulEquip < 1 and #drop.pokemon < 1)) then LogGreen("掉落为空") self:ClosePanel() return end local haveRecord = BattleRecordManager.isHaveRecord() this.btnResult:SetActive(haveRecord and args[5]) this.btnBattleBack:SetActive(haveRecord and args[5] and BattleManager.GetLastBattleType() ~= BATTLE_TYPE.MAP_FIGHT and not GuideManager.IsInMainGuide() and not MapManager.Mapping and BattleManager.GetLastBattleType() ~= BATTLE_TYPE.TASUILINGXIAO) this.expeditionGo:SetActive(compShowType == 5) this.guildDeathPos:SetActive(compShowType == 4)--十绝阵 this.guildTranscript:SetActive(compShowType == 6) this.guildCarDelay:SetActive(compShowType == 3) this.expeditionGo:SetActive(compShowType == 5) this.shenying:SetActive(compShowType == CompShowType.fourElement) this.tasuilingxiao:SetActive(compShowType == 7)--踏碎凌霄 this.FightLevel3:SetActive(compShowType == 8)--山河社稷图 this.FightLevel2:SetActive(compShowType == 8 and (not drop or (#drop.itemlist < 1 and #drop.equipId < 1 and #drop.Hero < 1 and #drop.soulEquip < 1 and #drop.pokemon < 1)))--山河社稷图 this.FightLevelAssistant:SetActive(compShowType == 9)--山河社稷图 this.qiJieCondition:SetActive(compShowType == 10)--七界试炼 this.dropGrid:SetActive(false) this.dropGridArena:SetActive(false) this.lvAndExpGo:SetActive(compShowType == 1) -- 设置背景遮罩的显隐 local isHideBG = args[6] this.btnBack:GetComponent("Image").color = Color.New(0, 0, 0, isHideBG and 0 or 0.8) if compShowType == 3 then this.GuildCarDelayShow() this.guildCarDelay:SetActive(compShowType == 3) elseif compShowType == 4 then this.GuildDeathPosShow() elseif compShowType == 6 then this.GuildTranscriptShow() elseif compShowType == 7 then--踏碎凌霄 this.TaSuiLingXiaoShow() elseif compShowType == 8 then--山河社稷图 this.FightLevelShow() elseif compShowType == 10 then--七界试炼 this.QiJieShow() elseif compShowType == CompShowType.fourElement then this.ShengYingShow(args[8]) end --如果没有掉落就return if not drop or (#drop.itemlist < 1 and #drop.equipId < 1 and #drop.Hero < 1 and #drop.soulEquip < 1 and #drop.pokemon < 1) then return 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 CheckRedPointStatus(RedPointType.Huaxutan_CompoundHero) 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.InitGrid() if #itemDataList < 1 then self:ClosePanel() self:SelectCanPopUpBagMaxMessage() else self:SetItemShow(drop) end this.SetComPShowState(compShowType)--一些特殊显隐 SoundManager.PlaySound(SoundConfig.Sound_Reward) this.ShowLvAndExp() self:SelectCanPopUpBagMaxMessage() end function this.InitGrid() this.dropGrid:SetActive(#itemDataList <= 25 ) this.dropGridArena:SetActive(#itemDataList > 25 ) for i = 1, #itemListPrefab do itemListPrefab[i].gameObject:SetActive(false) end if #itemDataList <= 25 then for i = 1, #itemDataList do --初始缓存<= 20 if not itemListPrefab[i] then local view = SubUIManager.Open(SubUIConfig.ItemView, this.dropGrid.transform) view.gameObject.name = "frame"..i itemListPrefab[i] = view end end else for i = 1, #itemDataList do --初始缓存> 20 if not itemListPrefab[i] then local view = SubUIManager.Open(SubUIConfig.ItemView, this.dropGrid2.transform) view.gameObject.name = "frame"..i itemListPrefab[i] = view end end end end --一些元素的显隐 function this.SetComPShowState(type) this.btnBack:GetComponent("Button").enabled = type ~= 2 this.ScrollView:SetActive(#itemDataList >= 1 ) this.lvAndExpGo:SetActive(type == 1) this.guildCarDelay:SetActive(type == 3) this.guildDeathPos:SetActive(type == 4) this.guildTranscript:SetActive(type == 6) this.tasuilingxiao:SetActive(type == 7) if type == 7 then this.noRewardText:SetActive(#itemDataList < 1) end end function this.ShengYingShow(propertyId) this.ScrollView.gameObject:SetActive(false) this.dropPrefab.gameObject:SetActive(false) this.shenying.gameObject:SetActive(true) LogGreen("propertyId:"..propertyId) this.shenyingTxt.text = ConfigManager.GetConfigData(ConfigName.PropertyConfig,propertyId).Info 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.damageDeathPosManager.historyMax then this.guildDeathPos_State.sprite=this.spLoader:LoadSprite("r_hero_zhanlishangsheng_png") elseif DeathPosManager.damage maxDmg or curDmg < maxDmg this.tasuilingxiao_State.gameObject:SetActive(b) if curDmg > maxDmg then this.tasuilingxiao_State.sprite=this.spLoader:LoadSprite("r_hero_zhanlishangsheng_png") elseif curDmg < maxDmg then this.tasuilingxiao_State.sprite=this.spLoader:LoadSprite("r_hero_zhanlixiajiang_png") end end end --山河社稷图 function this.FightLevelShow() local HardStageFightResponseMsg = FightLevelManager.GetHardStageFightResponseMsg() local oldBattlefightLevelData = FightLevelManager.GetcurBattlefightLevelData() local curBattlefightLevelData = FightLevelManager.GetChapterLevelData(oldBattlefightLevelData.config.Chapter,oldBattlefightLevelData.nodeId) local condition = curBattlefightLevelData.config.ConditionValue or {} this.isFirstEffect:SetActive(HardStageFightResponseMsg.currentIsHonour) if starListEffect and #starListEffect > 0 then for i=1,#starListEffect do Util.SetParticleSortLayer(starListEffect[i], this.sortingOrder + 1) end end for i = 1, math.max(#condition, #conditionGo) do local go = conditionGo[i] if not go then go = newObject(this.conditionGo[1]) go.transform:SetParent(this.Root.transform) go.transform.localScale = Vector3.one go.transform.localPosition = Vector3.zero conditionGo[i] = go end go.gameObject:SetActive(false) end for i, v in pairs(condition) do conditionGo[i]:SetActive(true) local noStarImage = Util.GetGameObject(conditionGo[i], "noStarImage") local getStarImage = Util.GetGameObject(conditionGo[i], "getStarImage") local isShowStar = FightLevelManager.GetCurLevelStarState(curBattlefightLevelData.state,i) noStarImage:SetActive(not isShowStar) getStarImage:SetActive(isShowStar) Util.GetGameObject(conditionGo[i], "Text"):GetComponent("Text").text = i if isShowStar then Util.GetGameObject(conditionGo[i], "infolText"):GetComponent("Text").text = string.format("%s",HardStageCondition[v].Describe) else Util.GetGameObject(conditionGo[i], "infolText"):GetComponent("Text").text = string.format("%s",HardStageCondition[v].Describe) end end end --公会副本 function this.GuildTranscriptShow() if GuildTranscriptManager.damage then this.guildTranscript_CurScore.text = GuildTranscriptManager.damage end end --七界试炼挑战条件信息 function this.QiJieShow() local data = QiJieShiLianManager.GetBattleResult() for i = 1, 3 do Util.GetGameObject(this.qiJieCondition,"Text ("..i..")"):GetComponent("Text").text = data[i] end end --当前背包是否已满 function RewardItemPopup:SelectCanPopUpBagMaxMessage() if(IndicationManager.canPopUpBagMaxMessage) then PopupTipPanel.ShowTip(Language[11507]) IndicationManager.canPopUpBagMaxMessage=false elseif(IndicationManager.getRewardFromMailMessage)then PopupTipPanel.ShowTip(Language[11508]) IndicationManager.getRewardFromMailMessage=false end end function RewardItemPopup:OnSortingOrderChange() if not itemDataList or #itemDataList < 0 then return end if #itemListPrefab > 0 then for i = 1, #itemListPrefab do if itemListPrefab[i] and itemDataList[i] then local view = itemListPrefab[i] local curItemData=itemDataList[i] view:SetEffectLayer(self.sortingOrder) end end end if starListEffect and #starListEffect > 0 then for i=1,#starListEffect do Util.SetParticleSortLayer(starListEffect[i], self.sortingOrder + 1) end sortingOrder = 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) if #itemDataList <= 25 then 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成员红点 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) --改为后端更新 Timer.New(function () isPopGetSSR = false callList:Pop()() end, 0.05):Start() end if curItemData.configData and curItemData.itemType==3 and curItemData.configData.Quality == 5 then HeroManager.DetectionOpenFiveStarActivity(curItemData.configData.Star) 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) then--皮肤 坐骑 func() else func() end end) end callList:Pop()() else for i = 1, #itemDataList do local view = itemListPrefab[i] local curItemData=itemDataList[i] view:OnOpen(true,curItemData,1.15,true,true,false,self.sortingOrder) view.gameObject:SetActive(true) end end 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 EquipTreasureManager.InitSingleTreasureData(itemdata.backData) elseif bagType==2 then end elseif itemdata.itemType==6 then if bagType==1 then PokemonManager.UpdatePokemonDatas(itemdata.backData,true) elseif bagType==2 then end end end --关卡通关掉落时展示经验等级信息 function this.ShowLvAndExp() if compShowType == 1 then this.exp.value=PlayerManager.exp/userLevelData[PlayerManager.level].Exp this.expText.text=PlayerManager.exp.."/"..userLevelData[PlayerManager.level].Exp this.lv.text= PlayerManager.level this.lvUpImage:SetActive(FightPointPassManager.oldLevel b.itemConfig.Quantity end end) end --界面关闭时调用(用于子类重写) function RewardItemPopup:OnClose() if compShowType == CompShowType.fourElement then compShowType = 0 return end BagManager.SetDropIsSHowEquipPrint(true) local fightConFigData = ConfigManager.GetConfigData(ConfigName.MainLevelConfig, FightPointPassManager.curOpenFight) if compShowType == 1 then compShowType = 0 if FightPointPassManager.oldLevel 0 then for i = 1, #itemListPrefab do destroy(itemListPrefab[i].gameObject) end end itemListPrefab = {} itemDataList = {} end return RewardItemPopup