From 730ca9d9e764c8750faf9b256291ca3a8c567c94 Mon Sep 17 00:00:00 2001 From: YangHua <1475658476@qq.com> Date: Thu, 29 Feb 2024 00:34:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=A8=E6=80=81=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E5=88=86=E7=BB=84=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Zion/Scripts/Adam/FormationManager.cs | 53 ++++++++++++++++++- Assets/Zion/Scripts/Adam/GameManager.cs | 16 +++--- .../UAV/UnmannedAerialVehicleManage.cs | 37 +++++++------ 3 files changed, 79 insertions(+), 27 deletions(-) diff --git a/Assets/Zion/Scripts/Adam/FormationManager.cs b/Assets/Zion/Scripts/Adam/FormationManager.cs index db1adb7d..f46e9553 100644 --- a/Assets/Zion/Scripts/Adam/FormationManager.cs +++ b/Assets/Zion/Scripts/Adam/FormationManager.cs @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; @@ -23,6 +24,7 @@ public class FormationManager : MonoSingleton public bool isStartFormation; public List formationInfos = new List(); public FormationInfo formationInfo; + public List allUavms = new List(); // Start is called before the first frame update void Start() { @@ -123,8 +125,12 @@ public class FormationManager : MonoSingleton } } - - public void SetGroupUAVMState(int uavmGroupID,int patternCut) + /// + /// 切换无人机状态 + /// + /// + /// + public void SetGroupUAVMState(int uavmGroupID, int patternCut) { List uavms = GroupUAVM(uavmGroupID); for (int j = 0; j < uavms.Count; j++) @@ -174,4 +180,47 @@ public class FormationManager : MonoSingleton formationInfo = null; CheckBtns(0); } + + public int wrjCount = 0; + + /// + /// 动态添加已经生成得数据 + /// + public void WhenSpawn() + { + List equipList = DeviceManager.Instance.devices; + + for (int i = 0; i < equipList.Count; i++) + { + int index = i; + if (equipList[index] != null && equipList[index].gameObject.layer == 11 && equipList[index].GetComponent()) + { + if (!allUavms.Contains(equipList[index].GetComponent())) + { + allUavms.Add(equipList[index].GetComponent()); + } + } + } + + + formationInfo = new FormationInfo(); + for (int i = 0; i < allUavms.Count; i++) + { + if (allUavms[i].groupId == wrjCount) + { + formationInfo.groupIndex = wrjCount; + formationInfo.uavms.Add(allUavms[i]); + } + } + + //wrjCount = -1; + //formationInfo = null; + + //allUavms = .Where(x => x != null && x.gameObject.layer == 11 && x.GetComponent()).ToList(); + //List uavms = DeviceManager.Instance.devices; + } + + + + } diff --git a/Assets/Zion/Scripts/Adam/GameManager.cs b/Assets/Zion/Scripts/Adam/GameManager.cs index 548449a1..c38db0ec 100644 --- a/Assets/Zion/Scripts/Adam/GameManager.cs +++ b/Assets/Zion/Scripts/Adam/GameManager.cs @@ -447,21 +447,16 @@ public class GameManager : MonoSingleton device.transform.position = new Vector3(float.Parse(deviceTran[0]), float.Parse(deviceTran[1]), float.Parse(deviceTran[2])); device.transform.eulerAngles = new Vector3(float.Parse(deviceTran[3]), float.Parse(deviceTran[4]), float.Parse(deviceTran[5])); } + UnmannedAerialVehicleManage uavm = device.GetComponent(); if (!string.IsNullOrEmpty(data.r2) || data.r2 != "") { int wrjModelCount = int.Parse(data.r2); - UnmannedAerialVehicleManage uavm = device.GetComponent(); if (uavm) { uavm.wrjModel = (WRJModel)wrjModelCount; device.name = uavm.wrjModel.ToString(); int bdxx = int.Parse(data.bdxx); uavm.groupId = bdxx; - if (bdxx != -1) - { - uavm.isGroup = true; - uavm.SetGroupTips(bdxx); - } } } @@ -472,12 +467,15 @@ public class GameManager : MonoSingleton { device.GetComponent().isPlayer = true; } - if (device.GetComponent()) + if (uavm) { - device.GetComponent().SetTipsColor(); - DroneViewDisplay.Instance.CreateUI(device.GetComponent(), false); + uavm.SetTipsColor(); + DroneViewDisplay.Instance.CreateUI(uavm, false); + } + FormationManager.Instance.WhenSpawn(); + } private void OnGetRoomUsers(string obj) diff --git a/Assets/Zion/Scripts/ModelFunction/UAV/UnmannedAerialVehicleManage.cs b/Assets/Zion/Scripts/ModelFunction/UAV/UnmannedAerialVehicleManage.cs index 0a0af6af..f1f6e971 100644 --- a/Assets/Zion/Scripts/ModelFunction/UAV/UnmannedAerialVehicleManage.cs +++ b/Assets/Zion/Scripts/ModelFunction/UAV/UnmannedAerialVehicleManage.cs @@ -858,26 +858,31 @@ public class UnmannedAerialVehicleManage : MonoBehaviour IEnumerator WeaponitemoneDataAddition() { yield return new WaitForSeconds(0.01f); - for (int i = 0; i < unmannedAerialVehicles.Count; i++) + + UnmannedAerialVehicle uav = unmannedAerialVehicles[0]; + if (uav != null) { - UnmannedAerialVehicle uav = unmannedAerialVehicles[i]; - if (uav != null) + uav.unmannedAerialVehicleManage = this; + uav.batteryLife = batteryLife; + uav.classificationWindResistance = classificationWindResistance; + uav.maximumFlyingSpeed = maximumFlyingSpeed; + uav.RCS = RCS; + uav.satellitePositioningFrequency = satellitePositioningFrequency; + uav.dataLinkCommunicationFrequency = dataLinkCommunicationFrequency; + uav.electronicReconnaissanceCapability = electronicReconnaissanceCapability; + uav.opticalReconnaissanceCapability = opticalReconnaissanceCapability; + uav.wrjModel = wrjModel; + if (uav.tips != null) + uav.tips.text = wrjModel.ToString(); + if (groupId > -1) { - uav.unmannedAerialVehicleManage = this; - uav.batteryLife = batteryLife; - uav.classificationWindResistance = classificationWindResistance; - uav.maximumFlyingSpeed = maximumFlyingSpeed; - uav.RCS = RCS; - uav.satellitePositioningFrequency = satellitePositioningFrequency; - uav.dataLinkCommunicationFrequency = dataLinkCommunicationFrequency; - uav.electronicReconnaissanceCapability = electronicReconnaissanceCapability; - uav.opticalReconnaissanceCapability = opticalReconnaissanceCapability; - uav.wrjModel = wrjModel; - if (uav.tips != null) - uav.tips.text = wrjModel.ToString(); - WRJName = wrjModel.ToString(); + isGroup = true; + SetGroupTips(groupId); } + Debug.Log($"++:badxx ==={groupId}"); + WRJName = wrjModel.ToString(); } + } #endregion