using AdamThinkDevicesData; using Newtonsoft.Json; using PData; using System.Collections; using System.Collections.Generic; using UnityEngine; 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.Root thinkDevicesData = new AdamThinkDevicesData.Root(); // 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.getRoomsRequset += OnGetRooms; AdamSync.SyncCreateRoom.getroomusersRequset += OnGetRoomsUsers; AdamSync.SyncCreateRoom.send2roomRequset += OnGetRoomsInfo; } 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) detaIteml = 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++) { if (subjectInfo[i].Id == practiceID && subjectInfo[i].UserName == GlobalFlag.currentUser.real_name) { return subjectInfo[i].Role; } } return "0"; } public void OnGetRooms(string msg) { Debug.Log("OnGetRooms====" + msg); } public void OnGetRoomsUsers(string msg) { Debug.Log("OnGetRooms====" + msg); } public void OnGetRoomsInfo(string msg) { Debug.Log("OnGetRooms====" + msg); } // Update is called once per frame void Update() { if (Input.GetKeyDown("o")) { string info = "getrooms "; Debug.Log(info); _ = AdamSync.SyncCreateRoom.SendMessageAsync(info); } if (Input.GetKeyDown("g")) { string info = "getroomusers "; Debug.Log(info); _ = AdamSync.SyncCreateRoom.SendMessageAsync(info); } if (Input.GetKeyDown("i")) { string info = "send2room " + "进入房间"; Debug.Log(info); _ = AdamSync.SyncCreateRoom.SendMessageAsync(info); } } private void OnDisable() { Debug.Log("OnDisable"); AdamSync.SyncCreateRoom.getRoomsRequset -= OnGetRooms; AdamSync.SyncCreateRoom.getroomusersRequset -= OnGetRoomsUsers; AdamSync.SyncCreateRoom.send2roomRequset -= OnGetRoomsInfo; } private void OnDestory() { Debug.Log("OnDestory"); AdamSync.SyncCreateRoom.getRoomsRequset -= OnGetRooms; AdamSync.SyncCreateRoom.getroomusersRequset -= OnGetRoomsUsers; AdamSync.SyncCreateRoom.send2roomRequset -= OnGetRoomsInfo; } }