using System; using LitJson; using SC.XR.Unity; using UnityEngine; using static ScenesManager; public class OfficeWindow : RemoteSingleton { private bool isClick = false; public void showCreateRoom() { if (!UserInfo.isRemindTip) { ScenesManager.Instance.showOffice(SceneType.CreateRoom); } else { if (!isClick) { isClick = true; OnCreateRoom(); } } } private void OnEnable() { isClick = false; } private void OnDisable() { isClick = false; } public void OnCreateRoom() { WSHandler.Office.OnGetRoomIdReveived -= getRoomId; WSHandler.Office.OnGetRoomIdReveived += getRoomId; WSHandler.Office.GetRoomID(); } private void getRoomId(JsonData data) { //Debug.Log(""); //Debug.Log(JsonConvert.SerializeObject(data)); WSHandler.Office.ChangeUserType(UserInfo.BusyType); RoomMainInfo.CreateRoom(); RoomMainInfo.roomNum = data["data"]["roomId"].ToString(); WSHandler.roomRtcinit(RoomMainInfo.roomNum); WSHandler.Office.OnGetRoomIdReveived -= getRoomId; } public void OnJoinRoom(string roomId) { Debug.Log("RoomMainInfo.roomNum......" + RoomMainInfo.roomNum); RoomMainInfo.roomNum = roomId; WSHandler.Office.OnJoinRoomReveived -= joinRoom; WSHandler.Office.OnJoinRoomReveived += joinRoom; WSHandler.Office.JoinRoom(roomId); //AgoraVideoAudioManager.Instance.SetChinnelName(roomId); } private void joinRoom(JsonData data) { switch(data["data"]["code"].ToString()) { case "200": RoomMainInfo.CreateRoom(); //Debug.Log("RoomMainInfo.roomNum"+ RoomMainInfo.roomNum); WSHandler.roomRtcinit(RoomMainInfo.roomNum); WSHandler.Office.ChangeUserType(UserInfo.BusyType); break; case "1000": PopUpInfo.Instance.showPublic(PopUpInfo.PopType.Tip, "房间号无效"); SetClick(); break; case "1001": PopUpInfo.Instance.showPublic(PopUpInfo.PopType.PopOk, "房间人数已满","知道了",GameStart.actionok); SetClick(); break; case "1003": PopUpInfo.Instance.showPublic(PopUpInfo.PopType.Tip, "房间不存在"); SetClick(); break; default: PopUpInfo.Instance.showPublic(PopUpInfo.PopType.Tip, "房间不存在"); SetClick(); break; } WSHandler.Office.OnJoinRoomReveived -= joinRoom; } public void SetClick() { if (JoinRoom.Instance) { JoinRoom.Instance.isClick = false; } } public void showJoinRoom() { ScenesManager.Instance.showOffice(SceneType.JoinRoom); } public void showUserSystem() { ScenesManager.Instance.showOffice(SceneType.UserSystem); } public void showRemoteSystem() { ScenesManager.Instance.showOffice(SceneType.RemoteSystem); } }