ScenesManager.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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. officeInt = 3,
  13. RoomInt = 4,
  14. publicInt = 5,
  15. }
  16. public enum SceneType
  17. {
  18. GameStartLogo = 10001,
  19. ShowLogin = 20001,
  20. ShowOffice = 30001,
  21. CreateRoom = 30101,
  22. JoinRoom = 30102,
  23. UserSystem = 30103,
  24. RemoteSystem = 30104,
  25. OfficeWindow =30105,
  26. ShowRoom = 40001,
  27. RoomMain = 40101,
  28. RoomOtherUser = 40102,
  29. RoomInfo = 40103,
  30. RoomFile = 40104,
  31. PopPublic = 50001,
  32. PopPeerView = 50101,
  33. PopUpInfo = 50101,
  34. PopCall = 50102,
  35. }
  36. private static ScenesManager instance;
  37. public static ScenesManager Instance
  38. {
  39. get
  40. {
  41. if (instance == null)
  42. {
  43. instance = new ScenesManager();
  44. }
  45. return instance;
  46. }
  47. }
  48. public List<SceneInfo> windows = new List<SceneInfo>();
  49. public Dictionary<int, List<SceneInfo>> dlglist = new Dictionary<int, List<SceneInfo>>();
  50. public void initWindow(GameObject window)
  51. {
  52. SceneInfo sceneInfo = window.AddComponent<SceneInfo>();
  53. SceneType stp = (SceneType)System.Enum.Parse(typeof(SceneType), window.name.Split('(')[0]);
  54. sceneInfo.setType(stp);
  55. int codeint = stp.GetHashCode() / 10000 ;
  56. if(stp.GetHashCode()-(codeint*10000)==1)
  57. {
  58. windows.Add(sceneInfo);
  59. // window.SetActive(false);
  60. }
  61. else
  62. {
  63. if(dlglist.ContainsKey(codeint))
  64. {
  65. List<SceneInfo> dlg = dlglist[codeint];
  66. dlg.Add(sceneInfo);
  67. dlglist[codeint]=dlg;
  68. }
  69. else
  70. {
  71. List<SceneInfo> dlg = new List<SceneInfo>();
  72. dlg.Add(sceneInfo);
  73. dlglist.Add(codeint,dlg);
  74. }
  75. }
  76. }
  77. public void showWindow(SceneType sceneType)
  78. {
  79. for (int i = 0; i < windows.Count; i++)
  80. {
  81. int codeint = windows[i]._sceneType.GetHashCode() / 10000;
  82. if (windows[i]._sceneType==sceneType|| codeint== mType.publicInt.GetHashCode())
  83. {
  84. windows[i].gameObject.SetActive(true);
  85. MonoBehaviour alist= windows[i].GetComponent<MonoBehaviour>();
  86. Type t = Type.GetType(alist.name);
  87. System.Reflection.MethodInfo md = t.GetMethod("initShow");
  88. if (md != null)
  89. {
  90. md.Invoke(alist,null);
  91. }
  92. }
  93. else
  94. {
  95. windows[i].gameObject.SetActive(false);
  96. }
  97. }
  98. }
  99. public void initPopUp()
  100. {
  101. // for (int i = 0; i < dlglist[mType.publicInt.GetHashCode()].Count; i++)
  102. // {
  103. // dlglist[mType.publicInt.GetHashCode()][i].gameObject.SetActive(false);
  104. // }
  105. }
  106. private PopPublic _popPublic;
  107. public PopPublic popPublic
  108. {
  109. get {
  110. if(!_popPublic)
  111. {
  112. for (int i = 0; i < dlglist[mType.publicInt.GetHashCode()].Count; i++)
  113. {
  114. PopPublic ppc = dlglist[mType.publicInt.GetHashCode()][i].GetComponent<PopPublic>();
  115. if (ppc)
  116. _popPublic= ppc;
  117. }
  118. }
  119. return _popPublic;
  120. }
  121. }
  122. public void initRoom()
  123. {
  124. for (int i = 0; i < dlglist[mType.RoomInt.GetHashCode()].Count; i++)
  125. {
  126. MonoBehaviour alist = dlglist[mType.RoomInt.GetHashCode()][i].GetComponent<MonoBehaviour>();
  127. Type t = Type.GetType(alist.name);
  128. System.Reflection.MethodInfo md = t.GetMethod("initShow");
  129. if (md != null)
  130. {
  131. md.Invoke(alist, null);
  132. }
  133. }
  134. }
  135. public void showOffice(SceneType stype)
  136. {
  137. for (int i = 0; i < dlglist[mType.officeInt.GetHashCode()].Count; i++)
  138. {
  139. if(stype == dlglist[mType.officeInt.GetHashCode()][i]._sceneType)
  140. {
  141. dlglist[mType.officeInt.GetHashCode()][i].gameObject.SetActive(true);
  142. MonoBehaviour alist = dlglist[mType.officeInt.GetHashCode()][i].GetComponent<MonoBehaviour>();
  143. Type t = Type.GetType(alist.name);
  144. System.Reflection.MethodInfo md = t.GetMethod("initShow");
  145. if (md != null)
  146. {
  147. md.Invoke(alist, null);
  148. }
  149. }
  150. else
  151. {
  152. dlglist[mType.officeInt.GetHashCode()][i].gameObject.SetActive(false);
  153. }
  154. }
  155. }
  156. public void showPop()
  157. {
  158. popPublic.gameObject.SetActive(true);
  159. }
  160. }