270 lines
		
	
	
		
			8.4 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			270 lines
		
	
	
		
			8.4 KiB
		
	
	
	
		
			C#
		
	
	
	
| using DG.Tweening;
 | |
| using System;
 | |
| using System.Linq;
 | |
| using UnityEngine;
 | |
| using UnityEngine.UI;
 | |
| 
 | |
| /// <summary>
 | |
| /// 模式选择
 | |
| /// </summary>
 | |
| [AddComponentMenu("PatternChoose/模式选择")]
 | |
| public class PatternChoose : MonoBehaviour
 | |
| {
 | |
|     static PatternChoose _inst;
 | |
|     public static PatternChoose Inst => _inst;
 | |
|     public Button TS_button;
 | |
|     public Button RL_button;
 | |
|     /// <summary>
 | |
|     /// 热力效果图
 | |
|     /// </summary>
 | |
|     public GameObject heatMap;
 | |
|     public GameObject search_go;
 | |
| 
 | |
|     Vector3 init_pos;
 | |
|     Vector3 init_rot;
 | |
| 
 | |
|     [SerializeField] public Color red_alarm;
 | |
|     [SerializeField] public Color yellow_alarm;
 | |
|     [SerializeField] public Color blue_alarm;
 | |
| 
 | |
|     public Button back_page;
 | |
| 
 | |
|     public Toggle roomCut;
 | |
|     public Toggle quanJing;
 | |
|     public Toggle niaoKan;
 | |
| 
 | |
|     [Header("上次点击的菜单类型")]
 | |
|     public Menu current_menu;
 | |
| 
 | |
|     /// <summary>
 | |
|     /// 设备新增窗口
 | |
|     /// </summary>
 | |
|     public GameObject sb_xz_page;
 | |
|     /// <summary>
 | |
|     /// 设备编辑窗口
 | |
|     /// </summary>
 | |
|     public GameObject sb_bj_page;
 | |
|     /// <summary>
 | |
|     /// 设备查看窗口
 | |
|     /// </summary>
 | |
|     public GameObject sb_ck_page;
 | |
|     /// <summary>
 | |
|     /// 端口新增窗口
 | |
|     /// </summary>
 | |
|     public GameObject dk_xz_page;
 | |
|     /// <summary>
 | |
|     /// 端口编辑窗口
 | |
|     /// </summary>
 | |
|     public GameObject dk_bj_page;
 | |
|     public CreateLine huaXian;
 | |
|     /// <summary>
 | |
|     /// 线缆
 | |
|     /// </summary>
 | |
|     public ByCode xianlan;
 | |
|     public GameObject xianlan_popup;
 | |
| 
 | |
|     public UIToCabinet uiToCabinet;
 | |
| 
 | |
|     public Image xunJianImg;
 | |
| 
 | |
|     [Header("时间筛选")]
 | |
|     public GameObject calendar;
 | |
|     //public ZCalendar zCalendar;
 | |
|     private void Awake()
 | |
|     {
 | |
| 
 | |
|         if (_inst != null && _inst != this)
 | |
|         {
 | |
|             Destroy(this.gameObject);
 | |
|         }
 | |
|         else
 | |
|         {
 | |
|             _inst = this;
 | |
|             //DontDestroyOnLoad(this.gameObject);
 | |
|         }
 | |
|         init_pos = Camera.main.transform.localPosition;
 | |
|         init_rot = Camera.main.transform.localEulerAngles;
 | |
|     }
 | |
|     void Start()
 | |
|     {
 | |
|         //Debug.Log("版本号 1.1.1");
 | |
|         roomCut.onValueChanged.AddListener((x) =>
 | |
|         {
 | |
|             if (CabinetUIManager.Instance.current_menu == Menu.M_数字孪生_智能巡检)
 | |
|                 return;
 | |
|             roomCut_fuc();
 | |
|         });
 | |
| 
 | |
|         quanJing.onValueChanged.AddListener((x) =>
 | |
|         {
 | |
|             if (!x)
 | |
|                 return;
 | |
|             quanJing_fuc();
 | |
|         });
 | |
| 
 | |
|         niaoKan.onValueChanged.AddListener((x) =>
 | |
|         {
 | |
|             niaoKan_fuc();
 | |
|         });
 | |
| 
 | |
|         back_page.onClick.AddListener(() =>
 | |
|         {
 | |
|             ExtendedFlycam.Inst.reminder((isgo) =>
 | |
|             {
 | |
|                 if (isgo)
 | |
|                 {
 | |
|                     quanJing_fuc();
 | |
|                     if (Menu.M_数字孪生_线缆连接_展示 == CabinetUIManager.Instance.current_menu)
 | |
|                     {
 | |
|                         SearchName searchName = search_go.GetComponent<SearchName>();
 | |
|                         searchName.showXianLan(searchName._co);
 | |
|                     }
 | |
|                     else if (Menu.M_数字孪生_场景管理 == CabinetUIManager.Instance.current_menu)
 | |
|                     {
 | |
|                         GameManager.Inst.search_box.GetComponent<SearchName>().LoadCabinet(SearchName.SearchType.机柜);
 | |
|                         GameManager.Inst.search_box.SetActive(true);
 | |
|                     }
 | |
|                 }
 | |
|             });
 | |
|         });
 | |
| 
 | |
|         //Debug.Log("版本号 1.1.1");
 | |
|     }
 | |
| 
 | |
|     /// <summary>
 | |
|     ///  点击切换房间
 | |
|     /// </summary>
 | |
|     public void roomCut_fuc()
 | |
|     {
 | |
|         ExtendedFlycam.Inst.QieHuan(CabinetUIManager.Instance.current_menu, 2);
 | |
|         for (int i = 0; i < xianlan.transform.childCount; i++)
 | |
|         {
 | |
|             xianlan.transform.GetChild(i).gameObject.SetActive(false);
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     /// <summary>
 | |
|     /// 点击全景
 | |
|     /// </summary>
 | |
|     public void quanJing_fuc()
 | |
|     {
 | |
|         //if (!quanJing.isOn)
 | |
|         //    return;
 | |
|         sb_ck_page.SetActive(false);
 | |
|         GameManager.Inst.magnifyState = false;
 | |
|         TransparentGlowManage.Inst.is_magnify = false;
 | |
|         for (int i = 0; i < CabinetUIManager.Instance.cabine_hights_now.Count; i++)
 | |
|         {
 | |
|             CabinetUIManager.Instance.cabine_hights_now[i].SetActive(true);
 | |
|         }
 | |
|         CabinetUIManager.Instance.cabine_hights_now.Clear();
 | |
|         if (Menu.M_全景监控_柜门状态 != CabinetUIManager.Instance.current_menu)
 | |
|         {
 | |
|             GameManager.Inst.power_close();
 | |
|             GameManager.Inst.Cabinets_go[0].GetComponent<ClickEvent>().openCap(false);
 | |
|         }
 | |
|         //ExtendedFlycam.Inst.CameraRtDisable();
 | |
|         GameManager.Inst.editorMenu.gameObject.SetActive(false);
 | |
|         ExtendedFlycam.Inst.QieHuan(CabinetUIManager.Instance.current_menu);
 | |
|         //ExtendedFlycam.Inst.CameraRtDisable();
 | |
|         for (int i = 0; i < xianlan.transform.childCount; i++)
 | |
|         {
 | |
|             xianlan.transform.GetChild(i).gameObject.SetActive(false);
 | |
|         }
 | |
| 
 | |
|         if (Menu.M_数字孪生_接地网 != CabinetUIManager.Instance.current_menu)
 | |
|         {
 | |
|             for (int i = 0; i < GameManager.Inst.Cabinets_go.Count; i++)
 | |
|             {
 | |
|                 //string s2 = GameManager.Inst.Cabinets_go[i].GetComponent<DeviceQuery>().deviceList.devicePosition.Split('-')[0];
 | |
|                 //if (s1 != s2)
 | |
|                 GameManager.Inst.Cabinets_go[i].SetActive(true);
 | |
|                 //else if (s1 == s2 && GameManager.Inst.Cabinets_go[i] != gameObject)
 | |
|                 GameManager.Inst.Cabinets_go[i].GetComponent<TransparentGlow>().F2();
 | |
|             }
 | |
|             for (int i = 0; i < GameManager.Inst.roomDoors.Count; i++)
 | |
|             {
 | |
|                 GameManager.Inst.roomDoors[i].gameObject.GetComponent<BoxCollider>().enabled = true;
 | |
|             }
 | |
|         }
 | |
|         else
 | |
|         {
 | |
|             var s = Array.FindAll(TransparentGlowManage.Inst.points.ToArray(), (item) =>
 | |
|             {
 | |
|                 return (item.GetComponent<TransparentGlow>() != null &&
 | |
|                 item.name != "R08" && item.name != "R15" && item.name != "R65" &&
 | |
|                 item.name != "R57" && item.name != "R54" && item.name != "R45" &&
 | |
|                 item.name != "R37" && item.name != "R29" && item.name != "R22");
 | |
|             }).Select(item => item.GetComponent<TransparentGlow>()).ToArray();
 | |
| 
 | |
|             TransparentGlowManage.Inst.transparencyALL(s);
 | |
|         }
 | |
| 
 | |
|         for (int i = 0; i < GameManager.Inst.TmsPorts_go.Count; i++)
 | |
|         {
 | |
|             GameManager.Inst.TmsPorts_go[i].GetComponent<PortQuery>().hight.SetActive(false);
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     /// <summary>
 | |
|     /// 点击鸟瞰
 | |
|     /// </summary>
 | |
|     public void niaoKan_fuc()
 | |
|     {
 | |
|         GameManager.Inst.editorMenu.gameObject.SetActive(false);
 | |
|         ExtendedFlycam.Inst.QieHuan(CabinetUIManager.Instance.current_menu, 3);
 | |
|     }
 | |
| 
 | |
|     // Update is called once per frame
 | |
|     void Update()
 | |
|     {
 | |
|         if (GameManager.Inst.magnifyState)
 | |
|         {
 | |
|             back_page.gameObject.SetActive(true);
 | |
|         }
 | |
|         else
 | |
|         {
 | |
|             back_page.gameObject.SetActive(false);
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     public void F1(bool isheatMap)
 | |
|     {
 | |
|         heatMap.SetActive(isheatMap);
 | |
|         ExtendedFlycam.Inst.init_mainCamera_rot();
 | |
|         Camera.main.transform.DOMove(/*TransparentGlowManage.Inst.MainCamera_pos*/init_pos, 1f);
 | |
|         Camera.main.transform.DORotateQuaternion(Quaternion.Euler(/*TransparentGlowManage.Inst.MainCamera_rot*/init_rot), 1f).OnComplete(() =>
 | |
|         {
 | |
|             //更新相机初始旋转角度
 | |
|             ExtendedFlycam.Inst.initialRotationEulerAngles = Camera.main.transform.localEulerAngles;
 | |
|         });
 | |
|         TransparentGlowManage.Inst.renewALL();
 | |
|     }
 | |
| 
 | |
|     void F2(bool isheatMap)
 | |
|     {
 | |
|         heatMap.SetActive(isheatMap);
 | |
|         ExtendedFlycam.Inst.init_mainCamera_rot();
 | |
|         Camera.main.transform.DOMove(/*TransparentGlowManage.Inst.MainCamera_pos*/init_pos, 1f);
 | |
|         Camera.main.transform.DORotateQuaternion(Quaternion.Euler(/*TransparentGlowManage.Inst.MainCamera_rot*/init_rot), 1f).OnComplete(() =>
 | |
|         {
 | |
|             //更新相机初始旋转角度
 | |
|             ExtendedFlycam.Inst.initialRotationEulerAngles = Camera.main.transform.localEulerAngles;
 | |
|         });
 | |
|         TransparentGlowManage.Inst.renewALL();
 | |
|     }
 | |
| 
 | |
| 
 | |
|     /// <summary>
 | |
|     /// 关闭所有弹窗
 | |
|     /// </summary>
 | |
|     public void clspup()
 | |
|     {
 | |
|         sb_bj_page.SetActive(false);
 | |
|         sb_xz_page.SetActive(false);
 | |
|         dk_bj_page.SetActive(false);
 | |
|         dk_xz_page.SetActive(false);
 | |
|         sb_ck_page.SetActive(false);
 | |
|     }
 | |
| }
 |