NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/PVP/PVPManager.DefenderPrepare.cs

56 lines
1.9 KiB
C#
Raw Normal View History

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-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;
PrepareTeamManager.Instance.Init(tgs, mapData, levelData.pvpDefendRegionId,
levelData.pvpDefendToward, NLDSceneManager.Instance.SceneCamera);
});
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();
await CommonUtils.CloseUIWithScene(UINameConst.UI_PVPDefendPrepare);
2023-12-29 15:07:04 +08:00
}
2024-01-08 19:14:33 +08:00
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;
}
byte[] teamData = PVPUnitInfo.Serialize(unitInfos);
NetHelper.SetDefenceTeamForPvp(characterIDs, vehicleID, teamData);
}
2023-12-29 15:07:04 +08:00
}