From 3b2a6bb9047cfce9f501593b3669a9c1af6c5df4 Mon Sep 17 00:00:00 2001
From: lcy <1459594991@qq.com>
Date: 星期三, 05 十一月 2025 17:40:23 +0800
Subject: [PATCH] 130 战斗修改回合样式

---
 Main/System/Team/TeamManager.cs |  122 +++++++++-------------------------------
 1 files changed, 29 insertions(+), 93 deletions(-)

diff --git a/Main/System/Team/TeamManager.cs b/Main/System/Team/TeamManager.cs
index c32a199..2afd452 100644
--- a/Main/System/Team/TeamManager.cs
+++ b/Main/System/Team/TeamManager.cs
@@ -1,28 +1,26 @@
 using System.Collections.Generic;
 using System.Linq;
 using UnityEngine;
-
+using System;
 
 
 public class TeamManager : GameSystemManager<TeamManager>
 {
 	protected Dictionary<TeamType, TeamBase> teamDict = new Dictionary<TeamType, TeamBase>();
 
+	public Action<TeamType> OnTeamChange = null;
+
 	public override void Init()
 	{
 		base.Init();
 		
-		HeroManager.Instance.onHeroChangeEvent += onHeroChangeEvent;
-        HeroManager.Instance.onHeroDeleteEvent += onHeroDeleteEvent;
         DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitialize;
     }
 
 	public override void Release()
 	{
 		base.Release();
-		HeroManager.Instance.onHeroChangeEvent += onHeroChangeEvent;
-        HeroManager.Instance.onHeroDeleteEvent += onHeroDeleteEvent;
-        DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitialize;
+        DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent -= OnBeforePlayerDataInitialize;
     }
 
 	protected void OnBeforePlayerDataInitialize()
@@ -30,106 +28,44 @@
 		teamDict.Clear();
 	}
 
