DianLiJianKongManager.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using XCharts.Runtime;
  6. using static Manager;
  7. public class DianLiJianKongManager : UpdateManager
  8. {
  9. public List<LineChart> lcs;
  10. public static DianLiJianKongManager Instance;
  11. public GameObject togglelist;
  12. public Text jiguiname;
  13. public wsdItem item;
  14. List<GameObject> items = new List<GameObject>();
  15. private void Awake()
  16. {
  17. Instance = this;
  18. }
  19. ServerData sData;
  20. public static bool isinit;
  21. public override void updateData()
  22. {
  23. base.updateData();
  24. if(chooseroom==0)
  25. {
  26. chooseroom = ServerRoomManager.chooswsd;
  27. }
  28. if (chooseroom == 0)
  29. {
  30. return;
  31. }
  32. Debug.Log("chooseroom=2=>" + chooseroom);
  33. if (sData!=null)
  34. {
  35. DataManager.Instance.GetTwoWsd(chooseroom, (data) => {
  36. Debug.Log("GetTwoWsd=2=>" + data);
  37. Toggle[] ts = togglelist.GetComponentsInChildren<Toggle>();
  38. for (int i = 0; i < ts.Length; i++)
  39. {
  40. if (ts[i].GetComponent<RoomToggleChoose>().id == chooseroom)
  41. {
  42. ts[i].isOn = true;
  43. break;
  44. }
  45. }
  46. sjds = data;
  47. updateRoomData();
  48. });
  49. }
  50. else
  51. {
  52. DataManager.Instance.GetWSD((data) => {
  53. sData = data;
  54. List<ServerjiguiData> jiguilist = new List<ServerjiguiData>();
  55. for (int i = 0; i < data.serverList.Count; i++)
  56. {
  57. togglelist.GetComponentsInChildren<Toggle>()[i].GetComponentInChildren<Text>().text = data.serverList[i].name;
  58. togglelist.GetComponentsInChildren<Toggle>()[i].GetComponent<RoomToggleChoose>().id = data.serverList[i].id;
  59. }
  60. Toggle[] ts = togglelist.GetComponentsInChildren<Toggle>();
  61. for (int i = 0; i < ts.Length; i++)
  62. {
  63. if (ts[i].GetComponent<RoomToggleChoose>().id == chooseroom)
  64. {
  65. ts[i].isOn = true;
  66. break;
  67. }
  68. }
  69. if (chooseroom!=0)
  70. {
  71. DataManager.Instance.GetTwoWsd(chooseroom, (data) => {
  72. Debug.Log("GetTwoWsd=2=>" + data);
  73. sjds = data;
  74. updateRoomData();
  75. });
  76. }
  77. // updateRoomData();
  78. });
  79. }
  80. }
  81. List<ServerjiguiData> sjds =new List<ServerjiguiData>();
  82. void updateRoomData()
  83. {
  84. for (int i = 0; i < items.Count; i++)
  85. {
  86. Destroy(items[i]);
  87. }
  88. for (int i = 0; i < sjds.Count; i++)
  89. {
  90. GameObject go = GameObject.Instantiate(item.gameObject, item.transform.parent);
  91. go.GetComponent<wsdItem>().initData(sjds[i]);
  92. go.SetActive(true);
  93. items.Add(go);
  94. }
  95. updatetu();
  96. }
  97. int chooseroom ;
  98. public void chooseToggle(int index)
  99. {
  100. chooseroom = index;
  101. updateData();
  102. }
  103. int jiguiindex = 0;
  104. public void chooseJiGuiToggle(int i)
  105. {
  106. jiguiindex = i;
  107. updatetu();
  108. }
  109. public void updatetu()
  110. {
  111. for (int i = 0; i < sjds.Count; i++)
  112. {
  113. if(sjds[i].id == jiguiindex)
  114. {
  115. jiguiname.text = sjds[i].name;
  116. break;
  117. }
  118. }
  119. DataManager.Instance.GetTwoWsdTb(chooseroom, jiguiindex, (data) => {
  120. for (int i = 0; i < data.Count; i++)
  121. {
  122. setLineData(lcs[i], data[i]);
  123. }
  124. });
  125. }
  126. private void OnDisable()
  127. {
  128. sData = null;
  129. }
  130. public IEnumerator show()
  131. {
  132. while (ServerRoomVideoManager.csid == 0)
  133. {
  134. yield return null;
  135. }
  136. chooseroom = ServerRoomManager.chooswsd;
  137. Debug.Log("chooseroom=1=>" + chooseroom);
  138. updateData();
  139. }
  140. private void OnEnable()
  141. {
  142. StartCoroutine(show());
  143. }
  144. }