QDManager.cs 9.8 KB

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