108 lines
3.3 KiB
C#
108 lines
3.3 KiB
C#
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>();
|
|
|
|
// 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 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;
|
|
}
|
|
}
|