56 lines
1.9 KiB
C#
56 lines
1.9 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 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);
|
|
});
|
|
}
|
|
|
|
public async void ExitDefendPrepare(List<PVPUnitInfo> unitInfosAfterEdit)
|
|
{
|
|
SetPVPDefenderPrepareData(unitInfosAfterEdit);
|
|
PrepareTeamManager.Instance.Dispose();
|
|
await CommonUtils.CloseUIWithScene(UINameConst.UI_PVPDefendPrepare);
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
byte[] teamData = PVPUnitInfo.Serialize(unitInfos);
|
|
NetHelper.SetDefenceTeamForPvp(characterIDs, vehicleID, teamData);
|
|
}
|
|
} |