添加动态获取分组操作
This commit is contained in:
parent
95464f34f8
commit
730ca9d9e7
|
@ -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<FormationManager>
|
|||
public bool isStartFormation;
|
||||
public List<FormationInfo> formationInfos = new List<FormationInfo>();
|
||||
public FormationInfo formationInfo;
|
||||
public List<UnmannedAerialVehicleManage> allUavms = new List<UnmannedAerialVehicleManage>();
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
@ -123,8 +125,12 @@ public class FormationManager : MonoSingleton<FormationManager>
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public void SetGroupUAVMState(int uavmGroupID,int patternCut)
|
||||
/// <summary>
|
||||
/// 切换无人机状态
|
||||
/// </summary>
|
||||
/// <param name="uavmGroupID"></param>
|
||||
/// <param name="patternCut"></param>
|
||||
public void SetGroupUAVMState(int uavmGroupID, int patternCut)
|
||||
{
|
||||
List<UnmannedAerialVehicleManage> uavms = GroupUAVM(uavmGroupID);
|
||||
for (int j = 0; j < uavms.Count; j++)
|
||||
|
@ -174,4 +180,47 @@ public class FormationManager : MonoSingleton<FormationManager>
|
|||
formationInfo = null;
|
||||
CheckBtns(0);
|
||||
}
|
||||
|
||||
public int wrjCount = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 动态添加已经生成得数据
|
||||
/// </summary>
|
||||
public void WhenSpawn()
|
||||
{
|
||||
List<EquipmentCommon> 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<UnmannedAerialVehicleManage>())
|
||||
{
|
||||
if (!allUavms.Contains(equipList[index].GetComponent<UnmannedAerialVehicleManage>()))
|
||||
{
|
||||
allUavms.Add(equipList[index].GetComponent<UnmannedAerialVehicleManage>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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<UnmannedAerialVehicleManage>()).ToList();
|
||||
//List<UnmannedAerialVehicleManage> uavms = DeviceManager.Instance.devices;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -447,21 +447,16 @@ public class GameManager : MonoSingleton<GameManager>
|
|||
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<UnmannedAerialVehicleManage>();
|
||||
if (!string.IsNullOrEmpty(data.r2) || data.r2 != "")
|
||||
{
|
||||
int wrjModelCount = int.Parse(data.r2);
|
||||
UnmannedAerialVehicleManage uavm = device.GetComponent<UnmannedAerialVehicleManage>();
|
||||
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<GameManager>
|
|||
{
|
||||
device.GetComponent<EquipmentCommon>().isPlayer = true;
|
||||
}
|
||||
if (device.GetComponent<UnmannedAerialVehicleManage>())
|
||||
if (uavm)
|
||||
{
|
||||
device.GetComponent<UnmannedAerialVehicleManage>().SetTipsColor();
|
||||
DroneViewDisplay.Instance.CreateUI(device.GetComponent<UnmannedAerialVehicleManage>(), false);
|
||||
uavm.SetTipsColor();
|
||||
DroneViewDisplay.Instance.CreateUI(uavm, false);
|
||||
|
||||
}
|
||||
|
||||
FormationManager.Instance.WhenSpawn();
|
||||
|
||||
}
|
||||
|
||||
private void OnGetRoomUsers(string obj)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue