From 494cb4b9a7c1a151d46dd02efc0eff464a040e01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A6=E5=8F=B7=E5=90=8D?= <3077614386@qq.com> Date: Sun, 21 Jan 2024 14:56:10 +0800 Subject: [PATCH] 1 --- Assets/Zion/Scripts/Adam/DeviceManager.cs | 36 ++++----- Assets/Zion/Scripts/HighPriorityTarget.cs | 8 +- .../UAV/UnmannedAerialVehicle.cs | 76 +++++++++++-------- 3 files changed, 68 insertions(+), 52 deletions(-) diff --git a/Assets/Zion/Scripts/Adam/DeviceManager.cs b/Assets/Zion/Scripts/Adam/DeviceManager.cs index 9ca2f67c..e24cb030 100644 --- a/Assets/Zion/Scripts/Adam/DeviceManager.cs +++ b/Assets/Zion/Scripts/Adam/DeviceManager.cs @@ -116,29 +116,31 @@ public class DeviceManager : MonoSingleton return tempUAM; } + public List unmannedAerialVehicleManages; public void SetCollider4WRJ(List attackColliders, ref Collider currentTarget) { if (attackColliders.Count > 0) { - List temp = GetGXWRJAndZSWRJ(); - for (int i = 0; i < temp.Count; i++) + unmannedAerialVehicleManages = GetGXWRJAndZSWRJ(); + for (int i = 0; i < unmannedAerialVehicleManages.Count; i++) { - if (temp[i].unmannedAerialVehicles[0] != null && temp[i].unmannedAerialVehicles[0].gameObject.activeSelf) + if (unmannedAerialVehicleManages[i].unmannedAerialVehicles[0] != null && unmannedAerialVehicleManages[i].unmannedAerialVehicles[0].gameObject.activeSelf) { - if (temp[i].unmannedAerialVehicles[0].attackTarget == null) + if (unmannedAerialVehicleManages[i].unmannedAerialVehicles[0].attackTarget == null) { - for (int j = 0; j < attackColliders.Count; j++) - { - Collider c = null; - if (attackColliders[i] != null) - { - c = attackColliders[i]; - } - if (attackColliders[j] != null) - { - temp[i].unmannedAerialVehicles[0].AttAck(attackColliders[j].transform); - } - } + unmannedAerialVehicleManages[i].unmannedAerialVehicles[0].AttAck(attackColliders[0].transform); + //for (int j = 0; j < attackColliders.Count; j++) + //{ + // Collider c = null; + // if (attackColliders[i] != null) + // { + // c = attackColliders[i]; + // } + // if (attackColliders[j] != null) + // { + // unmannedAerialVehicleManages[i].unmannedAerialVehicles[0].AttAck(attackColliders[j].transform); + // } + //} } } @@ -168,7 +170,7 @@ public class DeviceManager : MonoSingleton if(highPriorityTarget) { Vector3 Pos=new Vector3(float.Parse(info[3]), float.Parse(info[4]), float.Parse(info[5])); - highPriorityTarget.BeAssaulted(Pos, false); + highPriorityTarget.BeAssaulted(Pos, false, int.Parse(info[2])); } } else diff --git a/Assets/Zion/Scripts/HighPriorityTarget.cs b/Assets/Zion/Scripts/HighPriorityTarget.cs index a366424f..4569c79c 100644 --- a/Assets/Zion/Scripts/HighPriorityTarget.cs +++ b/Assets/Zion/Scripts/HighPriorityTarget.cs @@ -68,10 +68,6 @@ public class HighPriorityTarget : MonoBehaviour if (isSend) { HP -= 10; - GameObject Bao = Instantiate(explodePrefab, transform); - Bao.transform.localPosition = Pos; - Bao.transform.SetParent(null); - Bao.SetActive(true); string nowData = GetSyncDis(Pos); Debug.Log(nowData); _ = SyncCreateRoom.SendMessageAsync(string.Format("send2room {0}", nowData)); @@ -80,6 +76,10 @@ public class HighPriorityTarget : MonoBehaviour { HP = hp; } + GameObject Bao = Instantiate(explodePrefab, transform); + Bao.transform.localPosition = Pos; + Bao.transform.SetParent(null); + Bao.SetActive(true); if (HP < 50) { ModerFull.SetActive(false); diff --git a/Assets/Zion/Scripts/ModelFunction/UAV/UnmannedAerialVehicle.cs b/Assets/Zion/Scripts/ModelFunction/UAV/UnmannedAerialVehicle.cs index e44428b8..401bd914 100644 --- a/Assets/Zion/Scripts/ModelFunction/UAV/UnmannedAerialVehicle.cs +++ b/Assets/Zion/Scripts/ModelFunction/UAV/UnmannedAerialVehicle.cs @@ -72,7 +72,9 @@ public class UnmannedAerialVehicle : MonoBehaviour public GameObject explodePrefab; public TextMesh tips; - + /// + /// 攻击目标 + /// public Transform attackTarget; /// @@ -129,6 +131,44 @@ public class UnmannedAerialVehicle : MonoBehaviour Destroy(gameObject); } + /// + /// 销毁蓝方设备 + /// + /// + void AddBao(Transform _transform) + { + //设备 + EquipmentCommon _equipmentCommon = _transform.GetComponent(); + if (_equipmentCommon) + { + string nowData = string.Format("{0},{1}", "SetToBeDestroyed", _equipmentCommon.deviceID); + //Debug.Log(nowData); + _ = SyncCreateRoom.SendMessageAsync(string.Format("send2room {0}", nowData)); + string currentTime = System.DateTime.Now.ToString(); + string _log = currentTime + " " + unmannedAerialVehicleManage.equipmentCommon.equipmentType + "(" + unmannedAerialVehicleManage.equipmentCommon.deviceID + ")" + + "编号" + serialNumber + "子无人机" + "攻击摧毁了" + _equipmentCommon.equipmentType + "(" + _equipmentCommon.deviceID + ")"; + UploadLog(_log); + + WWWForm headers = new WWWForm(); + headers.AddField("id", _equipmentCommon.deviceID); + StartCoroutine(PostString(Url_Deletepracticedevicedetail, headers, data => + { + //Debug.Log(data); + })); + } + //重点打击目标 + HighPriorityTarget highPriorityTarget = _transform.GetComponent(); + if (highPriorityTarget ) + { + highPriorityTarget.BeAssaulted(transform.position, true); + } + + GameObject Bao = Instantiate(explodePrefab, _transform); + Bao.transform.localPosition = Vector3.zero; + Bao.transform.SetParent(null); + Bao.SetActive(true); + Destroy(_transform.gameObject); + } /// ///上传日志 /// @@ -153,33 +193,7 @@ public class UnmannedAerialVehicle : MonoBehaviour })); } - /// - /// 销毁蓝方设备 - /// - /// - void AddBao(Transform _transform) - { - EquipmentCommon _equipmentCommon = _transform.GetComponent(); - string nowData = string.Format("{0},{1}", "SetToBeDestroyed", _equipmentCommon.deviceID); - //Debug.Log(nowData); - _ = SyncCreateRoom.SendMessageAsync(string.Format("send2room {0}", nowData)); - string currentTime = System.DateTime.Now.ToString(); - string _log = currentTime + " " + unmannedAerialVehicleManage.equipmentCommon.equipmentType + "(" + unmannedAerialVehicleManage.equipmentCommon.deviceID + ")" - + "编号" + serialNumber + "子无人机" + "攻击摧毁了" + _equipmentCommon.equipmentType + "(" + _equipmentCommon.deviceID + ")"; - UploadLog(_log); - - WWWForm headers = new WWWForm(); - headers.AddField("id", _equipmentCommon.deviceID); - StartCoroutine(PostString(Url_Deletepracticedevicedetail, headers, data => - { - //Debug.Log(data); - })); - GameObject Bao = Instantiate(explodePrefab, _transform); - Bao.transform.localPosition = Vector3.zero; - Bao.transform.SetParent(null); - Bao.SetActive(true); - Destroy(_transform.gameObject); - } + private void OnBecameInvisible() @@ -210,8 +224,8 @@ public class UnmannedAerialVehicle : MonoBehaviour if (wrjModel == WRJModel.光学无人机) { Debug.Log("光学无人机攻击"); - //StopCoroutine(RangedAttack()); - //StartCoroutine(RangedAttack()); + StopCoroutine(RangedAttack()); + StartCoroutine(RangedAttack()); } else { @@ -235,7 +249,7 @@ public class UnmannedAerialVehicle : MonoBehaviour { while (attackTarget) { - yield return new WaitForSeconds(0.5f); + yield return new WaitForSeconds(5f); GameObject obj = Instantiate(bulletPrefab, bulletPoint.position, bulletPoint.rotation); obj.SetActive(true); Rigidbody rb = obj.GetComponent();