--国战PVP 战斗结算 local UICountryTargetBattleOverPanel = UIViewClass() local Result = { dogfall = 0, --平局 attackWin = 1,--攻击方获胜 beAttackWin = 2,--被攻击方获胜 } local MyResult ={ dogfall = 0, --平局 win = 1, --我方胜利 fail = 2,--我方失败 } --region 生命周期方法 function UICountryTargetBattleOverPanel:OnOpened(context) self:RegistSystemEvent(EventID.UI_UpdateFriendInfo,self.RefreshCells) self:Init(context.battleResult) end function UICountryTargetBattleOverPanel:OnClosed() CTL.LevelSelect.RemoveSummaryTemplateEffect(self) end function UICountryTargetBattleOverPanel:RefreshCells() self.mySyncPVPTeamScroll:RefreshCells(false) self.otherSyncPVPTeamScroll:RefreshCells(false) end function UICountryTargetBattleOverPanel:OnCellInit(scrollRect, index, cellTable, data) UIUtils.SetLabel(cellTable.name,data.name) UIUtils.SetLabel(cellTable.kill,data.killNum) UIUtils.SetLabel(cellTable.damage,data.hurt) CTL.Character.SetPortraitAndFrame(cellTable.HeroHead.UIHeroHead190, data.portraitId, data.frameId) if data.acid == BattleDataGetter.GetAcID() then cellTable.state_Name:SetState(1) else cellTable.state_Name:SetState(0) end if scrollRect == self.mySyncPVPTeamScroll then --我方 cellTable.state_Friend:SetState(MDL.Friend.IsPlayerFriend(data.acid) and 0 or 1) elseif scrollRect == self.otherSyncPVPTeamScroll then --敌方 cellTable.state_Enemy:SetState(MDL.Friend.IsPlayerRival(data.acid) and 0 or 1) end --如果是玩家自己,隐藏好友、仇敌按钮 if data.acid == BattleDataGetter.GetAcID() then UIUtils.SetActive(cellTable.group_Friends,false) UIUtils.SetActive(cellTable.group_Enemy,false) end end function UICountryTargetBattleOverPanel:OnCellClicked(scrollRect, index, cellTable, target, data) if target == cellTable.btn_AddFriend then --加好友 MDL.Friend.SendApplyFriend(data.acid) elseif target == cellTable.btn_AddEnemy then --加仇敌 MDL.Rival.RivalOperationRequest(data.acid, MDL.Rival.RivalOperationType.RivalOptCommonEnemy) end end --endregion function UICountryTargetBattleOverPanel:Init(battleResult) --胜利失败显示 local result = MyResult.dogfall local isMyAttack = self:IsInAttack(battleResult.attackerInfo.roleInfos,battleResult.defenderInfo.roleInfos) if isMyAttack then if battleResult.result == Result.attackWin then result = MyResult.win elseif battleResult.result == Result.beAttackWin then result = MyResult.fail end else if battleResult.result == Result.attackWin then result = MyResult.fail elseif battleResult.result == Result.beAttackWin then result = MyResult.win end end --我方获胜 self.summaryTemplateEffectHandle1,self.summaryTemplateEffectHandle2 = CTL.LevelSelect.ShowCommonSummaryTemplate(self,result == MyResult.win,false,false,result == MyResult.dogfall and CTL.LevelSelect.CommonSummaryType.Draw or nil) --攻击方、受击方国家 local attackCountryIDS = CTL.Country.GetCountryNameIDS(battleResult.attackerInfo.countryId) local beAttackCountryIDS = CTL.Country.GetCountryNameIDS(battleResult.defenderInfo.countryId) local enemyCountryId if isMyAttack then enemyCountryId = battleResult.defenderInfo.countryId UIUtils.SetLabel(self.txt_My, string.format("%s:%s",UIUtils.GetLocalizedTxt(Const_IDS.IDS_CountryPVP_Team_FightTeam1),UIUtils.GetLocalizedTxt(attackCountryIDS))) --攻击方 UIUtils.SetLabel(self.txt_Other,string.format("%s:%s",UIUtils.GetLocalizedTxt(Const_IDS.IDS_CountryPVP_Team_FightTeam2),UIUtils.GetLocalizedTxt(beAttackCountryIDS)))-- 受击方 else enemyCountryId = battleResult.attackerInfo.countryId UIUtils.SetLabel(self.txt_Other, string.format("%s:%s",UIUtils.GetLocalizedTxt(Const_IDS.IDS_CountryPVP_Team_FightTeam1),UIUtils.GetLocalizedTxt(attackCountryIDS))) --攻击方 UIUtils.SetLabel(self.txt_My,string.format("%s:%s",UIUtils.GetLocalizedTxt(Const_IDS.IDS_CountryPVP_Team_FightTeam2),UIUtils.GetLocalizedTxt(beAttackCountryIDS)))-- 受击方 end local resultTip = self:ShowResultTip(result,enemyCountryId) --详情 if isMyAttack then --攻击方 self.mySyncPVPTeamScroll:ReloadAll(battleResult.attackerInfo.roleInfos) --被攻击方 self.otherSyncPVPTeamScroll:ReloadAll(battleResult.defenderInfo.roleInfos) else --攻击方 self.otherSyncPVPTeamScroll:ReloadAll(battleResult.attackerInfo.roleInfos) --被攻击方 self.mySyncPVPTeamScroll:ReloadAll(battleResult.defenderInfo.roleInfos) end --XX 秒自动退出 local autoCloseTime = DataSheetManager.ConstData:GetDataByID("CountryPVPQuitTime").IntValue self.group_ExitTimer:ResetAndBeginCustomTimer(false, autoCloseTime, 0, resultTip) self:StartRepeatFunc(self.OnExitFun,autoCloseTime,1) end function UICountryTargetBattleOverPanel:OnExitFun(deltaTime, timeSinceUpdate) MDL.Level.SendRoleLeaveFuben() end --我方是否为攻击方 function UICountryTargetBattleOverPanel:IsInAttack(attackers,defenders) for i,v in ipairs(attackers) do if v.acid == BattleDataGetter.GetAcID() then return true end end for i,v in ipairs(defenders) do if v.acid == BattleDataGetter.GetAcID() then return false end end return false end --结算结果提示 function UICountryTargetBattleOverPanel:ShowResultTip(result,enemyCountryId) local content = "" if result == MyResult.win then --胜利 local countryData = DataSheetManager.CountryBase:GetDataByID(enemyCountryId) if countryData then local mapInfo = DataSheetManager.LevelInfoData:GetDataByLevelID(countryData.SceneId) local mapName = UIUtils.GetLocalizedTxt(Const_IDS[mapInfo.LevelNameIDS]) content = string.FormatByIdsId(Const_IDS.IDS_CountryPVP_WinTips,mapName) end elseif result == MyResult.fail then --失败 local countryID = MDL.Country.GetMyCountryId() local countryData = DataSheetManager.CountryBase:GetDataByID(countryID) if countryData then local mapInfo = DataSheetManager.LevelInfoData:GetDataByLevelID(countryData.SceneId) local mapName = UIUtils.GetLocalizedTxt(Const_IDS[mapInfo.LevelNameIDS]) content = string.FormatByIdsId(Const_IDS.IDS_CountryPVP_LoseTips,mapName) end else --平局 content = UIUtils.GetLocalizedTxt(Const_IDS.IDS_CountryPVP_DrawTips) end return content end return UICountryTargetBattleOverPanel