123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- using System;
- using LitJson;
- using rtc;
- using SC.XR.Unity;
- using UnityEngine;
- using static ScenesManager;
- public class OfficeWindow : RemoteSingleton<OfficeWindow>
- {
- 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);
- }
- }
|