QDManager.cs 11 KB

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