170 lines
5.3 KiB
C#
170 lines
5.3 KiB
C#
using Framework;
|
|
using Google.Protobuf.Collections;
|
|
using NLDPB;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Gameplay.LegionBattle
|
|
{
|
|
public sealed partial class LegionBattleManager
|
|
{
|
|
/// <summary>
|
|
/// 军团信息字典
|
|
/// </summary>
|
|
private Dictionary<BattlefieldActorCamp, LegionInfo> dicLegionInfo;
|
|
/// <summary>
|
|
/// 玩家信息字典
|
|
/// </summary>
|
|
private Dictionary<int, LegionActorInfo> dicActorInfo;
|
|
/// <summary>
|
|
/// 建筑信息字典
|
|
/// </summary>
|
|
private Dictionary<int, LegionBuildingInfo> dicBuildingInfo;
|
|
|
|
/// <summary>
|
|
/// 地图id
|
|
/// </summary>
|
|
public int MapId { get; private set; }
|
|
/// <summary>
|
|
/// 战场开始时间
|
|
/// </summary>
|
|
public DateTime StartTime { get; private set; }
|
|
/// <summary>
|
|
/// 持续时间
|
|
/// </summary>
|
|
public int TimeLength { get; private set; }
|
|
|
|
/// <summary>
|
|
/// 初始化军团战信息
|
|
/// </summary>
|
|
private void InitInfo()
|
|
{
|
|
dicLegionInfo = new Dictionary<BattlefieldActorCamp, LegionInfo>()
|
|
{
|
|
[BattlefieldActorCamp.CampA] = new LegionInfo(),
|
|
[BattlefieldActorCamp.CampB] = new LegionInfo()
|
|
};
|
|
|
|
dicActorInfo = new Dictionary<int, LegionActorInfo>();
|
|
dicBuildingInfo = new Dictionary<int, LegionBuildingInfo>();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 释放军团战信息
|
|
/// </summary>
|
|
private void ReleaseInfo()
|
|
{
|
|
if (null != dicLegionInfo)
|
|
{
|
|
dicLegionInfo.Clear();
|
|
dicLegionInfo = null;
|
|
}
|
|
|
|
if (null != dicActorInfo)
|
|
{
|
|
dicActorInfo.Clear();
|
|
dicActorInfo = null;
|
|
}
|
|
|
|
if (null != dicBuildingInfo)
|
|
{
|
|
dicBuildingInfo.Clear();
|
|
dicBuildingInfo = null;
|
|
}
|
|
}
|
|
|
|
#region 更新数据
|
|
/// <summary>
|
|
/// 设置军团信息
|
|
/// </summary>
|
|
public void SetLegionInfo(int mapId, uint startTime, int timeLength, MSG_LB_Legion legionA, MSG_LB_Legion legionB)
|
|
{
|
|
MapId = mapId;
|
|
StartTime = CommonUtils.GetTimeByTimestamp(startTime);
|
|
TimeLength = timeLength;
|
|
dicLegionInfo[BattlefieldActorCamp.CampA].CopyInfo(legionA);
|
|
dicLegionInfo[BattlefieldActorCamp.CampB].CopyInfo(legionB);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置军团战玩家信息
|
|
/// </summary>
|
|
public void SetActorInfo(MSG_LB_Actor info)
|
|
{
|
|
if (!dicActorInfo.TryGetValue((int)info.Id, out LegionActorInfo legionActorInfo))
|
|
{
|
|
legionActorInfo = new LegionActorInfo();
|
|
dicActorInfo[(int)info.Id] = legionActorInfo;
|
|
}
|
|
|
|
legionActorInfo.CopyInfo(info);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更新军团战玩家信息
|
|
/// </summary>
|
|
/// <param name="index"></param>
|
|
/// <param name="info"></param>
|
|
public void UpdateActorInfo(MSG_LB_ActorUpdate info)
|
|
{
|
|
if (!dicActorInfo.TryGetValue((int)info.Id, out LegionActorInfo legionActorInfo))
|
|
return;
|
|
|
|
legionActorInfo.CopyInfo(info);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 通过id更新军团战玩家信息
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <param name="command"></param>
|
|
/// <param name="x"></param>
|
|
/// <param name="z"></param>
|
|
/// <param name="pathX"></param>
|
|
/// <param name="pathZ"></param>
|
|
public void UpdateActorInfoById(int id, int command, int x, int z, RepeatedField<uint> pathX, RepeatedField<uint> pathZ)
|
|
{
|
|
if (!dicActorInfo.TryGetValue(id, out LegionActorInfo legionActorInfo))
|
|
return;
|
|
|
|
legionActorInfo.CopyInfo(command, x, z, pathX, pathZ);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置军团战建筑信息
|
|
/// </summary>
|
|
public void SetBuildingInfo(MSG_LB_Building info)
|
|
{
|
|
if (!dicBuildingInfo.TryGetValue((int)info.Index, out LegionBuildingInfo legionBuildingInfo))
|
|
{
|
|
legionBuildingInfo = new LegionBuildingInfo();
|
|
dicBuildingInfo[(int)info.Index] = legionBuildingInfo;
|
|
}
|
|
|
|
legionBuildingInfo.CopyInfo(info);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 通过索引更新军团战建筑信息
|
|
/// </summary>
|
|
public void UpdateBuildingInfoByIndex(int index, BattlefieldActorCamp camp, int defCount, int total)
|
|
{
|
|
dicBuildingInfo[index].CopyInfo(camp, defCount, total);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置军团战分数
|
|
/// </summary>
|
|
/// <param name="aScore"></param>
|
|
/// <param name="bScore"></param>
|
|
public void SetScore(int aScore, int bScore)
|
|
{
|
|
dicLegionInfo[BattlefieldActorCamp.CampA].SetScore(aScore);
|
|
dicLegionInfo[BattlefieldActorCamp.CampB].SetScore(bScore);
|
|
|
|
if (IsLegionBattle)
|
|
EventManager.Instance.Send(EventManager.EventName.UpdateLegionBattleScore);
|
|
}
|
|
#endregion
|
|
}
|
|
} |