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;
|
|
|
|
|
|
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-06-05 20:00:45 +08:00
|
|
|
|
await TerrainTypeConfig.Load();
|
2024-01-19 17:03:07 +08:00
|
|
|
|
await CommonUtils.OpenUIWithScene(UINameConst.UI_PVPDefendPrepare, _pvpLevelInfo.LevelScene, null, true,
|
|
|
|
|
|
LoadSceneMode.Additive, (sceneHandle) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
var tgs = UnityEngine.Object.FindObjectOfType<TerrainGridSystem>();
|
|
|
|
|
|
var mapData = _pvpLevelInfo.MapData;
|
|
|
|
|
|
var levelData = _pvpLevelInfo.LevelData;
|
2024-06-20 17:21:18 +08:00
|
|
|
|
var enemyPrepareRegionID = levelData.preparingRegionId;
|
2024-01-19 17:03:07 +08:00
|
|
|
|
PrepareTeamManager.Instance.Init(tgs, mapData, levelData.pvpDefendRegionId,
|
2024-06-20 17:21:18 +08:00
|
|
|
|
levelData.pvpDefendToward, NLDSceneManager.Instance.SceneCamera, enemyPrepareRegionID);
|
2024-01-19 17:03:07 +08:00
|
|
|
|
});
|
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();
|
|
|
|
|
|
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-01-09 16:12:29 +08:00
|
|
|
|
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++)
|
2024-01-03 14:56:46 +08:00
|
|
|
|
{
|
|
|
|
|
|
characterIDs[i] = unitInfos[i].unitID;
|
|
|
|
|
|
}
|
2024-06-07 18:48:55 +08:00
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-01-03 14:56:46 +08:00
|
|
|
|
|
|
|
|
|
|
byte[] teamData = PVPUnitInfo.Serialize(unitInfos);
|
|
|
|
|
|
NetHelper.SetDefenceTeamForPvp(characterIDs, vehicleID, teamData);
|
|
|
|
|
|
}
|
2023-12-29 15:07:04 +08:00
|
|
|
|
}
|