-	protected void onHeroChangeEvent(HeroInfo heroInfo)
+	public void OnHeroChangeEvent(HB124_tagSCLineupInfo vNetData)
 	{
-		//  鑻遍泟褰撳墠鎵�鏈夊湪鐨勯槦浼�
-		List<int> heroTeams = heroInfo.itemHero.GetUseData(81);
-
-		Dictionary<TeamType, KeyValuePair<int, int>> teamTypeShapeTypePositionDict = new Dictionary<TeamType, KeyValuePair<int, int>>();
-		foreach (var teamMsg in heroTeams)
+		var heroPack = PackManager.Instance.GetSinglePack(PackType.Hero);
+		HashSet<TeamType> teamTypeSet = new HashSet<TeamType>();
+		for (int i = 0; i < vNetData.LineupCnt; i++)
 		{
-			// 鎵�鍦ㄩ樀瀹逛俊鎭垪琛� [闃靛绫诲瀷*10000+闃靛瀷绫诲瀷*100+浣嶇疆缂栧彿, ...] 
-			int teamType = teamMsg / 10000;
-			int shapeType = (teamMsg % 10000) / 100;
-			int positionIndex = teamMsg % 100;
-
-			if (teamTypeShapeTypePositionDict.ContainsKey((TeamType)teamType))
+			TeamType teamType = (TeamType)vNetData.LineupList[i].LineupID;
+			teamTypeSet.Add(teamType);
+			var team = GetTeam(teamType);
+			for (int j = 0; j < vNetData.LineupList[i].HeroCnt; j++)
 			{
-				//  闃熶紞绫诲瀷鐩稿悓锛屾洿鏂伴樀鍨嬪拰浣嶇疆
-				Debug.LogError("褰撳墠鑻遍泟鎷ユ湁涓や釜鐩稿悓鐨勯槦浼嶄俊鎭�: " + teamType + " " + shapeType + " " + positionIndex + ", hero guid is " + heroInfo.itemHero.guid);
-			}
-			else
-			{
-				//  闃熶紞绫诲瀷涓嶅悓锛屾坊鍔犳柊鐨�
-				KeyValuePair<int, int> shapeTypePosition = new KeyValuePair<int, int>(shapeType, positionIndex);
-				teamTypeShapeTypePositionDict.Add((TeamType)teamType, shapeTypePosition);
-			}
-		}
-
-		//  閬嶅巻褰撳墠鎵�鏈夐槦浼� 鍒ゆ柇褰撳墠闃熶紞閲屾槸鍚︽湁璇ヨ嫳闆�
-		//  濡傛灉鏈夌殑璇� 璇诲彇涓�涓嬪綋鍓嶆槸鍚﹁鑻遍泟杩樺湪闃熶紞閲� 浣嶇疆鏄惁鍙戠敓鍙樺寲
-		//  鎴栬�呮槸闃靛瀷鍙戠敓鍙樺寲 鎴栬�呭崟绾殑鑻遍泟鍙戠敓鍙樺寲
-		//  濡傛灉娌℃湁鐨勮瘽 灏辫鏄庤鑻遍泟琚Щ鍑洪槦浼嶄簡
-		foreach (var team in teamDict.Values)
-		{
-			//  妫�鏌ヤ竴涓嬪綋鍓嶉槦浼嶆槸鍚︽湁璇ヨ嫳闆�
-			//  濡傛灉鏈夌殑璇� 璇诲彇涓�涓嬪綋鍓嶆槸鍚﹁鑻遍泟杩樺湪闃熶紞閲� 浣嶇疆鏄惁鍙戠敓鍙樺寲
-			TeamHero teamHero = team.GetHero(heroInfo.itemHero.guid);
-			if (teamHero != null)
-			{
-				if ((teamTypeShapeTypePositionDict.ContainsKey(team.teamType)))
+				int index = vNetData.LineupList[i].HeroItemIndexList[j];
+				HeroInfo hero;
+				if (index == 0)
 				{
-					KeyValuePair<int, int> shapeTypePosition = teamTypeShapeTypePositionDict[team.teamType];
-					//  鏇存柊闃熶紞淇℃伅 
-					// 鍙互鍒ゆ柇teamHero鐨刾ositionNum鏄惁璺焥hapeTypePosition.Value涓�鑷� 鍒ゆ柇鏄惁鍙樹綅缃簡
-					// 鍙互鍒ゆ柇teamHero鐨凷erverShapeType鏄惁璺焥hapeTypePosition.Key涓�鑷� 鍒ゆ柇鏄惁鍙橀樀鍨嬩簡
-					team.RefreshServerData(shapeTypePosition.Key, shapeTypePosition.Value, heroInfo);
+					hero = null;
 				}
 				else
 				{
-					//  闃熶紞閲屾湁杩欎釜鑻遍泟锛屼絾鏄湪闃熶紞淇℃伅閲屾病鏈変簡 缃┖ 锛堣绉诲嚭闃熶紞锛�
-					team.SetTeamHero(teamHero.positionNum, null);
+					var item = heroPack.GetItemByIndex(vNetData.LineupList[i].HeroItemIndexList[j] - 1);
+					if (item == null)
+					{
+						hero = null;
+						Debug.LogError("娌℃湁瀵瑰簲鐨勬灏嗘暟鎹紒");
+					}
+					hero = HeroManager.Instance.GetHero(item.guid);
+
 				}
-			}
-			//	鍘熸潵闃熶紞閲屾病杩欎釜鑻遍泟
-			else
-			{
-				//  濡傛灉褰撳墠闃熶紞绫诲瀷鍦ㄨ嫳闆勭殑鎵�鍦ㄩ樀瀹逛俊鎭垪琛ㄩ噷鏈夌殑璇�
-				//	灏辫鏄庨槦浼嶉噷鏂板浜嗚繖涓嫳闆� 锛堟柊澧炶繘闃熶紞锛�
-				if (teamTypeShapeTypePositionDict.ContainsKey(team.teamType))
-				{
-					KeyValuePair<int, int> shapeTypePosition = teamTypeShapeTypePositionDict[team.teamType];
-					team.RefreshServerData(shapeTypePosition.Key, shapeTypePosition.Value, null);
-				}
+				team.RefreshServerData(vNetData.LineupList[i].ShapeType, j, hero);
 			}
 		}
 
-
-		//  閬嶅巻鑻遍泟鎵�鍦ㄧ殑闃熶紞淇℃伅鍒楄〃 鏂板涓�涓嬪綋鍓嶅偍瀛樼殑闃熶紞閲屾病鏈夌殑闃熶紞
-		foreach (var teamTypeShapeTypePosition in teamTypeShapeTypePositionDict)
+		foreach (var tt in teamTypeSet)
 		{
-			//  濡傛灉褰撳墠闃熶紞绫诲瀷鍦ㄩ槦浼嶅瓧鍏搁噷娌℃湁鐨勮瘽
-			if (!teamDict.ContainsKey(teamTypeShapeTypePosition.Key))
-			{
-				//  鏂板缓涓�涓槦浼�
-				TeamBase team = new TeamBase(teamTypeShapeTypePosition.Key);
-				team.RefreshServerData(teamTypeShapeTypePosition.Value.Key, teamTypeShapeTypePosition.Value.Value, heroInfo);
-				teamDict.Add(teamTypeShapeTypePosition.Key, team);
-			}
-		}
-
-    } 
-
-
-	protected void onHeroDeleteEvent(HeroInfo heroInfo)
-	{
-		List<int> heroTeams = heroInfo.itemHero.GetUseData(81);
-
-		foreach (int teamMsg in heroTeams)
-		{
-			// 鎵�鍦ㄩ樀瀹逛俊鎭垪琛� [闃靛绫诲瀷*10000+闃靛瀷绫诲瀷*100+浣嶇疆缂栧彿, ...] 
-			int teamType = teamMsg / 10000;
-			int shapeType = (teamMsg % 10000) / 100;
-			int positionIndex = teamMsg % 100;
-
-			TeamBase team = GetTeam((TeamType)teamType);
-
-			if (team != null)
-			{
-				team.RefreshServerData(shapeType, positionIndex, null);
-			}
+			OnTeamChange?.Invoke(tt);
 		}
 	}
+
 
 	public bool HasTeam(TeamType teamType)
 	{
@@ -143,7 +79,7 @@
 		if (!teamDict.TryGetValue(teamType, out team))
 		{
 			team = new TeamBase(teamType);
-			team.CreateDefault(HeroManager.Instance.GetPowerfulHeroList());
+			// team.CreateDefault(HeroManager.Instance.GetPowerfulHeroList());
 			teamDict.Add(teamType, team);
 		}
 

--
Gitblit v1.8.0