local UISyncSoloBattleOverPanel = UIViewClass() local EnemyHighLightColor = "e46b71" local WINIMAGEPATH = "UI_PVP/1v1_msz_sl.png" local FAILEDIMAGEPATH = "UI_PVP/1v1_msz_sb.png" local WIN_BG_PATH = "1v1_zs_sljsd" local FAIL_BG_PATH = "1v1_zs_sbjsd" local timeStr = UIUtils.GetLocalizedTxt(Const_IDS.IDS_RankOptimization_AutoExit) local OneOnOneResultUIAutoCloseTime = DataSheetManager.ConstData:GetDataByID("OneOnOneResultUIAutoCloseTime").IntValue local OneOnOneResultUIRemindTime = DataSheetManager.ConstData:GetDataByID("OneOnOneResultUIRemindTime").IntValue function UISyncSoloBattleOverPanel:OnOpened(context) self:RegistSystemEvent(EventID.Interact_BattleResultThumbsUp, self.ThumbsUpRefresh) self:RefreshBattleInfo(context) UIUtils.SetActive(self.img_MyThumbs, MDL.ThumbsUp.GetThumbsUpNumber(BattleDataGetter.GetAcID()) > 0) UIUtils.SetActive(self.img_ThumbsUp, false) -- PK自定义模式下不显示积分 UIUtils.SetActive(self.myPoint_Group.gameObject, not context.IsCustomRoom) local showThumbs = true if not BattleDataGetter.IsSyncSolo() or context.IsCustomRoom then showThumbs = false end if BattleDataGetter.IsSyncSolo() or BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.SyncFairSoloTournament) then UIUtils.SetLabelText(self.lab_Quit,Const_IDS["IDS_1v1Sync_Settlement_Quit"]) else UIUtils.SetLabelText(self.lab_Quit, Const_IDS["IDS_FairPlay_FightRecord_Info_Back"]) end self:SetThumbBtnGroupShow(showThumbs) self.iconsInfo = context.Icons self.enemyId = context.enemyFighterRecords.playerId self.enemyName = context.enemyFighterRecords.fighterName self.thumbsUpId = context.ThumbsUpID for i, v in ipairs(self.iconsInfo) do if v.playerID == self.enemyId then self.enemyAcId = v.ACID self.enemyIcon = v.PortraitId if CTL.Character.IsRobot(v.ACID) then CTL.Character.SetRobotHead(self.otherPortrait) else CTL.Character.SetPortraitAndFrame(self.otherPortrait, v.PortraitId, v.FrameId) end else if context.IsCustomRoom then CTL.Character.SetPortraitAndFrame(self.myPortrait, v.PortraitId, v.FrameId) else CTL.Character.SetSelfPortraitAndFrame(self.myPortrait) end end end if BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.SyncFairSoloTournament) then local closeTime = DataSheetManager.ConstData:GetDataByID("FairTournamentResultUIAutoCloseTime").IntValue self.group_ExitTimer:ResetAndBeginCustomTimer(false, closeTime, 0, timeStr) self:StartRepeatFunc(self.DelaySendRoleLeaveFuben, closeTime, 1) elseif BattleDataGetter.IsSyncSolo() then self.group_ExitTimer:ResetAndBeginCustomTimer(false, OneOnOneResultUIAutoCloseTime, 0, timeStr) self:StartRepeatFunc(self.DelaySendRoleLeaveFuben, OneOnOneResultUIAutoCloseTime, 1) self:StartRepeatFunc(self.DelayAddTips, OneOnOneResultUIAutoCloseTime - OneOnOneResultUIRemindTime, 1) end end function UISyncSoloBattleOverPanel:DelaySendRoleLeaveFuben() MDL.Level.SendRoleLeaveFuben() end function UISyncSoloBattleOverPanel:DelayAddTips() CTL.Tips.AddTipsMsg(Const_IDS["IDS_GuildBoss_SceneClose"], OneOnOneResultUIRemindTime) end function UISyncSoloBattleOverPanel:OnClosed() MDL.ThumbsUp.ClearThumbsUpList() end function UISyncSoloBattleOverPanel:SetThumbBtnGroupShow(isShow) UIUtils.SetActive(self.btn_ThumbsActive, isShow) UIUtils.SetActive(self.btn_ThumbsDisable, false) end function UISyncSoloBattleOverPanel:OnButtonClicked(comp) if comp == self.btn_Quit then if BattleDataGetter.IsSyncSolo() or BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.SyncFairSoloTournament) then MDL.Level.SendRoleLeaveFuben() else self:CloseView() end elseif comp == self.btn_ThumbsActive then MDL.ThumbsUp.ThumbsUpReq(self.thumbsUpId, self.enemyAcId) UIUtils.SetActive(self.btn_ThumbsActive, false) UIUtils.SetActive(self.btn_ThumbsDisable, true) elseif comp == self.btn_ThumbsDisable then CTL.Tips.AddTipsMsg(Const_IDS["IDS_RecommendFriends_AlreadyThumbUp"]) end end function UISyncSoloBattleOverPanel:ThumbsUpRefresh() local thumbInfo = MDL.ThumbsUp.GetThumbsUpTipsList() if thumbInfo and thumbInfo.ThumbsUpID == self.thumbsUpId then if thumbInfo.TargetACID == BattleDataGetter.GetAcID() then --弹出点赞的tips local name, isRobot = nil, false if BattleDataGetter.IsPracticeRobot(self.enemyId) then name = CTL.Character.GetRobotName(self.enemyAcId) isRobot = true else name = self.enemyName end CTL.ThumbsUp.ShowThumbsUpTips(LuaConst.ActivityType.SyncSolo, true, name, self.enemyIcon, isRobot) ---默认先填1,后面需要服务器加一个数据推送 UIUtils.SetActive(self.img_MyThumbs, true) self:PlayUIAnimation("ThumbsLeft") else UIUtils.SetActive(self.img_ThumbsUp, true) self:PlayUIAnimation("ThumbsRight") end end end local function SortEntityList(a, b) return a.EntityID < b.EntityID end function UISyncSoloBattleOverPanel:RefreshBattleInfo(result) local diff = result.diffValue self.state_Over:SetState(result.isWin and 0 or 1) if result.isWin then CTL.Sound.PlayGameSound("MUSIC_Victory") self.txt_Point.text = UTL.Color.FormatGreenColor("+" .. diff) UTL.Item.SetAtlasSprite(self.img_Bg02, "UI_1v1", WIN_BG_PATH) if self.group_Over.CurState == 0 then UTL.Item.SetLocalizationImage(self.group_Over, self.img_Result, WINIMAGEPATH) else UIUtils.SetLabelText(self.txt_Result, Const_IDS.IDS_GuildWar_Win) self.loc_Color:SetState(0) end else CTL.Sound.PlayGameSound("MUSIC_Fail") self.txt_Point.text = UTL.Color.FormatRedColor(diff) UTL.Item.SetAtlasSprite(self.img_Bg02, "UI_1v1", FAIL_BG_PATH) if self.group_Over.CurState == 0 then UTL.Item.SetLocalizationImage(self.group_Over, self.img_Result, FAILEDIMAGEPATH) else UIUtils.SetLabelText(self.txt_Result, Const_IDS.IDS_GuildWar_Lose) self.loc_Color:SetState(1) end end --关卡时间 self.txt_Time.text = UTL.Time.FormatTimeSeconds(result.passTime) local myData = result.ourFighterRecords self.selfTotalDamage = 0 local totalKill = 0 local totalHp = 0 if myData and myData.damage then for i, v in ipairs(myData.damage) do self.mySyncSoloTeamScroll:AddData({isMyself = true, result = myData}, 0) self.selfTotalDamage = self.selfTotalDamage + myData.damage[i] totalKill = totalKill + myData.killNum[i] totalHp = totalHp + myData.leftHp[i] end else logging.error(LTAG.ERROR, "同步1V1结算没有找到房间内我方Entity数据,请程序检查!!!", myData, " myData.playerId : ", myData.playerId) end self.txt_MyTotalDamage.text = self.selfTotalDamage self.txt_MyTotalKill.text = totalKill self.txt_MyTotalHp.text = UTL.Attr.FormatNumberToPercentage(totalHp, 1) self.txt_MyName.text = myData.fighterName UIUtils.SetActive(self.lab_MyServer, CTL.CrossServer.IsShowServerTextInFairPlay()) self.lab_MyServer.text = string.FormatByIdsId(Const_IDS.IDS_1v1Sync_LoadingInfo_Service, myData.serId) local enemyData = result.enemyFighterRecords self.enemyTotalDamage = 0 totalKill = 0 totalHp = 0 if enemyData and enemyData.damage then for i, v in ipairs(enemyData.damage) do self.otherSyncSoloTeamScroll:AddData({isMyself = false, result = enemyData}, 0) self.enemyTotalDamage = self.enemyTotalDamage + enemyData.damage[i] totalKill = totalKill + enemyData.killNum[i] totalHp = totalHp + enemyData.leftHp[i] end else logging.error(LTAG.ERROR, "同步1V1结算没有找到房间内敌方Entity数据,请程序检查!!!", enemyData) end self.txt_EnemyTotalDamage.text = self.enemyTotalDamage self.txt_EnemyTotalKill.text = totalKill self.txt_EnemyTotalHp.text = UTL.Attr.FormatNumberToPercentage(totalHp, 1) local enemyAcId for i, v in ipairs(result.Icons) do if v.playerID == enemyData.playerId then enemyAcId = v.ACID end end if CTL.Character.IsRobot(enemyAcId) then self.txt_OtherName.text = CTL.Character.GetRobotName(enemyAcId) UIUtils.SetActive(self.lab_OtherServer, false) else self.txt_OtherName.text = enemyData.fighterName UIUtils.SetActive(self.lab_OtherServer, CTL.CrossServer.IsShowServerTextInFairPlay()) self.lab_OtherServer.text = string.FormatByIdsId(Const_IDS.IDS_1v1Sync_LoadingInfo_Service, enemyData.serId) end self.txt_Point2.text = UTL.Color.FormatGreenColor("-" .. 0) UIUtils.SetActive(self.txt_Point2, result.costProtectCard) UIUtils.SetActive(self.img_slash, result.costProtectCard) UIUtils.SetActive(self.protect_Node, result.costProtectCard) end function UISyncSoloBattleOverPanel:OnCellInit(scrollRect, index, cellTable, data) local result = data.result local heroIds = result.heroIds local isHeroAwakens = result.isHeroAwakens local mainHeroId = heroIds[(index+1)*2 - 1] local viceHeroId = heroIds[(index+1)*2] local isMainAwaken = isHeroAwakens[(index + 1) * 2 - 1] local isViceAwaken = isHeroAwakens[(index + 1) * 2] viceHeroId = CTL.HeroSelect.GetHeroIdByFuJiangRelate(viceHeroId) UTL.Item.SetHeroIconByHeroId(cellTable.img_MainHero, mainHeroId, isMainAwaken) UTL.Item.SetHeroIconByHeroId(cellTable.img_SubHero, viceHeroId, isViceAwaken) UIUtils.SetLabelText(cellTable.txt_HeroName, Const_IDS[DataSheetManager.HeroNum:GetDataByID(mainHeroId).NameIDS]) local damage = result.damage[index + 1] local killNum = result.killNum[index + 1] local leftHp = result.leftHp[index + 1] local color = data.isMyself and UTL.Color.ModelNameColor.Blue or EnemyHighLightColor local damageRate if data.isMyself then if self.selfTotalDamage == 0 then damageRate = UTL.Attr.FormatNumberToPercentage(0, 1) else damageRate = UTL.Attr.FormatNumberToPercentage(damage / self.selfTotalDamage, 1) end if data.result.decorateId and data.result.decorateId > 0 then local decorateResource = DataSheetManager.DecorateAdditionalRes:GetDataByID(data.result.decorateId).Resource3 UIUtils.SetImageByAssetBundle(cellTable.bg, decorateResource) end else if self.enemyTotalDamage == 0 then damageRate = UTL.Attr.FormatNumberToPercentage(0, 1) else damageRate = UTL.Attr.FormatNumberToPercentage(damage / self.enemyTotalDamage, 1) end if data.result.decorateId and data.result.decorateId > 0 then local decorateResource = DataSheetManager.DecorateAdditionalRes:GetDataByID(data.result.decorateId).Resource4 UIUtils.SetImageByAssetBundle(cellTable.bg, decorateResource) end end local damageStr = string.format("%s(%s)", UTL.String.GetCountStr(damage) , damageRate) cellTable.txt_Damage.text = CTL.SyncSolo.IsMaxNumber(damage, result.damage) and UTL.Color.FormatTextByColor(color, damageStr) or damageStr cellTable.txt_KillNum.text = CTL.SyncSolo.IsMaxNumber(killNum, result.killNum) and UTL.Color.FormatTextByColor(color, killNum) or killNum --如果剩余血量的数字太小,通过四舍保留操作会显示0.0%,造成误解,所以特殊处理一下 --小于0.1%的血量都默认显示成0.1% if leftHp > 0 and leftHp < 0.001 then leftHp = 0.001 end cellTable.txt_LeftHP.text = CTL.SyncSolo.IsMaxNumber(leftHp, result.leftHp) and UTL.Color.FormatTextByColor(color, UTL.Attr.FormatNumberToPercentage(leftHp, 1)) or UTL.Attr.FormatNumberToPercentage(leftHp, 1) end return UISyncSoloBattleOverPanel