57 lines
1.7 KiB
C#
57 lines
1.7 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
|
|
/// <summary>
|
|
/// 编队控制脚本
|
|
/// </summary>
|
|
public class FormationManager : MonoBehaviour
|
|
{
|
|
public Button startFormationBtn;
|
|
public Button submitFormationBtn;
|
|
public bool isStartFormation;
|
|
public List<UnmannedAerialVehicleManage> uavm = new List<UnmannedAerialVehicleManage>();
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
startFormationBtn.onClick.AddListener(OnStartFormation);
|
|
submitFormationBtn.onClick.AddListener(OnSubmit);
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
if (isStartFormation)
|
|
{
|
|
if (Input.GetKey(KeyCode.LeftControl) && Input.GetMouseButtonDown(0))
|
|
{
|
|
if (EventSystem.current.IsPointerOverGameObject()) return;
|
|
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
|
RaycastHit hitInfo;
|
|
if (Physics.Raycast(ray, out hitInfo, 1000))
|
|
{
|
|
if (hitInfo.collider.gameObject.tag == "WRJ")
|
|
{
|
|
if (!uavm.Contains(hitInfo.collider.gameObject.GetComponent<UnmannedAerialVehicleManage>()))
|
|
uavm.Add(hitInfo.collider.gameObject.GetComponent<UnmannedAerialVehicleManage>());
|
|
Debug.Log("拾取");
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public void OnStartFormation()
|
|
{
|
|
isStartFormation = true;
|
|
}
|
|
|
|
public void OnSubmit()
|
|
{
|
|
isStartFormation = false;
|
|
}
|
|
}
|