QDManager.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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. default:
  22. break;
  23. }
  24. }
  25. public static void Login()
  26. {
  27. ViewManager.Show<ModalStatusView>("登录中...");
  28. switch (LauncherConfig.ChannelId)
  29. {
  30. case (int)ChannelID.Test:
  31. bool login = GameController.CheckLoginCache(true);
  32. if (!login)
  33. {
  34. ViewManager.Hide<ModalStatusView>();
  35. ViewManager.Show<LoginInputView>();
  36. }
  37. break;
  38. case (int)ChannelID.DouYou:
  39. QDDouYouManager.Instance.Login();
  40. break;
  41. default:
  42. break;
  43. }
  44. }
  45. public static void OnCreateRole()
  46. {
  47. switch (LauncherConfig.ChannelId)
  48. {
  49. case (int)ChannelID.Test:
  50. break;
  51. case (int)ChannelID.DouYou:
  52. QDDouYouManager.Instance.OnCreateRole();
  53. break;
  54. default:
  55. break;
  56. }
  57. }
  58. public static void OnEnterGame()
  59. {
  60. switch (LauncherConfig.ChannelId)
  61. {
  62. case (int)ChannelID.Test:
  63. break;
  64. case (int)ChannelID.DouYou:
  65. QDDouYouManager.Instance.OnEnterGame();
  66. break;
  67. default:
  68. break;
  69. }
  70. }
  71. //回到登录界面,不退出账号
  72. public static void OnQuitToLoginView()
  73. {
  74. switch (LauncherConfig.ChannelId)
  75. {
  76. case (int)ChannelID.Test:
  77. break;
  78. case (int)ChannelID.DouYou:
  79. QDDouYouManager.Instance.OnQuitToLoginView();
  80. break;
  81. default:
  82. break;
  83. }
  84. }
  85. public static void Pay(int buyID, int count, string orderID, long price)
  86. {
  87. switch (LauncherConfig.ChannelId)
  88. {
  89. case (int)ChannelID.Test:
  90. break;
  91. case (int)ChannelID.DouYou:
  92. QDDouYouManager.Instance.Pay(buyID, count, orderID, price);
  93. break;
  94. default:
  95. break;
  96. }
  97. }
  98. public static void Logout()
  99. {
  100. GameGlobal.zoneScene.GetComponent<SessionComponent>()?.Disconnect();
  101. GameGlobal.zoneScene.GetComponent<ServerInfosComponent>()?.ServerInfoList?.Clear();
  102. GameGlobal.zoneScene.GetComponent<AccountInfoComponent>()?.Clear();
  103. if (PlayerPrefs.HasKey(GameConst.PASSWORD_LAST_LOGIN_KEY))
  104. {
  105. PlayerPrefs.DeleteKey(GameConst.PASSWORD_LAST_LOGIN_KEY);
  106. }
  107. switch (LauncherConfig.ChannelId)
  108. {
  109. case (int)ChannelID.Test:
  110. break;
  111. case (int)ChannelID.DouYou:
  112. QDDouYouManager.Instance.Logout();
  113. break;
  114. default:
  115. break;
  116. }
  117. }
  118. public static void Exit()
  119. {
  120. switch (LauncherConfig.ChannelId)
  121. {
  122. case (int)ChannelID.Test:
  123. GameController.ShowExitAlert();
  124. break;
  125. case (int)ChannelID.DouYou:
  126. QDDouYouManager.Instance.Exit();
  127. break;
  128. default:
  129. break;
  130. }
  131. }
  132. //上报角色行为给sdk
  133. public static void PushRoleAction(DouYouRoleLogReportType reportType)
  134. {
  135. //改名上报给sdk
  136. var zoneScene = GameGlobal.zoneScene;
  137. if (zoneScene == null) return;
  138. if (zoneScene.GetComponent<RoleInfosComponent>() == null ||
  139. zoneScene.GetComponent<RoleInfosComponent>().IsDisposed) return;
  140. var roleInfo = zoneScene.GetComponent<RoleInfosComponent>().GetCurrentRole();
  141. if (roleInfo == null) return;
  142. if (GameGlobal.myNumericComponent == null) return;
  143. int lvl = GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl);
  144. if (zoneScene.GetComponent<ServerInfosComponent>() == null) return;
  145. if (zoneScene.GetComponent<ServerInfosComponent>().recentlyServerInfo == null) return;
  146. string serverName = zoneScene.GetComponent<ServerInfosComponent>().recentlyServerInfo.ServerName;
  147. QDDouYouManagerInit.Instance.ReportRole((int)reportType,
  148. roleInfo.Id.ToString(), lvl.ToString(), roleInfo.Name, roleInfo.ServerId.ToString(),
  149. serverName);
  150. }
  151. public static bool IsTaptap
  152. {
  153. get { return LauncherConfig.ChannelId == (int)ChannelID.TapTap; }
  154. }
  155. public static bool IsHYKB
  156. {
  157. get { return LauncherConfig.ChannelId == (int)ChannelID.HYKB; }
  158. }
  159. public static bool IsBiliBili
  160. {
  161. get { return LauncherConfig.ChannelId == (int)ChannelID.BiliBili; }
  162. }
  163. public static bool IsHuaWei
  164. {
  165. get { return LauncherConfig.ChannelId == (int)ChannelID.HUAWEI; }
  166. }
  167. }
  168. }