删除设备接口调试

This commit is contained in:
账号名 2023-11-24 14:57:05 +08:00
parent 2d0f6cd10d
commit ea2b35a030
3 changed files with 55 additions and 8 deletions

View File

@ -54,6 +54,10 @@ public static class InterfaceManager
/// 修改环境
/// </summary>
public static string Url_update_env { get => IpAddress + "/Handler/Thinkingfile.ashx?action=update_env"; }
/// <summary>
/// 删除房间想定设备详情
/// </summary>
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<string> 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<string, string> headers = null,int time=50,Action<string> callback = null)
{
while (true)

View File

@ -4,6 +4,7 @@ using UnityEngine;
using DG.Tweening;
using System.Linq;
using AdamSync;
using static InterfaceManager;
/// <summary>
/// 无人机
@ -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<string, string> headers = new Dictionary<string, string>();
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);

View File

@ -6,6 +6,7 @@ using UnityEngine;
using AdamThinkDevicesData;
using AdamSync;
using System.Linq;
using static InterfaceManager;
/// <summary>
/// 单个无人机蜂群控制
@ -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<string, string> headers = new Dictionary<string, string>();
headers.Add("id", equipmentCommon.deviceID);
StartCoroutine(GetString(Url_Deletepracticedevicedetail, headers, data => {
Debug.Log(data);
}));
}
}
}