84 lines
2.5 KiB
C#
84 lines
2.5 KiB
C#
using Google.Protobuf.Collections;
|
|
using NLDPB;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace Gameplay.LegionBattle
|
|
{
|
|
/// <summary>
|
|
/// 军团战单次战斗数据
|
|
/// </summary>
|
|
public sealed class LegionBattleFightData
|
|
{
|
|
/// <summary>
|
|
/// 战斗id
|
|
/// </summary>
|
|
public uint Id { get; private set; }
|
|
|
|
/// <summary>
|
|
/// 攻击方列表
|
|
/// </summary>
|
|
public List<uint> ListAttackId { get; private set; }
|
|
/// <summary>
|
|
/// 防守方列表
|
|
/// </summary>
|
|
public List<uint> ListDefenceId { get; private set; }
|
|
/// <summary>
|
|
/// 开始战斗的时间
|
|
/// </summary>
|
|
public DateTime StartFightTime { get; private set; }
|
|
/// <summary>
|
|
/// 建筑数据
|
|
/// </summary>
|
|
public LegionBuildingData BuildingData { get; private set; }
|
|
/// <summary>
|
|
/// 是否攻击玩家
|
|
/// </summary>
|
|
public bool IsAttackActor { get { return null == BuildingData; } }
|
|
|
|
public LegionBattleFightData()
|
|
{
|
|
ListAttackId = new List<uint>();
|
|
ListDefenceId = new List<uint>();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 初次创建战斗
|
|
/// </summary>
|
|
public void InitData(uint id, float passTime, RepeatedField<uint> attacks, RepeatedField<uint> defences, Vector2Int buildingPos)
|
|
{
|
|
Id = id;
|
|
|
|
StartFightTime = CommonUtils.GetCurTime(CommonUtils.E_TimeType.Server).AddSeconds(-passTime); // 当前时间减去已经过去的时间
|
|
|
|
ListAttackId.AddRange(attacks);
|
|
ListDefenceId.AddRange(defences);
|
|
|
|
int index = LegionBattleManager.Instance.CurBattle.Map.BlockPosition2TGSCellIndex(buildingPos);
|
|
if (LegionBattleManager.Instance.TryGetBuildingDataByIndex(index, out LegionBuildingData buildingData))
|
|
BuildingData = buildingData;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更新战斗数据
|
|
/// </summary>
|
|
public void UpdateData(RepeatedField<uint> attacks, RepeatedField<uint> defences)
|
|
{
|
|
ListAttackId.Clear();
|
|
ListDefenceId.Clear();
|
|
|
|
ListAttackId.AddRange(attacks);
|
|
ListDefenceId.AddRange(defences);
|
|
}
|
|
|
|
public void Clear()
|
|
{
|
|
Id = 0;
|
|
ListAttackId.Clear();
|
|
ListDefenceId.Clear();
|
|
BuildingData = null;
|
|
}
|
|
}
|
|
} |