local UISyncTeamPVPBattleOverPanel = UIViewClass() local WINIMAGEPATH = "UI_PVP/1v1_msz_sl.png" local FAILEDIMAGEPATH = "UI_PVP/1v1_msz_sb.png" local WINBACKGROUND=ConstAssetPathConfig.AssetPath166 local FAILEDBACKGROUND=ConstAssetPathConfig.AssetPath167 local WINLIGHT=ConstAssetPathConfig.AssetPath168 local FAILEDLIGHT=ConstAssetPathConfig.AssetPath169 local WINSHINE=ConstAssetPathConfig.AssetPath170 local FAILEDSHINE=ConstAssetPathConfig.Path39 local timeStr = UIUtils.GetLocalizedTxt(Const_IDS.IDS_RankOptimization_AutoExit) local ThreeOnThreeResultUIAutoCloseTime = DataSheetManager.ConstData:GetDataByID("ThreeOnThreeResultUIAutoCloseTime").IntValue local TeamFairTournamentQuitTime = DataSheetManager.ConstData:GetDataByID("TeamFairTournamentQuitTime").IntValue local ThreeOnThreeResultUIRemindTime = DataSheetManager.ConstData:GetDataByID("ThreeOnThreeResultUIRemindTime").IntValue local ThumbsUpAnimationTime = 4 -- context 目前只有从回放界面查看战斗结果时,才会有值 function UISyncTeamPVPBattleOverPanel:OnOpened(context) self:InitInfo(context) self:InitPanel() end function UISyncTeamPVPBattleOverPanel:InitInfo(context) self.isHistoryResult = context ~= nil -- 只是查看历史战绩而已 self.result = context or MDL.SyncTeamPVP.GetBattleResult() self.thumbsUpId = self.result.ThumbsUpID self.iconsInfo = self.result.Icons self.mySelfPlayerID = CTL.Replay.GetMySelfPlayerID(self.iconsInfo, self.result.selfACID) --self.isAutoExit = false self.isShowThumbsUp = false self.hideThumbsUp = self.result.hideThumbsUp --服务器控制,切磋PK和天下会武3v3会隐藏 if context then self.hideThumbsUp = true end end function UISyncTeamPVPBattleOverPanel:InitPanel() UIUtils.SetLabelText(self.lab_WinLoc, Const_IDS.IDS_GuildWar_Win) UIUtils.SetLabelText(self.lab_LossLoc, Const_IDS.IDS_GuildWar_Lose) self:RegistSystemEvent(EventID.UI_SyncTeamPVPBattleOver_ShowResult, self.ShowResult) self:RegistSystemEvent(EventID.Interact_BattleResultThumbsUp, self.ThumbsUpRefresh) if self.isHistoryResult == false then local delayCloseTime = ThreeOnThreeResultUIAutoCloseTime if BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.SyncTeamFairChampionship) then delayCloseTime = TeamFairTournamentQuitTime end self.group_ExitTimer:ResetAndBeginCustomTimer(false, delayCloseTime, 0, timeStr) self:StartRepeatFunc(self.DelaySendRoleLeaveFuben, delayCloseTime, 1) if delayCloseTime > ThreeOnThreeResultUIRemindTime then self:StartRepeatFunc(self.DelayAddTips, delayCloseTime - ThreeOnThreeResultUIRemindTime, 1) end --self.group_Tip:ResetAndBeginCustomTimer(false, ThreeOnThreeResultUIAutoCloseTime, 0, UIUtils.GetLocalizedTxt(Const_IDS["IDS_TeamDungeon1_Quit_Tip"]), 1) end if MDL.ThumbsUp.GetThumbsUpTipsListLength() > 0 then self:StartRepeatFunc(self.OnUpdateFun, ThumbsUpAnimationTime) self.isShowThumbsUp = true self:ShowThumbsUpTips() end if self.isHistoryResult then UIUtils.SetLabelText(self.Text_exit, Const_IDS["IDS_FairPlay_FightRecord_Info_Back"]) else UIUtils.SetLabelText(self.Text_exit,Const_IDS["IDS_ExitBattleGround_Hint1"]) end end function UISyncTeamPVPBattleOverPanel:DelaySendRoleLeaveFuben() MDL.Level.SendRoleLeaveFuben() end function UISyncTeamPVPBattleOverPanel:DelayAddTips() CTL.Tips.AddTipsMsg(Const_IDS["IDS_GuildBoss_SceneClose"], ThreeOnThreeResultUIRemindTime) end function UISyncTeamPVPBattleOverPanel:OnClosed() MDL.ThumbsUp.ClearThumbsUpList() --self.isAutoExit = false end function UISyncTeamPVPBattleOverPanel:ShowThumbsUpTips() local thumbInfo = MDL.ThumbsUp.GetThumbsUpTipsList() if MDL.ThumbsUp.GetThumbsUpTipsListLength() <= 0 then self:StopRepeatFunc(self.OnUpdateFun) self.isShowThumbsUp = false end if thumbInfo then for i, v in ipairs(self.iconsInfo) do if v.ACID == thumbInfo.OriginACID then for index, value in ipairs(self.result.ourFighterRecords) do if v.playerID == value.playerId then local name if BattleDataGetter.IsPracticeRobot(v.playerID) then name = CTL.Character.GetRobotName(v.ACID) else name = value.fighterName end CTL.ThumbsUp.ShowThumbsUpTips(LuaConst.ActivityType.TVT, false, name, v.Icon) return end end for index, value in ipairs(self.result.enemyFighterRecords) do if v.playerID == value.playerId then local name if BattleDataGetter.IsPracticeRobot(v.playerID) then name = CTL.Character.GetRobotName(v.ACID) else name = value.fighterName end CTL.ThumbsUp.ShowThumbsUpTips(LuaConst.ActivityType.TVT, true, name, v.Icon) return end end end end end end function UISyncTeamPVPBattleOverPanel:OnUpdateFun(deltaTime, timeSinceUpdate) self:ShowThumbsUpTips() --目的是为了完成战斗之后可以自动退出,然后再次匹配。具体功能询问卫松,先注释保留。 --if self.isAutoExit then -- if timeSinceUpdate >= 3 then -- self:OnExit() -- self.isAutoExit = false -- self:StopRepeatFunc(self.OnUpdateFun) -- end --end end function UISyncTeamPVPBattleOverPanel:OnExit() MDL.Level.SendRoleLeaveFuben() end function UISyncTeamPVPBattleOverPanel:ThumbsUpRefresh() if not self.isShowThumbsUp then if MDL.ThumbsUp.GetThumbsUpTipsListLength() > 0 then self:StartRepeatFunc(self.OnUpdateFun, ThumbsUpAnimationTime) self.isShowThumbsUp = true self:ShowThumbsUpTips() end end self.mySyncPVPTeamScroll:RefreshCells() self.otherSyncPVPTeamScroll:RefreshCells() end function UISyncTeamPVPBattleOverPanel:GetIsWin() return self.result.isWin end function UISyncTeamPVPBattleOverPanel:ShowResult(myProgress,otherProgress) if self:GetIsWin() then UIUtils.SetImageByAssetBundle(self.img_BG, WINBACKGROUND) UIUtils.SetImageByAssetBundle(self.img_Light, WINLIGHT) UIUtils.SetImageByAssetBundle(self.img_Shine, WINSHINE) if self.loc_Title.CurState==0 then self.loc_Title:SetImage(0, WINIMAGEPATH, true) else UIUtils.SetActive(self.lab_WinLoc, true) UIUtils.SetActive(self.lab_LossLoc, false) end if not self.isHistoryResult then CTL.Sound.PlayGameSound("MUSIC_Victory") CTL.Sound.PlayGameSound("UI_victory_v1") end else UIUtils.SetImageByAssetBundle(self.img_BG, FAILEDBACKGROUND) UIUtils.SetImageByAssetBundle(self.img_Light, FAILEDLIGHT) UIUtils.SetImageByAssetBundle(self.img_Shine, FAILEDSHINE) if self.loc_Title.CurState==0 then self.loc_Title:SetImage(0, FAILEDIMAGEPATH, true) else UIUtils.SetActive(self.lab_WinLoc, false) UIUtils.SetActive(self.lab_LossLoc, true) end if not self.isHistoryResult then CTL.Sound.PlayGameSound("MUSIC_Fail") CTL.Sound.PlayGameSound("UI_failed_v1") end end if BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.SyncTeamFairChampionship) then --天下会武3v3需要显示双方战队名字 if BattleDataGetter.GetMyCampID() == 1 then UIUtils.SetLabel(self.constLable_My, string.FormatByIdsKey("IDS_Occupation", BattleDataGetter.GetCampName1())) UIUtils.SetLabel(self.constLable_other, string.FormatByIdsKey("IDS_Occupation", BattleDataGetter.GetCampName2())) else UIUtils.SetLabel(self.constLable_My, string.FormatByIdsKey("IDS_Occupation", BattleDataGetter.GetCampName2())) UIUtils.SetLabel(self.constLable_other, string.FormatByIdsKey("IDS_Occupation", BattleDataGetter.GetCampName1())) end else --显示我方\敌方 UIUtils.SetLabelText(self.constLable_My, Const_IDS.IDS_UI_Word1) UIUtils.SetLabelText(self.constLable_other, Const_IDS.IDS_UI_Word2) end local maxProgress = BattleDataGetter.GetTVTPointSpeed() local totalProgrss = FP.tonumberV1( FP.Math.Floor(FP.Const.One / maxProgress / LuaConst.TimeSpan) )-- 2000帧 self.lab_myProgess.text = tostring(math.floor(myProgress / totalProgrss * 100)).."%" self.lab_otherProgess.text = tostring(math.floor(otherProgress / totalProgrss * 100)).."%" self:SetResultInfo() --目的是为了完成战斗之后可以自动退出,然后再次匹配。具体功能询问卫松,先注释保留。 --if BattleDataGetter.GetMainPlayerBattleMemberType() == LuaConst.BattleMemberType.AI_Hero then -- self:StartRepeatFunc(self.OnUpdateFun, 0) -- self.isAutoExit = true --end end function UISyncTeamPVPBattleOverPanel:SetResultInfo() self.eloScore = self.result.EloScore self.diffValue = self.result.diffValue self.ourMvp = self.result.ourBestFighter self.enemyMvp = self.result.enemyBestFighter self.costProtectCard = self.result.costProtectCard UIUtils.SetActive(self.protect_Node, self.costProtectCard) self.selfTotalDamage = 0 for i, v in ipairs(self.result.ourFighterRecords) do self.selfTotalDamage = self.selfTotalDamage + v.totalDamage end for i, v in ipairs(self.result.ourFighterRecords) do self.mySyncPVPTeamScroll:AddData(v, 0) end self.enemyTotalDamage = 0 for i, v in ipairs(self.result.enemyFighterRecords) do self.enemyTotalDamage = self.enemyTotalDamage + v.totalDamage end for i, v in ipairs(self.result.enemyFighterRecords) do self.otherSyncPVPTeamScroll:AddData(v, 0) end end function UISyncTeamPVPBattleOverPanel:OnButtonClicked(obj) if obj == self.event_Exit then if self.isHistoryResult then self:CloseView() else self:OnExit() end end end function UISyncTeamPVPBattleOverPanel:OnCellClicked(scrollRect, index, cellTable, target, data) if target == cellTable.btn_ThumbsActive then for i, v in ipairs(self.iconsInfo) do if v.playerID == data.playerId then MDL.ThumbsUp.ThumbsUpReq(self.thumbsUpId, v.ACID) break end end UIUtils.SetActive(cellTable.btn_ThumbsActive, false) UIUtils.SetActive(cellTable.btn_ThumbsDisable, true) elseif target == cellTable.btn_ThumbsDisable then CTL.Tips.AddTipsMsg(Const_IDS["IDS_RecommendFriends_AlreadyThumbUp"]) end end function UISyncTeamPVPBattleOverPanel:GetIfShowRankScore() return not BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.SyncTeamFairChampionship) end function UISyncTeamPVPBattleOverPanel:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.mySyncPVPTeamScroll then UIUtils.SetActive(cellTable.group_Thumbsup.gameObject, not self.hideThumbsUp) if data.playerId == self.mySelfPlayerID then self:SetResultCell(cellTable, data, data.playerId == self.ourMvp, data.playerId,true) UIUtils.SetActive(cellTable.bg_Self.gameObject, true) if self:GetIfShowRankScore() then UIUtils.SetActive(cellTable.group_RankScore.gameObject, not self.hideThumbsUp) UIUtils.SetLabelText(cellTable.group_RankScore, Const_IDS.IDS_GradeScore) cellTable.RankScore.text = self.eloScore if self.diffValue > 0 or (self.diffValue == 0 and self:GetIsWin()) then UTL.Item.SetAtlasSprite(cellTable.upOrDown, "UI_CommonNew", "zb_zs_sjt") cellTable.upOrDownNum.text = UTL.Color.FormatGreenColor(math.abs(self.diffValue)) elseif self.diffValue < 0 or (self.diffValue == 0 and not self:GetIsWin()) then UTL.Item.SetAtlasSprite(cellTable.upOrDown, "UI_CommonNew", "zb_zs_xjt") cellTable.upOrDownNum.text = UTL.Color.FormatRedColor(math.abs(self.diffValue)) end UIUtils.SetActive(cellTable.upOrDown.gameObject, true) cellTable.protectNum.text = UTL.Color.FormatGreenColor("-" .. 0) UIUtils.SetActive(cellTable.protectNum, self.costProtectCard) UIUtils.SetActive(cellTable.img_slash, self.costProtectCard or (self.diffValue > 0 and data.isNegativeFight)) cellTable.state_Thumbs:SetState(0) else UIUtils.SetActive(cellTable.group_RankScore.gameObject, false) cellTable.state_Thumbs:SetState(0) end else self:SetResultCell(cellTable, data, data.playerId == self.ourMvp, data.playerId, true) UIUtils.SetActive(cellTable.bg_Self.gameObject, false) UIUtils.SetActive(cellTable.group_RankScore.gameObject, false) cellTable.state_Thumbs:SetState(1) end if data.decorateId and data.decorateId > 0 then local decorateResource = DataSheetManager.DecorateAdditionalRes:GetDataByID(data.decorateId).Resource3 UIUtils.SetImageByAssetBundle(cellTable.bg, decorateResource) end cellTable.txt_RankTeam.text = index + 1 elseif scrollRect == self.otherSyncPVPTeamScroll then UIUtils.SetActive(cellTable.group_Thumbsup.gameObject, not self.hideThumbsUp) self:SetResultCell(cellTable, data, data.playerId == self.enemyMvp, data.playerId, false) cellTable.txt_RankTeam.text = index + 1 cellTable.state_Thumbs:SetState(1) if data.decorateId and data.decorateId > 0 then local decorateResource = DataSheetManager.DecorateAdditionalRes:GetDataByID(data.decorateId).Resource4 UIUtils.SetImageByAssetBundle(cellTable.bg, decorateResource) end end for i, v in ipairs(self.iconsInfo) do if v.playerID == data.playerId then local num = MDL.ThumbsUp.GetThumbsUpNumber(v.ACID) cellTable.txt_Times.text = num if v.ACID == BattleDataGetter.GetAcID() then UIUtils.SetActive(cellTable.group_MyThumbs.gameObject, num > 0) end break end end end function UISyncTeamPVPBattleOverPanel:SetResultCell(cell, result, isMvp, playerID, isMyself) local isSelf = playerID == self.mySelfPlayerID local acid for i, v in ipairs(self.iconsInfo) do if v.playerID == playerID then acid = v.ACID break end end if CTL.Character.IsRobot(acid) then cell.name.text = isSelf and UTL.Color.FormatTextByColor(UTL.Color.yellow, CTL.Character.GetRobotName(acid)) or CTL.Character.GetRobotName(acid) else cell.name.text = isSelf and UTL.Color.FormatTextByColor(UTL.Color.yellow, result.fighterName) or result.fighterName end cell.killNum.text = result.killNum cell.deadNum.text = result.deadNum cell.time.text = UTL.Time.FormatTimeByFrameCount(result.fightingTime) cell.score.text = result.score if isMyself then if self.selfTotalDamage == 0 then cell.damage.text = "-" else cell.damage.text = UTL.Attr.FormatNumberToPercentage(result.totalDamage / self.selfTotalDamage, 1) end else if self.enemyTotalDamage == 0 then cell.damage.text = "-" else cell.damage.text = UTL.Attr.FormatNumberToPercentage(result.totalDamage / self.enemyTotalDamage, 1) end end UTL.Item.SetHeroIconByHeroId(cell.heroIcon, result.mainHero, result.mainHeroAwaken) if isMvp then UIUtils.SetActive(cell.bg_Normal, false) UIUtils.SetActive(cell.img_BG, true) UIUtils.SetActive(cell.img_MVP, true) if playerID==self.ourMvp then UIUtils.SetLocalizationImage(cell.img_MVP, "UI_PVP/3v3_msz_wfzs.png") else UIUtils.SetLocalizationImage(cell.img_MVP, "UI_PVP/3v3_msz_dfzs.png") end else UIUtils.SetActive(cell.bg_Normal, true) UIUtils.SetActive(cell.img_BG, false) UIUtils.SetActive(cell.img_MVP, false) end UIUtils.SetActive(cell.img_hangUp, result.isNegativeFight) end function UISyncTeamPVPBattleOverPanel:SetRankIcon(group, index) for i, v in ipairs(group) do if i == index then UIUtils.SetActive(v, true) else UIUtils.SetActive(v, false) end end end return UISyncTeamPVPBattleOverPanel