ScenesManager.cs 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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. ShowZhidao = 70001,
  60. ShowOffice = 300001,
  61. CreateRoom = 300101,
  62. JoinRoom = 300102,
  63. UserSystem = 300103,
  64. RemoteSystem = 300104,
  65. OfficeWindow = 300105,
  66. ShowRoom = 400001,
  67. RoomMain = 400101,
  68. RoomOtherUser = 400102,
  69. RoomInfo = 400103,
  70. RoomFile = 400104,
  71. PopPublic = 500001,
  72. PopPeerView = 500101,
  73. PopUpInfo = 500101,
  74. PopCall = 500102,
  75. }
  76. private SceneType onlineSceneType;
  77. private static ScenesManager instance;
  78. public static ScenesManager Instance
  79. {
  80. get
  81. {
  82. if (instance == null)
  83. {
  84. instance = new ScenesManager();
  85. }
  86. return instance;
  87. }
  88. }
  89. public List<SceneInfo> windows = new List<SceneInfo>();
  90. public Dictionary<int, List<SceneInfo>> dlglist = new Dictionary<int, List<SceneInfo>>();
  91. public void initWindow(GameObject window)
  92. {
  93. SceneInfo sceneInfo = window.AddComponent<SceneInfo>();
  94. SceneType stp = (SceneType)System.Enum.Parse(typeof(SceneType), window.name.Split('(')[0]);
  95. sceneInfo.setType(stp);
  96. int codeint = stp.GetHashCode() / 10000;
  97. if (stp.GetHashCode() - (codeint * 10000) == 1)
  98. {
  99. windows.Add(sceneInfo);
  100. // window.SetActive(false);
  101. }
  102. else
  103. {
  104. if (dlglist.ContainsKey(codeint))
  105. {
  106. List<SceneInfo> dlg = dlglist[codeint];
  107. dlg.Add(sceneInfo);
  108. dlglist[codeint] = dlg;
  109. }
  110. else
  111. {
  112. List<SceneInfo> dlg = new List<SceneInfo>();
  113. dlg.Add(sceneInfo);
  114. dlglist.Add(codeint, dlg);
  115. }
  116. }
  117. }
  118. public void initRoom()
  119. {
  120. Debug.Log("HJJLANGCHAORTC " + mType.RoomInt.GetHashCode());
  121. for (int i = 0; i < dlglist[mType.RoomInt.GetHashCode()].Count; i++)
  122. {
  123. MonoBehaviour alist = dlglist[mType.RoomInt.GetHashCode()][i].GetComponent<MonoBehaviour>();
  124. Debug.Log("HJJLANGCHAORTC " + alist.name);
  125. Type t = Type.GetType(alist.name);
  126. System.Reflection.MethodInfo md = t.GetMethod("initShow");
  127. if (md != null)
  128. {
  129. md.Invoke(alist, null);
  130. }
  131. }
  132. }
  133. public void showWindow(SceneType sceneType)
  134. {
  135. switch (sceneType)
  136. {
  137. case SceneType.GameStartLogo:
  138. break;
  139. case SceneType.ShowLogin:
  140. break;
  141. case SceneType.ShowChoose:
  142. XRRGBCamera.Instance.playCamera(1280, 720);
  143. break;
  144. case SceneType.ShowXunJian:
  145. XRRGBCamera.Instance.playCamera(1280, 720);
  146. break;
  147. case SceneType.ShowXJ:
  148. break;
  149. case SceneType.ShowDH:
  150. XRRGBCamera.Instance.playCamera(1280, 720);
  151. break;
  152. case SceneType.ShowRTC:
  153. XRRGBCamera.Instance.playCamera(1280, 720);
  154. break;
  155. case SceneType.ShowRTCRoomMain:
  156. break;
  157. case SceneType.ShowRTCHistory:
  158. break;
  159. case SceneType.ShowDevice:
  160. break;
  161. case SceneType.ShowBasicDevice:
  162. break;
  163. case SceneType.DeviceDetails:
  164. break;
  165. case SceneType.Navigationing:
  166. break;
  167. case SceneType.ShowOffice:
  168. break;
  169. case SceneType.CreateRoom:
  170. break;
  171. case SceneType.JoinRoom:
  172. break;
  173. case SceneType.UserSystem:
  174. break;
  175. case SceneType.RemoteSystem:
  176. break;
  177. case SceneType.OfficeWindow:
  178. break;
  179. case SceneType.ShowRoom:
  180. break;
  181. case SceneType.RoomMain:
  182. break;
  183. case SceneType.RoomOtherUser:
  184. break;
  185. case SceneType.RoomInfo:
  186. break;
  187. case SceneType.RoomFile:
  188. break;
  189. case SceneType.PopPublic:
  190. break;
  191. case SceneType.PopPeerView:
  192. break;
  193. case SceneType.PopCall:
  194. break;
  195. default:
  196. break;
  197. }
  198. for (int i = 0; i < windows.Count; i++)
  199. {
  200. int codeint = windows[i]._sceneType.GetHashCode() / 10000;
  201. if (windows[i]._sceneType == sceneType || codeint == mType.publicInt.GetHashCode())
  202. {
  203. windows[i].gameObject.SetActive(true);
  204. MonoBehaviour alist = windows[i].GetComponent<MonoBehaviour>();
  205. Type t = Type.GetType(alist.name);
  206. System.Reflection.MethodInfo md = t.GetMethod("initShow");
  207. if (md != null)
  208. {
  209. md.Invoke(alist, null);
  210. }
  211. onlineSceneType = sceneType;
  212. }
  213. else
  214. {
  215. windows[i].gameObject.SetActive(false);
  216. }
  217. }
  218. }
  219. public SceneType getWindow()
  220. {
  221. return onlineSceneType;
  222. }
  223. public void initPopUp()
  224. {
  225. // for (int i = 0; i < dlglist[mType.publicInt.GetHashCode()].Count; i++)
  226. // {
  227. // dlglist[mType.publicInt.GetHashCode()][i].gameObject.SetActive(false);
  228. // }
  229. }
  230. private PopPublic _popPublic;
  231. public PopPublic popPublic
  232. {
  233. get
  234. {
  235. if (!_popPublic)
  236. {
  237. for (int i = 0; i < dlglist[mType.publicInt.GetHashCode()].Count; i++)
  238. {
  239. PopPublic ppc = dlglist[mType.publicInt.GetHashCode()][i].GetComponent<PopPublic>();
  240. if (ppc)
  241. _popPublic = ppc;
  242. }
  243. }
  244. return _popPublic;
  245. }
  246. }
  247. public void showPop()
  248. {
  249. popPublic.gameObject.SetActive(true);
  250. }
  251. }