2025-03-13 19:43:56 +08:00
|
|
|
|
using cfg.CharacterCfg;
|
2025-03-13 19:10:04 +08:00
|
|
|
|
using Framework;
|
|
|
|
|
|
using Google.Protobuf.Collections;
|
|
|
|
|
|
using NLDPB;
|
|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Gameplay.LegionBattle
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 军团战队伍数据
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public sealed class LegionTeamData
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 编队数据字典
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private Dictionary<uint, LegionRoleData> dicLegionRoleData;
|
2025-03-13 19:43:56 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 编队职业数量
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private Dictionary<Ejob, int> dicJobCount;
|
2025-03-13 19:10:04 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 队伍角色列表,最多3个队伍,每个队伍n个角色
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public List<LegionRoleData>[] RoleDataLists { get; private set; }
|
2025-03-14 17:57:35 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 队伍名
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public string[] TeamNames { get; private set; }
|
2025-03-13 19:10:04 +08:00
|
|
|
|
|
|
|
|
|
|
public LegionTeamData()
|
|
|
|
|
|
{
|
|
|
|
|
|
dicLegionRoleData = new Dictionary<uint, LegionRoleData>();
|
2025-03-13 19:43:56 +08:00
|
|
|
|
dicJobCount = new();
|
2025-03-14 17:57:35 +08:00
|
|
|
|
TeamNames = new string[TableManager.Instance.Tables.GlobalConfig.MaxLegionTeamCount];
|
2025-03-13 19:10:04 +08:00
|
|
|
|
|
|
|
|
|
|
RoleDataLists = new List<LegionRoleData>[TableManager.Instance.Tables.GlobalConfig.MaxLegionTeamCount];
|
|
|
|
|
|
for (int i = 0; i < TableManager.Instance.Tables.GlobalConfig.MaxLegionTeamCount; ++i)
|
|
|
|
|
|
{
|
|
|
|
|
|
RoleDataLists[i] = new List<LegionRoleData>();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 初始化数据
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="listTeam"></param>
|
|
|
|
|
|
/// <param name="listCharacter"></param>
|
|
|
|
|
|
public void InitData(RepeatedField<MSG_LB_Team> listTeam, RepeatedField<MSG_LB_Character> listCharacter)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < listTeam.Count; ++i)
|
|
|
|
|
|
{
|
2025-03-24 13:17:42 +08:00
|
|
|
|
MSG_LB_Team teamData = listTeam[i];
|
|
|
|
|
|
|
|
|
|
|
|
if (TeamNames.Length > i)
|
|
|
|
|
|
TeamNames[i] = teamData.Name;
|
|
|
|
|
|
LegionRoleData data = new(teamData.Commander);
|
|
|
|
|
|
dicLegionRoleData[teamData.Commander] = data;
|
2025-03-13 19:10:04 +08:00
|
|
|
|
RoleDataLists[i].Add(data);
|
|
|
|
|
|
|
2025-03-24 13:17:42 +08:00
|
|
|
|
foreach (uint id in teamData.Units)
|
2025-03-13 19:10:04 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (0u == id)
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
data = new LegionRoleData(id);
|
|
|
|
|
|
dicLegionRoleData[id] = data;
|
|
|
|
|
|
RoleDataLists[i].Add(data);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < listCharacter.Count; ++i)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!dicLegionRoleData.TryGetValue(listCharacter[i].Id, out LegionRoleData legionRoleData))
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
legionRoleData.CopyData(listCharacter[i]);
|
|
|
|
|
|
}
|
2025-03-13 19:43:56 +08:00
|
|
|
|
|
|
|
|
|
|
foreach (LegionRoleData legionRoleData in dicLegionRoleData.Values)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (dicJobCount.TryGetValue(legionRoleData.Job, out int count))
|
|
|
|
|
|
dicJobCount[legionRoleData.Job] = ++count;
|
|
|
|
|
|
else
|
|
|
|
|
|
dicJobCount[legionRoleData.Job] = 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取职业数量
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="ejob"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public int GetJobCount(Ejob ejob)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (dicJobCount.TryGetValue(ejob, out int count))
|
|
|
|
|
|
return count;
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
2025-03-13 19:10:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|