OfficeWindow.cs 3.2 KB

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