OfficeWindow.cs 4.1 KB

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