OfficeWindow.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. using System;
  2. using LitJson;
  3. using SC.XR.Unity;
  4. using UnityEngine;
  5. using static ScenesManager;
  6. public class OfficeWindow : RemoteSingleton<OfficeWindow>
  7. {
  8. private bool isClick = false;
  9. public void showCreateRoom()
  10. {
  11. if (!UserInfo.isRemindTip)
  12. {
  13. ScenesManager.Instance.showOffice(SceneType.CreateRoom);
  14. }
  15. else
  16. {
  17. if (!isClick)
  18. {
  19. isClick = true;
  20. OnCreateRoom();
  21. }
  22. }
  23. }
  24. private void OnEnable()
  25. {
  26. isClick = false;
  27. }
  28. private void OnDisable()
  29. {
  30. isClick = false;
  31. }
  32. public void OnCreateRoom()
  33. {
  34. WSHandler.Office.OnGetRoomIdReveived -= getRoomId;
  35. WSHandler.Office.OnGetRoomIdReveived += getRoomId;
  36. WSHandler.Office.GetRoomID();
  37. }
  38. private void getRoomId(JsonData data)
  39. {
  40. //Debug.Log("");
  41. //Debug.Log(JsonConvert.SerializeObject(data));
  42. WSHandler.Office.ChangeUserType(UserInfo.BusyType);
  43. RoomMainInfo.CreateRoom();
  44. RoomMainInfo.roomNum = data["data"]["roomId"].ToString();
  45. WSHandler.roomRtcinit(RoomMainInfo.roomNum);
  46. WSHandler.Office.OnGetRoomIdReveived -= getRoomId;
  47. }
  48. public void OnJoinRoom(string roomId)
  49. {
  50. Debug.Log("RoomMainInfo.roomNum......" + RoomMainInfo.roomNum);
  51. RoomMainInfo.roomNum = roomId;
  52. WSHandler.Office.OnJoinRoomReveived -= joinRoom;
  53. WSHandler.Office.OnJoinRoomReveived += joinRoom;
  54. WSHandler.Office.JoinRoom(roomId);
  55. //AgoraVideoAudioManager.Instance.SetChinnelName(roomId);
  56. }
  57. private void joinRoom(JsonData data)
  58. {
  59. switch(data["data"]["code"].ToString())
  60. {
  61. case "200":
  62. RoomMainInfo.CreateRoom();
  63. //Debug.Log("RoomMainInfo.roomNum"+ RoomMainInfo.roomNum);
  64. WSHandler.roomRtcinit(RoomMainInfo.roomNum);
  65. WSHandler.Office.ChangeUserType(UserInfo.BusyType);
  66. break;
  67. case "1000":
  68. PopUpInfo.Instance.showPublic(PopUpInfo.PopType.Tip, "房间号无效");
  69. SetClick();
  70. break;
  71. case "1001":
  72. PopUpInfo.Instance.showPublic(PopUpInfo.PopType.PopOk, "房间人数已满","知道了",GameStart.actionok);
  73. SetClick();
  74. break;
  75. case "1003":
  76. PopUpInfo.Instance.showPublic(PopUpInfo.PopType.Tip, "房间不存在");
  77. SetClick();
  78. break;
  79. default:
  80. PopUpInfo.Instance.showPublic(PopUpInfo.PopType.Tip, "房间不存在");
  81. SetClick();
  82. break;
  83. }
  84. WSHandler.Office.OnJoinRoomReveived -= joinRoom;
  85. }
  86. public void SetClick()
  87. {
  88. if (JoinRoom.Instance)
  89. {
  90. JoinRoom.Instance.isClick = false;
  91. }
  92. }
  93. public void showJoinRoom()
  94. {
  95. ScenesManager.Instance.showOffice(SceneType.JoinRoom);
  96. }
  97. public void showUserSystem()
  98. {
  99. ScenesManager.Instance.showOffice(SceneType.UserSystem);
  100. }
  101. public void showRemoteSystem()
  102. {
  103. ScenesManager.Instance.showOffice(SceneType.RemoteSystem);
  104. }
  105. }