QDManager.cs 9.4 KB

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