164 lines
4.7 KiB
C#
164 lines
4.7 KiB
C#
using AdamThinkDevicesData;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UIElements;
|
|
|
|
public class Spectrumdetection : MonoBehaviour
|
|
{
|
|
public EquipmentCommon equipmentCommon;
|
|
#region 频谱探测的参数
|
|
/// <summary>
|
|
/// 探测距离
|
|
/// </summary>
|
|
public string Detectionrange;
|
|
/// <summary>
|
|
/// 批目标处理能力
|
|
/// </summary>
|
|
public string Batchcapacity;
|
|
/// <summary>
|
|
/// 探测成功率
|
|
/// </summary>
|
|
public string Detectionsuccessrate;
|
|
/// <summary>
|
|
/// 探测响应时间
|
|
/// </summary>
|
|
public string Responsetime;
|
|
/// <summary>
|
|
/// 测向精度
|
|
/// </summary>
|
|
public string Directionfindingaccuracy;
|
|
/// <summary>
|
|
/// 最小探测速度
|
|
/// </summary>
|
|
public string Minimumdetectionvelocity;
|
|
#endregion
|
|
|
|
private bool _isStartRehearsing = false;
|
|
/// <summary>
|
|
/// 是否正在演练
|
|
/// </summary>
|
|
public bool isStartRehearsing
|
|
{
|
|
get { return _isStartRehearsing; }
|
|
set
|
|
{
|
|
if (_isStartRehearsing != value)
|
|
{
|
|
_isStartRehearsing = value;
|
|
OnActivationChanged?.Invoke(_isStartRehearsing);
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 布尔值变化时触发时间
|
|
/// </summary>
|
|
public event System.Action<bool> OnActivationChanged;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public GameObject SpectrumdetectionUI;
|
|
void Start()
|
|
{
|
|
equipmentCommon = GetComponent<EquipmentCommon>();
|
|
// 订阅布尔值变化事件
|
|
OnActivationChanged += OnActivationChangedHandler;
|
|
}
|
|
/// <summary>
|
|
/// 演习是否启动
|
|
/// </summary>
|
|
void OnActivationChangedHandler(bool bol)
|
|
{
|
|
if (bol)
|
|
{
|
|
Debug.Log("开始演练");
|
|
}
|
|
else
|
|
{
|
|
Debug.Log("结束演练");
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 读取设备参数
|
|
/// </summary>
|
|
public void FillInTheData(List<List_paraItem> 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();//微波武器朝向无人机
|
|
}
|
|
/// <summary>
|
|
/// 搜索范围内的无人机
|
|
/// </summary>
|
|
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>())
|
|
{
|
|
unmannedAerialVehicle = colliders[i].GetComponent<UnmannedAerialVehicle>();
|
|
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;
|
|
}
|
|
}
|