ScenesManager.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. using SC.XR.Unity;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using UnityEngine;
  6. public class ScenesManager
  7. {
  8. public enum mType
  9. {
  10. LogoInt = 1,
  11. LoginInt = 2,
  12. ShowChoose = 3,
  13. ShowXunJian = 4,
  14. ShowRTC = 5,
  15. ShowDevice = 6,
  16. Navigationing = 8,
  17. officeInt = 30,
  18. RoomInt = 40,
  19. publicInt = 50,
  20. }
  21. public void showOffice(SceneType stype)
  22. {
  23. if(dlglist.ContainsKey(mType.officeInt.GetHashCode()))
  24. for (int i = 0; i < dlglist[mType.officeInt.GetHashCode()].Count; i++)
  25. {
  26. if (stype == dlglist[mType.officeInt.GetHashCode()][i]._sceneType)
  27. {
  28. dlglist[mType.officeInt.GetHashCode()][i].gameObject.SetActive(true);
  29. MonoBehaviour alist = dlglist[mType.officeInt.GetHashCode()][i].GetComponent<MonoBehaviour>();
  30. Type t = Type.GetType(alist.name);
  31. System.Reflection.MethodInfo md = t.GetMethod("initShow");
  32. if (md != null)
  33. {
  34. md.Invoke(alist, null);
  35. }
  36. }
  37. else
  38. {
  39. dlglist[mType.officeInt.GetHashCode()][i].gameObject.SetActive(false);
  40. }
  41. }
  42. }
  43. public enum SceneType
  44. {
  45. GameStartLogo = 10001,
  46. ShowLogin = 20001,
  47. ShowChoose = 30001,
  48. ShowXunJian = 40001,
  49. ShowXJ = 41001,
  50. ShowDH = 41002,
  51. ShowRTC = 50001,
  52. ShowRTCRoomMain = 51002,
  53. ShowRTCHistory = 51003,
  54. //ShowZhiDao = 50001,
  55. ShowDevice = 60001, // 设备基础信息
  56. ShowBasicDevice = 61001, // 设备基础详情
  57. DeviceDetails = 61002, // 设备详情
  58. Navigationing = 80001, // 导航中
  59. ShowOffice = 300001,
  60. CreateRoom = 300101,
  61. JoinRoom = 300102,
  62. UserSystem = 300103,
  63. RemoteSystem = 300104,
  64. OfficeWindow = 300105,
  65. ShowRoom = 400001,
  66. RoomMain = 400101,
  67. RoomOtherUser = 400102,
  68. RoomInfo = 400103,
  69. RoomFile = 400104,
  70. PopPublic = 500001,
  71. PopPeerView = 500101,
  72. PopUpInfo = 500101,
  73. PopCall = 500102,
  74. }
  75. private SceneType onlineSceneType;
  76. private static ScenesManager instance;
  77. public static ScenesManager Instance
  78. {
  79. get
  80. {
  81. if (instance == null)
  82. {
  83. instance = new ScenesManager();
  84. }
  85. return instance;
  86. }
  87. }
  88. public List<SceneInfo> windows = new List<SceneInfo>();
  89. public Dictionary<int, List<SceneInfo>> dlglist = new Dictionary<int, List<SceneInfo>>();
  90. public void initWindow(GameObject window)
  91. {
  92. SceneInfo sceneInfo = window.AddComponent<SceneInfo>();
  93. SceneType stp = (SceneType)System.Enum.Parse(typeof(SceneType), window.name.Split('(')[0]);
  94. sceneInfo.setType(stp);
  95. int codeint = stp.GetHashCode() / 10000;
  96. if (stp.GetHashCode() - (codeint * 10000) == 1)
  97. {
  98. windows.Add(sceneInfo);
  99. // window.SetActive(false);
  100. }
  101. else
  102. {
  103. if (dlglist.ContainsKey(codeint))
  104. {
  105. List<SceneInfo> dlg = dlglist[codeint];
  106. dlg.Add(sceneInfo);
  107. dlglist[codeint] = dlg;
  108. }
  109. else
  110. {
  111. List<SceneInfo> dlg = new List<SceneInfo>();
  112. dlg.Add(sceneInfo);
  113. dlglist.Add(codeint, dlg);
  114. }
  115. }
  116. }
  117. public void initRoom()
  118. {
  119. Debug.Log("HJJLANGCHAORTC " + mType.RoomInt.GetHashCode());
  120. for (int i = 0; i < dlglist[mType.RoomInt.GetHashCode()].Count; i++)
  121. {
  122. MonoBehaviour alist = dlglist[mType.RoomInt.GetHashCode()][i].GetComponent<MonoBehaviour>();
  123. Debug.Log("HJJLANGCHAORTC " + alist.name);
  124. Type t = Type.GetType(alist.name);
  125. System.Reflection.MethodInfo md = t.GetMethod("initShow");
  126. if (md != null)
  127. {
  128. md.Invoke(alist, null);
  129. }
  130. }
  131. }
  132. public void showWindow(SceneType sceneType)
  133. {
  134. for (int i = 0; i < windows.Count; i++)
  135. {
  136. int codeint = windows[i]._sceneType.GetHashCode() / 10000;
  137. if (windows[i]._sceneType == sceneType || codeint == mType.publicInt.GetHashCode())
  138. {
  139. windows[i].gameObject.SetActive(true);
  140. MonoBehaviour alist = windows[i].GetComponent<MonoBehaviour>();
  141. Type t = Type.GetType(alist.name);
  142. System.Reflection.MethodInfo md = t.GetMethod("initShow");
  143. if (md != null)
  144. {
  145. md.Invoke(alist, null);
  146. }
  147. onlineSceneType = sceneType;
  148. }
  149. else
  150. {
  151. windows[i].gameObject.SetActive(false);
  152. }
  153. }
  154. }
  155. public SceneType getWindow()
  156. {
  157. return onlineSceneType;
  158. }
  159. public void initPopUp()
  160. {
  161. // for (int i = 0; i < dlglist[mType.publicInt.GetHashCode()].Count; i++)
  162. // {
  163. // dlglist[mType.publicInt.GetHashCode()][i].gameObject.SetActive(false);
  164. // }
  165. }
  166. private PopPublic _popPublic;
  167. public PopPublic popPublic
  168. {
  169. get
  170. {
  171. if (!_popPublic)
  172. {
  173. for (int i = 0; i < dlglist[mType.publicInt.GetHashCode()].Count; i++)
  174. {
  175. PopPublic ppc = dlglist[mType.publicInt.GetHashCode()][i].GetComponent<PopPublic>();
  176. if (ppc)
  177. _popPublic = ppc;
  178. }
  179. }
  180. return _popPublic;
  181. }
  182. }
  183. public void showPop()
  184. {
  185. popPublic.gameObject.SetActive(true);
  186. }
  187. }