123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using static Manager;
- public class ShiPingJianKongManager : UpdateManager
- {
- public static ShiPingJianKongManager Instance;
- // Start is called before the first frame update
- void Awake()
- {
- Instance = this;
- }
- int chooseroom = 0;
- public void chooseToggle(int index)
- {
- if(index!=0)
- {
- chooseroom = index;
- updateData();
- }
- }
- public IEnumerator show()
- {
- while(ServerRoomVideoManager.csid==0)
- {
- yield return null;
- }
- chooseroom = ServerRoomVideoManager.csid;
- Debug.Log("chooseroom=2=>" + chooseroom);
- updateData();
- }
- private void OnEnable()
- {
- StartCoroutine(show());
- }
- public GameObject togglelist;
- ServerData sData;
- public static bool isinit;
- public override void updateData()
- {
- base.updateData();
- Debug.Log("chooseroom=2=>" + chooseroom);
- if (chooseroom == 0)
- {
- return;
- }
- if (sData != null)
- {
- DataManager.Instance.GetVideo((data) => {
- List<ServerjiguiData> jiguilist = new List<ServerjiguiData>();
- for (int i = 0; i < data.serverList.Count; i++)
- {
- togglelist.GetComponentsInChildren<Toggle>()[i].GetComponentInChildren<Text>().text = sData.serverList[i].name;
- togglelist.GetComponentsInChildren<Toggle>()[i].GetComponent<RoomToggleChoose>().id = sData.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;
- }
- }
- updatejiankong();
- });
- }
- 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 = sData.serverList[i].name;
- togglelist.GetComponentsInChildren<Toggle>()[i].GetComponent<RoomToggleChoose>().id = sData.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)
- {
- updatejiankong();
- }
- // updateRoomData();
- });
- }
- }
- private void updatejiankong()
- {
- DataManager.Instance.GetVideo((data) => {
- for (int i = 0; i < allgame.Count; i++)
- {
- Destroy(allgame[i]);
- }
- allgame = new List<GameObject>();
- int jlct = 0;
- int jfct = 0;
- for (int i = 0; i < data.serverList.Count; i++)
- {
- if (data.serverList[i].id == chooseroom)
- {
- for (int j = 0; j < data.serverList[i].videolist.Count; j++)
- {
- for (int z = 0; z < data.serverList[i].videolist[j].url.Count; z++)
- {
- if (data.serverList[i].videolist[j].type == 1)
- {
- jlct++;
- GameObject jll = GameObject.Instantiate(jilongleft.gameObject, jilongleft.transform.parent);
- GameObject jlr = GameObject.Instantiate(jilongright.gameObject, jilongright.transform.parent);
- jll.GetComponent<VideoLefttem>().setdata(data.serverList[i].videolist[j].url[z], jlct);
- jlr.GetComponent<VideoRight>().setdata(data.serverList[i].videolist[j].url[z], jlct);
- jll.SetActive(true);
- jlr.SetActive(true);
- allgame.Add(jll);
- allgame.Add(jlr);
- }
- else
- {
- jfct++;
- GameObject jfl = GameObject.Instantiate(jifangleft.gameObject, jifangleft.transform.parent);
- GameObject jfr = GameObject.Instantiate(jifangright.gameObject, jifangright.transform.parent);
- jfl.GetComponent<VideoLefttem>().setdata(data.serverList[i].videolist[j].url[z], jfct);
- jfr.GetComponent<VideoRight>().setdata(data.serverList[i].videolist[j].url[z], jfct);
- jfl.SetActive(true);
- jfr.SetActive(true);
- allgame.Add(jfl);
- allgame.Add(jfr);
- }
- }
- }
- }
- }
- });
- }
- public GameObject jilongleft;
- public GameObject jilongright;
- public GameObject jifangleft;
- public GameObject jifangright;
- List<GameObject> allgame = new List<GameObject>();
- }
|