QDManager.cs 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. using ET;
  2. using GFGGame.Launcher;
  3. using UnityEngine;
  4. namespace GFGGame
  5. {
  6. public class QDManager
  7. {
  8. public bool isLogining;
  9. public string uid;
  10. public static void Init()
  11. {
  12. switch (LauncherConfig.ChannelId)
  13. {
  14. case (int)ChannelID.Test:
  15. QDShareManager.Instance.Init();
  16. break;
  17. case (int)ChannelID.DouYou:
  18. QDDouYouManager.Instance.Init();
  19. QDShareManager.Instance.Init();
  20. break;
  21. case (int)ChannelID.DouYouDev:
  22. QDDouYouManager.Instance.Init();
  23. QDShareManager.Instance.Init();
  24. break;
  25. case (int)ChannelID.AppStore:
  26. #if !UNITY_EDITOR && UNITY_IOS
  27. QDAppStoreManager.Init();
  28. #endif
  29. break;
  30. default:
  31. break;
  32. }
  33. }
  34. public static void Login()
  35. {
  36. ViewManager.Show<ModalStatusView>("登录中...");
  37. switch (LauncherConfig.ChannelId)
  38. {
  39. case (int)ChannelID.Test:
  40. bool login = GameController.CheckLoginCache(true);
  41. if (!login)
  42. {
  43. ViewManager.Hide<ModalStatusView>();
  44. ViewManager.Show<LoginInputView>();
  45. }
  46. break;
  47. case (int)ChannelID.DouYou:
  48. QDDouYouManager.Instance.Login();
  49. break;
  50. case (int)ChannelID.DouYouDev:
  51. QDDouYouManager.Instance.Login();
  52. break;
  53. case (int)ChannelID.AppStore:
  54. //TODO 接douyou ios的sdk登录
  55. break;
  56. default:
  57. break;
  58. }
  59. }
  60. public static void OnCreateRole()
  61. {
  62. switch (LauncherConfig.ChannelId)
  63. {
  64. case (int)ChannelID.Test:
  65. break;
  66. case (int)ChannelID.DouYou:
  67. QDDouYouManager.Instance.OnCreateRole();
  68. break;
  69. case (int)ChannelID.DouYouDev:
  70. QDDouYouManager.Instance.OnCreateRole();
  71. break;
  72. default:
  73. break;
  74. }
  75. }
  76. public static void OnEnterGame()
  77. {
  78. switch (LauncherConfig.ChannelId)
  79. {
  80. case (int)ChannelID.Test:
  81. break;
  82. case (int)ChannelID.DouYou:
  83. QDDouYouManager.Instance.OnEnterGame();
  84. break;
  85. case (int)ChannelID.DouYouDev:
  86. QDDouYouManager.Instance.OnEnterGame();
  87. break;
  88. case (int)ChannelID.AppStore:
  89. //TODO 接入douYou sdk
  90. break;
  91. default:
  92. break;
  93. }
  94. }
  95. //回到登录界面,不退出账号
  96. public static void OnQuitToLoginView()
  97. {
  98. switch (LauncherConfig.ChannelId)
  99. {
  100. case (int)ChannelID.Test:
  101. break;
  102. case (int)ChannelID.DouYou:
  103. QDDouYouManager.Instance.OnQuitToLoginView();
  104. break;
  105. case (int)ChannelID.DouYouDev:
  106. QDDouYouManager.Instance.OnQuitToLoginView();
  107. break;
  108. case (int)ChannelID.AppStore:
  109. //TODO 接入douYou sdk
  110. break;
  111. default:
  112. break;
  113. }
  114. }
  115. public static void Pay(int buyID, int count, string orderID, long price)
  116. {
  117. switch (LauncherConfig.ChannelId)
  118. {
  119. case (int)ChannelID.Test:
  120. break;
  121. case (int)ChannelID.DouYou:
  122. QDDouYouManager.Instance.Pay(buyID, count, orderID, price);
  123. break;
  124. case (int)ChannelID.DouYouDev:
  125. QDDouYouManager.Instance.Pay(buyID, count, orderID, price);
  126. break;
  127. case (int)ChannelID.AppStore:
  128. //TODO 接入douYou sdk
  129. break;
  130. default:
  131. break;
  132. }
  133. }
  134. public static void Logout()
  135. {
  136. GameGlobal.zoneScene.GetComponent<SessionComponent>()?.Disconnect();
  137. GameGlobal.zoneScene.GetComponent<ServerInfosComponent>()?.ServerInfoList?.Clear();
  138. GameGlobal.zoneScene.GetComponent<AccountInfoComponent>()?.Clear();
  139. if (PlayerPrefs.HasKey(GameConst.PASSWORD_LAST_LOGIN_KEY))
  140. {
  141. PlayerPrefs.DeleteKey(GameConst.PASSWORD_LAST_LOGIN_KEY);
  142. }
  143. switch (LauncherConfig.ChannelId)
  144. {
  145. case (int)ChannelID.Test:
  146. break;
  147. case (int)ChannelID.DouYou:
  148. QDDouYouManager.Instance.Logout();
  149. break;
  150. case (int)ChannelID.DouYouDev:
  151. QDDouYouManager.Instance.Logout();
  152. break;
  153. case (int)ChannelID.AppStore:
  154. //TODO 接入douYou sdk
  155. break;
  156. default:
  157. break;
  158. }
  159. }
  160. public static void Exit()
  161. {
  162. switch (LauncherConfig.ChannelId)
  163. {
  164. case (int)ChannelID.Test:
  165. GameController.ShowExitAlert();
  166. break;
  167. case (int)ChannelID.DouYou:
  168. QDDouYouManager.Instance.Exit();
  169. break;
  170. case (int)ChannelID.DouYouDev:
  171. QDDouYouManager.Instance.Exit();
  172. break;
  173. case (int)ChannelID.AppStore:
  174. //TODO 接入douYou sdk
  175. break;
  176. default:
  177. break;
  178. }
  179. }
  180. //上报角色行为给sdk
  181. public static void PushRoleAction(DouYouRoleLogReportType reportType)
  182. {
  183. switch (LauncherConfig.ChannelId)
  184. {
  185. case (int)ChannelID.Test:
  186. break;
  187. case (int)ChannelID.DouYou:
  188. //改名上报给sdk
  189. var zoneScene = GameGlobal.zoneScene;
  190. if (zoneScene == null) return;
  191. if (zoneScene.GetComponent<RoleInfosComponent>() == null ||
  192. zoneScene.GetComponent<RoleInfosComponent>().IsDisposed) return;
  193. var roleInfo = zoneScene.GetComponent<RoleInfosComponent>().GetCurrentRole();
  194. if (roleInfo == null) return;
  195. if (GameGlobal.myNumericComponent == null) return;
  196. int lvl = GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl);
  197. if (zoneScene.GetComponent<ServerInfosComponent>() == null) return;
  198. if (zoneScene.GetComponent<ServerInfosComponent>().recentlyServerInfo == null) return;
  199. string serverName = zoneScene.GetComponent<ServerInfosComponent>().recentlyServerInfo.ServerName;
  200. QDDouYouManagerInit.Instance.ReportRole((int)reportType,
  201. roleInfo.Id.ToString(), lvl.ToString(), roleInfo.Name, roleInfo.ServerId.ToString(),
  202. serverName);
  203. break;
  204. case (int)ChannelID.DouYouDev:
  205. //改名上报给sdk
  206. var zoneSceneDev = GameGlobal.zoneScene;
  207. if (zoneSceneDev == null) return;
  208. if (zoneSceneDev.GetComponent<RoleInfosComponent>() == null ||
  209. zoneSceneDev.GetComponent<RoleInfosComponent>().IsDisposed) return;
  210. var roleInfoDev = zoneSceneDev.GetComponent<RoleInfosComponent>().GetCurrentRole();
  211. if (roleInfoDev == null) return;
  212. if (GameGlobal.myNumericComponent == null) return;
  213. int lvlDev = GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl);
  214. if (zoneSceneDev.GetComponent<ServerInfosComponent>() == null) return;
  215. if (zoneSceneDev.GetComponent<ServerInfosComponent>().recentlyServerInfo == null) return;
  216. string serverNameDev =
  217. zoneSceneDev.GetComponent<ServerInfosComponent>().recentlyServerInfo.ServerName;
  218. QDDouYouManagerInit.Instance.ReportRole((int)reportType,
  219. roleInfoDev.Id.ToString(), lvlDev.ToString(), roleInfoDev.Name, roleInfoDev.ServerId.ToString(),
  220. serverNameDev);
  221. break;
  222. case (int)ChannelID.AppStore:
  223. //TODO 接入douYou sdk
  224. break;
  225. default:
  226. break;
  227. }
  228. }
  229. public static bool IsTaptap
  230. {
  231. get { return LauncherConfig.ChannelId == (int)ChannelID.TapTap; }
  232. }
  233. public static bool IsHYKB
  234. {
  235. get { return LauncherConfig.ChannelId == (int)ChannelID.HYKB; }
  236. }
  237. public static bool IsBiliBili
  238. {
  239. get { return LauncherConfig.ChannelId == (int)ChannelID.BiliBili; }
  240. }
  241. public static bool IsHuaWei
  242. {
  243. get { return LauncherConfig.ChannelId == (int)ChannelID.HUAWEI; }
  244. }
  245. }
  246. }