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