From 24512a33c2d8ede4d008fa949a4078a220b066aa Mon Sep 17 00:00:00 2001 From: YangHua <1475658476@qq.com> Date: Fri, 19 Jan 2024 16:49:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=97=A0=E4=BA=BA=E6=9C=BA?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E8=AE=BE=E7=BD=AE=E6=94=BB=E5=87=BB=E7=9B=AE?= =?UTF-8?q?=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Zion/Scripts/Adam/DeviceManager.cs | 8 +++++--- .../UAV/UnmannedAerialVehicleManage.cs | 13 ++++++++----- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Assets/Zion/Scripts/Adam/DeviceManager.cs b/Assets/Zion/Scripts/Adam/DeviceManager.cs index 2ec5d17f..f44bb6a1 100644 --- a/Assets/Zion/Scripts/Adam/DeviceManager.cs +++ b/Assets/Zion/Scripts/Adam/DeviceManager.cs @@ -104,7 +104,6 @@ public class DeviceManager : MonoSingleton public void SetCollider4WRJ(List attackColliders) { - int _number = Random.Range(0, attackColliders.Count - 1); if (attackColliders.Count > 0) { List temp = GetGXWRJAndZSWRJ(); @@ -113,9 +112,12 @@ public class DeviceManager : MonoSingleton for (int j = 0; j < temp[i].unmannedAerialVehicles.Count; j++) { - if(temp[i].unmannedAerialVehicles[j] != null && temp[i].unmannedAerialVehicles[j].gameObject.activeSelf) + if (temp[i].unmannedAerialVehicles[j] != null && temp[i].unmannedAerialVehicles[j].gameObject.activeSelf) { - temp[i].unmannedAerialVehicles[j].AttAck(attackColliders[_number].transform); + if (temp[i].unmannedAerialVehicles[j].attackTarget == null) + { + temp[i].unmannedAerialVehicles[j].AttAck(attackColliders[i].transform); + } } } } diff --git a/Assets/Zion/Scripts/ModelFunction/UAV/UnmannedAerialVehicleManage.cs b/Assets/Zion/Scripts/ModelFunction/UAV/UnmannedAerialVehicleManage.cs index 1ee5abaa..f9bede5f 100644 --- a/Assets/Zion/Scripts/ModelFunction/UAV/UnmannedAerialVehicleManage.cs +++ b/Assets/Zion/Scripts/ModelFunction/UAV/UnmannedAerialVehicleManage.cs @@ -269,6 +269,9 @@ public class UnmannedAerialVehicleManage : MonoBehaviour } } + public List allColliders = new List(); + public List attackColliders1 = new List(); + /// /// 攻击打击 @@ -278,12 +281,12 @@ public class UnmannedAerialVehicleManage : MonoBehaviour //if (isEngagedTarget) return; if (wrjModel == WRJModel.电子侦察无人机 || wrjModel == WRJModel.光学无人机) { - List colliders = Physics.OverlapSphere(transform.position, detectionRadius).ToList(); // 检索范围内的所有碰撞体 - List attackColliders1 = new List(); - for (int i = 0; i < colliders.Count; i++) + allColliders = Physics.OverlapSphere(transform.position, detectionRadius).ToList(); // 检索范围内的所有碰撞体 + attackColliders1 = new List(); + for (int i = 0; i < allColliders.Count; i++) { - if (colliders[i].transform.tag == "AttackTarget") - attackColliders1.Add(colliders[i]); + if (allColliders[i].transform.tag == "AttackTarget") + attackColliders1.Add(allColliders[i]); } if (wrjModel == WRJModel.光学无人机)