96 lines
2.9 KiB
C#
96 lines
2.9 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
/// <summary>
|
|
/// WRJUI
|
|
/// </summary>
|
|
public class RadioAngleView : MonoBehaviour
|
|
{
|
|
/// <summary>
|
|
/// 无人机设备ID
|
|
/// </summary>
|
|
public string deviceID;
|
|
/// <summary>
|
|
/// 无人机类型
|
|
/// </summary>
|
|
public WRJModel typeWRJ;
|
|
/// <summary>
|
|
/// 无人机
|
|
/// </summary>
|
|
public Text textNmme;
|
|
/// <summary>
|
|
/// 放大按钮
|
|
/// </summary>
|
|
public Button btnAmplification;
|
|
/// <summary>
|
|
/// 关闭按钮
|
|
/// </summary>
|
|
public Button btnClose;
|
|
/// <summary>
|
|
/// 视角显示
|
|
/// </summary>
|
|
public RawImage rawShow;
|
|
|
|
public UnmannedAerialVehicleManage uavm;
|
|
|
|
public GameObject targetPointPrefab;
|
|
public List<GameObject> targets = new List<GameObject>();
|
|
|
|
void Start()
|
|
{
|
|
//textNmme=transform.Find("名称").GetComponent<Text>();
|
|
//btnAmplification = transform.Find("放大查看").GetComponent<Button>();
|
|
//btnClose = transform.Find("关闭").GetComponent<Button>();
|
|
//rawShow=transform.GetComponentInChildren<RawImage>();
|
|
btnAmplification.onClick.AddListener(() =>
|
|
{
|
|
//吧放大UI打开
|
|
DroneViewDisplay.Instance.RadioAngleViewMaxShow(textNmme.text, rawShow, typeWRJ);
|
|
});
|
|
btnClose.onClick.AddListener(() =>
|
|
{
|
|
transform.localScale = Vector3.zero;
|
|
transform.SetAsLastSibling();// 移到父物体的最后一个位置
|
|
});
|
|
}
|
|
private void Update()
|
|
{
|
|
if (typeWRJ != WRJModel.电子侦察无人机) return;
|
|
targets = GameObject.FindGameObjectsWithTag("AttackTarget").ToList().FindAll(GetQualifiedEquipment);
|
|
if (targets.Count == 0) return;
|
|
foreach (Transform child in rawShow.transform)
|
|
{
|
|
Destroy(child.gameObject);
|
|
}
|
|
|
|
foreach (GameObject target in targets)
|
|
{
|
|
Vector3 relativePosition = target.transform.position - uavm.transform.position;
|
|
Vector2 radarPosition = new Vector2(relativePosition.x, relativePosition.z) * 0.1f;
|
|
GameObject point = Instantiate(targetPointPrefab, rawShow.transform);
|
|
RectTransform rt = point.GetComponent<RectTransform>();
|
|
rt.anchoredPosition = radarPosition;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 获取符合条件的设备
|
|
/// </summary>
|
|
public bool GetQualifiedEquipment(GameObject obj)
|
|
{
|
|
if (obj != null)
|
|
{
|
|
if (obj.gameObject.tag == "AttackTarget"
|
|
&& obj.transform.GetComponent<HighPriorityTarget>()
|
|
&& obj.transform.GetComponent<HighPriorityTarget>().frequency.Contains(uavm.electronicReconnaissanceCapability))
|
|
return true;
|
|
else
|
|
return false;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
}
|