using AdamThinkDevicesData; using Newtonsoft.Json; using PData; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; public class UIBootstrap : MonoSingleton { public string url; public string sceneInfoUrl; public Editinformation editinformation = new Editinformation(); public SceneRoot currentSceneInfo = new SceneRoot(); public List subjectInfo = new List(); public List traininginformations = new List(); public AdamThinkDevicesData.DeviceData thinkDevicesData = new AdamThinkDevicesData.DeviceData(); // Start is called before the first frame update private async void Start() { editinformation = await AsyncWebReq.Post(url, null); for (int i = 0; i < editinformation.data.Count; i++) { Traininginformation t = new Traininginformation(); t = Jsonanalyze.FromJson(editinformation.data[i].VirtualPath); traininginformations.Add(t); } AdamSync.SyncCreateRoom.leaveRoomRequset += OnLeaveRoomInfo; AdamSync.SyncCreateRoom.send2worldRequset += OnGetWorldInfo; } public async void GetSceneData(string roomId) { string _url = sceneInfoUrl + roomId; //Debug.LogError(_url); currentSceneInfo = await AsyncWebReq.Get(_url); } public void GetSubjectInfo(List sdi) { subjectInfo = sdi; } public async void GetAllDeviceData() { thinkDevicesData = await AsyncWebReq.Post("http://111.229.30.246:48888/Handler/Thinkingfile.ashx?action=practicethinkdevice&Id=" + GlobalFlag.currentThinkId, null); } public AdamThinkDevicesData.DataItem GetDeviceByName(string deviceName) { AdamThinkDevicesData.DataItem detaIteml = null; for (int i = 0; i < thinkDevicesData.data.Count; i++) { if (thinkDevicesData.data[i].device_name == deviceName) return thinkDevicesData.data[i]; } return detaIteml; } public List GetListParaItemById(string deviceId) { for (int i = 0; i < thinkDevicesData.data.Count; i++) { if (thinkDevicesData.data[i].id == deviceId) return thinkDevicesData.data[i].list_para; } return null; } public string GetRoleByIDPracticeId(string practiceID) { for (int i = 0; i < subjectInfo.Count; i++) { int index = i; if (subjectInfo[index].Id == practiceID && subjectInfo[index].UserName == GlobalFlag.currentUser.real_name) { return subjectInfo[index].Role; } } return "0"; } public void OnGetWorldInfo(string msg) { Debug.Log("OnGetWorldInfo====" + msg); GameManager.Instance.RemovePlayer(ulong.Parse(msg)); } public void OnLeaveRoomInfo(string msg) { string[] data = msg.Split(','); Debug.Log(data[1]); _ = AdamSync.SyncCreateRoom.SendMessageAsync($"send2world {GlobalFlag.currentUser.user_id}"); SceneManager.LoadScene("SampleScene"); } private void OnDisable() { Debug.Log("OnDisable"); AdamSync.SyncCreateRoom.leaveRoomRequset -= OnLeaveRoomInfo; } private void OnDestory() { Debug.Log("OnDestory"); AdamSync.SyncCreateRoom.leaveRoomRequset -= OnLeaveRoomInfo; } }