98 lines
2.7 KiB
C#
98 lines
2.7 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
|
|
public class Mastermanagement : MonoBehaviour
|
|
{
|
|
|
|
public List<DragController> dragControllers = new List<DragController>();//蓝方设备用于存UI元素
|
|
public List<GameObject> weapongames = new List<GameObject>();//蓝方设备用于存储场景中的物体
|
|
void Awake()
|
|
{
|
|
|
|
}
|
|
void Start()
|
|
{
|
|
StartCoroutine(WaitGetAllDevice());
|
|
}
|
|
//蓝方设备
|
|
public IEnumerator WaitGetAllDevice()
|
|
{
|
|
yield return new WaitForSeconds(0.1f);
|
|
|
|
weapongames = DeviceManager.Instance.GetPlayerDecive1();
|
|
if (weapongames.Count > 0)
|
|
{
|
|
if (!weapongames[0].name.Contains("无人机"))
|
|
{
|
|
for (int i = 0; i < weapongames.Count; i++)
|
|
{
|
|
Noobj(weapongames[i]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//红方设备
|
|
//private IEnumerator PloneGetAllDevice()
|
|
//{
|
|
// yield return new WaitForSeconds(0.1f);
|
|
// planegames = DeviceManager.Instance.GetPlayerDecive1();
|
|
//}
|
|
|
|
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
//初始化场景的设备
|
|
public void Noobj(GameObject game)
|
|
{
|
|
for (int i = 0; i < dragControllers.Count; i++)
|
|
{
|
|
if (dragControllers[i].gameObject.name == game.name && dragControllers[i].gameObject.activeSelf)
|
|
{
|
|
dragControllers[i].gameObject.SetActive(false);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
//判断链表的名字是否有相等的
|
|
public void Onobj(GameObject game)
|
|
{
|
|
for (int i = 0; i < dragControllers.Count; i++)
|
|
{
|
|
if (dragControllers[i].gameObject.name == game.name && !dragControllers[i].gameObject.activeSelf)
|
|
{
|
|
dragControllers[i].gameObject.SetActive(true);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
//给列表添加游戏物体
|
|
public void OnAdd(GameObject obj)
|
|
{
|
|
if (!weapongames.Contains(obj))
|
|
{
|
|
weapongames.Add(obj);
|
|
}
|
|
}
|
|
//给游戏删除物体
|
|
public void Remove(GameObject obj)
|
|
{
|
|
if (weapongames.Contains(obj))
|
|
{
|
|
//EquipmentCommon equipmentCommon= obj.GetComponent<EquipmentCommon>();
|
|
//if (equipmentCommon)
|
|
//{
|
|
// DroneViewDisplay.Instance.DistroyUI(equipmentCommon.deviceID);
|
|
//}
|
|
weapongames.Remove(obj);
|
|
//DeviceManager.Instance.RemoveDevice(obj);
|
|
if (obj.GetComponent<UnmannedAerialVehicleManage>())
|
|
FormationManager.Instance.RemoveAppointWRJ(obj.GetComponent<UnmannedAerialVehicleManage>());
|
|
Destroy(obj);
|
|
}
|
|
}
|
|
}
|