QDManager.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. using System;
  2. using ET;
  3. using GFGGame.Launcher;
  4. using UnityEngine;
  5. namespace GFGGame
  6. {
  7. public class QDManager
  8. {
  9. public bool isLogining;
  10. public string uid;
  11. public static void Init()
  12. {
  13. switch (LauncherConfig.ChannelId)
  14. {
  15. case (int)ChannelID.Test:
  16. //QDShareManager.Instance.Init();
  17. break;
  18. case (int)ChannelID.DouYou:
  19. if (LauncherConfig.platformId == 2)
  20. {
  21. QDDouYouManagerIos.Instance.Init();
  22. }
  23. else
  24. {
  25. QDDouYouManager.Instance.Init();
  26. }
  27. //QDShareManager.Instance.Init();
  28. break;
  29. case (int)ChannelID.DouYouDev:
  30. QDDouYouManager.Instance.Init();
  31. //QDShareManager.Instance.Init();
  32. break;
  33. case (int)ChannelID.GFG:
  34. if (LauncherConfig.platformId == 2)
  35. {
  36. QDAppStoreManager.Init();
  37. }
  38. break;
  39. default:
  40. break;
  41. }
  42. }
  43. public static void Login()
  44. {
  45. ViewManager.Show<ModalStatusView>("登录中...");
  46. switch (LauncherConfig.ChannelId)
  47. {
  48. case (int)ChannelID.Test:
  49. bool login = GameController.CheckLoginCache(true);
  50. if (!login)
  51. {
  52. ViewManager.Hide<ModalStatusView>();
  53. ViewManager.Show<LoginInputView>();
  54. }
  55. break;
  56. case (int)ChannelID.DouYou:
  57. if (LauncherConfig.platformId == 2)
  58. {
  59. QDDouYouManagerIos.Instance.Login();
  60. }
  61. else
  62. {
  63. QDDouYouManager.Instance.Login();
  64. }
  65. break;
  66. case (int)ChannelID.DouYouDev:
  67. QDDouYouManager.Instance.Login();
  68. break;
  69. case (int)ChannelID.GFG:
  70. bool loginAppStore = GameController.CheckLoginCache(true);
  71. if (!loginAppStore)
  72. {
  73. ViewManager.Hide<ModalStatusView>();
  74. ViewManager.Show<LoginInputView>();
  75. }
  76. break;
  77. default:
  78. break;
  79. }
  80. }
  81. public static void OnCreateRole()
  82. {
  83. switch (LauncherConfig.ChannelId)
  84. {
  85. case (int)ChannelID.Test:
  86. break;
  87. case (int)ChannelID.DouYou:
  88. if (LauncherConfig.platformId == 1)
  89. {
  90. QDDouYouManager.Instance.OnCreateRole();
  91. }
  92. break;
  93. case (int)ChannelID.DouYouDev:
  94. QDDouYouManager.Instance.OnCreateRole();
  95. break;
  96. case (int)ChannelID.GFG:
  97. if (LauncherConfig.platformId == 2)
  98. {
  99. QDAppStoreManager.OnCreateRole();
  100. }
  101. break;
  102. default:
  103. break;
  104. }
  105. }
  106. public static void OnEnterGame()
  107. {
  108. switch (LauncherConfig.ChannelId)
  109. {
  110. case (int)ChannelID.Test:
  111. break;
  112. case (int)ChannelID.DouYou:
  113. if (LauncherConfig.platformId == 2)
  114. {
  115. QDDouYouManagerIos.Instance.OnEnterGame();
  116. }
  117. else
  118. {
  119. QDDouYouManager.Instance.OnEnterGame();
  120. }
  121. break;
  122. case (int)ChannelID.DouYouDev:
  123. QDDouYouManager.Instance.OnEnterGame();
  124. break;
  125. case (int)ChannelID.GFG:
  126. if (LauncherConfig.platformId == 2)
  127. {
  128. QDAppStoreManager.OnEnterGame();
  129. }
  130. break;
  131. default:
  132. break;
  133. }
  134. }
  135. //回到登录界面,不退出账号
  136. public static void OnQuitToLoginView()
  137. {
  138. switch (LauncherConfig.ChannelId)
  139. {
  140. case (int)ChannelID.Test:
  141. break;
  142. case (int)ChannelID.DouYou:
  143. if (LauncherConfig.platformId == 2)
  144. {
  145. QDDouYouManagerIos.Instance.OnQuitToLoginView();
  146. }
  147. else
  148. {
  149. QDDouYouManager.Instance.OnQuitToLoginView();
  150. }
  151. break;
  152. case (int)ChannelID.DouYouDev:
  153. QDDouYouManager.Instance.OnQuitToLoginView();
  154. break;
  155. case (int)ChannelID.GFG:
  156. break;
  157. default:
  158. break;
  159. }
  160. }
  161. public static void Pay(int buyID, int count, string orderID, long price)
  162. {
  163. switch (LauncherConfig.ChannelId)
  164. {
  165. case (int)ChannelID.Test:
  166. break;
  167. case (int)ChannelID.DouYou:
  168. if (LauncherConfig.platformId == 2)
  169. {
  170. QDDouYouManagerIos.Instance.Pay(buyID, count, orderID, price);
  171. }
  172. else
  173. {
  174. QDDouYouManager.Instance.Pay(buyID, count, orderID, price);
  175. }
  176. break;
  177. case (int)ChannelID.DouYouDev:
  178. QDDouYouManager.Instance.Pay(buyID, count, orderID, price);
  179. break;
  180. case (int)ChannelID.GFG:
  181. if (LauncherConfig.platformId == 2)
  182. {
  183. QDAppStoreManager.Pay(buyID, count, orderID, price);
  184. }
  185. break;
  186. default:
  187. break;
  188. }
  189. }
  190. public static void Logout()
  191. {
  192. GameGlobal.zoneScene.GetComponent<SessionComponent>()?.Disconnect();
  193. GameGlobal.zoneScene.GetComponent<ServerInfosComponent>()?.ServerInfoList?.Clear();
  194. GameGlobal.zoneScene.GetComponent<AccountInfoComponent>()?.Clear();
  195. if (PlayerPrefs.HasKey(GameConst.PASSWORD_LAST_LOGIN_KEY))
  196. {
  197. PlayerPrefs.DeleteKey(GameConst.PASSWORD_LAST_LOGIN_KEY);
  198. }
  199. switch (LauncherConfig.ChannelId)
  200. {
  201. case (int)ChannelID.Test:
  202. break;
  203. case (int)ChannelID.DouYou:
  204. if (LauncherConfig.platformId == 2)
  205. {
  206. QDDouYouManagerIos.Instance.Logout();
  207. }
  208. else
  209. {
  210. QDDouYouManager.Instance.Logout();
  211. }
  212. break;
  213. case (int)ChannelID.DouYouDev:
  214. QDDouYouManager.Instance.Logout();
  215. break;
  216. case (int)ChannelID.GFG:
  217. ViewManager.Show<LoginInputView>();
  218. break;
  219. default:
  220. break;
  221. }
  222. }
  223. public static void Exit()
  224. {
  225. switch (LauncherConfig.ChannelId)
  226. {
  227. case (int)ChannelID.Test:
  228. GameController.ShowExitAlert();
  229. break;
  230. case (int)ChannelID.DouYou:
  231. if (LauncherConfig.platformId == 2)
  232. {
  233. QDDouYouManagerIos.Instance.Exit();
  234. }
  235. else
  236. {
  237. QDDouYouManager.Instance.Exit();
  238. }
  239. break;
  240. case (int)ChannelID.DouYouDev:
  241. QDDouYouManager.Instance.Exit();
  242. break;
  243. case (int)ChannelID.GFG:
  244. GameController.ShowExitAlert();
  245. break;
  246. default:
  247. break;
  248. }
  249. }
  250. //上报角色行为给sdk
  251. public static void PushRoleAction(DouYouRoleLogReportType reportType)
  252. {
  253. var zoneScene = GameGlobal.zoneScene;
  254. if (zoneScene == null) return;
  255. if (zoneScene.GetComponent<RoleInfosComponent>() == null ||
  256. zoneScene.GetComponent<RoleInfosComponent>().IsDisposed) return;
  257. var roleInfo = zoneScene.GetComponent<RoleInfosComponent>().GetCurrentRole();
  258. if (roleInfo == null) return;
  259. if (GameGlobal.myNumericComponent == null) return;
  260. int roleLvl = GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl);
  261. int vipLvl = GameGlobal.myNumericComponent.GetAsInt(NumericType.VipLevel);
  262. if (zoneScene.GetComponent<ServerInfosComponent>() == null) return;
  263. if (zoneScene.GetComponent<ServerInfosComponent>().recentlyServerInfo == null) return;
  264. string serverName =
  265. zoneScene.GetComponent<ServerInfosComponent>().recentlyServerInfo.ServerName;
  266. string partyName = LeagueDataManager.Instance.LeagueData?.Name ?? "";
  267. string roleBalence = "0";
  268. switch (LauncherConfig.ChannelId)
  269. {
  270. case (int)ChannelID.Test:
  271. break;
  272. case (int)ChannelID.DouYou:
  273. if (LauncherConfig.platformId == 2)
  274. {
  275. QDDouYouManagerInitIos.Instance.ReportRoleInfo(((int)reportType).ToString(),
  276. roleInfo.ServerId.ToString(),
  277. serverName, roleInfo.Id.ToString(), roleInfo.Name, roleLvl.ToString(), vipLvl.ToString(),
  278. partyName,
  279. roleBalence);
  280. }
  281. else
  282. {
  283. QDDouYouManagerInit.Instance.ReportRole((int)reportType,
  284. roleInfo.Id.ToString(), roleLvl.ToString(), roleInfo.Name, roleInfo.ServerId.ToString(),
  285. serverName);
  286. }
  287. break;
  288. case (int)ChannelID.DouYouDev:
  289. QDDouYouManagerInit.Instance.ReportRole((int)reportType,
  290. roleInfo.Id.ToString(), roleLvl.ToString(), roleInfo.Name, roleInfo.ServerId.ToString(),
  291. serverName);
  292. break;
  293. case (int)ChannelID.GFG:
  294. break;
  295. default:
  296. break;
  297. }
  298. }
  299. public static bool IsTaptap
  300. {
  301. get { return LauncherConfig.ChannelId == (int)ChannelID.TapTap; }
  302. }
  303. public static bool IsHYKB
  304. {
  305. get { return LauncherConfig.ChannelId == (int)ChannelID.HYKB; }
  306. }
  307. public static bool IsBiliBili
  308. {
  309. get { return LauncherConfig.ChannelId == (int)ChannelID.BiliBili; }
  310. }
  311. public static bool IsHuaWei
  312. {
  313. get { return LauncherConfig.ChannelId == (int)ChannelID.HUAWEI; }
  314. }
  315. }
  316. }