using AdamThinkDevicesData; using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UIElements; public class Spectrumdetection : MonoBehaviour { public EquipmentCommon equipmentCommon; #region 频谱探测的参数 /// /// 探测距离 /// public string Detectionrange; /// /// 批目标处理能力 /// public string Batchcapacity; /// /// 探测成功率 /// public string Detectionsuccessrate; /// /// 探测响应时间 /// public string Responsetime; /// /// 测向精度 /// public string Directionfindingaccuracy; /// /// 最小探测速度 /// public string Minimumdetectionvelocity; #endregion private bool _isStartRehearsing = false; /// /// 是否正在演练 /// public bool isStartRehearsing { get { return _isStartRehearsing; } set { if (_isStartRehearsing != value) { _isStartRehearsing = value; OnActivationChanged?.Invoke(_isStartRehearsing); } } } /// /// 布尔值变化时触发时间 /// public event System.Action OnActivationChanged; /// /// /// public GameObject SpectrumdetectionUI; void Start() { equipmentCommon = GetComponent(); // 订阅布尔值变化事件 OnActivationChanged += OnActivationChangedHandler; } /// /// 演习是否启动 /// void OnActivationChangedHandler(bool bol) { if (bol) { Debug.Log("开始演练"); } else { Debug.Log("结束演练"); } } /// /// 读取设备参数 /// public void FillInTheData(List weaponitemone) { for (int i = 0; i < weaponitemone.Count; i++) { switch (weaponitemone[i].para_name) { case "探测距离:": Detectionrange = weaponitemone[i].para_value; break; case "批目标处理能力:": Batchcapacity = weaponitemone[i].para_value; break; case "探测成功率:": Detectionsuccessrate = weaponitemone[i].para_value; break; case "探测响应时间:": Responsetime = weaponitemone[i].para_value; break; case "测向精度:": Directionfindingaccuracy = weaponitemone[i].para_value; break; case "最小探测速度:": Minimumdetectionvelocity = weaponitemone[i].para_value; break; default: break; } } } void Update() { Search();//微波武器朝向无人机 } /// /// 搜索范围内的无人机 /// private void Search() { Collider[] colliders = Physics.OverlapSphere(transform.position, float.Parse(Detectionrange) * 100); for (int i = 0; i < colliders.Length; i++) { if (colliders[i].transform.gameObject.tag=="WRJ") { Debug.LogError("进来了"); UnmannedAerialVehicle unmannedAerialVehicle = null; if (colliders[i].GetComponent()) { unmannedAerialVehicle = colliders[i].GetComponent(); if (unmannedAerialVehicle !=null) { Microwaveweapon microwaveweapon = Microwaveweapon.MicrowaveweaponList.Find(x => (x != null && x.ismicow == false)); if (microwaveweapon) { microwaveweapon.ismicow = true; microwaveweapon.miceopos = unmannedAerialVehicle.transform; microwaveweapon.Orientation(); } } } } } } private void OnMouseDown() { if (equipmentCommon.isPlayer) { SpectrumdetectionUI.SetActive(true); } //SpectrumdetectionUI.SetActive(true); } private void OnDestroy() { OnActivationChanged -= OnActivationChangedHandler; } }