XunJianManager.cs 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. using System.Collections.Generic;
  2. using TMPro;
  3. using UnityEngine;
  4. using UnityEngine.Events;
  5. using UnityEngine.UI;
  6. using Blue;
  7. namespace GHZLangChao
  8. {
  9. public class XunJianManager : SingletonMonobehaviour<XunJianManager>, IController
  10. {
  11. public bool Test = false;
  12. [SerializeField] private GameObject SearchPanel; // 搜索面板
  13. [SerializeField] private Transform SearchPanelContent; // 搜索面板Item父物体
  14. [SerializeField] private GameObject FaultPanel; // 故障面板
  15. [SerializeField] private Transform FaultPanelContent;// 故障面板Item父物体
  16. [SerializeField] private Button Serach_Btn;
  17. public Button Fault_Btn;
  18. private FontStyle FontStyleB = FontStyle.Bold;
  19. private FontStyle FontStyleN = FontStyle.Normal;
  20. [SerializeField] private TextMeshProUGUI Serach_Text;
  21. [SerializeField] private TextMeshProUGUI Fault_Text;
  22. [SerializeField] private Button Titile_Btn;
  23. [SerializeField] private Button Nav_Btn; // 导航按钮
  24. [SerializeField] private GameObject Retract_go; // 收起
  25. [SerializeField] private GameObject Expand_go; // 展开
  26. private IQueueSystem mQueueSystem;
  27. public GameObject UI_go;
  28. public UnityEvent OnReset = new UnityEvent();
  29. public UnityEvent OnRetract = new UnityEvent();
  30. public UnityEvent OnExpand = new UnityEvent();
  31. private void Awake()
  32. {
  33. mQueueSystem = this.GetService<IQueueSystem>();
  34. mQueueSystem.Level3QueueCount.Register(mQueueSystemCountNotNull).UnRegisterWhenGameObjectDestroyed(gameObject);
  35. }
  36. void Start()
  37. {
  38. #if UNITY_EDITOR
  39. Test = true;
  40. #endif
  41. Serach_Btn.onClick.AddListener(SerachChange);
  42. Fault_Btn.onClick.AddListener(FaultChange);
  43. Nav_Btn.onClick.AddListener(StartNav);
  44. Titile_Btn.onClick.AddListener(ClickTitle);
  45. //UICallManager.Instance.MachineRoomInit();
  46. XRRGBCamera.Instance.stopCamera();
  47. Init();
  48. }
  49. public void StartXunJain()
  50. {
  51. UI_go.SetActive(false);
  52. }
  53. public void Next()
  54. {
  55. ShowXunJian.Instance.gotoWindow(ScenesManager.SceneType.ShowDH);
  56. }
  57. public void back()
  58. {
  59. ScenesManager.Instance.showWindow(ScenesManager.SceneType.ShowChoose);
  60. // BladeServerManager.Instance.isDaoHang = false;
  61. }
  62. public void Navigationing()
  63. {
  64. // ScenesManager.Instance.showWindow(ScenesManager.SceneType.Navigationing);
  65. }
  66. /// <summary>
  67. /// 初始化数据
  68. /// </summary>
  69. private void Init()
  70. {
  71. // 初始化搜索面板
  72. List<MachineParameters> listEquipmentData = UICallManager.Instance.GetMachineRoomData("").listEquipmentData;
  73. for (int i = 0; i < listEquipmentData.Count;i++)
  74. {
  75. GameObject go = Instantiate(InstantiateSystem.Instance.BlueObject.SearchPanel_Item,SearchPanelContent);
  76. SearchPanel_Item item = go.GetComponent<SearchPanel_Item>();
  77. item.Init(listEquipmentData[i]);
  78. go.name = listEquipmentData[i].deviceName;
  79. if(string.IsNullOrEmpty(listEquipmentData[i].deviceName)) Destroy(go);
  80. }
  81. // 初始化故障面板
  82. List<AlarmData> ListAlarmData = UICallManager.Instance.GetAlarmData();
  83. for (int i = 0; i < ListAlarmData.Count;i++)
  84. {
  85. GameObject go = Instantiate(InstantiateSystem.Instance.BlueObject.FaultPanel_Item,FaultPanelContent);
  86. FaultPanel_Item item = go.GetComponent<FaultPanel_Item>();
  87. item.Init(ListAlarmData[i]);
  88. go.name = ListAlarmData[i].title;
  89. }
  90. }
  91. #region UI监听
  92. private Color colorBlue = new Color32(25,107,255,255);
  93. private Color colorWhite = new Color32(255,255,255,255);
  94. public void SerachChange()
  95. {
  96. Serach_Text.fontStyle = (FontStyles)FontStyleB;
  97. Fault_Text.fontStyle = (FontStyles)FontStyleN;
  98. Serach_Text.color = colorBlue;
  99. Fault_Text.color = Color.white;
  100. IsSerach = true;
  101. }
  102. public void FaultChange()
  103. {
  104. Serach_Text.fontStyle = (FontStyles)FontStyleN;
  105. Fault_Text.fontStyle = (FontStyles)FontStyleB;
  106. Serach_Text.color = Color.white;
  107. Fault_Text.color = colorBlue;
  108. IsSerach = false;
  109. }
  110. private static MachineParameters mMachineParameter;
  111. public static MachineParameters MachineParameters
  112. {
  113. get => mMachineParameter;
  114. set => mMachineParameter = value;
  115. }
  116. private static AlarmData mAlarmData;
  117. public static AlarmData AlarmData
  118. {
  119. get => mAlarmData;
  120. set => mAlarmData = value;
  121. }
  122. private bool IsSerach = true; // 在Search面板下点击导航
  123. private void StartNav()
  124. {
  125. if(IsSerach)
  126. {
  127. MachineObj obj = UICallManager.Instance.QueryMachineObj(MachineParameters.deviceId);
  128. if (obj != null)
  129. {
  130. UICallManager.Instance.NavigatorServer(obj);
  131. UI_go.SetActive(false);
  132. Retract_go.SetActive(false);
  133. Expand_go.SetActive(true);
  134. }
  135. else
  136. Debug.LogError(" 未查找到设备 " + MachineParameters.deviceId + " " + MachineParameters.deviceName);
  137. }
  138. else
  139. {
  140. MachineObj obj = UICallManager.Instance.QueryMachineObj(AlarmData.deviceId);
  141. if (obj != null)
  142. {
  143. UICallManager.Instance.NavigatorServer(obj);
  144. UI_go.SetActive(false);
  145. Retract_go.SetActive(false);
  146. Expand_go.SetActive(true);
  147. }
  148. else
  149. Debug.LogError(" 未查找到设备 " + AlarmData.deviceId + " " + AlarmData.deviceName);
  150. }
  151. }
  152. public void showRTC()
  153. {
  154. LangChaoRTC.Instance.showRTC(0);
  155. ScenesManager.Instance.showWindow(ScenesManager.SceneType.RoomMain);
  156. }
  157. private bool isRetract = false;
  158. private void ClickTitle()
  159. {
  160. isRetract = !isRetract;
  161. if(isRetract)
  162. OnRetract?.Invoke();
  163. else
  164. OnExpand?.Invoke();
  165. }
  166. #endregion
  167. public void OpenEidotrCanvas()
  168. {
  169. SettingMachineRoomData.Instance.EditorOpen();
  170. }
  171. private void Update()
  172. {
  173. if (Test) return;
  174. #if UNITY_EDITOR
  175. return;
  176. #endif
  177. OnReset?.Invoke();
  178. }
  179. private void OnEnable()
  180. {
  181. ShowHideLevel3(true);
  182. }
  183. private void ShowHideLevel3(bool on)
  184. {
  185. Debug.Log("Level3Queue:" + mQueueSystem.Level3List.Count);
  186. foreach (var go in mQueueSystem.Level3List)
  187. {
  188. go.SetActive(on);
  189. }
  190. }
  191. private void mQueueSystemCountNotNull(int newCount)
  192. {
  193. Debug.Log($"打开的数量:{mQueueSystem.Level3QueueCount.Value}");
  194. }
  195. }
  196. }