From 02e13cfa81063db800cad02c8ba8932bfba2e6fe Mon Sep 17 00:00:00 2001
From: lcy <1459594991@qq.com>
Date: 星期四, 28 五月 2026 19:33:34 +0800
Subject: [PATCH] 666 新增代金券 修复商城货币框代币显示问题

---
 Main/System/Team/TeamManager.cs |  110 ++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 97 insertions(+), 13 deletions(-)

diff --git a/Main/System/Team/TeamManager.cs b/Main/System/Team/TeamManager.cs
index 4bf5ce6..1fc32a3 100644
--- a/Main/System/Team/TeamManager.cs
+++ b/Main/System/Team/TeamManager.cs
@@ -1,33 +1,117 @@
 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>();
+	protected Dictionary<int, TeamBase> teamDict = new Dictionary<int, TeamBase>();
 
-    public override void Init()
-    {
-        base.Init();
+	public Action<int> 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;
     }
 
-	public TeamBase GetTeam(TeamType teamType)
+	protected void OnBeforePlayerDataInitialize()
+	{
+		teamDict.Clear();
+	}
+
+	public void OnHeroChangeEvent(HB124_tagSCHeroPresetInfo vNetData)
+	{
+		var heroPack = PackManager.Instance.GetSinglePack(PackType.Hero);
+		HashSet<int> teamTypeSet = new HashSet<int>();
+		for (int i = 0; i < vNetData.PresetCnt; i++)
+		{
+			int teamType = vNetData.PresetList[i].PresetID;
+			teamTypeSet.Add(teamType);
+			var team = GetTeam(teamType);
+			for (int j = 0; j < vNetData.PresetList[i].HeroCnt; j++)
+			{
+				int index = vNetData.PresetList[i].HeroItemIndexList[j];
+				HeroInfo hero;
+				if (index == 0)
+				{
+					hero = null;
+				}
+				else
+				{
+					var item = heroPack.GetItemByIndex(vNetData.PresetList[i].HeroItemIndexList[j] - 1);
+					if (item == null)
+					{
+						hero = null;
+						Debug.LogError("娌℃湁瀵瑰簲鐨勬灏嗘暟鎹紒");
+					}
+					hero = HeroManager.Instance.GetHero(item.guid);
+
+				}
+				team.RefreshServerData(j, hero);
+			}
+		}
+
+		foreach (var tt in teamTypeSet)
+		{
+			OnTeamChange?.Invoke(tt);
+		}
+	}
+
+
+	public bool HasTeam(int teamType)
+	{
+		return teamDict.ContainsKey(teamType);
+	}
+
+	//閫氳繃闃靛鏂规ID鑾峰彇闃靛 浠�1寮�濮�
+	public TeamBase GetTeam(int presetID)
 	{
 		TeamBase team = null;
 
-		if (!teamDict.TryGetValue(teamType, out team))
+		if (!teamDict.TryGetValue(presetID, out team))
 		{
-			team = new TeamBase();
-			team.AddTeamHeros(HeroManager.Instance.GetPowerfulHeroList());
-			teamDict.Add(teamType, team);
+			team = new TeamBase(presetID);
+			// team.CreateDefault(HeroManager.Instance.GetPowerfulHeroList());
+			teamDict.Add(presetID, team);
 		}
 
 		return team;
 	}
+
+	//閫氳繃鎴樻枟绫诲瀷鑾峰彇闃靛
+	public TeamBase GetTeam(BattlePreSetType battlePassType)
+	{
+		int presetID = GetTeamID(battlePassType);
+		TeamBase team = null;
+
+		if (!teamDict.TryGetValue(presetID, out team))
+		{
+			team = new TeamBase(presetID);
+			// team.CreateDefault(HeroManager.Instance.GetPowerfulHeroList());
+			teamDict.Add(presetID, team);
+		}
+
+		return team;
+	}
+
+	// 鑾峰彇涓婚樀瀹规柟妗圛D
+	public int GetMainTeamID()
+	{
+		return FuncPresetManager.Instance.GetFuncPresetIDByBattleType((int)BattlePreSetType.Story, (int)FuncPresetType.Team);
+	}
+
+	// 鑾峰彇鎸囧畾鐨勬柟妗圛D
+	public int GetTeamID(BattlePreSetType battleType)
+	{
+		return FuncPresetManager.Instance.GetFuncPresetIDByBattleType((int)battleType, (int)FuncPresetType.Team);
+	}
 }
\ No newline at end of file

--
Gitblit v1.8.0