ShowRoom.cs 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. using System;
  2. using System.Collections.Generic;
  3. using LitJson;
  4. using SC.XR.Unity;
  5. using UnityEngine;
  6. using static ScenesManager;
  7. public class ShowRoom : RemoteSingleton<ShowRoom>
  8. {
  9. public List<FileConfig> fileConfiglist = new List<FileConfig>();
  10. public SCButton showMainScreenBtn;
  11. public override void Awake()
  12. {
  13. base.Awake();
  14. GameObject showMainScreenBtnObj = Resources.Load("ZhankaiBtn") as GameObject;
  15. showMainScreenBtnObj = Instantiate(showMainScreenBtnObj, this.transform);
  16. if (showMainScreenBtnObj)
  17. {
  18. showMainScreenBtn = showMainScreenBtnObj.transform.GetComponent<SCButton>();
  19. }
  20. }
  21. private void Start()
  22. {
  23. WSHandler.Office.OnRefuse += Refuse;
  24. WSHandler.Office.OnTimeout += TimeoutRefuse;
  25. if (showMainScreenBtn)
  26. {
  27. showMainScreenBtn.onClick.AddListener(ShowMainScreen);
  28. }
  29. }
  30. private void Refuse(JsonData data)
  31. {
  32. string peerId = data["data"]["peerId"].ToString();
  33. string nickName = data["data"]["nickName"].ToString();
  34. PopUpInfo.Instance.showPublic(PopUpInfo.PopType.Tip, nickName+"拒绝了你的邀请");
  35. if (!string.IsNullOrEmpty(peerId) && InviteDlg.Instance)
  36. {
  37. for (int i = InviteDlg.Instance.InvitingUnionIdList.Count - 1; i >= 0; i--)
  38. {
  39. if (peerId == InviteDlg.Instance.InvitingUnionIdList[i].UnionId)
  40. {
  41. InviteDlg.Instance.InvitingUnionIdList.Remove(InviteDlg.Instance.InvitingUnionIdList[i]);
  42. }
  43. }
  44. }
  45. RoomOtherUser.Instance.UpdateList();
  46. }
  47. private void TimeoutRefuse(JsonData data)
  48. {
  49. string peerId = data["data"]["peerId"].ToString();
  50. string nickName = data["data"]["nickName"].ToString();
  51. PopUpInfo.Instance.showPublic(PopUpInfo.PopType.Tip, nickName + "无应答");
  52. if (!string.IsNullOrEmpty(peerId) && InviteDlg.Instance)
  53. {
  54. for (int i = InviteDlg.Instance.InvitingUnionIdList.Count - 1; i >= 0; i--)
  55. {
  56. if (peerId == InviteDlg.Instance.InvitingUnionIdList[i].UnionId)
  57. {
  58. InviteDlg.Instance.InvitingUnionIdList.Remove(InviteDlg.Instance.InvitingUnionIdList[i]);
  59. }
  60. }
  61. }
  62. RoomOtherUser.Instance.UpdateList();
  63. }
  64. public void ShowMainScreen()
  65. {
  66. if (RoomInfo.Instance)
  67. {
  68. RoomInfo.Instance.gameObject.SetActive(true);
  69. }
  70. if (RoomMain.Instance)
  71. {
  72. RoomMain.Instance.gameObject.SetActive(true);
  73. }
  74. if (RoomOtherUser.Instance)
  75. {
  76. RoomOtherUser.Instance.gameObject.SetActive(true);
  77. }
  78. if (RoomFile.Instance)
  79. {
  80. RoomFile.Instance.gameObject.SetActive(true);
  81. }
  82. showMainScreenBtn.gameObject.SetActive(false);
  83. }
  84. public void HideMainScreen()
  85. {
  86. if (RoomInfo.Instance)
  87. {
  88. RoomInfo.Instance.gameObject.SetActive(false);
  89. }
  90. if (RoomMain.Instance)
  91. {
  92. RoomMain.Instance.gameObject.SetActive(false);
  93. }
  94. if (RoomOtherUser.Instance)
  95. {
  96. RoomOtherUser.Instance.gameObject.SetActive(false);
  97. }
  98. if (RoomFile.Instance)
  99. {
  100. RoomFile.Instance.gameObject.SetActive(false);
  101. }
  102. showMainScreenBtn.gameObject.SetActive(true);
  103. }
  104. public void ExitRoom()
  105. {
  106. if (PopPeerView.Instance && PopPublic.Instance && PopPeerView.Instance.list.parent != PopPublic.Instance.transform)
  107. {
  108. PopPeerView.Instance.list.position = new Vector3(0, 0, 0);
  109. PopPeerView.Instance.list.eulerAngles = new Vector3(0, 0, 0);
  110. PopPeerView.Instance.list.SetParent(PopPublic.Instance.transform);
  111. }
  112. if (PopUpInfo.Instance && PopPublic.Instance && PopUpInfo.Instance.transform.parent != PopPublic.Instance.transform)
  113. {
  114. PopUpInfo.Instance.transform.position = new Vector3(0, 0, 0);
  115. PopUpInfo.Instance.transform.eulerAngles = new Vector3(0, 0, 0);
  116. PopUpInfo.Instance.transform.SetParent(PopPublic.Instance.transform);
  117. }
  118. API_GSXR_Slam.GSXR_Reset_Slam();
  119. if (InviteDlg.Instance && InviteDlg.Instance.InvitingUnionIdList != null)
  120. {
  121. if (InviteDlg.Instance.InvitingUnionIdList.Count > 0)
  122. {
  123. InviteDlg.Instance.InvitingUnionIdList.Clear();
  124. }
  125. }
  126. if (RoomFile.Instance)
  127. {
  128. RoomFile.Instance.ClearAllFileItem();
  129. }
  130. if (ArrowList.Instance)
  131. {
  132. ArrowList.Instance.DeleteAll();
  133. }
  134. if (PrintscreenList.Instance)
  135. {
  136. PrintscreenList.Instance.DeleteAll();
  137. }
  138. if (PopPeerView.Instance)
  139. {
  140. PopPeerView.Instance.DestoryAll();
  141. }
  142. ShowMainScreen();
  143. if (PopCall.Instance)
  144. {
  145. PopCall.Instance.gameObject.SetActive(false);
  146. }
  147. transform.position = new Vector3(0, 0, 0);
  148. transform.eulerAngles = new Vector3(0, 0, 0);
  149. if (GameStart.Instance && GameStart.Instance.systemMenu)
  150. {
  151. GameStart.Instance.systemMenu.ResetPattern();
  152. }
  153. }
  154. public void NetErrorExitRoom()
  155. {
  156. if (InviteDlg.Instance && InviteDlg.Instance.InvitingUnionIdList != null)
  157. {
  158. if (InviteDlg.Instance.InvitingUnionIdList.Count > 0)
  159. {
  160. InviteDlg.Instance.InvitingUnionIdList.Clear();
  161. }
  162. }
  163. if (RoomFile.Instance)
  164. {
  165. RoomFile.Instance.ClearAllFileItem();
  166. }
  167. if (ArrowList.Instance)
  168. {
  169. ArrowList.Instance.DeleteAll();
  170. }
  171. if (PrintscreenList.Instance)
  172. {
  173. PrintscreenList.Instance.DeleteAll();
  174. }
  175. if (PopPeerView.Instance)
  176. {
  177. PopPeerView.Instance.DestoryAll();
  178. }
  179. ShowMainScreen();
  180. if (PopCall.Instance)
  181. {
  182. PopCall.Instance.gameObject.SetActive(false);
  183. }
  184. if (GameStart.Instance && GameStart.Instance.systemMenu)
  185. {
  186. GameStart.Instance.systemMenu.ResetPattern();
  187. }
  188. }
  189. private void OnDestroy()
  190. {
  191. WSHandler.Office.OnRefuse -= Refuse;
  192. WSHandler.Office.OnTimeout -= TimeoutRefuse;
  193. }
  194. public override void initShow()
  195. {
  196. base.initShow();
  197. ScenesManager.Instance.initRoom();
  198. RoomOtherUser.Instance.UpdateList();
  199. window[4].SetActive(false);
  200. if (GameStart.Instance && GameStart.Instance.systemMenu)
  201. {
  202. GameStart.Instance.systemMenu.Init();
  203. }
  204. }
  205. public void Reset()
  206. {
  207. RoomFile.SetIsOnFalse?.Invoke();
  208. if (ArrowList.Instance)
  209. {
  210. ArrowList.Instance.DeleteAll();
  211. }
  212. if (PrintscreenList.Instance)
  213. {
  214. PrintscreenList.Instance.DeleteAll();
  215. }
  216. //transform.position = new Vector3(-0.2f, 0, 0);
  217. //transform.eulerAngles = new Vector3(0, -30, 0);
  218. transform.position = new Vector3(0, 0, 0);
  219. transform.eulerAngles = new Vector3(0, 0, 0);
  220. ShowMainScreen();
  221. PopPeerView.CloseView?.Invoke();
  222. if (RoomFile.Instance)
  223. {
  224. RoomFile.Instance.ClearAllFilePrefab();
  225. RoomFile.Instance.ResetToggleValue();
  226. }
  227. if (RoomInfo.Instance)
  228. {
  229. RoomInfo.Instance.ResetChatText();
  230. }
  231. }
  232. }