OfficeWindow.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. using System;
  2. using LitJson;
  3. using Newtonsoft.Json;
  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 Start()
  26. {
  27. SettingSystem();
  28. }
  29. private void OnEnable()
  30. {
  31. isClick = false;
  32. }
  33. private void OnDisable()
  34. {
  35. isClick = false;
  36. }
  37. public void OnCreateRoom()
  38. {
  39. WSHandler.Office.OnGetRoomIdReveived -= getRoomId;
  40. WSHandler.Office.OnGetRoomIdReveived += getRoomId;
  41. WSHandler.Office.GetRoomID();
  42. }
  43. private void getRoomId(JsonData data)
  44. {
  45. //Debug.Log("");
  46. //Debug.Log(JsonConvert.SerializeObject(data));
  47. WSHandler.Office.ChangeUserType(UserInfo.BusyType);
  48. RoomMainInfo.CreateRoom();
  49. RoomMainInfo.roomNum = data["data"]["roomId"].ToString();
  50. WSHandler.roomRtcinit(RoomMainInfo.roomNum);
  51. WSHandler.Office.OnGetRoomIdReveived -= getRoomId;
  52. }
  53. public void OnJoinRoom(string roomId)
  54. {
  55. Debug.Log("RoomMainInfo.roomNum......" + RoomMainInfo.roomNum);
  56. RoomMainInfo.roomNum = roomId;
  57. WSHandler.Office.OnJoinRoomReveived -= joinRoom;
  58. WSHandler.Office.OnJoinRoomReveived += joinRoom;
  59. WSHandler.Office.JoinRoom(roomId);
  60. }
  61. private void joinRoom(JsonData data)
  62. {
  63. switch(data["data"]["code"].ToString())
  64. {
  65. case "200":
  66. RoomMainInfo.CreateRoom();
  67. //Debug.Log("RoomMainInfo.roomNum"+ RoomMainInfo.roomNum);
  68. WSHandler.roomRtcinit(RoomMainInfo.roomNum);
  69. WSHandler.Office.ChangeUserType(UserInfo.BusyType);
  70. break;
  71. case "1000":
  72. PopUpInfo.Instance.showPublic(PopUpInfo.PopType.Tip, "房间号无效");
  73. SetClick();
  74. break;
  75. case "1001":
  76. PopUpInfo.Instance.showPublic(PopUpInfo.PopType.PopOk, "房间人数已满","知道了",GameStart.actionok);
  77. SetClick();
  78. break;
  79. case "1003":
  80. PopUpInfo.Instance.showPublic(PopUpInfo.PopType.Tip, "房间不存在");
  81. SetClick();
  82. break;
  83. default:
  84. PopUpInfo.Instance.showPublic(PopUpInfo.PopType.Tip, "房间不存在");
  85. SetClick();
  86. break;
  87. }
  88. WSHandler.Office.OnJoinRoomReveived -= joinRoom;
  89. }
  90. public void SetClick()
  91. {
  92. if (JoinRoom.Instance)
  93. {
  94. JoinRoom.Instance.isClick = false;
  95. }
  96. }
  97. public void showJoinRoom()
  98. {
  99. ScenesManager.Instance.showOffice(SceneType.JoinRoom);
  100. }
  101. public void showUserSystem()
  102. {
  103. ScenesManager.Instance.showOffice(SceneType.UserSystem);
  104. }
  105. public void showRemoteSystem()
  106. {
  107. ScenesManager.Instance.showOffice(SceneType.RemoteSystem);
  108. }
  109. public void SettingSystem()
  110. {
  111. if (PlayerPrefs.HasKey(UserInfo.Account + "_SystemSetting"))
  112. {
  113. string SystemData = PlayerPrefs.GetString(UserInfo.Account + "_SystemSetting");
  114. SystemDatas data = JsonConvert.DeserializeObject<SystemDatas>(SystemData);
  115. CustomInfo.isSendVideo = data.Camera == 1 ? true : false;
  116. CustomInfo.isSendAudio = data.Mic == 1 ? true : false;
  117. UserInfo.systemDatas = data;
  118. }
  119. else
  120. {
  121. CustomInfo.isSendVideo = true;
  122. CustomInfo.isSendAudio = true;
  123. }
  124. }
  125. }