using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
///
/// 编队控制脚本
///
public class FormationManager : MonoBehaviour
{
public Button startFormationBtn;
public Button submitFormationBtn;
public bool isStartFormation;
public List uavm = new List();
// 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()))
uavm.Add(hitInfo.collider.gameObject.GetComponent());
Debug.Log("拾取");
}
}
}
}
}
public void OnStartFormation()
{
isStartFormation = true;
}
public void OnSubmit()
{
isStartFormation = false;
}
}