85 lines
2.5 KiB
C#
85 lines
2.5 KiB
C#
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using Cysharp.Threading.Tasks;
|
||
using Framework;
|
||
using Framework.Wrapper;
|
||
using Gameplay;
|
||
using Gameplay.Level;
|
||
using Gameplay.Net;
|
||
using Gameplay.SubSystems;
|
||
using PhxhSDK;
|
||
using TGS;
|
||
using UnityEngine;
|
||
using UnityEngine.SceneManagement;
|
||
|
||
//防守方布阵
|
||
public partial class PVPManager
|
||
{
|
||
private string _scenePath;
|
||
|
||
public async void EnterDefendPrepare()
|
||
{
|
||
await LoadingManager.Instance.ExecuteLoading(new PVPDefendLoadingExecutor(), 0f, 0f);
|
||
}
|
||
|
||
public async void ExitDefendPrepare(List<PVPUnitInfo> unitInfosAfterEdit)
|
||
{
|
||
SetPVPDefenderPrepareData(unitInfosAfterEdit);
|
||
PrepareTeamManager.Instance.Dispose();
|
||
await CommonUtils.CloseUIWithScene(UINameConst.UI_PVPDefendPrepare);
|
||
}
|
||
|
||
public async void ExitDefendPrepare()
|
||
{
|
||
PrepareTeamManager.Instance.Dispose();
|
||
await CommonUtils.CloseUIWithScene(UINameConst.UI_PVPDefendPrepare);
|
||
}
|
||
|
||
public void SavePvPDefenderPrepareData(List<PVPUnitInfo> unitInfosAfterEdit)
|
||
{
|
||
SetPVPDefenderPrepareData(unitInfosAfterEdit);
|
||
}
|
||
|
||
private void SetPVPDefenderPrepareData(List<PVPUnitInfo> unitInfos)
|
||
{
|
||
if (unitInfos.Count == 0)
|
||
return;
|
||
unitInfos.Sort((a, b) => a.type.CompareTo(b.type));
|
||
uint vehicleID = unitInfos[^1].type == Unit.UnitType.Vehicle ? unitInfos[^1].unitID : 0;
|
||
uint[] characterIDs = new uint[vehicleID == 0 ? unitInfos.Count : unitInfos.Count - 1];
|
||
for (int i = 0; i < characterIDs.Length; i++)
|
||
{
|
||
characterIDs[i] = unitInfos[i].unitID;
|
||
}
|
||
if (characterIDs.Length >= PrepareTeamManager.MaxOnFightNum)
|
||
{
|
||
DebugUtil.LogError("保存的CharacterID长度有误!!length:" + characterIDs.Length);
|
||
return;
|
||
}
|
||
|
||
for (int i = 0; i < characterIDs.Length; i++)
|
||
{
|
||
var curIdx = characterIDs[i];
|
||
int j = 0;
|
||
while (j < characterIDs.Length)
|
||
{
|
||
if (j == i)
|
||
{
|
||
++j;
|
||
continue;
|
||
}
|
||
if (curIdx == characterIDs[j])
|
||
{
|
||
DebugUtil.LogError("保存的CharacterID有重复!!ID:" + curIdx);
|
||
return;
|
||
}
|
||
|
||
++j;
|
||
}
|
||
}
|
||
|
||
byte[] teamData = PVPUnitInfo.Serialize(unitInfos);
|
||
NetHelper.SetDefenceTeamForPvp(characterIDs, vehicleID, teamData);
|
||
}
|
||
} |