QDManager.cs 9.9 KB

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