123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using XCharts.Runtime;
- using static Manager;
- public class DianLiJianKongManager : UpdateManager
- {
- public List<LineChart> lcs;
- public static DianLiJianKongManager Instance;
- public GameObject togglelist;
- public Text jiguiname;
- public wsdItem item;
- List<GameObject> items = new List<GameObject>();
- private void Awake()
- {
- Instance = this;
- }
- ServerData sData;
- public static bool isinit;
- public override void updateData()
- {
- base.updateData();
- if(chooseroom==0)
- {
- chooseroom = ServerRoomManager.chooswsd;
- }
- if (chooseroom == 0)
- {
- return;
- }
- Debug.Log("chooseroom=2=>" + chooseroom);
- if (sData!=null)
- {
- DataManager.Instance.GetTwoWsd(chooseroom, (data) => {
- Debug.Log("GetTwoWsd=2=>" + data);
- Toggle[] ts = togglelist.GetComponentsInChildren<Toggle>();
- for (int i = 0; i < ts.Length; i++)
- {
- if (ts[i].GetComponent<RoomToggleChoose>().id == chooseroom)
- {
- ts[i].isOn = true;
- break;
- }
- }
- sjds = data;
- updateRoomData();
- });
- }
- else
- {
- DataManager.Instance.GetWSD((data) => {
- sData = data;
- List<ServerjiguiData> jiguilist = new List<ServerjiguiData>();
- for (int i = 0; i < data.serverList.Count; i++)
- {
- togglelist.GetComponentsInChildren<Toggle>()[i].GetComponentInChildren<Text>().text = data.serverList[i].name;
- togglelist.GetComponentsInChildren<Toggle>()[i].GetComponent<RoomToggleChoose>().id = data.serverList[i].id;
- }
- Toggle[] ts = togglelist.GetComponentsInChildren<Toggle>();
- for (int i = 0; i < ts.Length; i++)
- {
- if (ts[i].GetComponent<RoomToggleChoose>().id == chooseroom)
- {
- ts[i].isOn = true;
- break;
- }
- }
- if (chooseroom!=0)
- {
- DataManager.Instance.GetTwoWsd(chooseroom, (data) => {
- Debug.Log("GetTwoWsd=2=>" + data);
- sjds = data;
- updateRoomData();
- });
- }
- // updateRoomData();
- });
- }
- }
- List<ServerjiguiData> sjds =new List<ServerjiguiData>();
- void updateRoomData()
- {
- for (int i = 0; i < items.Count; i++)
- {
- Destroy(items[i]);
- }
- for (int i = 0; i < sjds.Count; i++)
- {
- GameObject go = GameObject.Instantiate(item.gameObject, item.transform.parent);
- go.GetComponent<wsdItem>().initData(sjds[i],i);
- go.SetActive(true);
- items.Add(go);
- }
- Debug.Log("wsdItemchoose==>");
- updatetu();
- Invoke("chooseitem",1f);
- }
- void chooseitem()
- {
- Debug.Log("wsdItemchoose==>2");
- items[0].GetComponent<wsdItem>().chooseitem();
- }
- int chooseroom ;
- public void chooseToggle(int index)
- {
- chooseroom = index;
- updateData();
- }
- int jiguiindex = 0;
- public void chooseJiGuiToggle(int i)
- {
- jiguiindex = i;
- updatetu();
- }
- public void updatetu()
- {
- if(jiguiindex==0)
- {
- jiguiindex = sjds[0].id;
- jiguiname.text = sjds[0].name;
- }
- for (int i = 0; i < sjds.Count; i++)
- {
- if(sjds[i].id == jiguiindex)
- {
- jiguiname.text = sjds[i].name;
- break;
- }
- }
- DataManager.Instance.GetTwoWsdTb(ServerRoomManager.chooswsd, jiguiindex, (data) => {
- for (int i = 0; i < data.Count; i++)
- {
- if(data[i].sdata.Count>0)
- {
- for (int j =0;j<data[i].sdata.Count;j++)
- {
- if(data[i].sdata[j].values.Count>0)
- {
- Debug.Log(data[i].sdata[j].values[0]);
- lcs[i].gameObject.SetActive(true);
- break;
- }
- else
- {
- lcs[i].gameObject.SetActive(false);
- }
- }
- setLineData(lcs[i], data[i]);
- }
-
- }
- });
-
- }
- private void OnDisable()
- {
- sData = null;
- }
- public IEnumerator show()
- {
- while (ServerRoomVideoManager.csid == 0)
- {
- yield return null;
- }
- chooseroom = ServerRoomManager.chooswsd;
- Debug.Log("chooseroom=1=>" + chooseroom);
- updateData();
- }
- private void OnEnable()
- {
- for (int i = 0; i < lcs.Count; i++)
- {
- lcs[i].gameObject.SetActive(false);
- }
- StartCoroutine(show());
- }
- }
|