2024-12-16 15:50:22 +08:00
|
|
|
|
using System.Collections.Generic;
|
2025-01-09 19:37:58 +08:00
|
|
|
|
using System.Linq;
|
2024-12-26 16:58:15 +08:00
|
|
|
|
using cfg.LegionCfg;
|
2024-12-23 12:12:52 +08:00
|
|
|
|
using Framework;
|
2025-01-07 17:19:22 +08:00
|
|
|
|
using Gameplay;
|
2025-01-09 16:05:41 +08:00
|
|
|
|
using Gameplay.Common;
|
2024-12-26 16:58:15 +08:00
|
|
|
|
using Gameplay.Net;
|
|
|
|
|
|
using NLDPB;
|
2024-12-16 15:50:22 +08:00
|
|
|
|
using PhxhSDK;
|
2024-12-23 12:12:52 +08:00
|
|
|
|
using Sirenix.Utilities;
|
2025-01-09 19:37:58 +08:00
|
|
|
|
using UnityEngine;
|
2024-12-16 15:50:22 +08:00
|
|
|
|
|
2024-12-23 12:12:52 +08:00
|
|
|
|
public partial class LegionManager: Singlenton<LegionManager>, IInitable
|
2024-12-16 15:50:22 +08:00
|
|
|
|
{
|
2024-12-19 14:46:02 +08:00
|
|
|
|
public bool Belong2Legion => _myLegion != null;
|
2025-01-10 19:38:13 +08:00
|
|
|
|
public enum MemberOpType
|
|
|
|
|
|
{
|
|
|
|
|
|
All,
|
|
|
|
|
|
Add,
|
|
|
|
|
|
Update,
|
|
|
|
|
|
Remove
|
|
|
|
|
|
}
|
2025-01-16 17:22:20 +08:00
|
|
|
|
|
|
|
|
|
|
public enum EMyApplyStatus
|
|
|
|
|
|
{
|
|
|
|
|
|
None,
|
|
|
|
|
|
Already,
|
|
|
|
|
|
Refused,
|
|
|
|
|
|
}
|
2024-12-19 14:46:02 +08:00
|
|
|
|
|
2024-12-16 15:50:22 +08:00
|
|
|
|
#region API
|
|
|
|
|
|
|
|
|
|
|
|
public void Init()
|
|
|
|
|
|
{
|
|
|
|
|
|
_RegisterEvents();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Release()
|
|
|
|
|
|
{
|
|
|
|
|
|
_UnregisterEvents();
|
|
|
|
|
|
}
|
2024-12-19 14:46:02 +08:00
|
|
|
|
|
2025-01-10 19:38:13 +08:00
|
|
|
|
public void ClearMyLegion()
|
|
|
|
|
|
{
|
|
|
|
|
|
_myLegion = null;
|
|
|
|
|
|
_myLegionMemberList?.Clear();
|
|
|
|
|
|
_applyMemberList?.Clear();
|
|
|
|
|
|
}
|
2024-12-23 15:34:46 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 设置客户端的 MyLegion Base数据
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public void SetMyLegionBase()
|
|
|
|
|
|
{
|
2025-01-14 19:07:21 +08:00
|
|
|
|
if (_myLegion != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
_myLegion._ParseLegionBase(NetLegionBaseData);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
_myLegion = _GetParseLegionData(NetLegionBaseData);
|
2025-01-24 14:50:06 +08:00
|
|
|
|
EventManager.Instance.Send(EventManager.EventName.LegionBaseData);
|
2024-12-23 15:34:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-01-10 19:38:13 +08:00
|
|
|
|
/// 设置客户端的 MyLegion Member数据, 0全部刷新,1增加,2刷新,3减少
|
2024-12-23 15:34:46 +08:00
|
|
|
|
/// </summary>
|
2025-01-24 14:50:06 +08:00
|
|
|
|
public void SetMyLegionMembers(bool isAll = false)
|
2024-12-23 15:34:46 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (_myLegionMemberList == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
_myLegionMemberList = new();
|
|
|
|
|
|
}
|
2025-01-24 14:50:06 +08:00
|
|
|
|
else if(isAll)
|
2024-12-23 15:34:46 +08:00
|
|
|
|
{
|
|
|
|
|
|
_myLegionMemberList.Clear();
|
|
|
|
|
|
}
|
2025-01-24 14:50:06 +08:00
|
|
|
|
|
2024-12-23 15:34:46 +08:00
|
|
|
|
foreach (var memberData in NetLegionMemberList)
|
|
|
|
|
|
{
|
2025-01-24 14:50:06 +08:00
|
|
|
|
if (isAll)
|
2025-01-10 19:38:13 +08:00
|
|
|
|
{
|
2025-01-24 14:50:06 +08:00
|
|
|
|
_myLegionMemberList.Add(new ActorLegionData(memberData));
|
|
|
|
|
|
continue;
|
2025-01-10 19:38:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-01-24 14:50:06 +08:00
|
|
|
|
var index = _myLegionMemberList.FindIndex(item => item.ActorID == memberData.ActorId);
|
|
|
|
|
|
if (memberData.IsDelete > 0)
|
2025-01-10 19:38:13 +08:00
|
|
|
|
{
|
2025-01-24 14:50:06 +08:00
|
|
|
|
if (index > -1)
|
2025-01-10 19:38:13 +08:00
|
|
|
|
{
|
2025-01-24 14:50:06 +08:00
|
|
|
|
_myLegionMemberList.RemoveAt(index);
|
2025-01-10 19:38:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-01-24 14:50:06 +08:00
|
|
|
|
else
|
2025-01-10 19:38:13 +08:00
|
|
|
|
{
|
2025-01-24 14:50:06 +08:00
|
|
|
|
if (index > -1)
|
2025-01-10 19:38:13 +08:00
|
|
|
|
{
|
2025-01-24 14:50:06 +08:00
|
|
|
|
_myLegionMemberList[index] = new ActorLegionData(memberData);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
_myLegionMemberList.Add(new ActorLegionData(memberData));
|
2025-01-10 19:38:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-01-24 14:50:06 +08:00
|
|
|
|
|
2024-12-23 15:34:46 +08:00
|
|
|
|
}
|
2025-01-10 19:38:13 +08:00
|
|
|
|
|
|
|
|
|
|
NetLegionMemberList.Clear();
|
2025-01-24 14:50:06 +08:00
|
|
|
|
EventManager.Instance.Send(EventManager.EventName.LegionMemberData);
|
2024-12-23 15:34:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 设置客户端的 MyLegion ApplyMember数据
|
|
|
|
|
|
/// </summary>
|
2025-01-16 17:22:20 +08:00
|
|
|
|
public void SetMyLegionApplyMembers(bool isALl = false)
|
2024-12-23 15:34:46 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (_applyMemberList == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
_applyMemberList = new();
|
|
|
|
|
|
}
|
2025-01-16 17:22:20 +08:00
|
|
|
|
else if(isALl)
|
2024-12-23 15:34:46 +08:00
|
|
|
|
{
|
|
|
|
|
|
_applyMemberList.Clear();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-01-16 17:22:20 +08:00
|
|
|
|
if (isALl)
|
2024-12-23 15:34:46 +08:00
|
|
|
|
{
|
2025-01-16 17:22:20 +08:00
|
|
|
|
foreach (var applyData in NetLegionApplyDataList)
|
|
|
|
|
|
{
|
|
|
|
|
|
_applyMemberList.Add(new ActorLegionData(applyData));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var applyData in NetLegionApplyDataList)
|
|
|
|
|
|
{
|
|
|
|
|
|
var idx = _applyMemberList.FindIndex(member => member.ActorID == applyData.ActorId);
|
2025-02-06 15:43:28 +08:00
|
|
|
|
// if (applyData.IsDelete > 0)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// if (idx > -1)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// _applyMemberList.RemoveAt(idx);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// else
|
|
|
|
|
|
// {
|
|
|
|
|
|
// _applyMemberList.Add(new ActorLegionData(applyData));
|
|
|
|
|
|
// }
|
|
|
|
|
|
if (idx > -1)
|
2025-01-16 17:22:20 +08:00
|
|
|
|
{
|
2025-02-06 15:43:28 +08:00
|
|
|
|
_applyMemberList[idx] = new ActorLegionData(applyData);
|
2025-01-24 14:50:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
_applyMemberList.Add(new ActorLegionData(applyData));
|
2025-01-16 17:22:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-01-20 12:04:24 +08:00
|
|
|
|
|
|
|
|
|
|
NetLegionApplyDataList.Clear();
|
2025-01-16 17:22:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-01-20 18:37:14 +08:00
|
|
|
|
/// 自己申请的军团列表,
|
2025-01-16 17:22:20 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="isAll"></param>
|
|
|
|
|
|
public void SetMyApplyLegionList(bool isAll = false)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_myApplyLegionDatas == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
_myApplyLegionDatas = new();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if(isAll)
|
|
|
|
|
|
{
|
|
|
|
|
|
_myApplyLegionDatas.Clear();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var applyData in NetMyApplyLegionList)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (isAll)
|
|
|
|
|
|
{
|
|
|
|
|
|
_myApplyLegionDatas.Add(applyData.LegionId, new ApplyLegionData(applyData));
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (_myApplyLegionDatas.TryGetValue(applyData.LegionId, out var myApplyData))
|
|
|
|
|
|
{
|
2025-01-20 18:37:14 +08:00
|
|
|
|
if (applyData.Status == (uint) LegionExamineStatus.LgPass)
|
|
|
|
|
|
{
|
|
|
|
|
|
_myApplyLegionDatas.Remove(applyData.LegionId);
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
2025-01-16 17:22:20 +08:00
|
|
|
|
myApplyData.ExamineStatus = (LegionExamineStatus)applyData.Status;
|
|
|
|
|
|
myApplyData.OpTime = applyData.OpTime;
|
|
|
|
|
|
}
|
2025-01-20 14:22:28 +08:00
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
_myApplyLegionDatas.Add(applyData.LegionId, new ApplyLegionData(applyData));
|
|
|
|
|
|
}
|
2024-12-23 15:34:46 +08:00
|
|
|
|
}
|
2025-01-16 17:22:20 +08:00
|
|
|
|
NetMyApplyLegionList.Clear();
|
2024-12-23 15:34:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 设置客户端的 MyLegion 记录数据
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public void SetMyLegionLogs()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2025-01-06 19:03:07 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 刷新军团列表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public void SetLegionList()
|
|
|
|
|
|
{
|
|
|
|
|
|
_legions.Clear();
|
|
|
|
|
|
var legionDataList = NetLegionInfoDataList;
|
|
|
|
|
|
foreach (var legionData in legionDataList)
|
|
|
|
|
|
{
|
|
|
|
|
|
var legion = ParseLegion(legionData);
|
2025-01-09 19:37:58 +08:00
|
|
|
|
CorrectLegionData(legion);
|
2025-01-06 19:03:07 +08:00
|
|
|
|
_legions.Add(legion);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-12-26 16:58:15 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 确认是否有权限
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="eventID"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2024-12-30 13:39:26 +08:00
|
|
|
|
public bool CheckIsPermission(Permission eventID)
|
2024-12-26 16:58:15 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (_myLegion == null)
|
|
|
|
|
|
return false;
|
|
|
|
|
|
var eventCfg = TableManager.Instance.Tables.LegionPermissions.GetOrDefault(eventID);
|
|
|
|
|
|
if (eventCfg != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
var post = GetMyPost();
|
|
|
|
|
|
if (post != Position.None)
|
|
|
|
|
|
{
|
|
|
|
|
|
switch (post)
|
|
|
|
|
|
{
|
|
|
|
|
|
case Position.Member:
|
|
|
|
|
|
{
|
|
|
|
|
|
return eventCfg.Member > 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
case Position.RegimentalCommander:
|
|
|
|
|
|
{
|
|
|
|
|
|
return eventCfg.RegimentalCommander > 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
case Position.AssistantRegimentalCommander:
|
|
|
|
|
|
{
|
|
|
|
|
|
return eventCfg.AssistantRegimentalCommander > 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
case Position.Leroy:
|
|
|
|
|
|
{
|
|
|
|
|
|
return eventCfg.Leroy > 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
case Position.Diplomatist:
|
|
|
|
|
|
{
|
|
|
|
|
|
return eventCfg.Diplomatist > 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case Position.Commander:
|
|
|
|
|
|
{
|
|
|
|
|
|
return eventCfg.Commander > 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
default:
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-30 13:39:26 +08:00
|
|
|
|
public Position GetMyPost()
|
2024-12-26 16:58:15 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (_myLegion == null)
|
|
|
|
|
|
return Position.None;
|
|
|
|
|
|
if (_myLegionMemberList == null || _myLegionMemberList.Count <= 0)
|
|
|
|
|
|
return Position.None;
|
|
|
|
|
|
|
|
|
|
|
|
var myLegionActorData = _myLegionMemberList.Find(
|
|
|
|
|
|
data => data.ActorID == Actor.Instance.Base.GetProp(ActorProp.ActorId));
|
|
|
|
|
|
if (myLegionActorData != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return myLegionActorData.Post;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return Position.None;
|
|
|
|
|
|
}
|
2025-01-07 17:19:22 +08:00
|
|
|
|
|
|
|
|
|
|
public string GetPostStr(Position post)
|
|
|
|
|
|
{
|
|
|
|
|
|
switch (post)
|
|
|
|
|
|
{
|
|
|
|
|
|
case Position.Commander:
|
|
|
|
|
|
return CommonUtils.GetLocalizeText("legion_post_commander");
|
|
|
|
|
|
case Position.RegimentalCommander:
|
|
|
|
|
|
return CommonUtils.GetLocalizeText("legion_post_president");
|
|
|
|
|
|
case Position.AssistantRegimentalCommander:
|
|
|
|
|
|
return CommonUtils.GetLocalizeText("legion_post_assist_president");
|
|
|
|
|
|
case Position.Leroy:
|
|
|
|
|
|
return CommonUtils.GetLocalizeText("legion_post_leroy");
|
|
|
|
|
|
case Position.Diplomatist:
|
|
|
|
|
|
return CommonUtils.GetLocalizeText("legion_post_diplomatist");
|
|
|
|
|
|
case Position.Member:
|
|
|
|
|
|
return CommonUtils.GetLocalizeText("legion_post_member");
|
|
|
|
|
|
default:
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-01-09 16:05:41 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 是否合法军团标签
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
2025-01-09 19:37:58 +08:00
|
|
|
|
public bool CheckIsLegalLabelList(List<int> idxList)
|
2025-01-09 16:05:41 +08:00
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < idxList.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var tabIdx = idxList[i];
|
2025-01-09 19:37:58 +08:00
|
|
|
|
if (!CheckIsLegalLabel(tabIdx))
|
2025-01-09 16:05:41 +08:00
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-01-09 19:37:58 +08:00
|
|
|
|
public bool CheckIsLegalLabel(int idx)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!GLConfig.Inst.data.LegionLabelList.Contains(idx))
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-01-09 16:05:41 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 是否合法军团宣言
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="idx"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public bool CheckIsLegalManifesto(int idx)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (GLConfig.Inst.data.LegionDeclarationList.Contains(idx))
|
|
|
|
|
|
{
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-01-09 19:37:58 +08:00
|
|
|
|
public void CorrectMyLegion()
|
|
|
|
|
|
{
|
|
|
|
|
|
CorrectLegionData(_myLegion);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 校正军团不符合配置的数据
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="legion"></param>
|
|
|
|
|
|
public void CorrectLegionData(Legion legion)
|
|
|
|
|
|
{
|
|
|
|
|
|
CorrectTabList(legion);
|
|
|
|
|
|
CorrectManifesto(legion);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void CorrectManifesto(Legion legion)
|
|
|
|
|
|
{
|
|
|
|
|
|
var manifestoList = GLConfig.Inst.data.LegionDeclarationList;
|
|
|
|
|
|
if (!manifestoList.Contains(legion.ManifestoID))
|
|
|
|
|
|
{
|
|
|
|
|
|
legion.ManifestoID = manifestoList[0];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void CorrectTabList(Legion legion)
|
|
|
|
|
|
{
|
|
|
|
|
|
var count = legion.TabIdxList.Count;
|
|
|
|
|
|
var labelList = GLConfig.Inst.data.LegionLabelList;
|
|
|
|
|
|
if (count > labelList.Count)
|
|
|
|
|
|
{
|
|
|
|
|
|
legion.TabIdxList.Clear();
|
|
|
|
|
|
legion.TabIdxList = new List<int>(labelList);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var idx = legion.TabIdxList[i];
|
|
|
|
|
|
if (!CheckIsLegalLabel(idx))
|
|
|
|
|
|
{
|
|
|
|
|
|
legion.TabIdxList.Remove(idx);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (legion.TabIdxList.Count < 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
legion.TabIdxList.Add(labelList[0]);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-01-09 16:05:41 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取宣言文本
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="idx"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public string GetLegionLabelStr(int idx)
|
|
|
|
|
|
{
|
|
|
|
|
|
var labelIdxList = GLConfig.Inst.data.LegionLabelList;
|
|
|
|
|
|
var index = labelIdxList.Find(item => item == idx);
|
|
|
|
|
|
if (index > -1)
|
|
|
|
|
|
{
|
|
|
|
|
|
return CommonUtils.GetLocalizeText(E_LocalizePrefix.Legion_Label, idx);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DebugUtil.LogError($"无法获取军团标签文本, ID:{idx}");
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="idx"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public string GetLegionManifestoStr(int idx)
|
|
|
|
|
|
{
|
|
|
|
|
|
var manifestoIdxList = GLConfig.Inst.data.LegionDeclarationList;
|
|
|
|
|
|
var index = manifestoIdxList.Find(item => item == idx);
|
|
|
|
|
|
if (index > -1)
|
|
|
|
|
|
{
|
|
|
|
|
|
return CommonUtils.GetLocalizeText(E_LocalizePrefix.Legion_Declaration, idx);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DebugUtil.LogError($"无法获取军团宣言文本, ID:{idx}");
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
2025-01-09 19:37:58 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 随机获取一个宣言
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
2025-01-20 14:22:28 +08:00
|
|
|
|
public int GetRandomManifestoIdx(int curIdx)
|
2025-01-09 19:37:58 +08:00
|
|
|
|
{
|
|
|
|
|
|
var manifestoIdxList = GLConfig.Inst.data.LegionDeclarationList;
|
|
|
|
|
|
if (manifestoIdxList.Count > 0)
|
|
|
|
|
|
{
|
2025-01-20 14:22:28 +08:00
|
|
|
|
//var ranIdx = Random.Range(0, manifestoIdxList.Count);
|
2025-02-18 13:48:35 +08:00
|
|
|
|
var ranIdx = curIdx + 1 >= manifestoIdxList.Count ? 0 : ++curIdx;
|
2025-01-09 19:37:58 +08:00
|
|
|
|
return manifestoIdxList[ranIdx];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
2025-01-16 17:22:20 +08:00
|
|
|
|
|
|
|
|
|
|
public EMyApplyStatus GetApplyStatus(uint legionID)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_myApplyLegionDatas.TryGetValue(legionID, out var myApplyLegionData))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (myApplyLegionData.ExamineStatus == LegionExamineStatus.LgNone)
|
|
|
|
|
|
{
|
|
|
|
|
|
return EMyApplyStatus.Already;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (myApplyLegionData.ExamineStatus == LegionExamineStatus.LgReject)
|
|
|
|
|
|
{
|
|
|
|
|
|
return EMyApplyStatus.Refused;
|
|
|
|
|
|
}
|
2025-01-22 17:14:17 +08:00
|
|
|
|
|
2025-01-16 17:22:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return EMyApplyStatus.None;
|
|
|
|
|
|
}
|
2025-01-20 14:22:28 +08:00
|
|
|
|
|
|
|
|
|
|
public bool CheckPostLimit(Position position)
|
|
|
|
|
|
{
|
|
|
|
|
|
var count = 0;
|
|
|
|
|
|
var numData = TableManager.Instance.Tables.LegionPermissions.DataList[0];
|
|
|
|
|
|
var maxNum = 0;
|
|
|
|
|
|
switch (position)
|
|
|
|
|
|
{
|
|
|
|
|
|
case Position.RegimentalCommander:
|
|
|
|
|
|
maxNum = numData.RegimentalCommander;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case Position.AssistantRegimentalCommander:
|
|
|
|
|
|
maxNum = numData.AssistantRegimentalCommander;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case Position.Commander:
|
|
|
|
|
|
maxNum = numData.Commander;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case Position.Leroy:
|
|
|
|
|
|
maxNum = numData.Leroy;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case Position.Diplomatist:
|
|
|
|
|
|
maxNum = numData.Diplomatist;
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
maxNum = 20;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
2025-01-22 12:47:56 +08:00
|
|
|
|
|
|
|
|
|
|
if (maxNum == 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2025-01-20 14:22:28 +08:00
|
|
|
|
if (_myLegion != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_myLegionMemberList != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var actorData in _myLegionMemberList)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (actorData.Post == position)
|
|
|
|
|
|
{
|
|
|
|
|
|
++count;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return count >= maxNum;
|
|
|
|
|
|
}
|
2024-12-16 15:50:22 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Events
|
|
|
|
|
|
|
|
|
|
|
|
private void _RegisterEvents()
|
|
|
|
|
|
{
|
2024-12-23 12:12:52 +08:00
|
|
|
|
EventManager.Instance.Register(EventManager.EventName.LegionBaseData, _OnLegionBaseUpdate);
|
|
|
|
|
|
EventManager.Instance.Register(EventManager.EventName.LegionMemberData, _OnLegionMemberUpdate);
|
|
|
|
|
|
EventManager.Instance.Register(EventManager.EventName.LegionApplyData, _OnLegionApplyListUpdate);
|
|
|
|
|
|
EventManager.Instance.Register(EventManager.EventName.LegionCreateSuccess, _OnCreateSuccess);
|
2025-01-06 19:03:07 +08:00
|
|
|
|
EventManager.Instance.Register(EventManager.EventName.LegionQuitSuccess, _OnQuitSuccess);
|
2024-12-24 17:31:26 +08:00
|
|
|
|
EventManager.Instance.Register(EventManager.EventName.LegionJoinSendSuccess, _OnJoinApplySendSuccess);
|
2024-12-25 19:37:51 +08:00
|
|
|
|
EventManager.Instance.Register(EventManager.EventName.LegionMemberPostUpdate, _OnMemberPostUpdate);
|
2025-01-10 19:38:13 +08:00
|
|
|
|
EventManager.Instance.Register(EventManager.EventName.LegionJoinPermitted, _OnLegionJoinSuccess);
|
|
|
|
|
|
EventManager.Instance.Register(EventManager.EventName.LegionLose, _OnLegionLose);
|
2024-12-16 15:50:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void _UnregisterEvents()
|
|
|
|
|
|
{
|
2024-12-23 12:12:52 +08:00
|
|
|
|
EventManager.Instance.Unregister(EventManager.EventName.LegionBaseData, _OnLegionBaseUpdate);
|
|
|
|
|
|
EventManager.Instance.Unregister(EventManager.EventName.LegionMemberData, _OnLegionMemberUpdate);
|
|
|
|
|
|
EventManager.Instance.Unregister(EventManager.EventName.LegionApplyData, _OnLegionApplyListUpdate);
|
|
|
|
|
|
EventManager.Instance.Unregister(EventManager.EventName.LegionCreateSuccess, _OnCreateSuccess);
|
2025-01-06 19:03:07 +08:00
|
|
|
|
EventManager.Instance.Unregister(EventManager.EventName.LegionQuitSuccess, _OnQuitSuccess);
|
2024-12-24 17:31:26 +08:00
|
|
|
|
EventManager.Instance.Unregister(EventManager.EventName.LegionJoinSendSuccess, _OnJoinApplySendSuccess);
|
2024-12-25 19:37:51 +08:00
|
|
|
|
EventManager.Instance.Unregister(EventManager.EventName.LegionMemberPostUpdate, _OnMemberPostUpdate);
|
2025-01-10 19:38:13 +08:00
|
|
|
|
EventManager.Instance.Unregister(EventManager.EventName.LegionJoinPermitted, _OnLegionJoinSuccess);
|
|
|
|
|
|
EventManager.Instance.Unregister(EventManager.EventName.LegionLose, _OnLegionLose);
|
2024-12-23 12:12:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 军团BaseData更新
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private void _OnLegionBaseUpdate()
|
|
|
|
|
|
{
|
2024-12-23 15:34:46 +08:00
|
|
|
|
|
2024-12-23 12:12:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 军团成员列表更新
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private void _OnLegionMemberUpdate()
|
|
|
|
|
|
{
|
2024-12-23 15:34:46 +08:00
|
|
|
|
|
2024-12-23 12:12:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 军团申请成员列表更新
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private void _OnLegionApplyListUpdate()
|
|
|
|
|
|
{
|
2024-12-23 15:34:46 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
2024-12-23 12:12:52 +08:00
|
|
|
|
|
2024-12-23 15:34:46 +08:00
|
|
|
|
private void _OnLegionLogUpdate()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
2024-12-23 12:12:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 创建军团成功
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private void _OnCreateSuccess()
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("创建军团成功!");
|
2024-12-23 15:34:46 +08:00
|
|
|
|
if (IsPresident)
|
2024-12-23 12:12:52 +08:00
|
|
|
|
{
|
2024-12-23 15:34:46 +08:00
|
|
|
|
DebugUtil.LogG($"军团ID:{_myLegion.ID}");
|
2024-12-23 12:12:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 退出军团成功
|
|
|
|
|
|
/// </summary>
|
2025-01-06 19:03:07 +08:00
|
|
|
|
private void _OnQuitSuccess()
|
2024-12-23 12:12:52 +08:00
|
|
|
|
{
|
2025-01-10 19:38:13 +08:00
|
|
|
|
ClearMyLegion();
|
2024-12-16 15:50:22 +08:00
|
|
|
|
}
|
2024-12-23 15:34:46 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 加入军团成功
|
|
|
|
|
|
/// </summary>
|
2024-12-24 17:31:26 +08:00
|
|
|
|
private void _OnJoinApplySendSuccess()
|
2024-12-23 15:34:46 +08:00
|
|
|
|
{
|
2025-01-13 17:33:48 +08:00
|
|
|
|
DebugUtil.LogError("申请加入军团成功!!!");
|
2024-12-25 19:37:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 修改成员职位
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private void _OnMemberPostUpdate()
|
|
|
|
|
|
{
|
2025-01-14 14:50:13 +08:00
|
|
|
|
//DebugUtil.LogError("成员职位修改成功!!!");
|
2024-12-23 15:34:46 +08:00
|
|
|
|
}
|
2025-01-10 19:38:13 +08:00
|
|
|
|
|
|
|
|
|
|
private void _OnLegionJoinSuccess()
|
|
|
|
|
|
{
|
2025-01-13 17:33:48 +08:00
|
|
|
|
ReqMyLegionPart(LegionPart.Member);
|
2025-01-10 19:38:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void _OnLegionLose()
|
|
|
|
|
|
{
|
|
|
|
|
|
//ReqMyLegionPart(LegionPart.Member);
|
|
|
|
|
|
ClearMyLegion();
|
2025-01-20 13:08:33 +08:00
|
|
|
|
EventManager.Instance.Send(EventManager.EventName.LegionClear);
|
2025-01-10 19:38:13 +08:00
|
|
|
|
}
|
2024-12-16 15:50:22 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
}
|