BasicDeviceControl.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. using UnityEngine.UI;
  4. using Blue;
  5. namespace GHZLangChao
  6. {
  7. public class BasicDeviceControl : AbstractController
  8. {
  9. [SerializeField] private Toggle Arrow_Toggle; //箭头toggle
  10. [SerializeField] private Image ArrowToggleBackground; // 箭头toggle的背景
  11. [SerializeField] private GameObject FaultPanel; // 故障面板
  12. [SerializeField] private Transform FaultPanelContent;// 故障面板Item父物体
  13. [SerializeField] private Button Nav_Btn; // 导航按钮
  14. private bool isInit=false;
  15. private void Awake()
  16. {
  17. this.RegisterEvent<ShowDeviceEvent>(SetShowDeviceTransform);
  18. Nav_Btn.onClick.AddListener(StartNav);
  19. Arrow_Toggle.onValueChanged.AddListener((e) =>
  20. {
  21. if(!isInit) Init();
  22. if(e)
  23. ArrowToggleBackground.enabled = false;
  24. else
  25. ArrowToggleBackground.enabled = true;
  26. });
  27. UICallManager.Instance.GetDeviceTransform();
  28. }
  29. public void ShowChoose()
  30. {
  31. ScenesManager.Instance.showWindow(ScenesManager.SceneType.ShowChoose);
  32. }
  33. /// <summary>
  34. /// 初始化数据
  35. /// </summary>
  36. private void Init()
  37. {
  38. isInit = true;
  39. // 初始化故障面板
  40. List<AlarmData> ListAlarmData = UICallManager.Instance.GetAlarmData();
  41. for (int i = 0; i < ListAlarmData.Count;i++)
  42. {
  43. GameObject go = Instantiate(InstantiateSystem.Instance.BlueObject.FaultPanel_Item,FaultPanelContent);
  44. FaultPanel_Item item = go.GetComponent<FaultPanel_Item>();
  45. item.Init(ListAlarmData[i]);
  46. go.name = ListAlarmData[i].title;
  47. }
  48. for (int i = 0; i < ListAlarmData.Count;i++)
  49. {
  50. GameObject go = Instantiate(InstantiateSystem.Instance.BlueObject.FaultPanel_Item,FaultPanelContent);
  51. FaultPanel_Item item = go.GetComponent<FaultPanel_Item>();
  52. item.Init(ListAlarmData[i]);
  53. go.name = ListAlarmData[i].title;
  54. }
  55. }
  56. #region UI监听
  57. private static AlarmData mAlarmData;
  58. public static AlarmData AlarmData
  59. {
  60. get => mAlarmData;
  61. set => mAlarmData = value;
  62. }
  63. private void StartNav()
  64. {
  65. ScenesManager.Instance.showWindow(ScenesManager.SceneType.ShowXunJian);
  66. ShowXunJian.Instance.gotoWindow(ScenesManager.SceneType.ShowDH);
  67. BladeServerManager.Instance.isDaoHang = true;
  68. XunJianManager.Instance.FaultChange();
  69. (SceneIOCContainer.Instance.Pull("ShowChoose") as GameObject).SetActive(false);
  70. MachineObj obj = UICallManager.Instance.QueryMachineObj(AlarmData.deviceId);
  71. if (obj != null)
  72. UICallManager.Instance.NavigatorServer(obj);
  73. else
  74. Debug.LogError(" 未查找到设备 " + AlarmData.deviceId + " " + AlarmData.deviceName);
  75. }
  76. #endregion
  77. #region 事件监听
  78. private void SetShowDeviceTransform(ShowDeviceEvent e)
  79. {
  80. transform.position = e.ShowDeviceTransform.position;
  81. transform.rotation = e.ShowDeviceTransform.rotation;
  82. this.UnRegisterEvent<ShowDeviceEvent>(SetShowDeviceTransform);
  83. }
  84. #endregion
  85. }
  86. }