QDManager.cs 9.3 KB

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