133 lines
4.3 KiB
C#
133 lines
4.3 KiB
C#
using AdamThinkDevicesData;
|
|
using Newtonsoft.Json;
|
|
using PData;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class UIBootstrap : MonoSingleton<UIBootstrap>
|
|
{
|
|
public string url;
|
|
public string sceneInfoUrl;
|
|
public Editinformation editinformation = new Editinformation();
|
|
public SceneRoot currentSceneInfo = new SceneRoot();
|
|
public List<RSData.SubjectDataItem> subjectInfo = new List<RSData.SubjectDataItem>();
|
|
public List<Traininginformation> traininginformations = new List<Traininginformation>();
|
|
public AdamThinkDevicesData.Root thinkDevicesData = new AdamThinkDevicesData.Root();
|
|
// Start is called before the first frame update
|
|
private async void Start()
|
|
{
|
|
editinformation = await AsyncWebReq.Post<Editinformation>(url, null);
|
|
for (int i = 0; i < editinformation.data.Count; i++)
|
|
{
|
|
Traininginformation t = new Traininginformation();
|
|
t = Jsonanalyze.FromJson<Traininginformation>(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<SceneRoot>(_url);
|
|
|
|
}
|
|
public void GetSubjectInfo(List<RSData.SubjectDataItem> sdi)
|
|
{
|
|
subjectInfo = sdi;
|
|
}
|
|
|
|
public async void GetAllDeviceData()
|
|
{
|
|
thinkDevicesData = await AsyncWebReq.Post<AdamThinkDevicesData.Root>("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<List_paraItem> 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;
|
|
}
|
|
}
|