DianLiJianKongManager.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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],i);
  92. go.SetActive(true);
  93. items.Add(go);
  94. }
  95. Debug.Log("wsdItemchoose==>");
  96. updatetu();
  97. Invoke("chooseitem",1f);
  98. }
  99. void chooseitem()
  100. {
  101. Debug.Log("wsdItemchoose==>2");
  102. items[0].GetComponent<wsdItem>().chooseitem();
  103. }
  104. int chooseroom ;
  105. public void chooseToggle(int index)
  106. {
  107. chooseroom = index;
  108. updateData();
  109. }
  110. int jiguiindex = 0;
  111. public void chooseJiGuiToggle(int i)
  112. {
  113. jiguiindex = i;
  114. updatetu();
  115. }
  116. public void updatetu()
  117. {
  118. if(jiguiindex==0)
  119. {
  120. jiguiindex = sjds[0].id;
  121. jiguiname.text = sjds[0].name;
  122. }
  123. for (int i = 0; i < sjds.Count; i++)
  124. {
  125. if(sjds[i].id == jiguiindex)
  126. {
  127. jiguiname.text = sjds[i].name;
  128. break;
  129. }
  130. }
  131. DataManager.Instance.GetTwoWsdTb(ServerRoomManager.chooswsd, jiguiindex, (data) => {
  132. for (int i = 0; i < data.Count; i++)
  133. {
  134. if(data[i].sdata.Count>0)
  135. {
  136. for (int j =0;j<data[i].sdata.Count;j++)
  137. {
  138. if(data[i].sdata[j].values.Count>0)
  139. {
  140. Debug.Log(data[i].sdata[j].values[0]);
  141. lcs[i].gameObject.SetActive(true);
  142. break;
  143. }
  144. else
  145. {
  146. lcs[i].gameObject.SetActive(false);
  147. }
  148. }
  149. setLineData(lcs[i], data[i]);
  150. }
  151. }
  152. });
  153. }
  154. private void OnDisable()
  155. {
  156. sData = null;
  157. }
  158. public IEnumerator show()
  159. {
  160. while (ServerRoomVideoManager.csid == 0)
  161. {
  162. yield return null;
  163. }
  164. chooseroom = ServerRoomManager.chooswsd;
  165. Debug.Log("chooseroom=1=>" + chooseroom);
  166. updateData();
  167. }
  168. private void OnEnable()
  169. {
  170. for (int i = 0; i < lcs.Count; i++)
  171. {
  172. lcs[i].gameObject.SetActive(false);
  173. }
  174. StartCoroutine(show());
  175. }
  176. }