using System.Collections.Generic; using UnityEngine; public class BattleDetailWin : UIBase { [SerializeField] TextEx redName; [SerializeField] TextEx blueName; [SerializeField] List redList = new List(); [SerializeField] List blueList = new List(); BattleSettlementManager manager { get { return BattleSettlementManager.Instance; } } protected override void OnPreOpen() { Display(); } public void Display() { bool isMyStart = manager.isMyStartBattleDetail; BattleDetailMsg msg = manager.msg; string battleName = manager.BattleDetailBattleName; if (msg == null) return; if (isMyStart) { // 目前玩家主动发起的阵容一定是1,对方是 2, 如果是那种系统自动打的,一般1-左,2-右 int myWinFaction = 1; string myName = PlayerDatas.Instance.baseData.PlayerName; string enemyName = manager.GetBattleDetailEnemyNameByMyStart(battleName); if (battleName == BattleConst.TianziBillboradBattleField) { redName.text = myWinFaction == msg.winFaction ? enemyName : myName; blueName.text = myWinFaction == msg.winFaction ? myName : enemyName; } else { redName.text = myWinFaction == msg.winFaction ? myName : enemyName; blueName.text = myWinFaction == msg.winFaction ? enemyName : myName; } } List redBattleDetailHeroInfoList = manager.GetHeroInfo(msg, isMyStart, battleName, true); List blueBattleDetailHeroInfoList = manager.GetHeroInfo(msg, isMyStart, battleName, false); DisplayDetail(redList, redBattleDetailHeroInfoList); DisplayDetail(blueList, blueBattleDetailHeroInfoList); } public void DisplayDetail(List teamItemList, List infoList) { int mvpIndex = GetMvpIndex(infoList); GetMaxAttr(infoList, out ulong maxAtk, out ulong maxDef, out ulong maxCure); for (int i = 0; i < teamItemList.Count; i++) { if (i < infoList.Count) { teamItemList[i].SetActive(true); teamItemList[i].Display(new BattleDetailHeroInfoItemData() { index = i, mvpIndex = mvpIndex, maxAtk = maxAtk, maxDef = maxDef, maxCure = maxCure, info = infoList[i], }); } else { teamItemList[i].SetActive(false); } } } public int GetMvpIndex(List infos) { if (infos.IsNullOrEmpty()) return -1; int mvpIndex = -1; ulong mvpScore = 0; for (int i = 0; i < infos.Count; i++) { BattleDetailHeroInfo nowInfo = infos[i]; ulong nowValue = nowInfo.AtkHurt + nowInfo.DefHurt + nowInfo.CureHP; if (nowValue > mvpScore) { mvpIndex = i; mvpScore = nowValue; } } return mvpIndex; } public void GetMaxAttr(List infos, out ulong maxAtk, out ulong maxDef, out ulong maxCure) { maxAtk = 0; maxDef = 0; maxCure = 0; if (infos.IsNullOrEmpty()) return; for (int i = 0; i < infos.Count; i++) { BattleDetailHeroInfo nowInfo = infos[i]; if (nowInfo.AtkHurt > maxAtk) maxAtk = nowInfo.AtkHurt; if (nowInfo.DefHurt > maxDef) maxDef = nowInfo.DefHurt; if (nowInfo.CureHP > maxCure) maxCure = nowInfo.CureHP; } } } public class BattleDetailHeroInfoItemData { public int index; public int mvpIndex; public ulong maxAtk; public ulong maxDef; public ulong maxCure; public BattleDetailHeroInfo info; }