2023-12-29 15:07:04 +08:00
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
2024-01-08 13:59:23 +08:00
|
|
|
|
using System.Linq;
|
2023-12-29 15:07:04 +08:00
|
|
|
|
using Cysharp.Threading.Tasks;
|
|
|
|
|
|
using Framework;
|
2024-01-08 19:14:33 +08:00
|
|
|
|
using Framework.Wrapper;
|
2023-12-29 15:07:04 +08:00
|
|
|
|
using Gameplay;
|
2024-10-11 16:19:21 +08:00
|
|
|
|
using Gameplay.Common;
|
2023-12-29 15:07:04 +08:00
|
|
|
|
using Gameplay.Level;
|
2024-01-03 14:56:46 +08:00
|
|
|
|
using Gameplay.Net;
|
2023-12-29 15:07:04 +08:00
|
|
|
|
using Gameplay.SubSystems;
|
2023-12-29 19:58:17 +08:00
|
|
|
|
using PhxhSDK;
|
2023-12-29 15:07:04 +08:00
|
|
|
|
using TGS;
|
|
|
|
|
|
using UnityEngine;
|
2023-12-29 19:58:17 +08:00
|
|
|
|
using UnityEngine.SceneManagement;
|
2023-12-29 15:07:04 +08:00
|
|
|
|
|
2024-01-03 14:56:46 +08:00
|
|
|
|
//防守方布阵
|
2023-12-29 15:07:04 +08:00
|
|
|
|
public partial class PVPManager
|
|
|
|
|
|
{
|
2023-12-29 19:58:17 +08:00
|
|
|
|
private string _scenePath;
|
2023-12-29 15:07:04 +08:00
|
|
|
|
|
|
|
|
|
|
public async void EnterDefendPrepare()
|
|
|
|
|
|
{
|
2024-08-30 15:58:29 +08:00
|
|
|
|
await LoadingManager.Instance.ExecuteLoading(new PVPDefendLoadingExecutor(), 0f, 0f);
|
2023-12-29 15:07:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-01-03 14:56:46 +08:00
|
|
|
|
public async void ExitDefendPrepare(List<PVPUnitInfo> unitInfosAfterEdit)
|
2023-12-29 15:07:04 +08:00
|
|
|
|
{
|
2024-01-08 19:14:33 +08:00
|
|
|
|
SetPVPDefenderPrepareData(unitInfosAfterEdit);
|
2023-12-29 15:07:04 +08:00
|
|
|
|
PrepareTeamManager.Instance.Dispose();
|
2024-01-17 16:49:32 +08:00
|
|
|
|
await CommonUtils.CloseUIWithScene(UINameConst.UI_PVPDefendPrepare);
|
2023-12-29 15:07:04 +08:00
|
|
|
|
}
|
2024-01-08 19:14:33 +08:00
|
|
|
|
|
2024-06-04 19:21:34 +08:00
|
|
|
|
public async void ExitDefendPrepare()
|
|
|
|
|
|
{
|
|
|
|
|
|
PrepareTeamManager.Instance.Dispose();
|
2024-10-18 12:52:11 +08:00
|
|
|
|
//await GameSceneHelper.Instance.UnloadSceneForUIView();
|
2024-06-04 19:21:34 +08:00
|
|
|
|
await CommonUtils.CloseUIWithScene(UINameConst.UI_PVPDefendPrepare);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void SavePvPDefenderPrepareData(List<PVPUnitInfo> unitInfosAfterEdit)
|
|
|
|
|
|
{
|
|
|
|
|
|
SetPVPDefenderPrepareData(unitInfosAfterEdit);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-01-03 14:56:46 +08:00
|
|
|
|
private void SetPVPDefenderPrepareData(List<PVPUnitInfo> unitInfos)
|
|
|
|
|
|
{
|
2024-01-09 16:12:29 +08:00
|
|
|
|
if (unitInfos.Count == 0)
|
2024-01-08 19:14:33 +08:00
|
|
|
|
return;
|
2024-01-09 19:30:53 +08:00
|
|
|
|
unitInfos.Sort((a, b) => a.type.CompareTo(b.type));
|
2024-10-11 15:22:03 +08:00
|
|
|
|
//uint vehicleID = 0;//unitInfos[^1].type == Unit.UnitType.Vehicle ? unitInfos[^1].unitID : 0;
|
2024-09-23 15:53:38 +08:00
|
|
|
|
|
|
|
|
|
|
var buildingList = new List<uint>();
|
|
|
|
|
|
var characterIDList = new List<uint>();
|
2024-10-11 15:22:03 +08:00
|
|
|
|
var vehicleIDList = new List<uint>();
|
2024-09-23 15:53:38 +08:00
|
|
|
|
foreach (var unitInfo in unitInfos)
|
2024-01-03 14:56:46 +08:00
|
|
|
|
{
|
2024-09-23 15:53:38 +08:00
|
|
|
|
if (unitInfo.type == Unit.UnitType.Charactor)
|
|
|
|
|
|
{
|
|
|
|
|
|
characterIDList.Add(unitInfo.unitID);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (unitInfo.type == Unit.UnitType.Vehicle)
|
|
|
|
|
|
{
|
2024-10-11 15:22:03 +08:00
|
|
|
|
vehicleIDList.Add(unitInfo.unitID);
|
2024-09-23 15:53:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (unitInfo.type == Unit.UnitType.Building)
|
|
|
|
|
|
{
|
|
|
|
|
|
buildingList.Add(unitInfo.unitID);
|
|
|
|
|
|
}
|
2024-01-03 14:56:46 +08:00
|
|
|
|
}
|
2024-09-23 15:53:38 +08:00
|
|
|
|
|
|
|
|
|
|
uint[] characterIDs = characterIDList.ToArray();//new uint[vehicleID == 0 ? unitInfos.Count : unitInfos.Count - 1];
|
|
|
|
|
|
uint[] buildingIDs = buildingList.ToArray();
|
2024-10-11 15:22:03 +08:00
|
|
|
|
uint[] vehicleIDs = vehicleIDList.ToArray();
|
2024-09-23 15:53:38 +08:00
|
|
|
|
|
|
|
|
|
|
// for (int i = 0; i < characterIDs.Length; i++)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// characterIDs[i] = unitInfos[i].unitID;
|
|
|
|
|
|
// }
|
2024-10-11 16:19:21 +08:00
|
|
|
|
if (characterIDs.Length > GLConfig.Inst.data.PvpFightCharacterLimit)
|
2024-06-07 18:48:55 +08:00
|
|
|
|
{
|
|
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-09-23 15:53:38 +08:00
|
|
|
|
|
|
|
|
|
|
|
2024-10-11 16:19:21 +08:00
|
|
|
|
if (buildingIDs.Length > GLConfig.Inst.data.PvpFightBuildLimit)
|
2024-09-23 15:53:38 +08:00
|
|
|
|
{
|
2024-10-11 16:19:21 +08:00
|
|
|
|
DebugUtil.LogError("保存的BuildingID长度有误!!length:" + characterIDs.Length);
|
2024-09-23 15:53:38 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-01-03 14:56:46 +08:00
|
|
|
|
byte[] teamData = PVPUnitInfo.Serialize(unitInfos);
|
2024-10-11 16:19:21 +08:00
|
|
|
|
NetHelper.SetDefenceTeamForPvp(characterIDs, vehicleIDs, buildingIDs, teamData);
|
2024-01-03 14:56:46 +08:00
|
|
|
|
}
|
2023-12-29 15:07:04 +08:00
|
|
|
|
}
|