From af8dafd75f9a6fae017734d58fc7b34d6bdcd0f4 Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期一, 25 八月 2025 22:03:51 +0800
Subject: [PATCH] 0312 开启限帧

---
 Main/System/Team/TeamManager.cs |   86 ++++++++++++++++++++++++++++++++-----------
 1 files changed, 64 insertions(+), 22 deletions(-)

diff --git a/Main/System/Team/TeamManager.cs b/Main/System/Team/TeamManager.cs
index 7639faf..2afd452 100644
--- a/Main/System/Team/TeamManager.cs
+++ b/Main/System/Team/TeamManager.cs
@@ -1,21 +1,76 @@
 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 override void Init()
-    {
-        base.Init();
+	public Action<TeamType> OnTeamChange = null;
+
+	public override void Init()
+	{
+		base.Init();
+		
+        DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitialize;
     }
 
-    public override void Release()
-    {
-        base.Release();
+	public override void Release()
+	{
+		base.Release();
+        DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent -= OnBeforePlayerDataInitialize;
     }
+
+	protected void OnBeforePlayerDataInitialize()
+	{
+		teamDict.Clear();
+	}
+
+	public void OnHeroChangeEvent(HB124_tagSCLineupInfo vNetData)
+	{
+		var heroPack = PackManager.Instance.GetSinglePack(PackType.Hero);
+		HashSet<TeamType> teamTypeSet = new HashSet<TeamType>();
+		for (int i = 0; i < vNetData.LineupCnt; i++)
+		{
+			TeamType teamType = (TeamType)vNetData.LineupList[i].LineupID;
+			teamTypeSet.Add(teamType);
+			var team = GetTeam(teamType);
+			for (int j = 0; j < vNetData.LineupList[i].HeroCnt; j++)
+			{
+				int index = vNetData.LineupList[i].HeroItemIndexList[j];
+				HeroInfo hero;
+				if (index == 0)
+				{
+					hero = null;
+				}
+				else
+				{
+					var item = heroPack.GetItemByIndex(vNetData.LineupList[i].HeroItemIndexList[j] - 1);
+					if (item == null)
+					{
+						hero = null;
+						Debug.LogError("娌℃湁瀵瑰簲鐨勬灏嗘暟鎹紒");
+					}
+					hero = HeroManager.Instance.GetHero(item.guid);
+
+				}
+				team.RefreshServerData(vNetData.LineupList[i].ShapeType, j, hero);
+			}
+		}
+
+		foreach (var tt in teamTypeSet)
+		{
+			OnTeamChange?.Invoke(tt);
+		}
+	}
+
+
+	public bool HasTeam(TeamType teamType)
+	{
+		return teamDict.ContainsKey(teamType);
+	}
 
 	public TeamBase GetTeam(TeamType teamType)
 	{
@@ -23,22 +78,9 @@
 
 		if (!teamDict.TryGetValue(teamType, out team))
 		{
-			team = GetStoryTeam();
+			team = new TeamBase(teamType);
+			// team.CreateDefault(HeroManager.Instance.GetPowerfulHeroList());
 			teamDict.Add(teamType, team);
-		}
-
-		return team;
-	}	
-
-	public TeamBase GetStoryTeam()
-	{
-		TeamBase team = null;
-
-		if (!teamDict.TryGetValue(TeamType.Story, out team))
-		{
-			team = new TeamBase();
-			team.AddTeamHeros(HeroManager.Instance.GetPowerfulHeroList());
-			teamDict.Add(TeamType.Story, team);
 		}
 
 		return team;

--
Gitblit v1.8.0