修改打组逻辑
This commit is contained in:
parent
dfcfd33ad0
commit
55a7e3e109
|
|
@ -89,6 +89,8 @@ public class Mastermanagement : MonoBehaviour
|
||||||
//}
|
//}
|
||||||
weapongames.Remove(obj);
|
weapongames.Remove(obj);
|
||||||
DeviceManager.Instance.RemoveDevice(obj);
|
DeviceManager.Instance.RemoveDevice(obj);
|
||||||
|
if (obj.GetComponent<UnmannedAerialVehicleManage>())
|
||||||
|
FormationManager.Instance.RemoveAppointWRJ(obj.GetComponent<UnmannedAerialVehicleManage>());
|
||||||
Destroy(obj);
|
Destroy(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -142,7 +142,7 @@ public class PostureController : MonoBehaviour
|
||||||
for (int i = 0; i < blueObjs.Count; i++)
|
for (int i = 0; i < blueObjs.Count; i++)
|
||||||
{
|
{
|
||||||
CreatDeviceItem(blueContanier, blueObjs[i].name, blueObjs[i].deviceID, 1);
|
CreatDeviceItem(blueContanier, blueObjs[i].name, blueObjs[i].deviceID, 1);
|
||||||
blueObjs[i].onDeviceDelete += RemoveItem;
|
blueObjs[i].onDeviceDelete += RemoveBlueItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -152,14 +152,29 @@ public class PostureController : MonoBehaviour
|
||||||
|
|
||||||
public void RemoveItem(string id)
|
public void RemoveItem(string id)
|
||||||
{
|
{
|
||||||
|
UnmannedAerialVehicleManage temp = null;
|
||||||
for (int i = 0; i < redObjs.Count; i++)
|
for (int i = 0; i < redObjs.Count; i++)
|
||||||
{
|
{
|
||||||
if (redObjs[i].deviceID == id)
|
if (redObjs[i].deviceID == id)
|
||||||
{
|
{
|
||||||
|
temp = redObjs[i].GetComponent<UnmannedAerialVehicleManage>();
|
||||||
redObjs.Remove(redObjs[i]);
|
redObjs.Remove(redObjs[i]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
FormationManager.Instance.RemoveAppointWRJ(temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveBlueItem(string id)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < blueObjs.Count; i++)
|
||||||
|
{
|
||||||
|
if (blueObjs[i].deviceID == id)
|
||||||
|
{
|
||||||
|
blueObjs.Remove(blueObjs[i]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreatDeviceItem(Transform contanier, string objName, string id, int redOrBlue)
|
private void CreatDeviceItem(Transform contanier, string objName, string id, int redOrBlue)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using AdamSync;
|
||||||
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
@ -25,6 +26,7 @@ public class FormationManager : MonoSingleton<FormationManager>
|
||||||
public List<FormationInfo> formationInfos = new List<FormationInfo>();
|
public List<FormationInfo> formationInfos = new List<FormationInfo>();
|
||||||
public FormationInfo formationInfo;
|
public FormationInfo formationInfo;
|
||||||
public List<UnmannedAerialVehicleManage> allUavms = new List<UnmannedAerialVehicleManage>();
|
public List<UnmannedAerialVehicleManage> allUavms = new List<UnmannedAerialVehicleManage>();
|
||||||
|
public List<string> formationIDs = new List<string>();
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
|
|
@ -58,12 +60,9 @@ public class FormationManager : MonoSingleton<FormationManager>
|
||||||
UnmannedAerialVehicleManage uavmTemp = hitInfo.collider.gameObject.GetComponent<UnmannedAerialVehicleManage>();
|
UnmannedAerialVehicleManage uavmTemp = hitInfo.collider.gameObject.GetComponent<UnmannedAerialVehicleManage>();
|
||||||
if (uavmTemp != null && !uavmTemp.isGroup)
|
if (uavmTemp != null && !uavmTemp.isGroup)
|
||||||
{
|
{
|
||||||
if (!formationInfo.uavms.Contains(uavmTemp))
|
if (!formationIDs.Contains(uavmTemp.equipmentCommon.deviceID))
|
||||||
{
|
{
|
||||||
uavmTemp.isGroup = true;
|
formationIDs.Add(uavmTemp.equipmentCommon.deviceID);
|
||||||
uavmTemp.groupId = formationInfo.groupIndex;
|
|
||||||
uavmTemp.SetGroupTipsAndDatabaseInfo(formationInfo.groupIndex);
|
|
||||||
formationInfo.uavms.Add(uavmTemp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Debug.Log("拾取");
|
Debug.Log("拾取");
|
||||||
|
|
@ -138,6 +137,23 @@ public class FormationManager : MonoSingleton<FormationManager>
|
||||||
uavms[j].modeSwitch(patternCut);
|
uavms[j].modeSwitch(patternCut);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 移除指定无人机
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="uavm"></param>
|
||||||
|
public void RemoveAppointWRJ(UnmannedAerialVehicleManage uavm)
|
||||||
|
{
|
||||||
|
List<UnmannedAerialVehicleManage> uavms = GroupUAVM(uavm.groupId);
|
||||||
|
if (uavms.Contains(uavm))
|
||||||
|
uavms.Remove(uavm);
|
||||||
|
if (allUavms.Contains(uavm))
|
||||||
|
allUavms.Remove(uavm);
|
||||||
|
for (int j = 0; j < formationInfos.Count; j++)
|
||||||
|
{
|
||||||
|
if (formationInfos[j].uavms.Count == 0)
|
||||||
|
formationInfos.Remove(formationInfos[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private List<UnmannedAerialVehicleManage> GroupUAVM(int uavmGroupID)
|
private List<UnmannedAerialVehicleManage> GroupUAVM(int uavmGroupID)
|
||||||
{
|
{
|
||||||
|
|
@ -155,26 +171,70 @@ public class FormationManager : MonoSingleton<FormationManager>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void OnStartFormation()
|
public void OnStartFormation()
|
||||||
{
|
{
|
||||||
isStartFormation = true;
|
isStartFormation = true;
|
||||||
formationInfo = new FormationInfo();
|
|
||||||
formationInfo.groupIndex = formationInfos.Count;
|
|
||||||
CheckBtns(1);
|
CheckBtns(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnSubmit()
|
public void OnSubmit()
|
||||||
{
|
{
|
||||||
isStartFormation = false;
|
isStartFormation = false;
|
||||||
if (formationInfo.uavms.Count > 0)
|
|
||||||
|
string infoTemp = "";
|
||||||
|
for (int i = 0; i < formationInfo.uavms.Count; i++)
|
||||||
{
|
{
|
||||||
if (!formationInfos.Contains(formationInfo))
|
infoTemp += formationInfo.uavms[i].equipmentCommon.deviceID + ",";
|
||||||
formationInfos.Add(formationInfo);
|
|
||||||
}
|
}
|
||||||
formationInfo = null;
|
SendGroupToOther(formationInfos.Count.ToString(), infoTemp);
|
||||||
|
Debug.Log($"<color=blue>{infoTemp}</color>");
|
||||||
CheckBtns(0);
|
CheckBtns(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private char[] separators = { ',' }; // 设置分隔符为逗号
|
||||||
|
public void OnReciveMsg(string reciveInfo)
|
||||||
|
{
|
||||||
|
List<UnmannedAerialVehicleManage> uavms = GetAllWRJ();
|
||||||
|
|
||||||
|
var result = reciveInfo.Split(separators) // 对字符串进行切割操作
|
||||||
|
.Where(s => !String.IsNullOrWhiteSpace(s) && s != "") // 移除空白或者只包含空格的元素
|
||||||
|
.ToList();
|
||||||
|
if (result.Count > 0)
|
||||||
|
{
|
||||||
|
if (result[0] == "group")
|
||||||
|
{
|
||||||
|
formationInfo = new FormationInfo();
|
||||||
|
formationInfo.groupIndex = int.Parse(result[1]);
|
||||||
|
for (int i = 2; i < result.Count; i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < uavms.Count; j++)
|
||||||
|
{
|
||||||
|
if (uavms[j].equipmentCommon.deviceID == result[i])
|
||||||
|
{
|
||||||
|
uavms[j].groupId = int.Parse(result[1]);
|
||||||
|
uavms[j].isGroup = true;
|
||||||
|
uavms[j].SetGroupTipsAndDatabaseInfo(int.Parse(result[1]));
|
||||||
|
formationInfo.uavms.Add(uavms[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!formationInfos.Contains(formationInfo))
|
||||||
|
formationInfos.Add(formationInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 打组发送给别人
|
||||||
|
/// </summary>
|
||||||
|
private void SendGroupToOther(string groupIndex, string info)
|
||||||
|
{
|
||||||
|
string msg = $"send2room group,{groupIndex},{info}";
|
||||||
|
_ = SyncCreateRoom.SendMessageAsync(msg);
|
||||||
|
}
|
||||||
|
|
||||||
public void OnCancel()
|
public void OnCancel()
|
||||||
{
|
{
|
||||||
formationInfo = null;
|
formationInfo = null;
|
||||||
|
|
@ -183,25 +243,30 @@ public class FormationManager : MonoSingleton<FormationManager>
|
||||||
|
|
||||||
public int wrjCount = 0;
|
public int wrjCount = 0;
|
||||||
|
|
||||||
/// <summary>
|
public List<UnmannedAerialVehicleManage> GetAllWRJ()
|
||||||
/// 动态添加已经生成得数据
|
|
||||||
/// </summary>
|
|
||||||
public void WhenSpawn()
|
|
||||||
{
|
{
|
||||||
List<EquipmentCommon> equipList = DeviceManager.Instance.devices;
|
List<EquipmentCommon> equipList = DeviceManager.Instance.devices;
|
||||||
|
List<UnmannedAerialVehicleManage> allUavmsTemp = new List<UnmannedAerialVehicleManage>();
|
||||||
for (int i = 0; i < equipList.Count; i++)
|
for (int i = 0; i < equipList.Count; i++)
|
||||||
{
|
{
|
||||||
int index = i;
|
int index = i;
|
||||||
if (equipList[index] != null && equipList[index].gameObject.layer == 11 && equipList[index].GetComponent<UnmannedAerialVehicleManage>())
|
if (equipList[index] != null && equipList[index].gameObject.layer == 11 && equipList[index].GetComponent<UnmannedAerialVehicleManage>())
|
||||||
{
|
{
|
||||||
if (!allUavms.Contains(equipList[index].GetComponent<UnmannedAerialVehicleManage>()))
|
if (!allUavmsTemp.Contains(equipList[index].GetComponent<UnmannedAerialVehicleManage>()))
|
||||||
{
|
{
|
||||||
allUavms.Add(equipList[index].GetComponent<UnmannedAerialVehicleManage>());
|
allUavmsTemp.Add(equipList[index].GetComponent<UnmannedAerialVehicleManage>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return allUavmsTemp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 动态添加已经生成得数据
|
||||||
|
/// </summary>
|
||||||
|
public void WhenSpawn()
|
||||||
|
{
|
||||||
|
allUavms = GetAllWRJ();
|
||||||
|
|
||||||
foreach (var uam in allUavms)
|
foreach (var uam in allUavms)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -178,14 +178,14 @@ public class EquipmentCommon : MonoBehaviour
|
||||||
break;
|
break;
|
||||||
case "地面无线电干扰":
|
case "地面无线电干扰":
|
||||||
TerrestrialRadioInterferenceManger terrestrialRadioInterferenceManger = GetComponent<TerrestrialRadioInterferenceManger>();
|
TerrestrialRadioInterferenceManger terrestrialRadioInterferenceManger = GetComponent<TerrestrialRadioInterferenceManger>();
|
||||||
terrestrialRadioInterferenceManger.FillInTheData(weaponitemone);
|
terrestrialRadioInterferenceManger.FillInTheData(weaponitemone,deviceID);
|
||||||
terrestrialRadioInterferenceManger.isStartRehearsing = isStartRehearsing;
|
terrestrialRadioInterferenceManger.isStartRehearsing = isStartRehearsing;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "蜂群无人机":
|
case "蜂群无人机":
|
||||||
UnmannedAerialVehicleManage unmannedAerialVehicleManage = GetComponent<UnmannedAerialVehicleManage>();
|
UnmannedAerialVehicleManage unmannedAerialVehicleManage = GetComponent<UnmannedAerialVehicleManage>();
|
||||||
unmannedAerialVehicleManage.MatrixFormation(30, 1);
|
unmannedAerialVehicleManage.MatrixFormation(30, 1);
|
||||||
unmannedAerialVehicleManage.FillInTheData(weaponitemone);
|
unmannedAerialVehicleManage.FillInTheData(weaponitemone, deviceID);
|
||||||
unmannedAerialVehicleManage.isStartRehearsing = isStartRehearsing;
|
unmannedAerialVehicleManage.isStartRehearsing = isStartRehearsing;
|
||||||
DroneViewDisplay.Instance.CreateUI(unmannedAerialVehicleManage, false);
|
DroneViewDisplay.Instance.CreateUI(unmannedAerialVehicleManage, false);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,10 +45,10 @@ public class SingleMachineTest : MonoBehaviour
|
||||||
{
|
{
|
||||||
root = Newtonsoft.Json.JsonConvert.DeserializeObject<AdamThinkDevicesData.DeviceData>(msg1);
|
root = Newtonsoft.Json.JsonConvert.DeserializeObject<AdamThinkDevicesData.DeviceData>(msg1);
|
||||||
|
|
||||||
unmannedAerialVehicleManages.ForEach(x => x.FillInTheData(root.data[2].list_para));
|
//unmannedAerialVehicleManages.ForEach(x => x.FillInTheData(root.data[2].list_para));
|
||||||
radarMangers.ForEach(x => x.FillInTheData(root.data[0].list_para));
|
radarMangers.ForEach(x => x.FillInTheData(root.data[0].list_para));
|
||||||
laserFireControlPlatformMangers.ForEach(x => x.FillInTheData(root.data[3].list_para));
|
laserFireControlPlatformMangers.ForEach(x => x.FillInTheData(root.data[3].list_para));
|
||||||
terrestrialRadioInterferenceMangers.ForEach(x => x.FillInTheData(root.data[1].list_para));
|
//terrestrialRadioInterferenceMangers.ForEach(x => x.FillInTheData(root.data[1].list_para));
|
||||||
// 开始协程
|
// 开始协程
|
||||||
//StartTimer();
|
//StartTimer();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,8 @@ public class TerrestrialRadioInterferenceManger : MonoBehaviour
|
||||||
|
|
||||||
public EquipmentCommon equipmentCommon;
|
public EquipmentCommon equipmentCommon;
|
||||||
|
|
||||||
|
public string deviceID;
|
||||||
|
|
||||||
public static List<TerrestrialRadioInterferenceManger> terrestrialRadioInterferenceMangers = new List<TerrestrialRadioInterferenceManger>();
|
public static List<TerrestrialRadioInterferenceManger> terrestrialRadioInterferenceMangers = new List<TerrestrialRadioInterferenceManger>();
|
||||||
#region 地面无线电干扰数据
|
#region 地面无线电干扰数据
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -312,9 +314,9 @@ public class TerrestrialRadioInterferenceManger : MonoBehaviour
|
||||||
/// 数据写入
|
/// 数据写入
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="weaponitemone"></param>
|
/// <param name="weaponitemone"></param>
|
||||||
public void FillInTheData(List<List_paraItem> weaponitemone)
|
public void FillInTheData(List<List_paraItem> weaponitemone, string _deviceId)
|
||||||
{
|
{
|
||||||
|
deviceID = _deviceId;
|
||||||
for (int i = 0; i < weaponitemone.Count; i++)
|
for (int i = 0; i < weaponitemone.Count; i++)
|
||||||
{
|
{
|
||||||
switch (weaponitemone[i].para_name)
|
switch (weaponitemone[i].para_name)
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,7 @@ public class UnmannedAerialVehicleManage : MonoBehaviour
|
||||||
|
|
||||||
public EquipmentCommon equipmentCommon;
|
public EquipmentCommon equipmentCommon;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 打组ID
|
/// 打组ID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -601,7 +602,7 @@ public class UnmannedAerialVehicleManage : MonoBehaviour
|
||||||
/// 数据写入
|
/// 数据写入
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="weaponitemone"></param>
|
/// <param name="weaponitemone"></param>
|
||||||
public void FillInTheData(List<List_paraItem> weaponitemone)
|
public void FillInTheData(List<List_paraItem> weaponitemone, string _deviceId)
|
||||||
{
|
{
|
||||||
SenceInfo currentSceneInfo = new SenceInfo();
|
SenceInfo currentSceneInfo = new SenceInfo();
|
||||||
currentSceneInfo = UIBootstrap.Instance.currentSceneInfo.data;
|
currentSceneInfo = UIBootstrap.Instance.currentSceneInfo.data;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue