QDManager.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  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. #if GFGZSB
  21. AliManagerr.Instance.Init();
  22. //QDShareManager.Instance.Init();
  23. #else
  24. if (LauncherConfig.platformId == 2)
  25. {
  26. #if !UNITY_EDITOR && UNITY_IOS
  27. QDDouYouManagerIos.Instance.Init();
  28. #endif
  29. }
  30. else
  31. {
  32. QDDouYouManager.Instance.Init();
  33. }
  34. #endif
  35. break;
  36. case (int)ChannelID.DouYouDev:
  37. QDDouYouManager.Instance.Init();
  38. //QDShareManager.Instance.Init();
  39. break;
  40. case (int)ChannelID.AppStore:
  41. #if !UNITY_EDITOR && UNITY_IOS
  42. QDAppStoreManager.Init();
  43. #endif
  44. break;
  45. default:
  46. break;
  47. }
  48. }
  49. public static void Login()
  50. {
  51. ViewManager.Show<ModalStatusView>("登录中...");
  52. switch (LauncherConfig.ChannelId)
  53. {
  54. case (int)ChannelID.Test:
  55. bool login = GameController.CheckLoginCache(true);
  56. if (!login)
  57. {
  58. ViewManager.Hide<ModalStatusView>();
  59. ViewManager.Show<LoginInputView>();
  60. }
  61. break;
  62. case (int)ChannelID.DouYou:
  63. #if GFGZSB
  64. bool loginDouYou = GameController.CheckLoginCache(true);
  65. if (!loginDouYou)
  66. {
  67. ViewManager.Hide<ModalStatusView>();
  68. ViewManager.Show<LoginInputView>();
  69. }
  70. #else
  71. if (LauncherConfig.platformId == 2)
  72. {
  73. #if !UNITY_EDITOR && UNITY_IOS
  74. QDDouYouManagerIos.Instance.Login();
  75. #endif
  76. }
  77. else
  78. {
  79. QDDouYouManager.Instance.Login();
  80. }
  81. #endif
  82. break;
  83. case (int)ChannelID.DouYouDev:
  84. QDDouYouManager.Instance.Login();
  85. break;
  86. case (int)ChannelID.AppStore:
  87. //TODO 接douyou ios的sdk登录
  88. break;
  89. default:
  90. break;
  91. }
  92. }
  93. public static void OnCreateRole()
  94. {
  95. switch (LauncherConfig.ChannelId)
  96. {
  97. case (int)ChannelID.Test:
  98. break;
  99. case (int)ChannelID.DouYou:
  100. #if !GFGZSB
  101. if (LauncherConfig.platformId == 1)
  102. {
  103. QDDouYouManager.Instance.OnCreateRole();
  104. }
  105. #endif
  106. break;
  107. case (int)ChannelID.DouYouDev:
  108. QDDouYouManager.Instance.OnCreateRole();
  109. break;
  110. default:
  111. break;
  112. }
  113. }
  114. public static void OnEnterGame()
  115. {
  116. switch (LauncherConfig.ChannelId)
  117. {
  118. case (int)ChannelID.Test:
  119. break;
  120. case (int)ChannelID.DouYou:
  121. #if !GFGZSB
  122. if (LauncherConfig.platformId == 2)
  123. {
  124. #if !UNITY_EDITOR && UNITY_IOS
  125. QDDouYouManagerIos.Instance.OnEnterGame();
  126. #endif
  127. }
  128. else
  129. {
  130. QDDouYouManager.Instance.OnEnterGame();
  131. }
  132. #endif
  133. break;
  134. case (int)ChannelID.DouYouDev:
  135. QDDouYouManager.Instance.OnEnterGame();
  136. break;
  137. case (int)ChannelID.AppStore:
  138. //TODO 接入douYou sdk
  139. break;
  140. default:
  141. break;
  142. }
  143. }
  144. //回到登录界面,不退出账号
  145. public static void OnQuitToLoginView()
  146. {
  147. switch (LauncherConfig.ChannelId)
  148. {
  149. case (int)ChannelID.Test:
  150. break;
  151. case (int)ChannelID.DouYou:
  152. #if !GFGZSB
  153. if (LauncherConfig.platformId == 2)
  154. {
  155. #if !UNITY_EDITOR && UNITY_IOS
  156. QDDouYouManagerIos.Instance.OnQuitToLoginView();
  157. #endif
  158. }
  159. else
  160. {
  161. QDDouYouManager.Instance.OnQuitToLoginView();
  162. }
  163. #endif
  164. break;
  165. case (int)ChannelID.DouYouDev:
  166. QDDouYouManager.Instance.OnQuitToLoginView();
  167. break;
  168. case (int)ChannelID.AppStore:
  169. //TODO 接入douYou sdk
  170. break;
  171. default:
  172. break;
  173. }
  174. }
  175. public static void Pay(int buyID, int count, string orderID, long price)
  176. {
  177. switch (LauncherConfig.ChannelId)
  178. {
  179. case (int)ChannelID.Test:
  180. break;
  181. case (int)ChannelID.DouYou:
  182. #if GFGZSB
  183. //TODO gfg支付跳转
  184. ViewManager.Show<StorePayPropView>(new object[] { buyID, orderID, price });
  185. #else
  186. if (LauncherConfig.platformId == 2)
  187. {
  188. #if !UNITY_EDITOR && UNITY_IOS
  189. QDDouYouManagerIos.Instance.Pay(buyID, count, orderID, price);
  190. #endif
  191. }
  192. else
  193. {
  194. QDDouYouManager.Instance.Pay(buyID, count, orderID, price);
  195. }
  196. #endif
  197. break;
  198. case (int)ChannelID.DouYouDev:
  199. QDDouYouManager.Instance.Pay(buyID, count, orderID, price);
  200. break;
  201. case (int)ChannelID.AppStore:
  202. //TODO 接入douYou sdk
  203. break;
  204. default:
  205. break;
  206. }
  207. }
  208. public static void Logout()
  209. {
  210. GameGlobal.zoneScene.GetComponent<SessionComponent>()?.Disconnect();
  211. GameGlobal.zoneScene.GetComponent<ServerInfosComponent>()?.ServerInfoList?.Clear();
  212. GameGlobal.zoneScene.GetComponent<AccountInfoComponent>()?.Clear();
  213. if (PlayerPrefs.HasKey(GameConst.PASSWORD_LAST_LOGIN_KEY))
  214. {
  215. PlayerPrefs.DeleteKey(GameConst.PASSWORD_LAST_LOGIN_KEY);
  216. }
  217. switch (LauncherConfig.ChannelId)
  218. {
  219. case (int)ChannelID.Test:
  220. break;
  221. case (int)ChannelID.DouYou:
  222. #if !GFGZSB
  223. if (LauncherConfig.platformId == 2)
  224. {
  225. #if !UNITY_EDITOR && UNITY_IOS
  226. QDDouYouManagerIos.Instance.Logout();
  227. #endif
  228. }
  229. else
  230. {
  231. QDDouYouManager.Instance.Logout();
  232. }
  233. #endif
  234. break;
  235. case (int)ChannelID.DouYouDev:
  236. QDDouYouManager.Instance.Logout();
  237. break;
  238. case (int)ChannelID.AppStore:
  239. //TODO 接入douYou sdk
  240. break;
  241. default:
  242. break;
  243. }
  244. }
  245. public static void Exit()
  246. {
  247. switch (LauncherConfig.ChannelId)
  248. {
  249. case (int)ChannelID.Test:
  250. GameController.ShowExitAlert();
  251. break;
  252. case (int)ChannelID.DouYou:
  253. #if GFGZSB
  254. GameController.ShowExitAlert();
  255. #else
  256. if (LauncherConfig.platformId == 2)
  257. {
  258. #if !UNITY_EDITOR && UNITY_IOS
  259. QDDouYouManagerIos.Instance.Exit();
  260. #endif
  261. }
  262. else
  263. {
  264. QDDouYouManager.Instance.Exit();
  265. }
  266. #endif
  267. break;
  268. case (int)ChannelID.DouYouDev:
  269. QDDouYouManager.Instance.Exit();
  270. break;
  271. case (int)ChannelID.AppStore:
  272. //TODO 接入douYou sdk
  273. break;
  274. default:
  275. break;
  276. }
  277. }
  278. //上报角色行为给sdk
  279. public static void PushRoleAction(DouYouRoleLogReportType reportType)
  280. {
  281. switch (LauncherConfig.ChannelId)
  282. {
  283. case (int)ChannelID.Test:
  284. break;
  285. case (int)ChannelID.DouYou:
  286. //改名上报给sdk
  287. // var zoneScene = GameGlobal.zoneScene;
  288. // if (zoneScene == null) return;
  289. //
  290. // if (zoneScene.GetComponent<RoleInfosComponent>() == null ||
  291. // zoneScene.GetComponent<RoleInfosComponent>().IsDisposed) return;
  292. //
  293. // var roleInfo = zoneScene.GetComponent<RoleInfosComponent>().GetCurrentRole();
  294. // if (roleInfo == null) return;
  295. //
  296. // if (GameGlobal.myNumericComponent == null) return;
  297. // int lvl = GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl);
  298. //
  299. // if (zoneScene.GetComponent<ServerInfosComponent>() == null) return;
  300. // if (zoneScene.GetComponent<ServerInfosComponent>().recentlyServerInfo == null) return;
  301. //
  302. // string serverName = zoneScene.GetComponent<ServerInfosComponent>().recentlyServerInfo.ServerName;
  303. // QDDouYouManagerInit.Instance.ReportRole((int)reportType,
  304. // roleInfo.Id.ToString(), lvl.ToString(), roleInfo.Name, roleInfo.ServerId.ToString(),
  305. // serverName);
  306. break;
  307. case (int)ChannelID.DouYouDev:
  308. //改名上报给sdk
  309. var zoneSceneDev = GameGlobal.zoneScene;
  310. if (zoneSceneDev == null) return;
  311. if (zoneSceneDev.GetComponent<RoleInfosComponent>() == null ||
  312. zoneSceneDev.GetComponent<RoleInfosComponent>().IsDisposed) return;
  313. var roleInfoDev = zoneSceneDev.GetComponent<RoleInfosComponent>().GetCurrentRole();
  314. if (roleInfoDev == null) return;
  315. if (GameGlobal.myNumericComponent == null) return;
  316. int lvlDev = GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl);
  317. if (zoneSceneDev.GetComponent<ServerInfosComponent>() == null) return;
  318. if (zoneSceneDev.GetComponent<ServerInfosComponent>().recentlyServerInfo == null) return;
  319. string serverNameDev =
  320. zoneSceneDev.GetComponent<ServerInfosComponent>().recentlyServerInfo.ServerName;
  321. QDDouYouManagerInit.Instance.ReportRole((int)reportType,
  322. roleInfoDev.Id.ToString(), lvlDev.ToString(), roleInfoDev.Name, roleInfoDev.ServerId.ToString(),
  323. serverNameDev);
  324. break;
  325. case (int)ChannelID.AppStore:
  326. //TODO 接入douYou sdk
  327. break;
  328. default:
  329. break;
  330. }
  331. }
  332. public static bool IsTaptap
  333. {
  334. get { return LauncherConfig.ChannelId == (int)ChannelID.TapTap; }
  335. }
  336. public static bool IsHYKB
  337. {
  338. get { return LauncherConfig.ChannelId == (int)ChannelID.HYKB; }
  339. }
  340. public static bool IsBiliBili
  341. {
  342. get { return LauncherConfig.ChannelId == (int)ChannelID.BiliBili; }
  343. }
  344. public static bool IsHuaWei
  345. {
  346. get { return LauncherConfig.ChannelId == (int)ChannelID.HUAWEI; }
  347. }
  348. }
  349. }