From fd28aac1d869fee3f5f3ad8b7bbdec579fdf91c0 Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期四, 09 十月 2025 17:05:54 +0800
Subject: [PATCH] 257 子 【配套功能】新手引导 / 【常规】引导 - 修复和推送功能同时打开问题
---
Main/System/Team/TeamManager.cs | 128 +++++++++---------------------------------
1 files changed, 28 insertions(+), 100 deletions(-)
diff --git a/Main/System/Team/TeamManager.cs b/Main/System/Team/TeamManager.cs
index 7c000a5..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,115 +28,45 @@
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>>();
-
-
- // 澶勭悊褰撳墠璁板綍鍦ㄨ嫳闆勪俊鎭噷鐨勯槦浼嶄俊鎭�
- if (null != heroTeams)
+ var heroPack = PackManager.Instance.GetSinglePack(PackType.Hero);
+ HashSet<TeamType> teamTypeSet = new HashSet<TeamType>();
+ for (int i = 0; i < vNetData.LineupCnt; i++)
{
- foreach (var teamMsg in heroTeams)
+ TeamType teamType = (TeamType)vNetData.LineupList[i].LineupID;
+ teamTypeSet.Add(teamType);
+ var team = GetTeam(teamType);
+ for (int j = 0; j < vNetData.LineupList[i].HeroCnt; j++)
{
- // 鎵�鍦ㄩ樀瀹逛俊鎭垪琛� [闃靛绫诲瀷*10000+闃靛瀷绫诲瀷*100+浣嶇疆缂栧彿, ...]
- int teamType = teamMsg / 10000;
- int shapeType = (teamMsg % 10000) / 100;
- int positionIndex = teamMsg % 100 - 1; //甯冮樀浣嶇疆锛氭湇鍔$涓� 1 瀹㈡埛绔负0
-
- if (teamTypeShapeTypePositionDict.ContainsKey((TeamType)teamType))
+ int index = vNetData.LineupList[i].HeroItemIndexList[j];
+ HeroInfo hero;
+ if (index == 0)
{
- // 闃熶紞绫诲瀷鐩稿悓锛屾洿鏂伴樀鍨嬪拰浣嶇疆
- Debug.LogError("褰撳墠鑻遍泟鎷ユ湁涓や釜鐩稿悓鐨勯槦浼嶄俊鎭�: " + teamType + " " + shapeType + " " + positionIndex + ", hero guid is " + heroInfo.itemHero.guid);
+ hero = null;
}
else
{
- // 闃熶紞绫诲瀷涓嶅悓锛屾坊鍔犳柊鐨�
- KeyValuePair<int, int> shapeTypePosition = new KeyValuePair<int, int>(shapeType, positionIndex);
- teamTypeShapeTypePositionDict.Add((TeamType)teamType, shapeTypePosition);
+ 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);
}
}
-
- // 閬嶅巻褰撳墠鎵�鏈夐槦浼� 鍒ゆ柇褰撳墠闃熶紞閲屾槸鍚︽湁璇ヨ嫳闆�
- // 濡傛灉鏈夌殑璇� 鏍规嵁鑻遍泟閲岀殑淇℃伅褰撳墠鏄惁璇ヨ嫳闆勮繕鍦ㄩ槦浼嶉噷 鏄惁鍙戠敓鍙樺寲
- // =>1.闃靛瀷鍙戠敓鍙樺寲 2.浣嶇疆鍙戠敓鍙樺寲
- // 濡傛灉娌℃湁鐨勮瘽 灏辫鏄庤鑻遍泟琚Щ鍑洪槦浼嶄簡
- foreach (var team in teamDict.Values)
+ foreach (var tt in teamTypeSet)
{
- // 妫�鏌ヤ竴涓嬪綋鍓嶉槦浼嶆槸鍚︽湁璇ヨ嫳闆�
- // 濡傛灉鏈夌殑璇� 璇诲彇涓�涓嬪綋鍓嶆槸鍚﹁鑻遍泟杩樺湪闃熶紞閲� 浣嶇疆鏄惁鍙戠敓鍙樺寲
- TeamHero teamHero = team.GetHero(heroInfo.itemHero.guid);
- if (teamHero != null)
- {
- if ((teamTypeShapeTypePositionDict.ContainsKey(team.teamType)))
- {
- KeyValuePair<int, int> shapeTypePosition = teamTypeShapeTypePositionDict[team.teamType];
- // 鏇存柊闃熶紞淇℃伅
- // 鍙互鍒ゆ柇teamHero鐨刾ositionNum鏄惁璺焥hapeTypePosition.Value涓�鑷� 鍒ゆ柇鏄惁鍙樹綅缃簡
- // 鍙互鍒ゆ柇teamHero鐨凷erverShapeType鏄惁璺焥hapeTypePosition.Key涓�鑷� 鍒ゆ柇鏄惁鍙橀樀鍨嬩簡
- team.RefreshServerData(shapeTypePosition.Key, shapeTypePosition.Value, heroInfo);
- }
- else
- {
- // 闃熶紞閲屾湁杩欎釜鑻遍泟锛屼絾鏄湪闃熶紞淇℃伅閲屾病鏈変簡 缃┖ 锛堣绉诲嚭闃熶紞锛�
- team.RemoveHero(teamHero.positionNum);
- }
- }
- // 鍘熸潵闃熶紞閲屾病杩欎釜鑻遍泟
- else
- {
- // 濡傛灉褰撳墠闃熶紞绫诲瀷鍦ㄨ嫳闆勭殑鎵�鍦ㄩ樀瀹逛俊鎭垪琛ㄩ噷鏈夌殑璇�
- // 灏辫鏄庨槦浼嶉噷鏂板浜嗚繖涓嫳闆� 锛堟柊澧炶繘闃熶紞锛�
- if (teamTypeShapeTypePositionDict.ContainsKey(team.teamType))
- {
- KeyValuePair<int, int> shapeTypePosition = teamTypeShapeTypePositionDict[team.teamType];
- team.RefreshServerData(shapeTypePosition.Key, shapeTypePosition.Value, heroInfo);
- }
- }
- }
-
-
- // 閬嶅巻鑻遍泟鎵�鍦ㄧ殑闃熶紞淇℃伅鍒楄〃 鏂板涓�涓嬪綋鍓嶅偍瀛樼殑闃熶紞閲屾病鏈夌殑闃熶紞
- foreach (var teamTypeShapeTypePosition in teamTypeShapeTypePositionDict)
- {
- // 濡傛灉褰撳墠闃熶紞绫诲瀷鍦ㄩ槦浼嶅瓧鍏搁噷娌℃湁鐨勮瘽
- 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 - 1; //甯冮樀浣嶇疆锛氭湇鍔$涓� 1 瀹㈡埛绔负0
-
- TeamBase team = GetTeam((TeamType)teamType);
-
- if (team != null)
- {
- team.RefreshServerData(shapeType, positionIndex, null);
- }
+ OnTeamChange?.Invoke(tt);
}
}
+
public bool HasTeam(TeamType teamType)
{
return teamDict.ContainsKey(teamType);
--
Gitblit v1.8.0