ScenesManager.cs 5.5 KB

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