QDManager.cs 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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. //TODO gfg支付跳转
  124. ViewManager.Show<StorePayPropView>(new object[] { buyID, orderID, price });
  125. break;
  126. case (int)ChannelID.DouYouDev:
  127. QDDouYouManager.Instance.Pay(buyID, count, orderID, price);
  128. break;
  129. case (int)ChannelID.AppStore:
  130. //TODO 接入douYou sdk
  131. break;
  132. default:
  133. break;
  134. }
  135. }
  136. public static void Logout()
  137. {
  138. GameGlobal.zoneScene.GetComponent<SessionComponent>()?.Disconnect();
  139. GameGlobal.zoneScene.GetComponent<ServerInfosComponent>()?.ServerInfoList?.Clear();
  140. GameGlobal.zoneScene.GetComponent<AccountInfoComponent>()?.Clear();
  141. if (PlayerPrefs.HasKey(GameConst.PASSWORD_LAST_LOGIN_KEY))
  142. {
  143. PlayerPrefs.DeleteKey(GameConst.PASSWORD_LAST_LOGIN_KEY);
  144. }
  145. switch (LauncherConfig.ChannelId)
  146. {
  147. case (int)ChannelID.Test:
  148. break;
  149. case (int)ChannelID.DouYou:
  150. QDDouYouManager.Instance.Logout();
  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. QDDouYouManager.Instance.Exit();
  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. if (zoneScene.GetComponent<RoleInfosComponent>() == null ||
  194. zoneScene.GetComponent<RoleInfosComponent>().IsDisposed) return;
  195. var roleInfo = zoneScene.GetComponent<RoleInfosComponent>().GetCurrentRole();
  196. if (roleInfo == null) return;
  197. if (GameGlobal.myNumericComponent == null) return;
  198. int lvl = GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl);
  199. if (zoneScene.GetComponent<ServerInfosComponent>() == null) return;
  200. if (zoneScene.GetComponent<ServerInfosComponent>().recentlyServerInfo == null) return;
  201. string serverName = zoneScene.GetComponent<ServerInfosComponent>().recentlyServerInfo.ServerName;
  202. QDDouYouManagerInit.Instance.ReportRole((int)reportType,
  203. roleInfo.Id.ToString(), lvl.ToString(), roleInfo.Name, roleInfo.ServerId.ToString(),
  204. serverName);
  205. break;
  206. case (int)ChannelID.DouYouDev:
  207. //改名上报给sdk
  208. var zoneSceneDev = GameGlobal.zoneScene;
  209. if (zoneSceneDev == null) return;
  210. if (zoneSceneDev.GetComponent<RoleInfosComponent>() == null ||
  211. zoneSceneDev.GetComponent<RoleInfosComponent>().IsDisposed) return;
  212. var roleInfoDev = zoneSceneDev.GetComponent<RoleInfosComponent>().GetCurrentRole();
  213. if (roleInfoDev == null) return;
  214. if (GameGlobal.myNumericComponent == null) return;
  215. int lvlDev = GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl);
  216. if (zoneSceneDev.GetComponent<ServerInfosComponent>() == null) return;
  217. if (zoneSceneDev.GetComponent<ServerInfosComponent>().recentlyServerInfo == null) return;
  218. string serverNameDev =
  219. zoneSceneDev.GetComponent<ServerInfosComponent>().recentlyServerInfo.ServerName;
  220. QDDouYouManagerInit.Instance.ReportRole((int)reportType,
  221. roleInfoDev.Id.ToString(), lvlDev.ToString(), roleInfoDev.Name, roleInfoDev.ServerId.ToString(),
  222. serverNameDev);
  223. break;
  224. case (int)ChannelID.AppStore:
  225. //TODO 接入douYou sdk
  226. break;
  227. default:
  228. break;
  229. }
  230. }
  231. public static bool IsTaptap
  232. {
  233. get { return LauncherConfig.ChannelId == (int)ChannelID.TapTap; }
  234. }
  235. public static bool IsHYKB
  236. {
  237. get { return LauncherConfig.ChannelId == (int)ChannelID.HYKB; }
  238. }
  239. public static bool IsBiliBili
  240. {
  241. get { return LauncherConfig.ChannelId == (int)ChannelID.BiliBili; }
  242. }
  243. public static bool IsHuaWei
  244. {
  245. get { return LauncherConfig.ChannelId == (int)ChannelID.HUAWEI; }
  246. }
  247. }
  248. }