This commit is contained in:
YangHua 2024-01-19 16:18:00 +08:00
parent 4ff4d87b90
commit ff95a85b05
2 changed files with 34 additions and 28 deletions

View File

@ -71,7 +71,7 @@ public class UnmannedAerialVehicle : MonoBehaviour
/// </summary> /// </summary>
public GameObject explodePrefab; public GameObject explodePrefab;
public Transform attackTarget;
private void OnTriggerEnter(Collider other) private void OnTriggerEnter(Collider other)
{ {
if (unmannedAerialVehicleManage.equipmentCommon.isPlayer && other.tag == "AttackTarget") if (unmannedAerialVehicleManage.equipmentCommon.isPlayer && other.tag == "AttackTarget")
@ -140,7 +140,7 @@ public class UnmannedAerialVehicle : MonoBehaviour
//_ = SyncCreateRoom.SendMessageAsync(string.Format("send2room {0}", nowData)); //_ = SyncCreateRoom.SendMessageAsync(string.Format("send2room {0}", nowData));
DeviceManager.Instance.send2roomStr.Enqueue(nowData); DeviceManager.Instance.send2roomStr.Enqueue(nowData);
string currentTime = System.DateTime.Now.ToString(); string currentTime = System.DateTime.Now.ToString();
string _log= currentTime + " " + unmannedAerialVehicleManage.equipmentCommon.equipmentType + "(" + unmannedAerialVehicleManage.equipmentCommon.deviceID + ")" string _log = currentTime + " " + unmannedAerialVehicleManage.equipmentCommon.equipmentType + "(" + unmannedAerialVehicleManage.equipmentCommon.deviceID + ")"
+ "编号" + serialNumber + "子无人机" + "自杀式攻击自爆了"; + "编号" + serialNumber + "子无人机" + "自杀式攻击自爆了";
UploadLog(_log); UploadLog(_log);
} }
@ -170,7 +170,8 @@ public class UnmannedAerialVehicle : MonoBehaviour
WWWForm wWWForm = new WWWForm(); WWWForm wWWForm = new WWWForm();
wWWForm.AddField("data", uploadLogMainJson); wWWForm.AddField("data", uploadLogMainJson);
Debug.Log(uploadLogMainJson); Debug.Log(uploadLogMainJson);
StartCoroutine(PostString(Url_Addpracticelog, wWWForm, data => { StartCoroutine(PostString(Url_Addpracticelog, wWWForm, data =>
{
Debug.Log(data); Debug.Log(data);
})); }));
} }
@ -187,14 +188,15 @@ public class UnmannedAerialVehicle : MonoBehaviour
_ = SyncCreateRoom.SendMessageAsync(string.Format("send2room {0}", nowData)); _ = SyncCreateRoom.SendMessageAsync(string.Format("send2room {0}", nowData));
string currentTime = System.DateTime.Now.ToString(); string currentTime = System.DateTime.Now.ToString();
string _log = currentTime + " " + unmannedAerialVehicleManage.equipmentCommon.equipmentType + "(" + unmannedAerialVehicleManage.equipmentCommon.deviceID + ")" string _log = currentTime + " " + unmannedAerialVehicleManage.equipmentCommon.equipmentType + "(" + unmannedAerialVehicleManage.equipmentCommon.deviceID + ")"
+ "编号" + serialNumber + "子无人机" + "攻击摧毁了"+ _equipmentCommon.equipmentType + "(" + _equipmentCommon.deviceID + ")"; + "编号" + serialNumber + "子无人机" + "攻击摧毁了" + _equipmentCommon.equipmentType + "(" + _equipmentCommon.deviceID + ")";
UploadLog(_log); UploadLog(_log);
WWWForm headers = new WWWForm(); WWWForm headers = new WWWForm();
headers.AddField("id", _equipmentCommon.deviceID); headers.AddField("id", _equipmentCommon.deviceID);
//StartCoroutine(PostString(Url_Deletepracticedevicedetail, headers, data => { StartCoroutine(PostString(Url_Deletepracticedevicedetail, headers, data =>
// //Debug.Log(data); {
//})); //Debug.Log(data);
}));
GameObject Bao = Instantiate(explodePrefab, _transform); GameObject Bao = Instantiate(explodePrefab, _transform);
Bao.transform.localPosition = Vector3.zero; Bao.transform.localPosition = Vector3.zero;
Bao.transform.SetParent(null); Bao.transform.SetParent(null);
@ -218,9 +220,12 @@ public class UnmannedAerialVehicle : MonoBehaviour
/// </summary> /// </summary>
public void AttAck(Transform target) public void AttAck(Transform target)
{ {
if (attackTarget == null)
{
transform.DOKill();
attackTarget = target;
Debug.Log("开始攻击目标..:" + target.name); Debug.Log("开始攻击目标..:" + target.name);
Vector3 _v3 = target.position; Vector3 _v3 = target.position;
transform.DOLookAt(_v3, 0.1f).OnComplete(() => transform.DOLookAt(_v3, 0.1f).OnComplete(() =>
{ {
float distance = Vector3.Distance(transform.position, target.position); float distance = Vector3.Distance(transform.position, target.position);
@ -233,6 +238,7 @@ public class UnmannedAerialVehicle : MonoBehaviour
}); });
}); });
} }
}
/// <summary> /// <summary>
/// 发起攻击 /// 发起攻击

View File

@ -275,7 +275,7 @@ public class UnmannedAerialVehicleManage : MonoBehaviour
/// </summary> /// </summary>
private void SelectiveAttackDrone() private void SelectiveAttackDrone()
{ {
if (isEngagedTarget) return; //if (isEngagedTarget) return;
if (wrjModel == WRJModel. || wrjModel == WRJModel.) if (wrjModel == WRJModel. || wrjModel == WRJModel.)
{ {
List<Collider> colliders = Physics.OverlapSphere(transform.position, detectionRadius).ToList(); // 检索范围内的所有碰撞体 List<Collider> colliders = Physics.OverlapSphere(transform.position, detectionRadius).ToList(); // 检索范围内的所有碰撞体
@ -290,7 +290,7 @@ public class UnmannedAerialVehicleManage : MonoBehaviour
{ {
if (attackColliders1.Count > 0) if (attackColliders1.Count > 0)
{ {
isEngagedTarget = true; //isEngagedTarget = true;
//colliders1.ForEach(x => Debug.Log(x.transform.name)); //colliders1.ForEach(x => Debug.Log(x.transform.name));
int _number = UnityEngine.Random.Range(0, attackColliders1.Count - 1); int _number = UnityEngine.Random.Range(0, attackColliders1.Count - 1);
List<UnmannedAerialVehicle> _unmannedAerialVehicles = unmannedAerialVehicles.FindAll(x => x != null && x.gameObject.activeSelf); List<UnmannedAerialVehicle> _unmannedAerialVehicles = unmannedAerialVehicles.FindAll(x => x != null && x.gameObject.activeSelf);