From ea2b35a0303c8702acccd8bb2473ac239e3f43b3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=B4=A6=E5=8F=B7=E5=90=8D?= <3077614386@qq.com>
Date: Fri, 24 Nov 2023 14:57:05 +0800
Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E8=AE=BE=E5=A4=87=E6=8E=A5?=
=?UTF-8?q?=E5=8F=A3=E8=B0=83=E8=AF=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Assets/Zion/Scripts/InterfaceManager.cs | 29 +++++++++++++++++++
.../UAV/UnmannedAerialVehicle.cs | 6 ++++
.../UAV/UnmannedAerialVehicleManage.cs | 28 +++++++++++++-----
3 files changed, 55 insertions(+), 8 deletions(-)
diff --git a/Assets/Zion/Scripts/InterfaceManager.cs b/Assets/Zion/Scripts/InterfaceManager.cs
index 6c18d55d..90217237 100644
--- a/Assets/Zion/Scripts/InterfaceManager.cs
+++ b/Assets/Zion/Scripts/InterfaceManager.cs
@@ -54,6 +54,10 @@ public static class InterfaceManager
/// 修改环境
///
public static string Url_update_env { get => IpAddress + "/Handler/Thinkingfile.ashx?action=update_env"; }
+ ///
+ /// 删除房间想定设备详情
+ ///
+ public static string Url_Deletepracticedevicedetail { get => IpAddress + "/Handler/Thinkingfile.ashx?action=deletepracticedevicedetail"; }
#endregion
public static string GetLocalTxt(string path)
@@ -172,6 +176,31 @@ public static class InterfaceManager
}
}
+
+ public static IEnumerator PostString(string url, WWWForm formdata, Action callback = null)
+ {
+ using (UnityWebRequest www = UnityWebRequest.Post(url, formdata))
+ {
+ yield return www.SendWebRequest();
+ if (www.isNetworkError || www.isHttpError)
+ {
+ callback(null);
+ Debug.Log("网络请求失败了");
+ }
+ else
+ {
+ if (!string.IsNullOrEmpty(www.downloadHandler.text))
+ {
+ callback(www.downloadHandler.text);
+ }
+ else
+ {
+ callback(null);
+ }
+ }
+ }
+ }
+
public static IEnumerator GetString(string url, Dictionary headers = null,int time=50,Action callback = null)
{
while (true)
diff --git a/Assets/Zion/Scripts/ModelFunction/UAV/UnmannedAerialVehicle.cs b/Assets/Zion/Scripts/ModelFunction/UAV/UnmannedAerialVehicle.cs
index d78022e4..9bf9bc15 100644
--- a/Assets/Zion/Scripts/ModelFunction/UAV/UnmannedAerialVehicle.cs
+++ b/Assets/Zion/Scripts/ModelFunction/UAV/UnmannedAerialVehicle.cs
@@ -4,6 +4,7 @@ using UnityEngine;
using DG.Tweening;
using System.Linq;
using AdamSync;
+using static InterfaceManager;
///
/// 无人机
@@ -155,6 +156,11 @@ public class UnmannedAerialVehicle : MonoBehaviour
string nowData = string.Format("{0},{1}", "SetToBeDestroyed", _equipmentCommon.deviceID);
Debug.Log(nowData);
_ = SyncCreateRoom.SendMessageAsync(string.Format("send2room {0}", nowData));
+ Dictionary headers = new Dictionary();
+ headers.Add("id", _equipmentCommon.deviceID);
+ StartCoroutine(GetString(Url_Deletepracticedevicedetail, headers, data => {
+ Debug.Log(data);
+ }));
GameObject Bao = Instantiate(explodePrefab, _transform);
Bao.transform.localPosition = Vector3.zero;
Bao.transform.SetParent(null);
diff --git a/Assets/Zion/Scripts/ModelFunction/UAV/UnmannedAerialVehicleManage.cs b/Assets/Zion/Scripts/ModelFunction/UAV/UnmannedAerialVehicleManage.cs
index 9dd756f1..28cb0be0 100644
--- a/Assets/Zion/Scripts/ModelFunction/UAV/UnmannedAerialVehicleManage.cs
+++ b/Assets/Zion/Scripts/ModelFunction/UAV/UnmannedAerialVehicleManage.cs
@@ -6,6 +6,7 @@ using UnityEngine;
using AdamThinkDevicesData;
using AdamSync;
using System.Linq;
+using static InterfaceManager;
///
/// 单个无人机蜂群控制
@@ -143,14 +144,7 @@ public class UnmannedAerialVehicleManage : MonoBehaviour
// Update is called once per frame
void Update()
{
- if (isStartRehearsing && equipmentCommon.isPlayer && pattern == Pattern.攻击)
- {
- if (airRoute)
- {
- StartMoveObjectAlongPath();
- }
- }
- if (equipmentCommon.isPlayer &&isStartRehearsing)
+ if(isStartRehearsing && equipmentCommon.isPlayer)
{
switch (pattern)
{
@@ -161,9 +155,27 @@ public class UnmannedAerialVehicleManage : MonoBehaviour
break;
case Pattern.攻击:
SelectiveAttackDrone();
+ if (airRoute)
+ {
+ StartMoveObjectAlongPath();
+ }
break;
}
+
+ var _unmannedAerialVehicle = unmannedAerialVehicles.FindAll(x => x != null);
+ if (_unmannedAerialVehicle==null)
+ {
+ string nowData = string.Format("{0},{1}", "SetToBeDestroyed", equipmentCommon.deviceID);
+ Debug.Log(nowData);
+ _ = SyncCreateRoom.SendMessageAsync(string.Format("send2room {0}", nowData));
+ Dictionary headers = new Dictionary();
+ headers.Add("id", equipmentCommon.deviceID);
+ StartCoroutine(GetString(Url_Deletepracticedevicedetail, headers, data => {
+ Debug.Log(data);
+ }));
+ }
}
+
}