QDManager.cs 13 KB

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